Hibernate tries to recreate previously created tables

Description

Dear Hibernate team,

I encouter a problem with hibernate when javax.persistence.schema-generation.database.action=create is enable. Hibernate try to (re)create a previously created table during database schema generation.

Below, my step that raised the bug :
1) I check if my postgresql database is fully empty;
2) I build my EAR. I use OpenEJB+Hibernate+JUnit for my tests cases without errors (not same properties);
2) I pull my EAR to WildFly through Netbeans. I obtain this output :

Maven output

------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 1.342s
Finished at: Fri Aug 08 19:57:17 CEST 2014
Final Memory: 6M/15M
------------------------------------------------------------------------
NetBeans: Deploying on WildFly Application Server 8.1.0
profile mode: false
debug mode: false
force redeploy: true
Initial deploying EAR to E:\WildFly\8.1.0\standalone\deployments\obyon-ear-1.0.ear
Completed initial distribution of EAR
Deploying E:\WildFly\8.1.0\standalone\deployments\obyon-ear-1.0.ear
{"JBAS014671: Failed services" => {
"jboss.persistenceunit.\"obyon-ear-1.0.ear/obyon-portal-1.0.war#obyon\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"obyon-ear-1.0.ear/obyon-portal-1.0.war#obyon\":

javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table CATEGORYS (id bigserial not null, visible boolean not null, primary key (id))]
Caused by: javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table CATEGORYS (id bigserial not null, visible boolean not null, primary key (id))]
Caused by: org.postgresql.util.PSQLException: ERREUR: la relation « categorys » existe déjà",
"jboss.persistenceunit.\"obyon-ear-1.0.ear#obyon\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"obyon-ear-1.0.ear#obyon\": javax.persistence.PersistenceException: Unable to execute JPA schema

generation create command [create table CATEGORYS (id bigserial not null, visible boolean not null, primary key (id))]
Caused by: javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table CATEGORYS (id bigserial not null, visible boolean not null, primary key (id))]
Caused by: org.postgresql.util.PSQLException: ERREUR: la relation « categorys » existe déjà"
}}

3) I check the generated database tables/relationships, everything is okay.

Database seems good, but the generated error abort the EAR deployement.

Below, my persistence.xml :

I will provide a test case ASAP

Environment

Windows 7 32Bits
WildFly 8.1.0 Final
PostgreSQL 9.3

Activity

Show:
Guillaume Chauvet
August 8, 2014, 7:46 PM

"create" : The provider will create the database artifacts on application deployment. The artifacts will remain unchanged after application redeployment [1].

[1] http://docs.oracle.com/javaee/7/tutorial/doc/persistence-intro005.htm;

Guillaume Chauvet
August 10, 2014, 11:20 AM

Test case patch that reproduce this issue

Guillaume Chauvet
August 10, 2014, 11:44 AM

Rewrite test (using H2 in memory database only)

Steve Ebersole
October 27, 2015, 7:15 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 28, 2015, 3:24 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Assignee

Unassigned

Reporter

Guillaume Chauvet

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure