views:

46

answers:

3

I'm looking for temporal libraries for Java, i.e. libraries which allow to store multiple historical version of the same concept. I'm looking for a library which has an API to do something like:

Instant i1 = Instant.valueOf("2010-01-01");
Instant i2 = Instant.valueOf("2010-01-02");
Attribute<String> a =  ....
a.setValue(i1, "String as of 2010-01-01");
a.setValue(i2, "String as of 2010-01-02");

You can find a discussion about temporal issues on the nice articles by Martin Fowler

One library I found is JTemporal, which seems pretty good to me, but it's not complete and lacks support for Hibernate persistance. I'd like support for temporal sets too, i.e. sets defined in an exact point in time. JTemporal does that, but persisting the TemporalSet is not easy.

+1  A: 

Look at Deuce STM - Java Software Transactional Memory.

Eugene Kuleshov
how is that relevant?
Bozho
Based on description: "allow to store multiple historical version of the same concept"
Eugene Kuleshov
A: 

Joda-time should be covering your requirements.

Joda-Time provides a quality replacement for the Java date and time classes. The design allows for multiple calendar systems, while still providing a simple API. The 'default' calendar is the ISO8601 standard which is used by XML. The Gregorian, Julian, Buddhist, Coptic, Ethiopic and Islamic systems are also included, and we welcome further additions. Supporting classes include time zone, duration, format and parsing.

It has (like JTemporal) support for instants, periods, etc.

It also has hibernate support.

Bozho
No it isn't, joda-time is a good replacement for handling dates, but, as far as I know, it doesn't offer something like a collection that can store multiple values of an object with their valid times
cdarwin
You are right, joda-time offers the basic structures which you need when handling temporal data, but no data structure which can hold that temporal data
cdarwin
+1  A: 

Have a look at DaoFusion framework which acts as a bitemporal framework with tight integration into Hibernate. It should be exactly what you are looking for.

Quoted from the linked website:

Bitemporal pattern offers an elegant and sophisticated way of dealing with most temporal issues. The bitemporal pattern implementation offered by DAO Fusion builds upon a bitemporal framework created by Erwin Vervaet and Christophe Vanfleteren. You can learn more about this framework from their presentation Temporal Issues in a Rich Domain Model.

codescape
I forgot it, but I already examined it. That is good code, but, if I correctly recall, is much similar to JTemporal, and uses the same "trick" which can be used with JTemporal to achieve Hibernate persistance: use an uderlying collection which Hibernate knows hot to map.I'm not sure that is the best approach with Hibernate, and, moreover, this trick cannot be used to store JTemporal TemporalSet, which is a collection of collections
cdarwin
That's the way it works.. providing a persistable list to Hibernate and providing a bitemporal object to the application.
codescape