-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping pojo to dynamic table names
PostPosted: Sun Nov 02, 2008 8:20 pm 
Newbie

Joined: Sun Nov 02, 2008 8:05 pm
Posts: 1
Location: Seattle
Hi,
Is it possible in hibernate to dynamically bind the table name to a pojo?
(properties of pojo and column names of the table remain same,but the tables are created dynamically with random names)
Any help appiciated.
Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 4:17 pm 
Newbie

Joined: Thu Oct 23, 2008 6:37 pm
Posts: 2
I'm with this same problem. You managed to solve it? And some columns in my case change the name ....
Sorry for my english, I'm learning yet.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 6:06 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
We are doing something like that in our project. Here is a summary of the procedure:

1. We have a template file that contains the basic structure of a Hibernate XML mapping file. See http://base.thep.lu.se/browser/trunk/sr ... awData.xml

2. In our startup code we read in this template file as an XML Document object. We are using JDOM for this. Once we have it as a Document it is easy to manipulate attributes, for example, the table-name. We are also adding <property> definitions for some additional properties (defined by a system admin in a different XML file).

The relevant part of this code can be found at http://base.thep.lu.se/browser/trunk/sr ... .java#L297

3. The last part simply registers the manipulated Document with the Hibernate configuration: Configuration.addDocument().

4. Once everything is setup the configuration is used to create the SessionFactory: http://base.thep.lu.se/browser/trunk/sr ... .java#L185

I hope you can make some use of this information.


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