A more generic approach to defining DataRoot? #381
Unanswered
Soromeister
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I am looking for guidance on how I can get a more generic approach to defining my root objects.
At the moment, I am using Micronaut framework with its EclipseStore integration and have something like this:
This forces me to work with concrete implementations of each object's Repository implementation, so I have:
Problem is that now I have duplicate code in each of these service classes, taking for example creation of a new element, I am simply getting a new element, verifying whether it's already present in the storage and then, generate a new TSID, followed by storing the element either via @StoreParam, @StoreReturn or manually invoking
storageManager.storeRoot()
.I am trying to approach this from a generic point of view, so I made a BaseRepository, BaseService and so on to deliver a more generic approach, however, I am currently stuck with the DataRoot class fields.
I actually require the structure to be like this, having ROOT > customers > ... and then ROOT > profiles > ... and so on (when I use the EclipseStore Client GUI, this is how they show up).
I tried a more generic approach to this by declaring my DataRoot as below:
Now, in my BaseService, I am simply passing the entity class to glue it to the actual entity:
With this, in something like my SocialService, I pass on the entity class:
I can somewhat de-duplicate my code, but now I have this in the data representation:
How can I avoid getting the full package + class name as a key and instead have it look just like before?
Instead of
ROOT > entities > [0] > <k, v>
I need it to beROOT > entities > customers > <TSID, Customer>
and thenROOT > entities > socials > <TSID, Social>
and so on.If my approach is completely wrong, please suggest the best way to handle this, given that I'll be adding more entities to my application.
Beta Was this translation helpful? Give feedback.
All reactions