Hi,
We use hibernate 3
We have a class of type A which includes a component of type Data with a set of Contexts
This way :
Code:
public class Context {
protected String id;
protected String name;
<...>
}
Code:
public class Data {
protected Set<Context> contexts;
<...>
}
Code:
public class A{
protected String id;
protected String name;
protected Data data;
<...>
}
The mapping files are :
Code:
<hibernate-mapping >
<class name="Context" table="CONTEXT" >
<id type="string" name="id" column="CONTEXT_ID" length="20">
<generator class="..." />
</id>
<property name="name" type="string">
<column name="NAME" length="50" />
</property>
</class>
</hibernate-mapping>
and :
Code:
<hibernate-mapping >
<class name="A" table="A">
<id type="string" name="id" column="A_ID" length="20">
<generator class="..." />
</id>
<property name="name" type="string">
<column name="NAME" length="50" />
</property>
<component name="data">
<set name="contexts" table="CONTEXT_A">
<key column="A_FK" />
<many-to-many class="Context" column="CONTEXT_FK" order-by="CONTEXT_ID asc"/>
</set>
</component>
</class>
</hibernate-mapping>
At the same time we have a sub class of type B
Code:
public class B extends A {
}
With a mapping file as :
Code:
<hibernate-mapping >
<joined-subclass name="B" extends="A"
table="B">
<key column="B_ID" />
</joined-subclass>
</hibernate-mapping>
when we write a HQL query this way :
Code:
select count(b) from B as b left join b.data.contexts as context where context.name = :value
The query is correctly translated but an oracle exception is thrown due to a bad management of join :
select count(b0_.B_ID) as col_0_0_ from B b0_
inner join A b0_1_ on b0_.B_ID=b0_1_.A_ID
inner join CONTEXT_A contexts1_ on
b0_1_.B_ID=contexts1_.A_FK
inner join CONTEXT context2_ on contexts1_.CONTEXT_FK=context2_.CONTEXT_ID
inner join A context2_1_ on context2_.CONTEXT_ID=context2_1_.A_ID
where context2_.NAME = ?
Error message is : ORA-00904: "B0_1_"."B_ID" : identificateur non valide
And it's true because the bold part of request must be
b0_1_.A_ID because "contexts" set is part of component Data in A and not in B.
what'is wrong ?
thansk is advance