-
1. Re: hibernate.hbm2ddl.auto value="update" on PostgresSQL 9.4(x86) DB issue with Hibenate 5.1 & Wildfly 10.1.0
mayerw01 Nov 15, 2016 9:51 AM (in response to parag.goyal)I'd suggest to use
<property name="javax.persistence.schema-generation.database.action" value="none"/>
-
2. Re: hibernate.hbm2ddl.auto value="update" on PostgresSQL 9.4(x86) DB issue with Hibenate 5.1 & Wildfly 10.1.0
parag.goyal Nov 17, 2016 8:19 AM (in response to mayerw01)I can't use <property name="javax.persistence.schema-generation.database.action" value="none"/> because "none" does not do any thing.
Actually, our requirements is schema/table needs to created if any of them does not already exist, in case table/schema already exists then these should remain intact with data.
As per JPA documentation above should be achievable by <property name="javax.persistence.schema-generation.database.action" value="create"/> or by <property name="hibernate.hbm2ddl.auto" value="update"/>. I tried both options but both are behaving same ways. We were achieving above functionality <property name="hibernate.hbm2ddl.auto" value="update"/> till Wildfly 8.2.1 (even in lower version of JBoss), I am not sure this functionality is broken from PostgreSQL's Driver side or Dialect side.
My problem is still unresolved. Please let me know if you have some solution.
-
3. Re: hibernate.hbm2ddl.auto value="update" on PostgresSQL 9.4(x86) DB issue with Hibenate 5.1 & Wildfly 10.1.0
mayerw01 Nov 19, 2016 6:59 AM (in response to parag.goyal)I would recommend to use 'hibernate.hbm2ddl.auto' only for test purposes. For production I'd rather use the standard persistence approach.
The standard Hibernate behaviour when using 'create' is to create the tables unconditionally which may produce errors if the table already exists.
I guess the reason is that although Postgres supports 'IfExistsAfterTableName' this feature is disabled in the Dialect (maybe you could try your own version with this feature enabled).
Therefore you should use your own create script which checks this.
When using Postgres this should be simple since you may use statements like
CREATE TABLE IF NOT EXISTS ...
The entries in your persistence.xml may then look like:
<property name="javax.persistence.schema-generation.database.action" value= "create"/>
<property name="javax.persistence.schema-generation.create-script-source" value= "{path to your create.sq}l"/>