We want to implement a "versioning" feature in our Java project(JSF/EJB/JSF). Let me give an example:
----- | A | ----- 1/\1 / \ */ \* ----- ----- | B | | C | ----- -----
The above diagram shows a simple object-graph with 3 objects i.e., A, B and C. B and C "is part" of A, any changes on A and/or B and/or C need to create a new version of A.
The question is, how to implement it, both in Java side and Database side ?
We got 2 solution so far and not settled yet:
SolutionA: very changes on the parts of A will cause a new deep clone of A, and this clone will be persistant via JPA to database as a new version. Pros: implementation is easy, cons: there are many redundancy(considering the case that the object graph is very big) in both java side and database.
SolutionB: only create changed part of A in database. Pros: no redundancy,DB performance may be better. Cons: this break the object-graph and we have to manually maintain the relations/references among objects. may drive development into a nightmare.
Any idea ?