-->
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: A dynamic name table
PostPosted: Thu Feb 21, 2008 11:57 am 
Newbie

Joined: Thu Feb 21, 2008 11:01 am
Posts: 2
Hello,

I would like to know how we could had a dynamic table name in hibernate.

I've 10 environnements with 10 tables (with the same structure) with a specific name on each environnement. How i can place it in a properties file ?

This is an example :

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="fr.toto.domain">
<class name="BonDeTravail" table="TAB_X1" schema="F_SW">
<id name="numeroSecu" column="F_Id" > </id>
<property name="pole" column='"NOM"' type="string" />
</class>
</hibernate-mapping>

The name "TAB_X1" can be "TAB_N3" on other environnement .....


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 21, 2008 12:11 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
You can manipulate table names when create SessionFactory for that environment. You have to create a SessionFactory for each environment. So you can access Configuration class properties to read the mappings and update the table name. Be cautious!!!


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.