-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Could not resolve property exception on 3 Tables join.
PostPosted: Tue Feb 19, 2013 10:40 pm 
Newbie

Joined: Tue Feb 19, 2013 10:12 pm
Posts: 1
Hi, I am trying to generate the following SQL in hibernate using the HibernateTemplate:
Code:
SELECT TRAN_CLNT_GRP.GRP_NAME AS GRP_NAME
  FROM TRAN_CLNT_GRP
  JOIN TRAN_USER_GRP
    ON TRAN_CLNT_GRP.GRP_ID_SGN = TRAN_USER_GRP.GRP_ID
  JOIN TRAN_CLNT
    ON TRAN_CLNT.CLNT_ID_SGN = TRAN_USER_GRP.CLNT_ID
WHERE TRAN_USER_GRP.USER_ID = 'foobar'
   AND TRAN_CLNT.CLNT_NAME = 'Internal Client'

This is the method I wrote using a DetachedCriteria....
Code:
public List<String> fetchSecAdminGroupByUserId(final String userID) {
      
      final DetachedCriteria criteria = DetachedCriteria
            .forClass(TranClntGrp.class);
      criteria.createCriteria("tranClnt");
      criteria.createCriteria("tranUserGrp");
      
      criteria.setProjection(Projections
            .projectionList()
            .add(Projections.property("tranClntGrp.grpName").as("grpName")));
      criteria.add(Restrictions.eq("tranUserGrp.comp_id.userId", userID));
      criteria.add(Restrictions.eq("tranClnt.clntName", "Agilink Internal Client"));
      
      final List<String> results = (List) get(criteria);
      return results;
   }

These are the tables value objects :
Code:
public class TranUserGrp implements Serializable {
       private dao.hibernate.vo.TranUserGrpPK comp_id;
      ..................}

Code:
public class TranUserGrpPK implements Serializable {
    private Long clntId;
    private String userId;
    private Long grpId;
    ..............}

Code:
public class TranClntGrp implements Serializable {
    private dao.hibernate.vo.TranClntGrpPK comp_id;
    private String grpName;
    ...................}

Code:
public class TranClnt implements Serializable {
    private Long clntIdSgn;
    private String clntName;
    ......................}

When I ran my method it is throwing this exception: org.hibernate.QueryException: could not resolve property: tranUserGrp of: .dao.hibernate.vo.TranClntGrp
Can you please tell me what I am doing wrong? Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.