@Override public HomeInvite findHomeInviteById(int id) { String q = "find homeInvite where id = :id"; Query<HomeInvite> query = ebean.createQuery(HomeInvite.class, q); query.setParameter("id", id); return query.findUnique(); }
@Override public Set<HomeInvite> findAllAvailableInvites(String invitee) { String q; if (configCore.useEbeanSearchLower()) q = "find homeInvite where lower(invitedPlayer) = lower(:invitee)"; else q = "find homeInvite where invitedPlayer = :invitee"; Query<HomeInvite> query = ebean.createQuery(HomeInvite.class, q); query.setParameter("invitee", invitee); return query.findSet(); }
public Result list() { String jointTagNames = Form.form().bindFromRequest().get("tags"); // Fetch items from the database List<Item> items; if (jointTagNames != null && !jointTagNames.isEmpty()) { List<String> tagNames = Arrays.asList(jointTagNames.split(",")); String oql = "find item " + "where tags.name in (:tagList) " + "group by id " + "having count(distinct tags.name) = :tagCount"; Query<Item> query = Item.find.setQuery(oql); query.setParameter("tagList", tagNames); query.setParameter("tagCount", tagNames.size()); items = query.orderBy().desc("uploadDate").findList(); } else { items = Item.find.orderBy().desc("uploadDate").findList(); } if (items != null) { String serialized = new JSONSerializer() .include("id") .include("name") .include("storageKey") .include("tags.name") .include("uploadDate") .include("fileSize") .exclude("*") .serialize(items); return ok(serialized); } else return notFound(); }
@Override public HomeInvite findInviteByHomeAndInvitee(Home home, String invitee) { String q; if (configCore.useEbeanSearchLower()) q = "find homeInvite where home = :home and lower(invitedPlayer) = lower(:invitee)"; else q = "find homeInvite where home = :home and invitedPlayer = :invitee"; Query<HomeInvite> query = ebean.createQuery(HomeInvite.class, q); query.setParameter("home", home.getId()); query.setParameter("invitee", invitee); return query.findUnique(); }
@Override public Set<HomeInvite> findInvitesByHome(Home home) { String q = "find homeInvite where home = :home"; Query<HomeInvite> query = ebean.createQuery(HomeInvite.class, q); query.setParameter("home", home.getId()); return query.findSet(); }