On a start, hello to everyone!
I have two classes
Code:
class Source{
int id;
Set<Thread> threads;
String lang;
... // other fields, getters and setters
}
class Thread{
long id;
Source parent;
String lang;
... // other fields, getters and setters
}
and mappings
Code:
<class name="Source" table="source">
<id name="id">
<generator class="native" />
</id>
<property name="lang" length="5" />
<set name="threads" inverse="true">
<key column="thread_id" not-null="true" />
<one-to-many class="Thread" />
</set>
</class>
<class name="Thread" table="thread">
<id name="id" column="thread_id">
<generator class="native" />
</id>
<many-to-one name="source" column="source_id" class="ThreadsSource" />
<!-- point of interrest -->
<join table="source" >
<key foreign-key="source_id" >
<column name="id" />
</key>
<property name="lang" update="false" insert="false" />
</join>
</class>
I want 'lang' property from Source class to be populated over it's Threads (i want 'source' property to be loaded lazy and 'lang' property fetched from 'source' table immediately and placed into Thread class). Hibernate is placing 'lang' property in SQL queury but it's join fragment is like this:
Quote:
join source on thread.thread_id = source.id
and it should be:
Quote:
join source on thread.source_id = source.id
There is no change if I remove 'foreign-key' parameter from '<key ...' or when i place 'inverse' into the '<join ...'.
I would be greatful if you help me with it.
Thanks
Piotrek
---
hibernate 3.3.0.SP1
on 3.5.6-Final too