I have at first sight a simple issue but can't wrap my head around on how to solve. I have an abstract class
Compound is made up of
Structures. Then there is also a
Container which holds 1
A "special" implementation of
Versions. For that type of
Compound I want the
Container to hold the
Compound and not the
You could say "just create an interface
Containable" and a
Container holds 1
Containable. However that won't work. The reason is I'm creating a framework and the main part of that framework is to simplify storing and especially searching for special data type held by
Structure objects. Hence to search for
Containers which contain a
Compound made up of a specific
Structure requires that the "Path" from
Structure is well defined (Number of relationships or joins).
I hope this was understandable. My question is how to design the classes and relationships to be able to do what I outlined.
Kind of translation issue. with version i did not mean in terms of "versioning" but more in terms of "different variety" but fundamentally the same. There is no active / inactive. All are active.
Also note that these classes are entity classes and hence complex inheritance and hierarchies can be problematic.
Just don't see how either pattern (Composite, decorator) can work. I tried but the problem is the "path traversal", eg. implementing it in the context of Spring-data and QueryDSL.
I've created Class diagramm with comments that might help to understand the issue. Batch = Version.