• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating c3p0 config with hibernatetool (in ANT)

 
Philippe Desrosiers
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty new to Hibernate, and I'm trying to work through generating my hbm.xml files and hibernate.cfg.xml file using an ANT script. So far everything is working perfectly, but I'd like to be able to specify my c3p0 connection pooling settings (say in a separate properties or xml file), and have those settings merged into the hibernate.cfg.xml file when I run the ANT script.

The docs for Hibernate-tools don't really go into this, but is there a way to specify arbitrary properties, and have them imported into the final config file somehow?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a hibernate.cfg.xml file and also create a hibernate.properties file. In the properties file put all your database connection info. Hibernate looks for both in the classpath when it kicks off.
 
Philippe Desrosiers
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gregg! Does one file take precedence over the other (ie: if the same property is defined in both the hibernate.properties and hibernate.cfg.xml file, which value is used?)

thanks again,
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Philippe Desrosiers:
Thanks Gregg! Does one file take precedence over the other (ie: if the same property is defined in both the hibernate.properties and hibernate.cfg.xml file, which value is used?)

thanks again,


I honestly don't know. How about we google that together. First one with the answer wins!!
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If both the hibernate.properties and hibernate.cfg.xml files are found in the application classpath, then hibernate.cfg.xml overrides the settings found in the hibernate.properties file.


http://www.developer.com/open/article.php/3559931

I win!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic