Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » automatic schema update
automatic schema update [message #675977] Thu, 02 June 2011 09:03 Go to next message
kRu Missing name is currently offline kRu Missing nameFriend
Messages: 5
Registered: June 2011
Junior Member
I'm currently using EclipseLink 2.2 with HSQLDB 2.2 for an embedded file db. I've defined the structure of the db by using JPA annotations. The problem I have now is, that updating the structure (class members/annotations) will be not reflected in the db structure.
Via eclipselink.ddl-generation setting I can create the db completly new, but I want to keep the old data and just "update" the structure.
I found this feature in ObjectDB as "Automatic Schema Evolution" and it's described as following:
Quote:

  • For every field in the new schema for which there is a matching field in the old schema, the new field in the new entity object is initialized using the value of the matching old field in the original entity object.
  • Fields in the new schema that do not have matching fields in the old schema are initialized with default values (0, false or null).
  • Fields in the old schema that do not have matching fields in the new schema are simply ignored (and their content is lost).

Also Hibernate has an option called hibernate.hbm2ddl.auto for updating the schema or validate it.
Is there a possibility to get my desired behavior, i.e. keeping the old data and update the structure?

Thanks in advance,
Johannes
Re: automatic schema update [message #676042 is a reply to message #675977] Thu, 02 June 2011 15:15 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please log a enhancement request in EclipseLink for this feature and vote for it.

As a workaround you will need to ALTER your tables yourself to add any new columns. Generally migrating schema requires some work anyway, as new columns normally need the data defaulted to some value, etc.


James : Wiki : Book : Blog : Twitter
Re: automatic schema update [message #676181 is a reply to message #676042] Fri, 03 June 2011 06:25 Go to previous messageGo to next message
kRu Missing name is currently offline kRu Missing nameFriend
Messages: 5
Registered: June 2011
Junior Member
Thank you James! I'll do that and hope a lot of people will vote Wink
I already tried checking the schema validity myself, and i have some more questions:
How can I get (easily) the ddl for a specific class or just a field (except of letting eclipselink create a file with the schema). I saw there are classes like SchemaManager which are used for creation, but I couldn't figure out how to do that exactly.

Thank you for your help,
Johannes
Re: automatic schema update [message #676840 is a reply to message #676181] Mon, 06 June 2011 17:30 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The org.eclipse.persistence.tools.schemaframework package includes several classes for DDL generation. A TableDefinition can be used the create the DDL for a table.
The DefaultTableGenerator can generate a TableDefinition for an Entity class.


James : Wiki : Book : Blog : Twitter
Previous Topic:Syncing two databases
Next Topic:Load only part of object graph
Goto Forum:
  


Current Time: Thu Apr 25 13:33:54 GMT 2024

Powered by FUDForum. Page generated in 0.03613 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top