-->
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: Dynamic hibernate mapping file
PostPosted: Sun Aug 08, 2010 5:41 am 
Newbie

Joined: Sat Aug 07, 2010 5:37 am
Posts: 6
I want to change the schema name in my mapping file depending on the deployement environnement.
The schema name is not the same for all the classes in the mapping file.

Unfortunately, we dont use maven to deploy in different environnements.

<class
name="ClassName"
table="tableName"
schema="owner" />

Is there any way to that with hibernate.
For example:
<class
name="ClassName"
table="tableName"
schema="${prop}" />

And in the a properties file:
prop=owner

The goal, is to put all the data to be configurable in one external file.
Thx in advance for you help.


Top
 Profile  
 
 Post subject: Re: Dynamic hibernate mapping file
PostPosted: Mon Aug 09, 2010 4:24 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi IlikeJava,

If the tables are configurable , what about the columns ? not all the columns present in one table is present in all the other tables. So if you have the table design / purpose of this implementation, it can be answerable.

--

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: Dynamic hibernate mapping file
PostPosted: Mon Aug 09, 2010 3:11 pm 
Newbie

Joined: Sat Aug 07, 2010 5:37 am
Posts: 6
Here is an example of my mapping file:

<!-- ============================ -->
<!-- Table TABLE1 -->
<!-- ============================ -->
<class table="TABLE1"
name="com.myCompany.Entity1" lazy="false" schema="SCHEMA1">
<!-- Attributs -->
<id column="ID" name="id" type="string" />
<property column="ACTION_TYPE" name="actionType"
type="com.myCompany.ActionEnumType" not-null="true" />
<property column="PRIORITY" name="priority"
type="com.myCompany.PriorityEnumType" not-null="true" />
<property column="DATE_MAJ" name="dateMaj" />
</class>
<!-- ============================ -->
<!-- Table TABLE2 -->
<!-- ============================ -->
<class table="TABLE2"
name="com.myCompany.Entity2"
lazy="false" schema="SCHEMA2">
<!-- Attributs -->
<id column="ID" name="id" type="string" />
<property column="ACTION_TYPE" name="actionType"
type="com.myCompany.ActionEnumType" not-null="true" />
<property column="PRIORITY" name="priority"
type="com.myCompany.PriorityEnumType" not-null="true" />
<property column="DATE_MAJ" name="dateMaj" />
</class>
<!-- ============================ -->
<!-- Table TABLE3 -->
<!-- ============================ -->
<class table="TABLE3"
name="com.myCompany.Entity3"
lazy="false" schema="SCHEMA3">
<!-- Attributs -->
<id column="ID" name="id" type="string" />
<property column="ACTION_TYPE" name="actionType"
type="com.myCompany.ActionEnumType" not-null="true" />
<property column="PRIORITY" name="priority"
type="com.myCompany.PriorityEnumType" not-null="true" />
<property column="DATE_MAJ" name="dateMaj" />
</class>

The goal, is to put all the data to be configurable in one external file.
The purpose is to define the schema name dynamically because it depends on the deployment environment.
Unfortunetely, we can't use in our project neither Maven nor Ant.
How or where can i set the different schemas name to resolve this issue?

Thx in advance for you help.


Top
 Profile  
 
 Post subject: Re: Dynamic hibernate mapping file
PostPosted: Tue Aug 10, 2010 2:15 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi IlikeJava,

I can understand your problem. So each deployment environment has different users present. But here all the tables are present in all the schema.

Option 1:
Whether the schema name is same for all mapping files say deployment_environment_A ?

Option 2:
Even schema name changes with in the same deployment_environment_A for each entities?

If it is Option 1, then it can be configured initially in cfg xml file.

Ex :

Schema table
------- -------
one Table1 (No of records : 50)
two Table1 (No of records : 06)
--------------------------------------

Is this how you want to access different records each time ?

You can go through this article for more information.

http://forum.springsource.org/showthrea ... datasource

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: Dynamic hibernate mapping file
PostPosted: Tue Aug 10, 2010 6:52 pm 
Newbie

Joined: Sat Aug 07, 2010 5:37 am
Posts: 6
My case is more: Option 2:
The schema name changes with in the same deployment_environment_A for each entity.

I need to execute queries with joins from tables belonging to differents schemas.
For the moment, if i want that the schema name depends on the deplyement environnement, i cant do it with an HQL query,


Top
 Profile  
 
 Post subject: Re: Dynamic hibernate mapping file
PostPosted: Fri Aug 13, 2010 1:47 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi ILikeJava,

Have a look at this comment. In the first post, there is another link which you might find it useful.

viewtopic.php?f=1&t=1006385

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: Dynamic hibernate mapping file
PostPosted: Sat Aug 14, 2010 6:48 pm 
Newbie

Joined: Sat Aug 07, 2010 5:37 am
Posts: 6
thx for ur help guys.
I am still having the same problem.
Apparently the only solution is to use Ant or Maven.
Any other solution is welcome.


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.