qb.order("link.details.updateEvent.id", false);
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { final Filter f = filter(opts); final QueryBuilder qb = new QueryBuilder(); qb.select("distinct r").from("Roi", "r"); qb.join("r.image", "i", false, false); qb.join("r.shapes", "shapes", false, true); // fetch qb.join("r.folderLinks", "folderLinks", true, true); // fetch qb.join("folderLinks.parent", "folder", true, true); // fetch qb.where(); qb.and("i.id = :id"); qb.filter("r", f); qb.filterNow(); qb.order("r.id", true); // ascending qb.param("id", imageId); return qb.queryWithoutFilter(session).list(); } }));
/** * Build a query string based on the current {@link #excludes} {@link List}. * The query expects a single :id parameter to be set on execution. The * {@link #excludes} list is used to filter out unwanted {@link EventLog} * instances. */ private void initQueryString() { List<String> copy = excludes; // Instead of synchronizing QueryBuilder qb = new QueryBuilder(); qb.select("el"); qb.from("EventLog", "el"); qb.where(); qb.and("el.id > :id"); if (copy != null) { for (String exclude : copy) { qb.and("el.entityType != '" + exclude + "'"); } } qb.order("id", true); query = qb.queryString(); }
String orderByPath = orderByPath(orderBy); boolean ascending = orderByAscending(orderBy); qb.order("this." + orderByPath, ascending);
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { final Filter f = filter(opts); final QueryBuilder qb = new QueryBuilder(); qb.select("distinct r").from("Roi", "r"); qb.join("r.shapes", "s", false, true); // fetch qb.join("r.folderLinks", "folderLinks", true, true); // fetch qb.join("folderLinks.parent", "folder", true, true); // fetch qb.join("r.image", "i", false, false); qb.where(); qb.and("i.id = :id"); qb.and(" ( s.theZ is null or s.theZ = :z ) "); qb.and(" ( s.theT is null or s.theT = :t ) "); qb.filter("r", f); qb.filterNow(); qb.order("r.id", true); // ascending qb.param("id", imageId); qb.param("z", z); qb.param("t", t); return qb.queryWithoutFilter(session).list(); } }));