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.
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.
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.