-->
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: Help: Mixing <join> and <joined-subclass>
PostPosted: Fri Mar 16, 2007 5:52 am 
Newbie

Joined: Thu Mar 15, 2007 2:25 am
Posts: 6
I have a situation in which I think I need to mix the <join> and <joined-subclass. elements, but of course this is prohibited by the DTD. I wouldlike any help or suggestions...

I have a simple class heirarchy as follows:

Code:
                    Actor (abstract base class)
                             |                 
                  ----------------------
                 |                      |
        Organization               Individual               (concrete classes)


Actor has the following properties:
#Name
#Description
#StartDate

Organization and Individual have a couple properties of their own.

What complicates this is that the name and description are internationalized strings and therefore stored in a separate joined table in the database. The database schema for these is a follows (i cannot change the schema).

Actor
Actor_Id integer
StartDate date
...

ActorMessage
Actor_Id
Name
Description
Locale

Organization
Actor_Id
Industry
Region
...

Individual
Address
...

Basically, I would like to join the Actor and ActorMessages using a <join> element to persits and retrieve the internationalized actor strings from two tables (into one actor object) whil also using the <joined-subclass> elements to define my table-per-subclass inheritance structure using the table schema i have. The mapping would look something like this...

Code:
<class name="com.sb.app.model.Actor" table="Actor">
     <id name="id" column="Actor_Id">
          <generator class="native"/>
     </id>
     <property name="startDate" column="StartDate" type="date"/>
     <join table="ActorMessage">
          <key column="Actor_Id"/>
          <property name="name" column="Name" length="512"/>
          <property name="description" column="Description" length="4000"/>
          <property name="locale" column="Locale" length="5"/>
     </join>
     <joined-subclass name="Organization" table="Organization">
          <key column="Actor_Id"/>
          <property name="industry" column="Industry">
          <property name="region" column="Region"/>
          ... other properties
     </joined-subclass>
     <joined-subclass name="Individual" table="Individual">
          <key column="Actor_Id"/>
          <property name="address" column="Address">
          ... other properties
     </joined-subclass>
</class>


This seems like the ideal/most elegant way to describe my class model given the database schema, the problem is that the DTD doesn't allow the coexistence of the <join> and <joined-subclass> elements. I can't figure out another mapping strategy that will acheive exactly what my business model describes give the db schema. And the DB schema seems appropriate for the problem.

Any help is appreciated.

Regards,
Eric


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 12:08 pm 
Beginner
Beginner

Joined: Tue Jun 28, 2005 2:43 pm
Posts: 29
Location: Silicon Valley
One possibility is to map ActorMessage directly as a class associated with Actor.

Code:
                    Actor <----- ActorMessage
                       |                 
            ----------------------
           |                      |
  Organization               Individual               (concrete classes)


Your hibernate mapping is then a straightforward <one-to-one> association instead of a <join> element.

You can keep all the same methods on Actor in your java code, but make get/setName and get/setDescription delegate to the associated ActorMessage object.


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.