Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Custom Insert/Update/Delete (Virsioning)(Need an Advice, how to realize Topic)
Custom Insert/Update/Delete (Virsioning) [message #1022829] Fri, 22 March 2013 11:51 Go to next message
Roman Smushkevich is currently offline Roman Smushkevich
Messages: 4
Registered: June 2012
Junior Member
Hallo, everyone!

In my small project I use EclipseLink as a persistence framework.
The data structure is designed to use joined strategy. Besides, the entity table supports a special kind of versioning, which according to versioning methodology are:
1. One table, that holds the version numbers;
2. One common table on top of the hierarchy, that holds the entity key and two additional fields, namly creation version and deletion version.
3. Entity tables, that hold the entity attributes.
Each entity table has its own version field.
In case of the entity instance creation, one row will be created in the top table with new entity key and current version as a creation version. All entity tables in hierarchy will get one new row with current version and actual entity attributes.
In case of update only tables, which hold update attributes, will get new rows with new version.
In case of deleting only the row in the top table will be updated. The field deletion version will be updated with the current version.

The mechanism (queries) for such versioning methodology has been alredy programmed. I'm producing the simple query with the complex "where clause" to load only the row with last version.

The question is, how to substitute the apropriate Insert/Update/Delete queries with those, which instead of default operations will call specialized operations . In my case I want to substitute all update calls with insert calls; delete call with update call and so on. Is there some special solution for such cases? I would like to intercept all update calls and substitute them with appropriated insert statements.
Re: Custom Insert/Update/Delete (Virsioning) [message #1027056 is a reply to message #1022829] Tue, 26 March 2013 10:06 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can override the CRUD operations using a DescriptorCustomizer and the DescriptorQueryManager API.

See,

http://wiki.eclipse.org/EclipseLink/Examples/JPA/SoftDelete

http://wiki.eclipse.org/EclipseLink/Examples/JPA/CRUDStoredProcedures

Also consider EclipseLink's history support,

http://wiki.eclipse.org/EclipseLink/Examples/JPA/History


James : Wiki : Book : Blog : Twitter
Re: Custom Insert/Update/Delete (Virsioning) [message #1027310 is a reply to message #1027056] Tue, 26 March 2013 16:57 Go to previous message
Roman Smushkevich is currently offline Roman Smushkevich
Messages: 4
Registered: June 2012
Junior Member
Thanks for the answer. I've looked through these links. The idea with SoftDelete is partially acceptable, but it should be realized through the DeleteQueryRedirector, while extra version number should be prepared on Databse side.
But 2 other cases (Insert/Update) don't consider the hierarchy. Under hierarchy I mean the multiple statements, which will concern in case of Update those tables with updated fields.
So, if you have another porposal, I would appriciate it.
Previous Topic:Aggregated objects cannot be written/deleted/queried independently from their owners
Next Topic:Refresh entity doesnt work with relationships
Goto Forum:
  


Current Time: Wed Aug 20 08:49:20 EDT 2014

Powered by FUDForum. Page generated in 0.01625 seconds