有一个类:
Class A{
long objectPK;
string objectname;
long parentID;
long priorID;
int type//取值:type=2,type=3,type=6;
string userID;
}
现在有一个hql语句,我想用criteria表示:
hql="from A as obj1 where obj1.userID=sender and obj1.type=2 and obj1.parentID=0 and obj1.objectPK in (select obj2.priorID from A as obj2 where obj2.userID is null and obj2.type=6 )"
请问这个用hibernate Criteria如何表示?多谢!
Class A{
long objectPK;
string objectname;
long parentID;
long priorID;
int type//取值:type=2,type=3,type=6;
string userID;
}
现在有一个hql语句,我想用criteria表示:
hql="from A as obj1 where obj1.userID=sender and obj1.type=2 and obj1.parentID=0 and obj1.objectPK in (select obj2.priorID from A as obj2 where obj2.userID is null and obj2.type=6 )"
请问这个用hibernate Criteria如何表示?多谢!
解决方案 »
- SSH整合出现如下错误,求解?
- Hibernate初学者出现一个错误,跪求高手解决!!!
- 怎么动态 加载一个方法 加载到ApplicationContext上下文中
- Access denied for user 'root'@'localhost' (using password: NO)
- 有谁想找工作
- tomcat和apache集成问题
- 跪求 Spring Web Flow教程
- 哪位好人提供有关jbuilder9+weblogic6+oracle8的配置方法
- EJB的server和client在同一台电脑上有意义吗?JSP+Bean+EJB结构是不是需要三台电脑才合理?
- jsp 编译后 输出 到网页中的动态内容是何时被添加进去的
- 急急 关于运行java做的exe程序获取一个文件的类容,在线等..
- java后台实现调用ocx
criteria.add(Restrictions.eq("userID", "sender"))
.add(Restrictions.eq("userID", "sender"))
.add(Restrictions.eq("parentID", new Long(0)))
//下边这段用sql,因为你的class A没有关联,criteria 没办法,当然你也可以先把那些objectPK 查询出来,然后传一个数组进来
//做法是这样的 .add(Restrictions.in("objectPK ", objPks));//objpks是一个数组
.add(Restrictions.sqlRestriction(" objectPK in (select obj2.priorID from A as obj2 where obj2.userID is null and obj2.type=6 ");