9

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.

cdarwin
  • 3,801
  • 8
  • 38
  • 56
  • can't you do this with a `Map` ? – Bozho Oct 25 '10 at 21:41
  • This is what JTemporal does, but temporal support is much more, like merging adjacent periods with the same value, and much more. The Map, however, is of for a single temporal attribute, but handling temporal sets is more difficult – cdarwin Oct 25 '10 at 21:55

2 Answers2

4

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.

stefanglase
  • 9,652
  • 4
  • 29
  • 41
  • 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 Oct 25 '10 at 21:47
  • That's the way it works.. providing a persistable list to Hibernate and providing a bitemporal object to the application. – stefanglase Oct 25 '10 at 21:51
2

Look at Deuce STM - Java Software Transactional Memory.

Eugene Kuleshov
  • 30,122
  • 5
  • 61
  • 63