List of usage examples for org.hibernate Query setResultTransformer
@Deprecated Query<R> setResultTransformer(ResultTransformer transformer);
From source file:org.squashtest.tm.service.internal.batchexport.ExportDao.java
License:Open Source License
@SuppressWarnings("unchecked") private <R> List<R> findRequirementModels(String queryName, List<Long> versionIds, Class<R> resclass) { Session session = getStatelessSession(); Query q = session.getNamedQuery(queryName); q.setParameterList("versionIds", versionIds, LongType.INSTANCE); q.setResultTransformer(new EasyConstructorResultTransformer(resclass)); return q.list(); }
From source file:org.squashtest.tm.service.internal.batchexport.ExportDao.java
License:Open Source License
@SuppressWarnings("unchecked") private void getModelRequirementCUF(RequirementModel requirementModel) { Session session = getStatelessSession(); Query q = session.getNamedQuery("requirement.excelRequirementExportCUF"); q.setLong("requirementVersionId", requirementModel.getId()); q.setResultTransformer(new EasyConstructorResultTransformer(CustomField.class)); requirementModel.setCufs(q.list());//from ww w . j a v a 2s. co m }
From source file:org.squashtest.tm.service.internal.repository.hibernate.CustomFieldBindingDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") protected List<NewBindingPosition> recomputeBindingPositions() { Session session = currentSession();/*from w ww . j a v a 2 s . c om*/ Query q = session.getNamedQuery("CustomFieldBinding.recomputeBindingPositions"); q.setResultTransformer(Transformers.aliasToBean(NewBindingPosition.class)); return q.list(); }
From source file:org.squashtest.tm.service.internal.repository.hibernate.HibernateUserDao.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// w ww . jav a2 s . co m public List<User> findAllAdminOrManager() { Query query = em.unwrap(Session.class).createSQLQuery(FIND_ALL_MANAGER_AND_ADMIN); query.setResultTransformer(new SqLIdResultTransformer()); List<Long> ids = query.list(); return findAllByIds(ids); }
From source file:org.squashtest.tm.service.internal.repository.hibernate.TestCaseDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w w w .j a v a 2 s . c om*/ public List<Long> findAllTestCaseIdsByNodeIds(Collection<Long> nodeIds) { if (nodeIds.isEmpty()) { return Collections.emptyList(); } Query query = currentSession().createSQLQuery(FIND_ALL_DESCENDANT_TESTCASE_QUERY); query.setParameterList("nodeIds", nodeIds, LongType.INSTANCE); query.setResultTransformer(new SqLIdResultTransformer()); return query.list(); }
From source file:org.squashtest.tm.service.security.acls.jdbc.DerivedPermissionsManager.java
License:Open Source License
private Collection<Long> findMembers(long partyId) { Query query = em.unwrap(Session.class).createSQLQuery(FIND_TEAM_MEMBERS_OR_USER); query.setParameter("id", partyId, LongType.INSTANCE); query.setResultTransformer(new SqLIdResultTransformer()); return query.list(); }
From source file:org.squashtest.tm.service.security.acls.jdbc.DerivedPermissionsManager.java
License:Open Source License
private Collection<Long> findUsers(ObjectIdentity identity) { // first find the parties managing that thing Query query = em.unwrap(Session.class).createSQLQuery(FIND_PARTIES_USING_IDENTITY); query.setParameter("id", identity.getIdentifier(), LongType.INSTANCE); query.setParameter("class", identity.getType(), StringType.INSTANCE); query.setResultTransformer(new SqLIdResultTransformer()); Collection<Long> partyIds = query.list(); // then find the corresponding users Collection<Long> userIds = new HashSet<>(); for (Long id : partyIds) { userIds.addAll(findMembers(id)); }/*from w ww.jav a 2s . c om*/ return userIds; }
From source file:org.squashtest.tm.service.security.acls.jdbc.DerivedPermissionsManager.java
License:Open Source License
private Collection<Long> findAllUsers() { Query query = em.unwrap(Session.class).createSQLQuery(FIND_ALL_USERS); query.setResultTransformer(new SqLIdResultTransformer()); return query.list(); }
From source file:org.squashtest.tm.service.security.acls.jdbc.DerivedPermissionsManager.java
License:Open Source License
private Collection<Long> retainUsersManagingAnything(Collection<Long> ids) { if (!ids.isEmpty()) { Set<Long> userIds = new HashSet<>(); Collection<Long> buffer; // first, get users directly managing anything Query query = em.unwrap(Session.class).createSQLQuery(RETAIN_USERS_MANAGING_ANYTHING); query.setParameterList("ids", ids, LongType.INSTANCE); query.setResultTransformer(new SqLIdResultTransformer()); buffer = query.list();/*w ww . j a v a 2 s . co m*/ userIds.addAll(buffer); // second, get users managing through teams or project leaders (which sounds quite silly I agree) query = em.unwrap(Session.class).createSQLQuery(RETAIN_MEMBERS_OF_TEAMS_MANAGING_ANYTHING); query.setParameterList("ids", ids, LongType.INSTANCE); query.setResultTransformer(new SqLIdResultTransformer()); buffer = query.list(); userIds.addAll(buffer); return userIds; } else { return Collections.emptyList(); } }
From source file:OTS.DataModels.MySqlDataSource.java
@Override public void ExecuteCustomDataSet(String sql, List<?> items, Class<?> type) { Session session = null;/*from ww w. j av a 2 s . co m*/ try { sessionFactory = NewHibernateUtil.getSessionFactory(); session = sessionFactory.openSession(); Query query = session.createSQLQuery(sql); query.list(); query.setResultTransformer(Transformers.aliasToBean(type)); items.addAll(query.list()); } finally { if (session != null) { session.close(); } } }