赶尸匠漫画全部:Hibernate限制查询结果集
来源:百度文库 编辑:九乡新闻网 时间:2024/04/20 04:38:03
一个单独的查询条件是org.hibernate.criterion.Criterion
接口的一个实例。org.hibernate.criterion.Restrictions
类 定义了获得某些内置Criterion
类型的工厂方法。
List cats = sess.createCriteria(Cat.class).add( Restrictions.like("name", "Fritz%") ).add( Restrictions.between("weight", minWeight, maxWeight) ).list();
约束可以按逻辑分组。
List cats = sess.createCriteria(Cat.class).add( Restrictions.like("name", "Fritz%") ).add( Restrictions.or(Restrictions.eq( "age", new Integer(0) ),Restrictions.isNull("age")) ).list();
List cats = sess.createCriteria(Cat.class).add( Restrictions.in( "name", new String[] { "Fritz", "Izi", "Pk" } ) ).add( Restrictions.disjunction().add( Restrictions.isNull("age") ).add( Restrictions.eq("age", new Integer(0) ) ).add( Restrictions.eq("age", new Integer(1) ) ).add( Restrictions.eq("age", new Integer(2) ) )) ).list();
Hibernate提供了相当多的内置criterion类型(Restrictions
子类), 但是尤其有用的是可以允许你直接使用SQL。
List cats = sess.createCriteria(Cat.class).add( Restrictions.sqlRestriction("lower({alias}.name) like lower(?)", "Fritz%", Hibernate.STRING) ).list();
{alias}
占位符应当被替换为被查询实体的列别名。
Property
实例是获得一个条件的另外一种途径。你可以通过调用Property.forName()
创建一个Property
。
Property age = Property.forName("age");List cats = sess.createCriteria(Cat.class).add( Restrictions.disjunction().add( age.isNull() ).add( age.eq( new Integer(0) ) ).add( age.eq( new Integer(1) ) ).add( age.eq( new Integer(2) ) )) ).add( Property.forName("name").in( new String[] { "Fritz", "Izi", "Pk" } ) ).list();
Hibernate限制查询结果集
Hibernate中的criteria查询
hibernate 联合查询
Hibernate,HQL外置查询
Hibernate实体查询
Hibernate 查询,做分页处理
Hibernate插入、查询、删除操作 HQL (转)
乙肝检查结果指标查询
**VFP与 EXCEL - 查询结果输出-很好
hibernate 缓存
Hibernate配置文件
Hibernate参考资料
sp_lock 结果集含义
2011年各地高考成绩、录取日程及录取结果查询
江苏省教育考试院 考生可通过三种方式免费查询录取结果
hibernate 动态pojo Map
hibernate Restrictions用法
hibernate inverse样例
hibernate 二级缓存实际应用
Hibernate 参数设置一览表
Hibernate的dialect大全
Hibernate配置常见异常
Struts Hibernate Spring 概要
Hibernate Tools Guide