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.