I am trying to join multiple table to join using criteria but getting error in doing so can someone please help me in it My code is
我正在尝试加入多个表来加入使用标准,但是这样做会有错误,有人可以帮助我,我的代码是
final Session session = getSession();
final Criteria criteria = session.createCriteria(ReferralPaymentInfo.class).createCriteria("SIGNUP_REFERRAL");
System.out.println("before");
List list = criteria.list();
System.out.println("after");
I also tried this code final Session session = getSession(); final Criteria criteria =session.createCriteria(ReferralPaymentInfo.class); criteria.setFetchMode("SIGNUP_REFERRAL", FetchMode.JOIN); List list = criteria.list();
我也试过这段代码最后的Session session = getSession(); final Criteria criteria = session.createCriteria(ReferralPaymentInfo.class); criteria.setFetchMode(“SIGNUP_REFERRAL”,FetchMode.JOIN); List list = criteria.list();
This gives result only from table ReferralPaymentInfo and not considering table SIGNUP_REFERRAL Can some one please help me out T
这只给出了来自表ReferralPaymentInfo的结果,而没有考虑表SIGNUP_REFERRAL可以请一些人来帮助我T
1 个解决方案
#1
0
try this
尝试这个
DetachedCriteria ownerCriteria = DetachedCriteria.forClass(Owner.class);
ownerCriteria.setProjection(Property.forName("id"));
ownerCriteria.add(Restrictions.eq("ownername", "name"));
Criteria criteria = getSession().createCriteria(Pet.class);
criteria.add(Property.forName("ownerId").in(ownerCriteria));
#1
0
try this
尝试这个
DetachedCriteria ownerCriteria = DetachedCriteria.forClass(Owner.class);
ownerCriteria.setProjection(Property.forName("id"));
ownerCriteria.add(Restrictions.eq("ownername", "name"));
Criteria criteria = getSession().createCriteria(Pet.class);
criteria.add(Property.forName("ownerId").in(ownerCriteria));