Hi have a User Object, which has many Relation Objects and we use OneToMany annotation for User attribute which has list of Relation objects it holds.
In order to find a perticular relation of the user, the commented approach results in 'cannot simultaneously fetch multiple bags'
However when I use the select stament, things work fine. Using Set instead of List is not applicable to us as we need to have get(i) and other behavious realted to List.
Session lSession = HibernateUtil.getTransactionSession();
Query query = lSession.createQuery(
"SELECT x FROM Relation x WHERE x.relation = :aRelation and x.user.loginID = :aLoginID");
query.setParameter("aRelation", aRelation);
query.setParameter("aLoginID", aLoginID);
Relation lRelation = (Relation) query.uniqueResult();
//Session session = HibernateUtil.getSession();
//Criteria cr = session.createCriteria(Relation.class);
//cr.add(Restrictions.ilike(Relation.FIELD_RELATION, aRelation));
//cr.createCriteria(UserAssociated.FIELD_USER).add(
// Restrictions.ilike(User.FIELD_LOGIN_ID, aLoginID));
//Relation lRelation = (Relation) cr.uniqueResult();
lSession.close();
return lRelation;
Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com