| Lovro Pandzic - First, Java 10 Value Types do not sound to me to be viable for mapping as an entity as they are designed with pass-by-value semantics inherently, exactly as primitives in Java: when passing a Value Type a copy is made and the copy is passed. Everytime you pass an entity to a method or return it from a method you'd get a new copy of it. That inherently breaks the semantics of an entity in Hibernate and JPA. As for my lazy loading concerns... there are 2 cases where this comes into play:
- Loading an entity reference (Session#load, EntityManager#getReference, etc)
- Lazy to-one associations
We also have to consider the difference between proxy-based and bytecode-based lazy loading. In the first case, we are passed the entity id and asked to build a lazy version of the entity. How are you seeing this working? And up-front, pulling the other constructor vales from the database is not a valid answer  In the second case, I can see this possibly working with bytecode-based lazy loading. But with proxy-based lazy loading I just don't see how this works. To me it seems like this really opens up the situation where now we have multiple ways to instantiate an entity simultaneously depending on use case. To me that is an inconsistency. I guess as long as we could limit this to at most 2 "instantiation strategies" per entity (one for just-id binding, one for ResultSet binding) I could be ok with that. Feel free to start a P/R showing what you intended. We can discuss here, or on the dev mailing list. |