-->
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.  [ 10 posts ] 
Author Message
 Post subject: Problem with Multiple Hibernate properties Files.
PostPosted: Sat Dec 06, 2003 5:39 pm 
Newbie

Joined: Fri Oct 17, 2003 12:40 pm
Posts: 16
I have multiple projects, each having their own hibernate properties file under their classpath. All these business projects use a common project to create a SessionFactory. Everything works fine, when all the hibernate.properties file, refer to the same database.
When I have my first project hibernate properties file, pointing to database A and remaining hibernate properties file pointing to Database B and run the application, all projects are trying to connect to database A. How do I make projects to look for its own hibernate.properties file.
When I asked this question before, I was asked to use hibernate.cfg.xml file. This file will also, go under the classpath, how is it different from hibernate.properties file(Considering my problem).
Remember, that all my projects go to a common project, to get the SessionFactory.

I would like to fix with hibernate.properties file. Since, all my projects are in place, a fix with hibernate.properties file is appreciated.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 7:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
If I understand your problem correctly you just need a way to specify different properties for different apps, right ?

Then just use Configuration.addProperties(Properties extraProperties) instead of just relying on the default loading of hibernate.properties from the classpath.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 7:21 pm 
Newbie

Joined: Fri Oct 17, 2003 12:40 pm
Posts: 16
Yes, I need different properties (different databases) for every project. I have mentioned the different database names in the hibernate.properties file of every project. Why the correct properites is not picked up from hibernate.properites file. The purpose of having hibernate.properties under the classpath for every project, is defeated.
I will end up having a if statement, to build correct configuration properities for each project, since I have one common project, which builds the Session Factory.

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 7:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I do not follow your arguments!?

How hard is it to provide an argument in your common project that loads the property files that is initialized with a different value per subproject ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 8:01 pm 
Newbie

Joined: Fri Oct 17, 2003 12:40 pm
Posts: 16
It is not hard at all. It is just adding one line. What I am trying to understand is, the differences are mentioned in their respective hibernate.properties. Why it is not getting the correct properties from the hibernate.properties file.

Why the projects are holding on to the properties mentioned in the first project. Why each project, is not looking at its own hibernate.properties file.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 8:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Probably because they pick up the FIRST /hibernate.properties file in the classpath!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 8:12 pm 
Newbie

Joined: Fri Oct 17, 2003 12:40 pm
Posts: 16
Exactly. How do I fix this problem with multiple hibernate.properties files. I want each project, to pick from its hibernate.properties file from its own classpath. How can I do this.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 8:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh ? You can't have more than one hibernate.properties in the classpath!
It's standard resource loading semantics!

If you want to use ANOTHER set of properties then call something like "addProperties(Properties props)" or some of the 10 other ways of configuring a Configuration (look at all the addXXX() methods)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 8:38 pm 
Newbie

Joined: Fri Oct 17, 2003 12:40 pm
Posts: 16
Thanks.


Top
 Profile  
 
 Post subject: multiple database schemas
PostPosted: Thu Dec 18, 2003 7:39 am 
Newbie

Joined: Thu Dec 18, 2003 7:26 am
Posts: 2
Does the usage of multiple configuration files and/or the use of multiple hibernate services mean that java objects of different packages can persist in different database schemas (oracle) under different user roles?

Is there something specific to be done apart from defining config files to get this working?

thanks for your answer


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