Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Modelevolution and -migration - My approach
Modelevolution and -migration - My approach [message #1059717] Tue, 21 May 2013 10:50
Florian Pirchner is currently offline Florian PirchnerFriend
Messages: 94
Registered: July 2009


i have experience in JPA, but never used EclipseLink-API directly.

It would be nice if you could tell me whether my ideas can be done using the eclipse link API (or even internal classes).

My goal is to provide a simple model-evolution and migration module for my open source project.

The idea:
There is an entity called ItemEntity which is properly managed by EclipseLink. It contains different ForeignKeyConstraints to other tables.
A developer creates a new version of ItemEntity and adds / removes / renames properties.

An OSGi bundle should be used to migrate the current entity properly to its new version.
Therefore i need 3 entities:
1) the active ItemEntity
2) a new ItemEntity_v100 (Its schema matches the version before model evolution)
3) a new ItemEntity_v101 (Its schema matches the version after model evolution)

What should happen?
1) Create table ItemEntity_v100 by API (after FKConstraints have been removed)
2) Create table ItemEntity_v101 by API (after FKConstraints have been removed)
3) Copy all records from ItemEntity to ItemEntity_v100
4) Read all records from ItemEntity_v100 and call some MigrationImpl that returns a migrated ItemEntity_v101
5) Write converted ItemEntity_v101-instance to its table
6) Remove all FKConstraints on ItemEntity
7) Drop ItemEntity
8) Create ItemEntity with same schema as ItemEntity_v101
9) Copy all records from ItemEntity_v101 to ItemEntity
10) Conclusion: ItemEntity was properly migrated.

How to do:
The developer provides an OSGi bundle with all entities and adds 2 additional entities for the current and the old version: ItemEntity_v100 and ItemEntity_v101. They are also managed by JPA.

Then the developer creates a bundle and adds a persistence.xml into it with eclipselink.ddl-generation=NONE. So the tables ItemEntity_v100 and ItemEntity_v101 will not become created.

The question:
Now i would like to use EclipseLink-API to create ItemEntity_v100 and ItemEntity_v101 on database and to manage by JPA. But before creation i would like to remove the FKConstraints.

Something like that:
TableDefinition tabledef = UnknownUtil.createTableDefinition(ItemEntity_v100.class);

And before dropping ItemEntity i will also have to remove all FKConstraints by EclipseLink-API.

Is there a way doing that stuff with EclipseLink API?
Are there any examples?
Can anyone point me to code in eclipse link project how to do?

Thanks a lot for your help...
Best, Florian
Previous Topic:JPA and Excel import/export
Next Topic:Convert varchar to nvarchar for specific columns only.
Goto Forum:

Current Time: Fri May 25 22:56:42 GMT 2018

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

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

Back to the top