Hi,

Here is a problem I am trying to solve with JPA. Any ideas/suggestions
are most welcome and very much appreciated :

I would like to define a Customer entity that actually maps to different
physical database tables. Well, the @SecondaryTable annotation
was my first try. But I soon found out that it only splits the entity
into a "single row" across multiple tables. Unfortunately, in my case,
I have generational data of the Customer ( history data in multiple rows
) that is in, let's say, table B and the constant data ( as a single row
)
in table A.

So, in essence, I want to have a Customer class, for example, like the
following :

class Customer {
   String cid;
   String ssn;
   Timestamp startDate;
   Timestamp endDate;
   String lastName;
   String firstName;
}

Table A stores 'cid'(prim key) and 'ssn'.  Table B stores the rest of
the fields( primary key is cid+startDate, with a foreign key referring
to cid in table A ).
So, there will be a oneToMany relation between a row in table A and
table B. 

Well, one solution is to have the same kind of Object-Model mapping. I
already did this and the application works fine.
I used Customer and Customer X entities having a one-to-one relationship
with the tables A and B respectively and defined a 
One-to-many collection of CustomerX in Customer class.

But I am not satisfied with this solution because I am "forced" to carry
the "physical database mapping" up to the "object-model".
I would prefer to just have one entity Customer and when I persist that,
it should insert/update row in table A and insert/update row in table B
in just one persist()/merge() call. Is this possible ?

Do I need to write my own implementation of
org.apache.openjpa.jdbc.kernel.UpdateManager
implementation instead of using the default implementation
org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager ????

Cheers,
jay

Jayagopi Jagadeesan
phone :  +358 9 453 4362   
mobile : +358 40 589 2454
e-mail :  [EMAIL PROTECTED]
http://www.tieto-tapiola.fi
Within every living soul there is a silent teacher(Conscience)


Reply via email to