-->
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.  [ 2 posts ] 
Author Message
 Post subject: how to create two aliases for same entity with createCriteri
PostPosted: Fri Oct 17, 2008 11:32 am 
Beginner
Beginner

Joined: Fri Sep 28, 2007 4:58 am
Posts: 21
Location: Chennai, India
Hi All,

I have a scenario like below.

Criteria studentCriteria = s.createCriteria(Student.class);
studentCriteria.createCriteria("preferredCourse", "preferredCourse1", Criteria.LEFT_JOIN);
studentCriteria.createCriteria("preferredCourse", "preferredCourse2", Criteria.LEFT_JOIN);

When I used the above I am getting an error show below.
org.hibernate.QueryException: duplicate association path: impactImperatives
at org.hibernate.loader.criteria.CriteriaQueryTranslator.createAssociationPathCriteriaMap(CriteriaQueryTranslator.java:141)

please do the needful.

Thanks in advance.

Regards,

_________________
Purushotham Podaralla


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2008 1:14 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
I believe multiple aliasing can't be done in using Criteria, and they are not in a hurry to implement this feature, either.

You can use HQL, instead:

Code:
      Query query=session.createQuery("
                                  select s from Student s
                                  left join s.preferredCourse pc1
                                  left join s.preferredCourse pc2" );
      query.list();

_________________
Gonzalo Díaz


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.