-->
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: Custom hibernate.properties with WildFly 8
PostPosted: Wed Apr 12, 2017 8:47 am 
Newbie

Joined: Wed Apr 12, 2017 8:26 am
Posts: 2
I have an ear file which contains only the basic configuration:

Code:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">

  <persistence-unit name="tdaSupply">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <jta-data-source>java:jboss/datasources/tda-sql-DS</jta-data-source>
    <class>de.gevas.tda.supply.element.SupplyElement</class>
       ….
    <exclude-unlisted-classes />
  </persistence-unit>
</persistence>


The properties I want to set external.
Inside the documentation:
https://docs.jboss.org/hibernate/orm/3. ... ogrammatic

I read, that I can define the path to hibernate.property with the parameter -Dproperty

Because I want to use different property files I start WildFly with this line for example:

Code:
-Dproperty=C:/Mapping/D/Server/WildFly/wildfly_aktuell/standalone/configuration/gevas/standalone/configuration/gevas/hibernate_postgres.properties


The entityManager I get this way:
@PersistenceContext(unitName = "tdaSupply")
protected EntityManager entityManager;


In my program I can read the SystemProperty "property" with success.
But it seems, that hibernate can not find the property file. In my logfiie I can find this:

hibernate.cfg.Environment [ INFO] 20170412 14:39:38.769 ServerService Thread Pool -- 23 HHH000206: hibernate.properties not found

The entityManager is created with some standard properties which I have logged out with
Map<String, Object> properties = entityManager.getEntityManagerFactory().getProperties();
for(Map.Entry<String, Object> e : properties.entrySet())
{
logger.info("enMgr key = " + e.getKey() + ", val = " + e.getValue().toString());
}

There I can not find my properties from the external file.
It is not possible for me to use only one hibernate.properties file inside the ear, because I have to be flexible with every start of the WildFly and I can not manage two ear files. Reason is test with jenkins and all databases for example.

What is wrong?


Top
 Profile  
 
 Post subject: Re: custom hibernate.properties with WildFly 8
PostPosted: Thu Apr 13, 2017 8:00 am 
Newbie

Joined: Wed Apr 12, 2017 8:26 am
Posts: 2
It was a misunderstanding of the documentation.
-Dproperty=xxxx

doesn't mean -Dproperty=[path to hibernate.properties file]
it means: for example:
-Dhibernate.hbm2ddl.auto=create-drop

How can I use an external property file?
Is this possible with a hibernate.cfg.xml file?


Top
 Profile  
 
 Post subject: Re: custom hibernate.properties with WildFly 8
PostPosted: Thu Apr 13, 2017 8:06 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
If you want to use an external hibernate.cfg.xml file, you need to provide the hibernate.ejb.cfgfile configuration property.

Check out the project User Guide for more details about Hibernate configurations.


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.