[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9. Historical Data

BeanKeeper keeps versioning all objects. By default none of these objects are deleted physically ever, and all historical object information is available for selection. Historical selects return the resultset which exactly matches the resultset that would be returned if the query was ran at the date specified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1 Query

The syntax of the query is:

 
find right where right.subject.name='Joe' at ?

The above example lists the rights of Joe, which Joe posessed at a given date. The interesting part is the "at ?" construct. The date of the query must be submitted as a standard query parameter, so a full historical select could be something like this:

 
Date yesterday = computeYesterday();
List yesterdaysResult = getStore().find("find right where right.subject.name='Joe' at ?", new Object[] { yesterday });

Note, that historical queries do not return objects inserted at the given date, but results, like the query was executed at that date.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2 Concurrency

Historical queries behave as their non-historical alteregos. All queries see all modifications made inside the same transaction they were executed in, but no modifications of other transaction during running. So if a historical query points to a past date on which the current transaction was still active (say, 2 seconds in the past), then all modifications of the current transaction up until that point are visible. But usually, a historical query points much further into the past, and usually points beyond the start of current transaction, in which case, it sees only commited transactions. It is not possible to make a historical query which points into the middle of a transaction! All transactions are visible like they were created in an exact instant in time, no temporary phases are visible, not even in historical queries. All transactions are made visible at the single millisecond (in fact, the scale is finer than that) when they are commited, even if the transaction lasted several seconds or even minutes.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Robert Brautigam on November, 21 2009 using texi2html 1.78.