Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Querying archived entities(Ideas for fetching entities from archives.)
Querying archived entities [message #554153] Fri, 20 August 2010 10:27 Go to next message
Max Mustermann
Messages: 4
Registered: August 2010
Junior Member
Hello,
I have the need to preserve deleted entities, which in my opinion is not that uncommon. I don't care for versioning entities, I sometimes just need the latest version regardless, whether the entity has been deleted or not.

Currently I collect all removed entities in a set of additional tables. When an entity is removed, its table row is inserted into this archiving table by a trigger. Much like a history table, but without preserving previous version as I only care for deletes.

That works fine in the db, except that it does not preserve any associations in the archive tables. So the data is there, but I struggle to find out, how to tell eclipselink that it should look in the archive, when I need it.

I also experimented with history support, but that is not really what I want, as I don't need a specific version, I just need to be able to reconstruct that entity after deletion.
Re: Querying archived entities [message #554171 is a reply to message #554153] Fri, 20 August 2010 06:49 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
I'd assume that you need to simply map that history table and treat it as a entity of its own.


On 8/20/2010 5:27 PM, Max Mustermann wrote:
> Hello,
> I have the need to preserve deleted entities, which in my opinion is not that uncommon. I don't care for versioning entities, I sometimes just need the latest version regardless, whether the entity has been deleted or not.
>
> Currently I collect all removed entities in a set of additional tables. When an entity is removed, its table row is inserted into this archiving table by a trigger. Much like a history table, but without preserving previous version as I only care for deletes.
>
> That works fine in the db, except that it does not preserve any associations in the archive tables. So the data is there, but I struggle to find out, how to tell eclipselink that it should look in the archive, when I need it.
>
> I also experimented with history support, but that is not really what I want, as I don't need a specific version, I just need to be able to reconstruct that entity after deletion.
Re: Querying archived entities [message #554437 is a reply to message #554171] Mon, 23 August 2010 07:34 Go to previous message
Max Mustermann
Messages: 4
Registered: August 2010
Junior Member
Hi,
I think, I found a satisfying solution:
I have remapped the existing entities in a second persistence unit using orm.xml. So I have one persistence unit with the active data defined using annotations, and one persistence unit which queries some views unioning the archive tables to the original base tables of the active data.

The benefits of this is, that an entity of the archive is not a "different" entity. It is an object of the same type as active data would be and thus nicely integrates in the existing code without the need to form a special case.

That seems to work quite well, with respect to my test cases. But there are some caveats: First, the archive does not retain relations, thus no referential integrity. Second, I currently see no clean way to prevent persisting an entity from the archive in the active data set, which essentially breaks the primary key assumptions in the archive. And finally, one should be aware, that all named queries may need to be moved into the orm.xml instead of defining them by annotations, because depending on the persistence unit they traverse associations, which may or may not be defined in the archived data.
Previous Topic:CriteriaBulder
Next Topic:Example of EclipseLink-EMF integration
Goto Forum:
  


Current Time: Tue Sep 23 12:41:02 GMT 2014

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

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