Hibernate version:
2.1.6
Hi there,
is it possible to use outer-join with "joined-subclasses"?
Background:
It's not possible to add a version-column to exisiting database-tables (due to existing applications which should not be changed). Therefore i want to add a seperate table for versioning. The version-information is kept in a root-class (for each object a different one).
The mapping will work via "joined-subclass".
The Problem is, that there're about >20 million records in the current db and i 'm not allowed to add a version-record to all of them.
Therefore it would be a possiblity to use "outer-join"-fetching and adding a version-number (if it's null or '0') 'by hand'.
I haven't managed it so far to use a one-to-one-Relationship with versioning, so this is my last option not to use "optimistic-lock='all'" with 'detached objects' ... (i hope my 'hibernate in action'-book will arrive soon)
Mapping for version-root-object:
Code:
<hibernate-mapping>
<class
name="hibernate.test.EntryVersion"
table="testtable_v"
optimistic-lock="version">
<id
name="id"
column="id"
type="integer"
unsaved-value="0">
<generator class="increment"/>
</id>
<version column="version" name="version"/>
<joined-subclass name="hibernate.test.Entry" table="testtable">
<key column="id"/>
<property name="changefield" type="string"/>
</joined-subclass>
</class>
</hibernate-mapping>
Mapping for data-object:Code:
<hibernate-mapping>
<class
name="hibernate.test.Entry"
table="testtable">
<id
name="id"
column="id"
type="integer"
unsaved-value="0">
<generator class="increment"/>
</id>
<property
name="changeField"
column="changeField"
type="string"
length="100"/>
</class>
</hibernate-mapping>
I've tried setting "hibernate.use_outer_join=true" and "hibernate.max_fetch_depth=0" but wihtout a result. I hope this is a rfm-question and i'm only a little stupid ;)
I wasn't able to find 'outer-join' for 'joined-subclass' in the mapping-dtd.
Another possiblity would be using proxies. But it wouldn't be easy handling all situations ... i don't like it.
A third alternativ is to write my own persister for that ... if the version-entry is not available i could create one and retry the "select" ...
This is my favorit, if 'outer-join" is not possible.
thx!
carsten