Hello all,
this question references to Hibernate-Core 3.2.6.ga and Hibernate-Annotations 3.3.1.GA.
As stated in
Java Persistence with Hibernate, chapter 3.4.1 p.147 et sqq., one can map a class several times using the entity-name tag.
I wonder if this somehow could be done using Hibernate-Annotations.
The goal my team mates and I want to reach is the following:
We're working on an application that connects to a legacy DB2 with a highly normalized table structure that must not be changed. We use the javax annotation
@Table(name="VW98578") pointing to our tables.
So we created annotated entity classes using Hibernate tools reverse engineering and integrated everything using Spring 2.5. This works all fine :-)
But every table has two (!) mirror tables. One is for saving an historic record whenever an update or delete has occurred.
The other one is for storing temporary changes that remain temporary as long as the user doesn't explicitly submits her/his changes.
During the time the user works with the temporary table, the domain object is programmatically "locked". I.e. in a lookup table the entity's id is linked to the user's id.
My approach would now be to write Hibernate Interceptors, one for the historic data persistence, the other one to route the user's changes to the temporary views.
As we speak of of 100+ tables, I hesitate repeating the entities for the historical and temporary use.
The Hibernate reference and "Java Persistence (...)" show an intuitive way to reuse an entity class pointing to different tables using
<entity-name> (see
http://www.hibernate.org/hib_docs/reference/en/html/mapping-entityname.html).
Is there any way to get this configured using Hibernate Annotations? I couldn't find one, but would really appreciate any confirmation.
Or did somebody find a solution for a similar requirement?
Thanks for reading so far and kind regards from Europe, Germany, Berlin,
Karsten