List of usage examples for org.hibernate FetchMode SELECT
FetchMode SELECT
To view the source code for org.hibernate FetchMode SELECT.
Click Source Link
From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.VIEW_ReservationMapping.java
License:Open Source License
@Transient @SuppressWarnings("unchecked") public static final List<VIEW_ReservationMapping> getMappingsForNRPSResID(final long resId) throws DatabaseException { final List<VIEW_ReservationMapping> mappings = (List<VIEW_ReservationMapping>) (new TransactionManager( new Long(resId)) { @Override/*from w w w. ja v a 2 s . c om*/ protected void dbOperation() { this.result = this.session.createCriteria(VIEW_ReservationMapping.class) .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("nrpsReservationId", this.arg)) .list(); } }).getResult(); return mappings; }
From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.VIEW_ReservationMapping.java
License:Open Source License
@Transient @SuppressWarnings("unchecked") public static final List<VIEW_ReservationMapping> getMappingsForNSPResID(final long resId) throws DatabaseException { final List<VIEW_ReservationMapping> mappings = (List<VIEW_ReservationMapping>) (new TransactionManager( new Long(resId)) { @Override/* ww w.j a va 2 s . c o m*/ protected void dbOperation() { this.result = this.session.createCriteria(VIEW_ReservationMapping.class) .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("reservationId", this.arg)) .list(); } }).getResult(); return mappings; }
From source file:fr.gael.dhus.service.UserService.java
License:Open Source License
/** * Retrieves corresponding users at the given criteria. * * @param criteria criteria contains filter and order of required collection. * @param skip number of skipped valid results. * @param top max of valid results. * @return a list of {@link User}//from ww w . j a v a 2s . c o m */ @Transactional(readOnly = true) public List<User> getUsers(DetachedCriteria criteria, int skip, int top) { if (criteria == null) { criteria = DetachedCriteria.forClass(User.class); } criteria.setFetchMode("roles", FetchMode.SELECT); criteria.setFetchMode("restrictions", FetchMode.SELECT); List<User> result = userDao.listCriteria(criteria, skip, top); return result; }
From source file:grails.orm.HibernateCriteriaBuilder.java
License:Apache License
/** * Use a select query//from w w w . ja v a 2 s . c om * * @param associationPath The path of the association */ public void select(String associationPath) { criteria.setFetchMode(calculatePropertyName(associationPath), FetchMode.SELECT); }
From source file:id.co.sambaltomat.core.dao.hibernate.GenericDaoHibernate.java
protected void processJoinPath(Criteria criteria, List<JoinPath> joinPaths, ProjectionList projectionList) { boolean isDistinctRoot = true; if (joinPaths != null && !joinPaths.isEmpty()) { for (JoinPath joinPath : joinPaths) { if (joinPath.joinType == JoinType.INNER_JOIN) criteria.createCriteria(joinPath.path, joinPath.alias, CriteriaSpecification.INNER_JOIN); else if (joinPath.joinType == JoinType.LEFT_JOIN) criteria.createCriteria(joinPath.path, joinPath.alias, CriteriaSpecification.LEFT_JOIN); else if (joinPath.joinType == JoinType.NON_DISTINCT_ROOT_ENTITY) isDistinctRoot = false;/* ww w. ja v a2 s.com*/ else if (joinPath.joinType == JoinType.GROUPING_FIELD) { if (projectionList == null) { projectionList = Projections.projectionList(); } projectionList.add(Projections.groupProperty(joinPath.alias)); } else criteria.setFetchMode(joinPath.path, FetchMode.SELECT); } } if (isDistinctRoot) criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); }
From source file:it.archiworld.addressbook.AddressbookBean.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) public List<Address> searchAddress(Address address) throws Throwable { Session session = ((HibernateSession) manager).getHibernateSession(); Example example = Example.create(address); example.ignoreCase();//from w w w .j a va2 s . c o m example.excludeZeroes(); example.enableLike(); if (address instanceof Member) return session.createCriteria(Member.class).add(example).addOrder(Order.asc("lastname")) .setFetchMode("renewal", FetchMode.SELECT).setFetchMode("specializations", FetchMode.SELECT) .setFetchMode("formations", FetchMode.SELECT).setFetchMode("committeemembers", FetchMode.SELECT) .list(); if (address instanceof Person) { List<Address> result = session.createCriteria(Person.class).add(example).addOrder(Order.asc("lastname")) .list(); List<Address> result2 = new ArrayList<Address>(); for (int i = 0; i < result.size(); i++) if (!(result.get(i) instanceof Member) && !(result.get(i) instanceof ServiceMember)) result2.add(result.get(i)); return result2; } if (address instanceof Company) { return session.createCriteria(Company.class).add(example).addOrder(Order.asc("denomination")).list(); } return new ArrayList<Address>(); }
From source file:it.archiworld.addressbook.AddressbookBean.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) public List<Address> searchAddress(Class entityClass, Criterion criterion, List<Order> orders) throws Throwable { Session session = ((HibernateSession) manager).getHibernateSession(); Criteria criteria = session.createCriteria(entityClass); if (orders.size() > 0) { criteria.setMaxResults(1);/* w w w. j a va 2 s . c o m*/ Iterator<Order> ordIt = orders.iterator(); while (ordIt.hasNext() == true) { criteria.addOrder(ordIt.next()); } } else { criteria.addOrder(Order.asc("lastname")); } criteria.add(criterion).setFetchMode("renewal", FetchMode.SELECT) .setFetchMode("specializations", FetchMode.SELECT).setFetchMode("formations", FetchMode.SELECT) .setFetchMode("committeemembers", FetchMode.SELECT); return criteria.list(); }
From source file:net.sf.xplanner.dao.impl.TaskDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w .j a v a2s .c om @Transactional(readOnly = true) public List<Task> getCurrentTasksForPerson(final int personId) { final Criteria criteria = this.createCriteria(); criteria.createAlias("userStory", "userStory"); criteria.createAlias("userStory.iteration", "iteration"); final Date now = new Date(); criteria.add(Restrictions.le("iteration.startDate", now)); criteria.add(Restrictions.ge("iteration.endDate", now)); criteria.add(Restrictions.eq("acceptorId", personId)); criteria.setFetchMode("timeEntries", FetchMode.SELECT); return criteria.list(); }
From source file:net.sf.xplanner.dao.impl.UserStoryDaoImpl.java
License:Open Source License
@Override @Transactional()// ww w . ja v a 2 s .com public List<UserStory> getStoriesForPersonWhereCustomer(final int personId) { final Criteria criteria = this.createCriteria(); criteria.createAlias("customer", "customer"); criteria.createAlias("iteration", "iteration"); criteria.add(Restrictions.eq("customer.id", personId)); criteria.add(Restrictions.gt("iteration.endDate", new Date())); criteria.setFetchMode("tasks", FetchMode.SELECT); criteria.setFetchMode("tasks.timeEntries", FetchMode.SELECT); return criteria.list(); }
From source file:net.sf.xplanner.dao.impl.UserStoryDaoImpl.java
License:Open Source License
@Override @Transactional()/*from ww w . j av a2s . c o m*/ public List<UserStory> getStoriesForPersonWhereTracker(final int personId) { final Criteria criteria = this.createCriteria(); criteria.createAlias("iteration", "iteration"); criteria.add(Restrictions.eq("trackerId", personId)); criteria.add(Restrictions.gt("iteration.endDate", new Date())); criteria.setFetchMode("tasks", FetchMode.SELECT); criteria.setFetchMode("tasks.timeEntries", FetchMode.SELECT); return criteria.list(); }