/** * Returns all the records. Same as {@link #findAll}. */ @Instrument public static <T extends Model> List<T> all(){ return (List<T>)query().list(); }
/** * Returns all the records or the model. */ @Instrument public static <T extends Model> List<T> findAll() { return (List<T>)query().list(); }
@Override public List<AuthzSSOLogin> loadLoginsInSession(AuthzSSOSession session) { List<AuthzSSOLoginEntity> entities = null; if(null != loadLoginsInSessionCommand) { entities = dao.createQuery(AuthzSSOLoginEntity.class, loadLoginsInSessionCommand).list(); }else{ entities = dao.createCriteriaQuery(AuthzSSOLoginEntity.class).where("session_id = ?", session.getId()).list(); } List<AuthzSSOLogin> logins = new ArrayList<>(); for(AuthzSSOLoginEntity entity : entities) { logins.add(createLoginFromEntity(entity)); } return logins; }
@Instrument public static <T extends Model> List<T> lastUpdated(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().lastUpdated().list(); }
@Override public List<AuthzSSOLogin> loadLoginsInSession(AuthzSSOSession session) { List<AuthzSSOLoginEntity> entities = null; if(null != loadLoginsInSessionCommand) { entities = dao.createQuery(AuthzSSOLoginEntity.class, loadLoginsInSessionCommand).list(); }else{ entities = dao.createCriteriaQuery(AuthzSSOLoginEntity.class).where("session_id = ?", session.getId()).list(); } List<AuthzSSOLogin> logins = new ArrayList<>(); for(AuthzSSOLoginEntity entity : entities) { logins.add(createLoginFromEntity(entity)); } return logins; }
@Instrument public static <T extends Model> List<T> lastCreated(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().lastCreated(num).list(); }
@Override public void run() { List changes = LogContext.execWithResult(LogLevel.INFO, () -> changesQuery.param("maxValue", maxValue).list()); if (!changes.isEmpty()) { log.debug("Found {} changes", changes.size()); Object lastNotified = null; try { for (int i = 0; i < changes.size(); i++) { Object entity = changes.get(i); listener.onEntityChanged(dao, entity); lastNotified = entity; } } catch (Throwable e) { log.error("Error notify listener '{}': {}", listener.getClass(), e.getMessage(), e); } if (null != lastNotified) { Object newMaxValue = EntityWrapper.wrap(dao.getOrmContext(), em, lastNotified).get(fm.getFieldName()); if (null != newMaxValue) { log.debug("Set maxValue from {} to {}", maxValue, newMaxValue); this.maxValue = newMaxValue; } } } }
@Instrument public static <T extends Model> List<T> first(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().orderByIdAsc().limit(num).list(); }
@Instrument public static <T extends Model> List<T> last(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().orderByIdDesc().limit(num).list(); }
List<Record> totalExpanded = expandQuery.limit(ac.getExpandLimit() + 1).list(); if (totalExpanded.size() > ac.getExpandLimit()) { throw new BadRequestException("Expanded records of '" + rp.getName() + "' exceed max limit " + ac.getExpandLimit());
List<Record> resultList = expandQuery.list(); if (resultList.size() > ac.getExpandLimit()) { throw new BadRequestException("Expanded records of '" + rp.getName() + "' exceed max limit " + ac.getExpandLimit());
record.put(rp.getName(), expandQuery.list()); } else { record.put(rp.getName(), expandQuery.firstOrNull());