-->
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.  [ 1 post ] 
Author Message
 Post subject: Same Code different database environments
PostPosted: Tue Sep 19, 2006 12:10 pm 
Beginner
Beginner

Joined: Wed Sep 13, 2006 7:24 am
Posts: 26
I am wondering how people have implemented Hibernate to work on different database environments, without having to recompile the code.

What we have done, is to create a jar with the “hibernate.cfg.xml” , “*.hbm.xml” files and java code included, but at the moment, if we want to move to a different environment (i.e. Development to Test or Production), we would have to recompile the code (or at least re-jar the code with the different hibernate.cfg.xml).

Are there any document or notes about configurations on the fly or can someone suggests how they have managed this.

Hibernate version: 3.1.3

the hibernate.cfg.xml:
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
   <property name="connection.url">
      jdbc:inetdae7:{server}:{server port}?database={database}
   </property>
   <property name="connection.driver_class">
      com.inet.tds.TdsDriver
   </property>
   <property name="connection.username">{username}</property>
   <property name="connection.password">{password}</property>
   <property name="show_sql">true</property>
   <property name="connection.pool_size">-1</property>
   <property name="cache.provider_class">
      org.hibernate.cache.NoCacheProvider
   </property>
   <property name="current_session_context_class">thread</property>
   <property name="hbm2ddl.auto">update</property>
   <property name="hibernate.dialect">
      org.hibernate.dialect.SQLServerDialect
   </property>
   <mapping
      resource="project/data/schema/User.hbm.xml" />
   <mapping
      resource="project/data/schema/Group.hbm.xml" />

</session-factory>

</hibernate-configuration>


reason for "jar"ing the hibernate code is that many system will use the same jar.

_________________
Ben


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.