List of usage examples for org.hibernate SharedSessionContract createCriteria
@Deprecated Criteria createCriteria(String entityName);
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityDao.java
License:Open Source License
/** * Provides all entities.//from w ww .ja va2 s . c o m * * @param ssc * @return */ @Override public List<E> getEntites(final SharedSessionContract ssc, final Integer firstResult, final Integer maxResults) { // Query final Criteria criteria = ssc.createCriteria(entityClass); final String defaultSortingProperty = defaultSortingProperty(); if (defaultSortingProperty != null) { criteria.addOrder(Order.asc(defaultSortingProperty)); } if (firstResult != null) { criteria.setFirstResult(firstResult); } if (maxResults != null) { criteria.setMaxResults(maxResults); } // Done @SuppressWarnings("unchecked") final List<E> entities = criteria.list(); return entities; }
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityDao.java
License:Open Source License
/** * Provides all entities by a given property. * * @param ssc//from w w w . j a v a 2s. co m * @param property * @param value * @return */ @Override public List<E> getEntitesByProperty(final SharedSessionContract ssc, final String property, final Object value, final Integer firstResult, final Integer maxResults) { // Query final Criteria criteria = ssc.createCriteria(entityClass); if (property != null && value != null) { criteria.add(Restrictions.eq(property, value)); } if (firstResult != null) { criteria.setFirstResult(firstResult); } if (maxResults != null) { criteria.setMaxResults(maxResults); } final String defaultSortingProperty = defaultSortingProperty(); if (defaultSortingProperty != null) { criteria.addOrder(Order.asc(defaultSortingProperty)); } // Done @SuppressWarnings("unchecked") final List<E> entities = criteria.list(); return entities; }
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityDao.java
License:Open Source License
/** * Provides a unique entity by a given property value. * * @param ssc/*w ww. j ava 2 s.co m*/ * @param property * @param value * @return */ @Override public E getUniqueEntityByProperty(final SharedSessionContract ssc, final String property, final Object value) { // Query final Criteria criteria = ssc.createCriteria(entityClass); if (property != null && value != null) { criteria.add(Restrictions.eq(property, value)); } // Done @SuppressWarnings("unchecked") final E entity = (E) criteria.uniqueResult(); return entity; }
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityDao.java
License:Open Source License
/** * Counts all entities.//from w w w. java 2 s .c om * * @param ssc * @return */ @Override public long countAll(final SharedSessionContract ssc) { // Query final Criteria criteria = ssc.createCriteria(entityClass); // Projection criteria.setProjection(Projections.count("id")); // Done Long count = (Long) criteria.uniqueResult(); if (count == null) { count = 0l; } return count; }
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityWithIdDao.java
License:Open Source License
@Override public E getEntity(final SharedSessionContract ssc, final long id) { // Query//from w ww. j a v a 2s. co m final Criteria criteria = ssc.createCriteria(getEntityClass()); criteria.add(Restrictions.idEq(id)); // Done @SuppressWarnings("unchecked") final E result = (E) criteria.uniqueResult(); return result; }
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityWithIdDao.java
License:Open Source License
@Override public List<E> getEntities(final SharedSessionContract ssc, final Collection<Long> ids) { if (ids.isEmpty()) { return Collections.emptyList(); }/* w w w . j av a 2s .com*/ // Query final Criteria criteria = ssc.createCriteria(getEntityClass()); criteria.add(Restrictions.in("id", ids)); // Done @SuppressWarnings("unchecked") final List<E> result = criteria.list(); return result; }
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityWithIdDao.java
License:Open Source License
@Override public Long getMaxId(final SharedSessionContract ssc) { // Query//from ww w. ja v a 2s .c o m final Criteria criteria = ssc.createCriteria(getEntityClass()); // Projection criteria.setProjection(Projections.max("id")); // Done final Long result = (Long) criteria.uniqueResult(); return result; }
From source file:com.romeikat.datamessie.core.base.dao.impl.Source2SourceTypeDao.java
License:Open Source License
public List<Source2SourceType> getForSourceId(final SharedSessionContract ssc, final long sourceId) { // Query/*w w w. j ava2 s . co m*/ final Criteria criteria = ssc.createCriteria(Source2SourceType.class); criteria.add(Restrictions.eq("sourceId", sourceId)); // Done @SuppressWarnings("unchecked") final List<Source2SourceType> entities = criteria.list(); return entities; }
From source file:com.romeikat.datamessie.core.base.dao.impl.Source2SourceTypeDao.java
License:Open Source License
public List<Source2SourceType> getForProjectId(final SharedSessionContract ssc, final long projectId) { // Query// w w w .j ava 2s .co m final Criteria criteria = ssc.createCriteria(Source2SourceType.class); criteria.add(Restrictions.eq("projectId", projectId)); // Done @SuppressWarnings("unchecked") final List<Source2SourceType> entities = criteria.list(); return entities; }
From source file:com.romeikat.datamessie.core.base.query.entity.execute.AbstractEntityQueryExecutor.java
License:Open Source License
public Criteria createCriteria(final SharedSessionContract ssc, final Class<E> targetClass) { final Criteria criteria = ssc.createCriteria(targetClass); return criteria; }