I'm trying to implement some sort of time slicing for my entities. I'm using JPA and Hibernate.
So far, I've come up with a conceptual idea:
For an entity X I need an XVersion entity. X contains a list of XVersion entities. X contains an id and static data, XVersion contains time-sliced data (containing a validFrom and validTo field). Now I don't want to get every XVersion in X, only the currently valid one (date between validFrom and validTo).
I think I can achieve this through adding a where clause into my query (select x from X left join fetch x.versions where :date between x.versions.validFrom and x.versions.validTo), but I'd rather use the @Filter annotation on my collection.
However, when I add a filter on the collection with a condition, JPA (or Hibernate) does not filter the collection on the condition I had given.
Am I missing something? Did it forget something concerning the filter? I read the Filter documentation on Hibernate Annotations, but I couldn't find what I missed.
Does Hibernate (or even JPA for that matter) support time-slicing of entities? It seems such a widely spread concept, but I haven't found information about it concerning JPA implementation.
|