In a new Java project I plan to use an extra layer above Hibernate entities. So there would be a CustomerEntity
and CustomerDomain
. The reason for that is that the CustomerDomain
can contain extra data fields from other sources like SOA or other DB. (Maybe DTO is better here than Domain.)
In the pilot solution both the entity class and the domain class has a constructor the copies common fields. Like :
public CustomerDomain(CustomerEntity entity)
In case of complex objects, this solution reads all data from the entity that makes Lazy loading ineffective.
So my question is how to separate database entities from business entities keeping the lazy loading benefits?