-->
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.  [ 1 post ] 
Author Message
 Post subject: Cast betwen Subclasses
PostPosted: Fri Feb 23, 2007 7:14 am 
Newbie

Joined: Fri Feb 23, 2007 6:28 am
Posts: 1
Hi

I have the following structure:

Class Organisation mapped to TORGANISAT table, it contains an Id and some general fields and there are some Sub-classes and DB table with a foreign key (fk_torg_laufnr) to the organisation table for each subclass.

The Mapping looks something like that:
Code:
<hibernate-mapping>
   <class name="najs.model.Organisation" table="TORGANISAT">
      <cache usage="read-write" />
      <id name="id" column="ILAUFNUMMER" type="java.lang.Integer">
         <generator class="sequence">
            <param name="sequence">seq_torganisat</param>
         </generator>
      </id>
      <property name="orgNr" type="java.lang.String">
         <column name="SORGNR" length="10" not-null="false" />
      </property>
      [...]
      <joined-subclass name="najs.model.Schule" table="TSCHULE">
         <key column="FK_TORG_LAUFNR" />
         <property name="name" type="java.lang.String">
            <column name="SNAME" length="50" not-null="true" />
         </property>
         [...]
      </joined-subclass>
      [...]
      <joined-subclass name="najs.model.Verein" table="TVEREIN">
         <key column="FK_TORG_LAUFNR" />
         <property name="name" type="java.lang.String">
            <column name="SNAME" length="50" not-null="true" />
         </property>
         [...]
      </joined-subclass>


Now I have to convert some Class-Objects to other Subclass types (eg School to Institution). On DB the only thing that should be done is to delete the entry in TSCHULE (for School) and insert new entry in TVEREIN (Institution), but leave the base in TORGANISAT untouched.

I've done it so far with native sql (direct on the jdbc connection from hibernate), but I cannot load the new Object with Hibernate in the same Request. I've checked it by setting a breakpoint after the commit is done with Squirrel SQL Client, the changes are on DB but Hibernate returns then the old data.

Does anyone now a better solution for this type of cast? Or at least how I can get the actual data from Hibernate?[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.