本文整理汇总了Java中net.sf.hibernate.Criteria类的典型用法代码示例。如果您正苦于以下问题:Java Criteria类的具体用法?Java Criteria怎么用?Java Criteria使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Criteria类属于net.sf.hibernate包,在下文中一共展示了Criteria类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CriteriaImpl
import net.sf.hibernate.Criteria; //导入依赖的package包/类
/**
* Copy all the internal attributes of the given CrtieriaImpl
* except alter the root persistent class type to be the given one.
*/
public CriteriaImpl(Class persistentClass, CriteriaImpl original) {
this.persistentClass = persistentClass;
this.classByAlias = original.classByAlias;
this.classByAlias.put(Criteria.ROOT_ALIAS, persistentClass);
this.criteria = original.criteria;
this.orderings = original.orderings;
this.fetchModes = original.fetchModes;
this.associationPathByAlias = original.associationPathByAlias;
this.aliasByAssociationPath = original.aliasByAssociationPath;
this.lockModes = original.lockModes;
this.maxResults = original.maxResults;
this.firstResult = original.firstResult;
this.timeout = original.timeout;
this.fetchSize = original.fetchSize;
this.session = original.session;
this.resultTransformer = original.resultTransformer;
this.counter = original.counter;
this.cacheable = original.cacheable;
this.cacheRegion = original.cacheRegion;
}
示例2: listarLogGestorDocumentalErrores
import net.sf.hibernate.Criteria; //导入依赖的package包/类
/**
* @ejb.interface-method
* @ejb.permission role-name="${role.admin}"
* @ejb.permission role-name="${role.operador}"
*/
public List listarLogGestorDocumentalErrores(Date startDate, Date endDate, String idUsuario) {
Session session = getSession();
try {
Criteria criteria = session.createCriteria(LogGestorDocumentalError.class);
if (startDate != null) {
criteria.add(Expression.ge("fecha",startDate));
}
if (endDate != null) {
criteria.add(Expression.le("fecha",endDate));
}
if (idUsuario != null){
criteria.add(Expression.eq("usuarioSeycon",idUsuario));
}
List results = criteria.list();
return results;
} catch (HibernateException he) {
throw new EJBException(he);
} finally {
close(session);
}
}
示例3: listarLogOperaciones
import net.sf.hibernate.Criteria; //导入依赖的package包/类
/**
* @ejb.interface-method
* @ejb.permission role-name="${role.admin}"
* @ejb.permission role-name="${role.operador}"
*/
public List listarLogOperaciones(Date startDate, Date endDate, String idUsuario, String idTipoOperacion) {
Session session = getSession();
try {
Criteria criteria = session.createCriteria(LogOperacion.class);
if (startDate != null) {
criteria.add(Expression.ge("fecha",startDate));
}
if (endDate != null) {
criteria.add(Expression.le("fecha",endDate));
}
if (idUsuario != null){
criteria.add(Expression.eq("usuarioSeycon",idUsuario));
}
if (idTipoOperacion != null){
TipoOperacion tipoOperacion = (TipoOperacion) session.load(TipoOperacion.class,idTipoOperacion);
criteria.add(Expression.eq("tipoOperacion",tipoOperacion));
}
List results = criteria.list();
return results;
} catch (HibernateException he) {
throw new EJBException(he);
} finally {
close(session);
}
}
示例4: getObjects
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public List getObjects(Object obj) throws ApplicationException{
Session s = null;
List list = null;
try {
s = sf.openSession();
Criteria c = s.createCriteria(obj.getClass());
c.add(Example.create(obj));
list = c.list();
} catch (Exception ex){
log.error(ex);
if (log.isDebugEnabled())
log .debug("getObjects|Failure|Error in getting objects"+ ex.getMessage());
throw new ApplicationException("An error occured in getting objects" + "\n" + ex.getMessage());
}finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log.debug("getObjects|Failure|Error in Closing Session |" + ex2.getMessage());
}
}
if (log.isDebugEnabled())
log .debug("getObjects|Success|Successful in deleting the "+ obj.getClass().getName());
return list;
}
示例5: getObjects
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public List getObjects(Object obj) {
Session s = null;
List list = null;
try {
s = sf.openSession();
Criteria c = s.createCriteria(obj.getClass());
c.add(Example.create(obj));
list = c.list();
} catch (Exception ex){
ex.printStackTrace();
}finally {
try {
s.close();
} catch (Exception ex2) {
ex2.printStackTrace();
}
}
return list;
}
示例6: getObjects
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public List getObjects(Object obj) throws ApplicationException{
Session s = null;
List list = null;
try {
s = sf.openSession();
Criteria c = s.createCriteria(obj.getClass());
c.add(Example.create(obj));
list = c.list();
} catch (Exception ex){
log.error(ex);
if (log.isDebugEnabled())
log .debug("getObjects|Failure|Error in getting objects"+ ex.getMessage());
throw new ApplicationException("An error occured in getting objects" + "\n" + ex.getMessage(), ex);
}finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log.debug("getObjects|Failure|Error in Closing Session |" + ex2.getMessage());
}
}
if (log.isDebugEnabled())
log .debug("getObjects|Success|Successful in deleting the "+ obj.getClass().getName());
return list;
}
示例7: createCriteriaAt
import net.sf.hibernate.Criteria; //导入依赖的package包/类
private Criteria createCriteriaAt(String rootAlias, String associationPath, String alias) throws HibernateException {
String testAlias = StringHelper.root(associationPath);
if ( classByAlias.containsKey(testAlias) ) {
rootAlias = testAlias;
associationPath = associationPath.substring( rootAlias.length() + 1 );
}
createAlias(rootAlias, associationPath, alias);
return new Subcriteria(alias, associationPath);
}
示例8: Page
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public Page( Criteria criteria, int page, int pageSize ) throws HibernateException
{
this.page = page;
this.pageSize = pageSize;
results = criteria.setFirstResult(page * pageSize)
.setMaxResults(pageSize+1)
.list();
}
示例9: listarPaletas
import net.sf.hibernate.Criteria; //导入依赖的package包/类
/**
* @ejb.interface-method
* @ejb.permission role-name="${role.admin},${role.operador}"
*/
public List/*Paleta*/ listarPaletas() {
Session session = getSession();
try {
Criteria criteri = session.createCriteria(Paleta.class);
criteri.setCacheable(true);
return criteri.list();
} catch (HibernateException he) {
throw new EJBException(he);
} finally {
close(session);
}
}
示例10: generateRootAlias
import net.sf.hibernate.Criteria; //导入依赖的package包/类
protected String generateRootAlias(String tableName) {
return Criteria.ROOT_ALIAS;
}
示例11: createCriteria
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public Criteria createCriteria(final Class persistentClass) {
return getSession().createCriteria(persistentClass);
}
示例12: createCriteria
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public Criteria createCriteria(Class persistentClass) {
return new CriteriaImpl(persistentClass, this);
}
示例13: add
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public Criteria add(Criterion expression) {
CriteriaImpl.this.add(rootAlias, expression);
return this;
}
示例14: createAlias
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public Criteria createAlias(String associationPath, String alias)
throws HibernateException {
CriteriaImpl.this.createAlias(rootAlias, associationPath, alias);
return this;
}
示例15: addOrder
import net.sf.hibernate.Criteria; //导入依赖的package包/类
public Criteria addOrder(Order order) {
throw new UnsupportedOperationException("subcriteria cannot be ordered");
}