@Override public List<Group> findAll() { TypedQuery<Group> allGroupsQuery = em.createNamedQuery("info.galleria.domain.Group.findAllGroups", Group.class); List<Group> result = allGroupsQuery.getResultList(); return result; }
@Override public List<SpaceObject> getSpaceObjects() { TypedQuery<SpaceObject> typedQuery = em.createQuery("SELECT m FROM SpaceObject m", SpaceObject.class); List<SpaceObject> result = typedQuery.getResultList(); return result; }
public static List<Node> findNodesByParent(Node parent, long regionId) { if (parent == null) { throw new IllegalArgumentException("The parent argument is required"); } List<Node> resultList = new ArrayList<Node>(); Set<Node> availableList = new HashSet<Node>(); Set<Node> currentList; EntityManager em = Node.entityManager(); TypedQuery<Node> q; if (NO_REGION == regionId) { q = em.createQuery("SELECT o FROM Node AS o WHERE o.active = :active", Node.class); } else { q = em.createQuery( "SELECT o FROM Node AS o WHERE o.region = :region AND o.active = :active", Node.class); q.setParameter("region", Region.findRegion(regionId)); } q.setParameter("active", true); availableList.addAll(q.getResultList()); currentList = collectParents(new ArrayList<Node>(availableList), parent); availableList.addAll(currentList); q = em.createQuery( "SELECT o FROM Node AS o WHERE o IN :childs AND o.active = :active", Node.class); while (currentList.size() > 0) { q.setParameter("childs", currentList); q.setParameter("active", true); currentList = collectParents(q.getResultList(), parent); availableList.addAll(currentList); } q = em.createQuery( "SELECT o FROM Node AS o WHERE o IN :avaliable AND o.parent = :parent ORDER BY o.rate DESC, o.name ASC", Node.class); q.setParameter("parent", parent); q.setParameter("avaliable", availableList); for (Node node : q.getResultList()) { if (node instanceof Entity) { Entity entity = (Entity) node; Set<Resource> resList = new HashSet<Resource>(); for (Resource res : entity.getResources()) { resList.add(Resource.findResource(res.getId())); } entity.setResources(resList); } resultList.add(node); } return resultList; }
public List<UserEntity> getUserByLogin(String login) { TypedQuery<UserEntity> query = em.createNamedQuery("UserEntity.findByLogin", UserEntity.class) .setParameter("login", login); if (query.getResultList().size() != 1) { System.out.print(login + " not found"); return null; } return query.getResultList(); }
@Override public List<Withdrawal> getAll() { TypedQuery<Withdrawal> query = (TypedQuery<Withdrawal>) em.createQuery("SELECT w FROM Withdrawal w"); return query.getResultList(); }
@Override public List<Payment> findAll() { TypedQuery<Payment> query = em.createQuery("SELECT p FROM Payment p", Payment.class); log.debug("The query selecting all payments has been created."); List<Payment> listP = query.getResultList(); return listP; }
@Override public List<Withdrawal> getWithdrawalsOfTrading(Trading trading) { TypedQuery<Withdrawal> query = (TypedQuery<Withdrawal>) em.createQuery("SELECT w FROM Withdrawal w WHERE w.pk.trading=:trading"); query.setParameter("trading", trading); return query.getResultList(); }
public UserEntity getUserByLoginAndPassword(String login, String password) { TypedQuery<UserEntity> query = em.createNamedQuery("UserEntity.findByLoginAndPassword", UserEntity.class) .setParameter("login", login) .setParameter("password", password); List<UserEntity> result = query.getResultList(); if (result.size() != 1) return null; return result.get(0); }
@Override public List<Payment> findByMerchantId(int merchantId) { TypedQuery<Payment> query = em.createQuery("SELECT p FROM Payment p" + "WHERE p.merchantId = :id", Payment.class); query.setParameter("id", merchantId); log.debug( "The query selecting all payments of a merchant with id=" + merchantId + " has been created."); return query.getResultList(); }
public static List<TuserInfo> getList(String where, String orderby, List<Object> params) { TypedQuery<TuserInfo> q = entityManager().createQuery("from TuserInfo o " + where + orderby, TuserInfo.class); if (null != params && !params.isEmpty()) { int index = 1; for (Object param : params) { q.setParameter(index, param); index = index + 1; } } return q.getResultList(); }
/** * Método que sirve para encontrarTodos registros a la base de datos * * @return Tipo de retorno List<EspacioFísico> */ public List<EspacioFísico> encontrarTodos() { List<EspacioFísico> lista = null; try { TypedQuery<EspacioFísico> typedQuery = entityManager.createQuery("SELECT t FROM espaciofísico t ", EspacioFísico.class); lista = typedQuery.getResultList(); } catch (Exception e) { e.printStackTrace(); } finally { } return lista; }
public static List<Node> findAllNodes(String like) { if (like.length() == 0) { return findAllNodes(); } else { TypedQuery<Node> q = entityManager() .createQuery( "SELECT o FROM Node o WHERE lower(o.name) LIKE :like AND dtype = 'Node'", Node.class); q.setParameter("like", "%" + like.toLowerCase() + "%"); return q.getResultList(); } }
public synchronized <T> List<T> loadAll(Class<T> entityClass, String orderBy) { final EntityManager em = getEntityManager(); try { final TypedQuery<T> query = em.createQuery( "SELECT c FROM " + entityClass.getName() + " c " + ((orderBy == null) ? "" : " ORDER BY " + orderBy), entityClass); return query.getResultList(); } finally { em.close(); } }
public static void initialiseSubscriptions( EntityManagerFactory entityManagerFactory, Long immediateFrequency) { EntityManager badSubsEm = entityManagerFactory.createEntityManager(); TypedQuery<Subscription> badSubsQuery = badSubsEm.createNamedQuery("subscription.unInitialised", Subscription.class); List<Subscription> uninitialisedSubscriptions = badSubsQuery.getResultList(); badSubsEm.close(); if (uninitialisedSubscriptions.size() > 0) { logger.debug("Initialising {} subscriptions", uninitialisedSubscriptions.size()); for (Subscription s : uninitialisedSubscriptions) { logger.debug( "Scheduling new run for {} subscription {}", s.getSubscriber().emailAddress, s.getId()); EntityManager schedEm = entityManagerFactory.createEntityManager(); schedEm.getTransaction().begin(); s.calculateNextScheduledRun(immediateFrequency); schedEm.merge(s); schedEm.getTransaction().commit(); schedEm.close(); } } }
public List<UserEntity> getAll() { TypedQuery<UserEntity> namedQuery = (TypedQuery<UserEntity>) em.createNamedQuery("UserEntity.getAll"); return namedQuery.getResultList(); }
@Transactional(readOnly = true) public List<Course> findAll() { TypedQuery<Course> query = entityManager.createQuery("select course from Course course", Course.class); return query.getResultList(); }