Hibernate 使用中的一些总结

来源:互联网 发布:c amf数据 编辑:程序博客网 时间:2024/05/17 23:13


1、对于substrng函数,下标从1开始,java从0开始,用法

List<Subject> list = getHibernateUtil().createQuery("from Subject s where s.del = false and substring(s.subId,1,3) =:subjectId and length(s.subId)<>3").setString("subjectId", subjectId).list();


2、以实体中的集合作为查询条件,如一个用户有很多的角色,查询角色id含有11的用户

String hql = "select distinct a from Admin a left join fetch a.roles r where a.isdel <>2 and r.roleId=11" ;

原创粉丝点击