-->
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: duplicate association path
PostPosted: Mon May 05, 2008 1:56 pm 
Newbie

Joined: Mon May 05, 2008 1:42 pm
Posts: 1
Hi,

I have a problem with Criteria object. No matter if I use the approach that embeds a criteria in a criteria or I use createAlias when I try to fetch something in a join table, I always get this exception:

org.hibernate.QueryException: duplicate association path

See the exemple below that comes from the hibernate documentation:

15.4. Associations
You may easily specify constraints upon related entities by navigating associations using createCriteria().

List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "F%") )
.createCriteria("kittens")
.add( Restrictions.like("name", "F%") )
.list();
note that the second createCriteria() returns a new instance of Criteria, which refers to the elements of the kittens collection.

The following, alternate form is useful in certain circumstances.

List cats = sess.createCriteria(Cat.class)
.createAlias("kittens", "kt")
.createAlias("mate", "mt")
.add( Restrictions.eqProperty("kt.name", "mt.name") )
.list();

However, it works if only one element is fetched. Each time two criterias are fetched in the same time (say I want all kittens that are brown and all kitttens that hav a short tail), I got the exception.

Is there a way to prevent getting this exception?

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.