How to initialize Hibernate entities fetched by a remote method call? <p>When calling a remote service (e.g. over RMI) to load a list of entities from a database using Hibernate, how do you manage it to initialize all the fields and references the client needs?</p> <p>Example: The client calls a remote method to load all customers. With each customer the client wants the reference to the customer's list of bought articles to be initialized.</p> <p>I can imagine the following solutions:</p> <ol> <li><p>Write a remote method for each special query, which initializes the required fields (e.g. Hibernate.initialize()) and returns the domain objects to the client.</p></li> <li><p>Like 1. but create DTOs</p></li> <li><p>Split the query up into multiple queries, e.g. one for the customers, a second for the customers' articles, and let the client manage the results</p></li> <li><p>The remote method takes a DetachedCriteria, which is created by the client and executed by the server</p></li> <li><p>Develop a custom "Preload-Pattern", i.e. a way for the client to specify explicitly which properties to preload.</p></li> </ol>