-->
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.  [ 7 posts ] 
Author Message
 Post subject: Sharing data classes
PostPosted: Thu Sep 02, 2004 10:57 am 
Newbie

Joined: Mon Jul 05, 2004 8:37 am
Posts: 15
Hibernate version:
2.1

Name and version of the database you are using:
Oracle9i


Is there a way to share data classes among different tables in hibernate? I have multiple tables that are named differently but have the same structure. I was wondering if there was a way to use the same data object for multiple tables?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 8:10 pm 
Newbie

Joined: Wed Sep 01, 2004 7:04 pm
Posts: 3
Location: Melbourne, Australia
I haven't actually done this, but from reading the docs I would have thought you could multiple configuration files for the same class and add and remove them from the Configuration. Or programatically change the configuration to point a class at a different table.

by the way, this is just a guess. I am sure one of the other more advanced users would have a moer difinitive answer.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 2:31 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Can you give a litle bit more information about your scenario? It depends whether this tables are in the same db and wheter you want to access them in the same session/transaction or in separate ones.

HTH
Ernst


Top
 Profile  
 
 Post subject: Re: Sharing data classes
PostPosted: Fri Sep 03, 2004 5:23 am 
Newbie

Joined: Tue Jan 27, 2004 3:26 pm
Posts: 18
twufire wrote:
Hibernate version:
2.1

Name and version of the database you are using:
Oracle9i


Is there a way to share data classes among different tables in hibernate? I have multiple tables that are named differently but have the same structure. I was wondering if there was a way to use the same data object for multiple tables?


You can configure multiple session factories (thus multiple sessions) with different mappings. This is not elegant solution, though.

In hibernate3 there are named-entities. You just map named entities to tables (not ordinary classes). But this is in alpha stage :(

Artur


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 5:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
In Hibernate3 there is (named entities), but in Hibernate 2.1, you would need to use multiple SessionFactory instances.


Top
 Profile  
 
 Post subject: multiple session factories
PostPosted: Fri Sep 03, 2004 8:09 am 
Newbie

Joined: Mon Jul 05, 2004 8:37 am
Posts: 15
That makes sense. Thank You.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 12:26 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I think a good way is to create new table with one more field, copy data to this new table and create views for old applications using new enum field, it must be possible to do it without problems on Oracle, you can create partitions by this field to maintain index per partition too(it is known as transparent data model optimization ).


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