-->
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.  [ 4 posts ] 
Author Message
 Post subject: Criteria object generating erroneous SQL
PostPosted: Fri Jun 25, 2004 4:37 pm 
Regular
Regular

Joined: Thu Jan 29, 2004 10:34 am
Posts: 52
Location: Austin, TX
i've been using the Criteria API quite successfully so far. but after a recent change in the model (one-to-one was changed to many-to-one due to the limitation in oracle to do primary key based association between 1..1 entities) the generated sql started to look something like this:

Code:
from deviceconfigurationversion this
   inner join managed_element x0_ on this.managedElement=x0_.id
   left outer join IOSManagedElementImpl x0__1_ on x0_.id=x0__1_.ManagedElement
   left outer join ThreeCOM_4400MngdElementImpl x0__2_ on x0_.id=x0__2_.ManagedElement
   inner join chassis x1_ on x0_.chassis=x1_.id
   left outer join IOSChassisImpl x1__1_ on x1_.id=x1__1_.Chassis
   left outer join ThreeCOM_4400ChassisImpl x1__2_ on x1_.id=x1__2_.Chassis
   inner join memory x2_ on x1_.flashMemory=x2_.id
   inner join chassis x1_ on x0__1_.chassis=x1_.id
   left outer join IOSChassisImpl x1__1_ on x1_.id=x1__1_.Chassis
   left outer join ThreeCOM_4400ChassisImpl x1__2_ on x1_.id=x1__2_.Chassis
   inner join memory x2_ on x1_.flashMemory=x2_.id
   inner join chassis x1_ on x0__2_.chassis=x1_.id
   left outer join IOSChassisImpl x1__1_ on x1_.id=x1__1_.Chassis
   left outer join ThreeCOM_4400ChassisImpl x1__2_ on x1_.id=x1__2_.Chassis
   inner join memory x2_ on x1_.flashMemory=x2_.id

where (x2_.mem_size>?)


which simply causes this on mysql
Code:
ERROR 1066: Not unique table/alias: 'x1_'


since the same table alias is being used for a table in multiple joins. i'm wondering if anyone has ran into this kind of problem. the model is quite complex and has several joined subclasses.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2004 4:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
what version of hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2004 4:42 pm 
Regular
Regular

Joined: Thu Jan 29, 2004 10:34 am
Posts: 52
Location: Austin, TX
2.1.4


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2004 5:53 pm 
Regular
Regular

Joined: Thu Jan 29, 2004 10:34 am
Posts: 52
Location: Austin, TX
i'm still debugging this but if it's of any help, the associations go like this:

(1) deviceconfigurationversion ---> managed_element (many-to-one)
(2) managed_element ----> chassis (many-to-one)
(3) chassis ----> memory (many-to-one)
(chassis has a column flashMemory)

and IOSManagedElementImpl, ThreeCOM_4400MngdElementImpl etc. are all joined subclasses.

the exact same criteria works fine when (1) and (2) are mapped as one-to-one.

any known bugs? (gavin?)

ty


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.