java - Partially object loading in Hibernate -


I have a class that is sometimes not necessary to fully load. Can I load it partially, or do I need to make a light version of the class (and new mapping for it)?

For example: class message with id, title, body, author, timestamp when I want to delete message, I need only two fields Is id, author .

I have a class that sometimes needs to be fully loaded Does not happen. Can I load it partially, or do I need to make a light version of the class (and new mapping for it)?

In theory, see Hibernate Lazy Property Loading If you use buildtime bytecode instrumentation. But I do not have much experience with it, I "light version" approach if is really necessary.

Prefer example: class message with id, title, body, author, timestamp. When I want to delete the message, I just need two field IDs, authors.

This is probably not the best example as you can use here (which is more generally than loading messages to delete those examples and To remove them). See the section but if you can not do this, then loading an entity to remove it is the cost to pay while using an ORM.


Comments