-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate.hbm2ddl.auto issue with Hibenate 3 to 5 migration
PostPosted: Fri Sep 16, 2016 3:49 pm 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
I have an application presently running (without issue) on JBoss 6 that I am attempting to upgrade to run on WildFly 10.1. Much of this upgrade is going well. However, the upgrade from Hibernate 3.4 (on JBoss 6) to Hibernate 5.1 (on WildFly 10.1) is causing a few issues.

Specifically, in my persistence.xml, I include the following property (NOTE, this is not a new addition, it was there and working well with Hibernate 3.4/JBOSS 6).

Code:
<property name="hibernate.hbm2ddl.auto" value="update"/>


Please NOTE: I am NOT making any schema or other DB changes as part of the upgrade. Furthermore, I am pointing at the same database instance that has been successfully running under the JBoss 6/Hibernate 3.4 instance. Therefore, I am confident that inclusion of this property should have no actual work/update to do upon first run with the WildFly 10.1/Hibernate 5.1 version.

However, inclusion of this property appears to 1) erroneously determine that it needs to make updates and 2) fail to do so successfully. It results in the following stack trace:



Code:
Failed to start service jboss.persistenceunit."app.ear#PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."PU": javax.persistence.PersistenceException: [PersistenceUnit: PU] Unable to build Hibernate SessionFactory
      ...
      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: PU] Unable to build Hibernate SessionFactory
      ...
      Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [create index company_id_index on APPROVER (COMPANY_ID)]
      ...
      Caused by: org.postgresql.util.PSQLException: ERROR: relation "company_id_index" already exists



Also, if I comment out the above hbm2ddl property in the persistence.xml, everything deploys and works successfully (on Hibernate 5.1/WildFly 10) including access to both the table and index mentioned in the above error. However, I really would like to maintain access to this property for future planned DB updates in development.

Again, the table and index in question already exist (as confirmed by the final error).

Is Hibernate now no longer case insensitive (COMPANY_ID_INDEX being different than company_id_index)?

If so, how can I configure it so that it is case insensitive as it used to be (Postgres defaults all of this to lower....)

TIA!


Top
 Profile  
 
 Post subject: Re: hibernate.hbm2ddl.auto issue with Hibenate 3 to 5 migration
PostPosted: Sat Sep 17, 2016 3:46 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
There have been all sorts of changes in the naming strategy, so Hibernate 5 uses the JPA cpes which is different than the legacy HBM one that was available on Hibernate 3.

Try setting the hibernate.implicit_naming_strategy property to legacy-hbm:

Code:
<property name="hibernate.implicit_naming_strategy" value="legacy-hbm"/>


Top
 Profile  
 
 Post subject: Re: hibernate.hbm2ddl.auto issue with Hibenate 3 to 5 migration
PostPosted: Mon Sep 19, 2016 4:26 pm 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
Thank you for your reply and idea!

Unfortunately, the addition of hibernate.implicit_naming_strategy property to legacy-hbm, did not resolve the issue. I am left with the exact same stack trace and error messages as before.

I also tried legacy-jpa with the same results


Top
 Profile  
 
 Post subject: Re: hibernate.hbm2ddl.auto issue with Hibenate 3 to 5 migration
PostPosted: Sat Sep 24, 2016 2:48 pm 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
Doh! Face palm! I recently discovered that similar errors were also occurring related to hbm2ddl index creation with Hibernate 3.4/JBoss 6 as I am now experiencing with Hibernate 5.1/Wildfly 10.1; however, they were NOT preventing successful start up of the persistence module. Essentially, they were being only subtly suppressed. I'm not sure if this is an expected change related to the Hibernate versions or not, as they do prevent it's start up in Hibernate 5.1/Wildfly 10.1?

The underlying issue here turned out to be that index names must be unique across the entire schema in Postgres. So multiple entities each having a FK to a COMPANY_ID column must each have a unique name for the index. Indices are relations in Postgres (driving the unique across schema requirement).

Thank you for the suggestions and apologies for the confusion.


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