You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Morley, Liam " <lm...@WPI.EDU> on 2004/06/26 06:13:28 UTC

mapping the same class to multiple tables?

My application has to support undo using persistence, as someone must be able to change a previously entered field after closing and re-opening the application.

All of my classes extend my own PersistentObject class, but certain classes can be entered into the "History" (to be undone later), and those classes implement a marker interface called "Enterable".

I'd like to have two methods as follows:

store(PersistentObject)
storeEnterable(Enterable)

where storeEnterable() would store the Enterable in a history table. Is this possible?

-- 
Liam Morley
lmorley@wpi.edu

Re: mapping the same class to multiple tables?

Posted by ed...@mgrinformatica.com.br.
I have a similar solution in my job. I've done in the following way:

class A {
...
}

class A_normal extends A {
}

class A_history extends A {
}

Only A_normal and A_history are mapped in repository.xml.

So, if I need to manipulate the object, I use class A. To store a normal object, I use and
instance of A_normal. If I need to store a history object, I use A_history. Now, if I need
to move one object A_normal to A_history, I use the method copyProperties in common-beans
library to do the job. The I start a transaction, delete A_normal and insert the A_history.

I think can be several ways to get job done, this is just one.

Best regards,

Richter

> My application has to support undo using persistence, as someone must be able to change a
> previously entered field after closing and re-opening the application.
>
> All of my classes extend my own PersistentObject class, but certain classes can be entered
> into the "History" (to be undone later), and those classes implement a marker interface
> called "Enterable".
>
> I'd like to have two methods as follows:
>
> store(PersistentObject)
> storeEnterable(Enterable)
>
> where storeEnterable() would store the Enterable in a history table. Is this possible?
>
> --
> Liam Morley
> lmorley@wpi.edu
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org