-->
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.  [ 6 posts ] 
Author Message
 Post subject: Different schema names for test and production
PostPosted: Tue Mar 01, 2005 3:41 pm 
Newbie

Joined: Tue Mar 01, 2005 3:20 pm
Posts: 6
Hi:

Working on my first spring/hibernate project. We have a DB2 database, which uses different schema names for test and production. For instance,
to access table policy in test I have to code select * from test.policy, and for production, select * from prod.policy.

Here is my hdm.xml file. I hope there is a way to use some setting, which will allow me to set the schema name from a helper class at run time and still preserving hibernate good coding practices.

In place of schema I put question marks.

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.fpi.domain.impl">
<class name="PolicySpecificsImpl" schema="???" table="policy">
<composite-id name="policyKey" class="com.fpi.domain.impl.PolSpecDb2PrimaryKey">
<key-property name="companyNumber" column="c_num"/> <key-property name="prefix" column="prfx" type="string"/>
<key-property name="policyId" column="polNum" type="integer"/>
</composite-id>
</class>
</hibernate-mapping>

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 4:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look at the Configuration class...you should be able to look up the class and change the assocated table schema at runtime.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 4:47 pm 
Newbie

Joined: Tue Mar 01, 2005 3:20 pm
Posts: 6
Max, thank you for the reply. We are using Spring, so maybe there is a way to override this setting from one of the Spring classes, like LocalSessionFactoryBean.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 8:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dont know spring. just use the Hibernate Configuration - much easier/simpler ,)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 10:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
hibernate.default_schema


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 11:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
oh yeah of course - i had just understood it was for one specific table, but now that i reread it default_schema is what you are looking for.

_________________
Max
Don't forget to rate


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