-->
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.  [ 9 posts ] 
Author Message
 Post subject: How to manage dynamic table names
PostPosted: Tue Sep 23, 2003 4:09 am 
Newbie

Joined: Tue Sep 23, 2003 3:58 am
Posts: 2
Hi

I am working on a serverbased web-application where tables are created dynamically, sort of on a project-basis. When a new project is created in the application, a new table is created dynamically. Later on when the projects is finished, the table is dropped from the database.

I have started to use hibernate for this project but I dont know how to handle the mapping for these dynamic tables. Each dynamic table is more or less a copy of template table, and they map to the same Class.

Does anybody have any idea on how to map one class to a dynamic number of tables, all with a slightly different table name ?

Any idea would be welcome.

Regards
Erik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2003 1:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
It is difficult and complex but it can be done. You need to get to the Configuration class and bind the Meta Data etc. You will need to create a new session factory to use the new mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2004 9:23 pm 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
I have a very similar situation.

I don't mind digging for the proper configuration and recreating
a session factory, but I do not understand how a single class
can be mapped to several tables - possibly with different structure
in my case.

Can someone elaborate on David's response?

Thanks!

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 9:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Manual building of the mapping DOM tree and passing it to the configure() method would be the way which will work most likely. That way you can generate your mappings completely dynamical.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 9:51 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Mapping one concrete class to different tables is not (yet) allowed. This is expected in the 2.2 version.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 9:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
What you can do however (I think mschulz rather meant that) is to map one class differently for different SessionFactories. One class may however not be spread out over mutliple tables at the same time. (may be possible in 2.2. as emmanuel said)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 4:38 pm 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
What I am looking for is the equivalent thing to a
<dynamic-component>, but on the class-level.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 4:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The <dynamic-class> mapping is already implement in the v22branch.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2004 5:27 pm 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
Thanks Gavin,

I'll check that out.


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