Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - Can I put hibernate.properties in an ear file?

 
Theodore David Williams
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to be able to my hibernate.properties in my ear file so that those properties are local to that one ear file's entities.

Here is my current ear structure, I put the entities.jar in the lib directory

ear
--lib
----entity.jar
META-INF
--application.xml

I have tried hibernate.properties in the root, in the lib, and in META-INF/lib, but it is not getting picked up.
 
Sylvain Bouchard
Ranch Hand
Posts: 41
Java ME Objective C Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tedd,

The hibernate.properties file must be in a place that is picked up by the classpath.
Your EAR file only deploy a Jar file ?
 
Theodore David Williams
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there some place in the ear file that I can place the hibernate.properties such that it is on the classpath.

Yes in this simple example I just have one jar that contains the entity classes. Inside the ear is the jar, and the application.xml.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tedd, could you check your private messages? Thanks.

-Cameron McKenzie
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the JavaDoc for the configuration object:

https://www.hibernate.org/hib_docs/v3/api/org/hibernate/cfg/Configuration.html

You can read from a Properties object:


addProperties

public Configuration addProperties(Properties extraProperties)
Set the given properties


And a Properties object can be read from a properties file, of course. So, if you use this, you simply read from the properties file, which is packaged with your Java classes in a package appropriate folder structure.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic