At work I’ve been using our in house ORM (pre 2000) and we’re looking at moving to another ORM solution for our java, however there are some specific requirements. Does anyone know any form or ORM that supports these requests?
-
Support for inheritance: In our java we have quite a deep inheritance structure and currently if I add an attribute to a class at the “top” then I have to manually edit the ORM procedure (in SQL) to add the new class for each of the sub classes
-
Support for decorator tables: A few of our classes need to be able to store any (user provided) attribute against a particular object, currently this is just a table that matches Item Id to a row containing FieldName and FieldValue and we pull all of these in as attributes. See below for a better explanation.
-
Object persistence inbuilt, so objects are only loaded and written to/from the database when requested and otherwise are left in memory. Would also be great if any changes could be automatically saved when you finish, rather than having to call
.save()(though potentially dangerous?) -
As usual, easy to use (preferably – isn’t this what we all want?) and good performance
Thanks for your time, happy to update the question with what we chose and why and some hints we discover while implementing!
Further explanation of #2:
(please don’t ask why it has to be like this, changing it is “out of scope” of this project)
Item table:
ItemId | Type | Price
-------|-------|-------
1 | Mouse | 9.99
2 | Dog | 12.99
Decorator table:
ItemId | FieldName | Value
-------|-----------|-------
1 | Age | 12
2 | Breed | Blue Long Hair
2 | Name | Fluffy
Item Objects:
Item1
ItemId -> 1
Type -> Mouse
Price -> 9.99
Age -> 12
Item2
ItemId -> 2
Type -> Dog
Price -> 12.99
Breed -> Blue Long Hair
Name -> Fluffy
1 Answer