0

I am currently using EclipseLink JPA and in my persistence.xml file i have this property set

<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

The value field currently set to drop and create tables on each run is causing my test data to be deleted. Unfortunately, EclipseLink does not support an update schema property that integrates with any changes to Entities in my project. I read somewhere, Hibernate-tools can be used to update the database schema without deleting current records?

I have tried this property

 <property name="eclipselink.ddl-generation" value="create-tables"/>

while it does keep my data, it doesn't update table schema.

In my persistence.xml can i include the hibernate property ?

 property name="hibernate.hbm2ddl.auto" value="update"
Warz
  • 7,386
  • 14
  • 68
  • 120

2 Answers2

1

EclipseLink (as of 2.3.2) doesn't support DDL altering existing tables to add missing fields. Please see feature request https://bugs.eclipse.org/bugs/show_bug.cgi?id=368365

Chris
  • 20,138
  • 2
  • 29
  • 43
0

No, you can use only standart jpa properties or properties of your persistence provider (EclipseLink in your case). I believe that here you will find your answer.

Community
  • 1
  • 1
Balconsky
  • 2,234
  • 3
  • 26
  • 39
  • okay, i understand that i cant mix persistence provider's but the link you sent doesn't give an answer on how to set the property that tells EclipseLink to 'update' the schema. The value = 'create-table' according to EclipseLink will execute a CREATE TABLE SQL for each table. If the table already exists. I need it to update the schema without erasing the data – Warz Jan 09 '12 at 22:34
  • This is not impossible to update your database and save old data. – Balconsky Jan 09 '12 at 22:51
  • Note* this isnt for production but rather for development. It becomes annoying that i have to keep creating the same records as i am testing. Do you have an example? – Warz Jan 10 '12 at 00:44