Thanks for sharing, Andrey!
One reflection on persistence (not related to Andrey's post per se) is to keep it dumb. As is so often the case, it's easy to get into a mode where you add more and more bells and whistles to cater to first one specific use case, then another.
You get a very, very long way by addressing only the following:
- Give me any object matching a specific pattern (typically an id, but you can do e.g. generic JPath queries)
- Optionally, also include anything upstream from any matches, along any of a specified list of link types (e.g. COMPOSITION and ARTIFACT).
- Optionally, also include anything downstream from any matches, along any of a specified list of link types (e.g. CAUSE).
Then you can build all kinds of sophisticated services on top of that very simple foundation.