This is a historical data processing problem. Suppose you have a class MyClass, for example the following:
class MyClass {
String field1;
Integer field2;
Long field3;
getField1() {...}
setField1(String ...) {...}
...
}
Now suppose I need to make MyClass save and retrieve old data, what's the best way to do this?
requirements are designed to save classes through Hibernate. And have no more than two tables on the "object" : only one table and one table for the class of "continuity" (the one that is the entity that evolves over time) and another table for historical data (as suggested here )
Please note, I must be able to assign arbitrary valid time for field values.
The class should have an interface such as:
class MyClass {
getField1At(Instant i) {...}
setField1At(Instant i, String ...) {...}
...
}
I am currently using the JTemporal library and it has a class TemporalAttribute<T>that looks like a map: you can do things like T myAttr.get(Instant i)to get myAttr version in Instant i. I know how to save TemporalAttribute in a table with Hibernate (it's simple: I save the SortedMap used by TemporalAttribute, and you get a table with start and end time and attribute value).
The real problem is that here we have several attributes.
I have a solution, but it is not clear, and I would like to hear your ideas.
source
share