-->
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.  [ 3 posts ] 
Author Message
 Post subject: hiberante configuration outside of jar file
PostPosted: Wed Oct 29, 2008 12:27 pm 
Newbie

Joined: Wed Oct 29, 2008 12:20 pm
Posts: 2
I'm usting Hibernate version 2 and creating configuration object in following way:
Configuration cfg = new Configuration.configure("my-hibernate.cfg.xml");

Whole application is packed in one jar called "my.jar".

This jar file goes than as one of the app library which is packed as "my.ear" file. I need to be able to modify "dialect" property from "my-hibernate.cfg.xml" file for each ear that I craete.

How can I externalize hibernate configuration to be placed outside of this jar file?
Is it possbile to overrite it with "hibernate.properties" placed outsice of this jar file, but still in the ear file if my configruation file is defined explicitely during Configuration object creation?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 03, 2008 8:46 am 
Newbie

Joined: Wed Oct 29, 2008 12:20 pm
Posts: 2
anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2008 10:27 am 
Newbie

Joined: Wed Jul 09, 2008 11:31 am
Posts: 2
Try this:
Code:
// configurates from properties
// put there default values
Configuration cfg = new Configuration();

// configure from File
File f = new File("my-hibernate.cfg.xml");
if (f.exists) {
    // configure from file "my-hibernate.cfg.xml" outside of jar
    // put in it what you want override when deployed
    cfg.configure(f); 
}
else {
    // configure from file inside jar
    // put there what you want override when developing
    cfg.configure(new File("my-hibernate.cfg.xml"));
}


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