-->
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.  [ 5 posts ] 
Author Message
 Post subject: using hibernate.properties together with hibernate.cfg.xml ?
PostPosted: Mon Aug 23, 2004 3:45 am 
Beginner
Beginner

Joined: Mon Jul 05, 2004 9:29 am
Posts: 38
hi,

is it possible to use the hibernate.cfg.xml together with hibernate.properties?

the data model we have created is generic and should be used by other projects in my company, so we plan to distribute it as a .jar file containing the beans + the mapping files (*.hbm.xml and hibernate.cfg.xml) without any connection parameters as datasource, jdbc url, username, password, dialect... so the people would only have to supply a valid hibernate.properties file to set their connection up.

is it possible?

thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 4:25 am 
Regular
Regular

Joined: Thu Aug 05, 2004 2:27 am
Posts: 54
Location: South Africa
I'm also new to hibernate and can't say if that's possible or not, I think not though, I recall people having problems with both.
Anyway, you can also set the connection up programatically, using params, or whatever input the first time, and save it to file or whatever.
A little closer to what you want is to have them supply a connection.properties file for instance and you use that


Top
 Profile  
 
 Post subject: Re: using hibernate.properties together with hibernate.cfg.x
PostPosted: Mon Aug 23, 2004 5:01 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
kalgon wrote:
...
is it possible?

http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-xmlconfig
"An alternative approach is to specify a full configuration in a file named hibernate.cfg.xml. This file can be used as a replacement for the hibernate.properties file or, if both are present, override properties."

_________________
Leonid Shlyapnikov


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 5:22 am 
Beginner
Beginner

Joined: Mon Jul 05, 2004 9:29 am
Posts: 38
thanks, I would have prefered properties to override the xml but I'll have to live with it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 5:29 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
In the Chapter 3 of the online reference you can find all methods to passing parameters to the Configuration object and to create a Session.

In your case you can keep a properties file inside your jar and require an other properties file with installation specific setting.
Then you can build a Configuration creating a Properties object with all these properties.

So you can also limit the option that a user can set and choose their names


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