Explain a simple statement hibernate

Category: Java EE
 
gxb392560688
2008-12-21 08:50:51

Sponsored Links
Session session = this.getSession();
Criteria criteria = session.createCriteria(ClazzRoleUser.class);
criteria.add(Restrictions.eq("clazz.clazzID", clazzId));
criteria.add(Restrictions.eq("user.userID", userId));


explain What do you mean?

Sponsored Links

qq277105395
2008-12-21 09:03:39
Session session = this.getSession (); / / equivalent to the link to get JDBC
Criteria criteria = session.createCriteria (ClazzRoleUser.class); / / equivalent to get Statement, but operated on here
Objects do limit, only ClazzRoleUser (corresponding table)

criteria.add (Restrictions.eq ("clazz.clazzID", clazzId)); / / pretty Add a table to the query conditions in clazzID = clazzId
criteria.add (Restrictions.eq ("user.userID", userId)); / / Similarly
luojian12345
2008-12-21 09:05:54
FROM ClazzRoleUser cru WHERE (clazz.clazzID = clazzId) and (user.userID = userId)

know Is not
hushuang1314
2008-12-21 09:15:09
Criteria object can only query on a table object, an object can not be applied in addition to query other tables ........

This is the hibernate norms, not able to freely change ..........

If you need to use objects child objects to operate other tables, only use HQL statement ....... ....
amoteyueshen
2008-12-21 09:18:09
added:

Criteria object typically used synthetic mode ..........

this is a landlord point just outside the subject complement ...
prince_x00
2008-12-21 09:33:45
selecct * from ClazzRoleUser where clazzID = clazzID and userID = userID do not understand me? Brother
xiaohu_ff
2008-12-21 09:45:26
ok, but now there is a problem!
Clazz property is ClazzRoleUser inside a class reference.
Clazz.clazzID I checked when the need to check the ID of the table Clazz But I do not want to go Clazz list check!
just want to check on their table! how to do?

not know clearly did not, I feel not good expression
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.