-->
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.  [ 2 posts ] 
Author Message
 Post subject: using outer-join with 'joined subclasses'?
PostPosted: Mon Oct 18, 2004 4:55 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 18, 2004 10:36 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
okay ... writing my own Persister isn't really a good idea, because it won't handle all situations.

The only possibililty for me using "version"-columns seems to depend on using "outer-join" with a joind-subclass because the ibm db2 on as400 doesn't support anything which i've found so far (including instead-of-trigger).

it would be great if someone has an idea how to manage outer-joins with joined-subclasses ...

and if i'm only completely blind, you can hit me and i'll go back to school and learn something different ;-)

thx!
carsten

P.S.: Using my own HQL to load a class is a way which i wouldn't like to go because i think it will be difficult doing it in a generic way ... (must be for all 'read-methods' like 'load', 'get', 'find' etc..)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.