-->
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: Discussion about table-per-concrete-class
PostPosted: Fri Nov 25, 2005 10:57 am 
Newbie

Joined: Wed Oct 26, 2005 7:35 am
Posts: 10
I have the following problem:

We want to change our object to relational mapping tool to hibernate.
In our previous mapping tool we used the following strategy:
- table-per-concrete-class
- identity id generation
- generate POJO's from our mapping-document.

We don't need polymorphism !!

If I do this with hibernate I can choose the following solutions:

1. union-subclass mapping.
This seems to me the best solution for table-per-conrete-class, but then we have to change the id-generation method. Now we generate an Id which is unique for each table. But when we have to use union-subclass then we have to convert our id-generation strategy to a global generation strategy.
If we do that then we have a big backwards compatabiliy problem, because I have to change the ids of the records to global ids. And I have to change the foreign keys with them.
So this solution is very difficult to apply.

2. define multiple classes.

Then I will use the simple way of mapping

Code:
<class name="SubClass1" extends "SuperClass>
..
</class>

<class name="SubClass2" extends "SuperClass>
..
</class>


Now I have to write SuperClass by hand. I cannot generate it. And also have to define the common properties twice ( One time in SubClass1 and one time in SubClass2 ). This will generate in the code my properties twice.
I can relax this drawback when I use
<!ENTITY allproperties SYSTEM "SuperClass.xml">

This solution is possible, but has some drawbacks:
- I have to write the SuperClass by myself
- I have to use ENTITY to prevent double coded xml ( I don't like this )
- From ideal perspective the common properties have to be defined in the super-class.

Discussion

Is it possible to relax the usage of union-subclass, so that I can use identity id generation ?
Of course I will accept the drawback that I break polymorphism.

Or maybe the SuperClass of solution 2 have to be generated with the properties shared in the SubClasses.

Or I have to accept this situation.

What do you think ?


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.