persistence@glassfish.java.net

Re: Implementing Temporal Property (or Temporal Object) using JPA?

From: Hurragutt <hurragutt_at_gmail.com>
Date: Fri, 31 Aug 2007 08:52:43 +0200

Hi.
It is an architectural decision to use JPA for persistence, and our
tool of choice has been TopLink Essentials, so the Oracle TopLink
product is not an option for us.

We have implemented Temporal Property pattern exactly as it is
written in the article, supporting bi-temporality via
BiTemporalCollection which is a wrapper on SingleTemporalCollection
which in turn wraps a single java.util.Map (and some business
functionality).

So our biggest struggle has been how to map this Object
(BiTemporalCollection) which is a map in a map structure into the
database using JPA mapping in annotations or XML.

We are working with an assumption right now which is exactly what you
are suggesting. By maintaining a parallel List of <class>Version
objects in addition to this map in map structure, we can easily
persist the list to the database using @OneToMany, and by marking the
BiTemporalCollection as @Transient we are able to model our versioned
objects using the Temporal Property pattern.

Thanks for your thoughts on the issue.

Sincerely,
Paul Nyheim

On 8/30/07, James Sutherland <jamesssss_at_yahoo.com> wrote:
>
> TopLink Essentials does not have any built-in historization support. So you
> could try this directly by mirroring your classes with a <class>Version
> class that stores the history. You could define a @OneToMany relationship
> from the class to its history. Your application would need to add a new
> version to its history for every update. You may also want an isDeleted
> flag in your version object to know that is no longer exists. You could try
> to automate adding the version objects to the history through events, such
> as the JPA prePersist and preUpdate events, or the TopLink preInsert and
> preUpdate events.
>
> The Oracle TopLink product does have built-in historization support, so you
> may wish to investigate this in the TopLink 11g preview release. You just
> need to config the TopLink descriptor to support history, then it will take
> care of maintaining a history table and allow historical querying.
>
>
>
> Hurragutt wrote:
> >
> > Hi.
> > Have anyone tried to implement Martin Fowlers Temporal Property
> > (http://www.martinfowler.com/eaaDev/TemporalProperty.html) pattern
> > using JPA?
> >
> > Or Temporal Object (http://www.martinfowler.com/eaaDev/TemporalObject.html
> > )?
> >
> > Sincerely,
> > Paul Nyheim
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Implementing-Temporal-Property-%28or-Temporal-Object%29-using-JPA--tf4340306.html#a12414231
> Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.
>