alternatives to ManagedEntityMode #820
Conversation
| @Documented | ||
| @Target(TYPE) | ||
| @Retention(RUNTIME) | ||
| public @interface ReadOnly { |
There was a problem hiding this comment.
Given this definition, I think the name @ReadOnly is odd since you can insert and remove entries. IMO @Immutable like we have in Hibernate ORM is a better name for this. It might be worth adding a section about inheritance i.e. polymorphic subclasses inherit the behavior.
Additionally, it might be interesting to allow the annotation on FIELD/METHOD to control which persistent attributes contribute to dirty checking, similar to what we define in Hibernate ORM already, which would allow us to get rid of the Hibernate ORM specific annotation.
There was a problem hiding this comment.
I think the name @readonly is odd since you can insert and remove entries.
I .... guess I don't find that very odd?
It's perhaps slightly odd to say that you can delete a read-only thing, but I don't see how it's strange to say that you can create one.
IMO
@Immutablelike we have in Hibernate ORM is a better name for this.
"Immutable" to me implies a much higher level of un-modifiability than "read only". When I say something is "immutable", I usually mean in some sort of Platonic sense. Not just in the sense of "I'm not interested in modifying this thing".
There was a problem hiding this comment.
By the way, I consdered calling it @Unflushable, and I think maybe that's better.
| * @see ReadOnly | ||
| * @see #flush | ||
| */ | ||
| void enableFlush(Object entity); |
There was a problem hiding this comment.
AFAIU, in Hibernate ORM it's impossible to make @Immutable entities non-read-only, so I would rather not do this. Also see org.hibernate.engine.internal.AbstractEntityEntry#setReadOnly.
There was a problem hiding this comment.
What exists in Hibernate today grew organically and it shows. I don't think it's an especially perfect model.
An alternative solution to #62, since I'm afraid that #668 might be getting out of hand.