I would like to build a set of versioned data, such that I can easily retrieve any version of data.
Tables would be structured as such:
OID
key column
data
version id (numeric system-wide increasing value over time)
So for instance if I have a simple table for a document which stores it's title, I may have:
row 1: oid=xx1, docid=yy1, title=My First Title, version=15
row 2: oid=xx2, docid=yy1, title=My Revised Title, version=267
The most common query would be to get the current version of an object (so if I ask for the title for docid=yy1 I would get "My Revised Title").
However, another common query would be to get the version of an object as of a certain period in time (as referenced by the version id). So for instance if I ask for the title of docid=yy1 where the revision is <= 200, the answer would be "My First Title".
There would actually be many tables built like this, and thus I may want to join across tables, but still be able to query for the most recent record as of a specific version id.
I have built a custom JDBC API to deal with this, but I would prefer to be able to handle via JPA.
Does anyone have a recommendation for an elegant way to handle this in JPA? Should I switch to another technology altogether?
Thanks,
ken
Tables would be structured as such:
OID
key column
data
version id (numeric system-wide increasing value over time)
So for instance if I have a simple table for a document which stores it's title, I may have:
row 1: oid=xx1, docid=yy1, title=My First Title, version=15
row 2: oid=xx2, docid=yy1, title=My Revised Title, version=267
The most common query would be to get the current version of an object (so if I ask for the title for docid=yy1 I would get "My Revised Title").
However, another common query would be to get the version of an object as of a certain period in time (as referenced by the version id). So for instance if I ask for the title of docid=yy1 where the revision is <= 200, the answer would be "My First Title".
There would actually be many tables built like this, and thus I may want to join across tables, but still be able to query for the most recent record as of a specific version id.
I have built a custom JDBC API to deal with this, but I would prefer to be able to handle via JPA.
Does anyone have a recommendation for an elegant way to handle this in JPA? Should I switch to another technology altogether?
Thanks,
ken