Force hibernate to eager load a relationship when required by the user

I am using hibernate to map my models to db. Using a home-made engine based on CriteriaBuilder API, I am trying to join (fetch) a relation only at user’s demand.

So for an entity Country that holds :

  • A set of regions (OneToMany)
  • The spatial information of the country (OneToOne)

If the user asks to include a relationship, I perform a fetch :

this.root.fetch(relation.getField.getName(), relation.joinType());

If the relationship is a OneToOne : As expected, my entity now holds the object. If the user doesn’t specify the inclusion, then the entity will hold an instance of HibernateProxy, which I discard when serializing.

If the relationship is a OneToMany : In both case, included or not, the entity holds an instance of a PersistentSet.

So my question is : Is it normal that hibernate returns me a PersistentSet instance even if I asked the join to be a fetch ?

If yes, from a PersistentSet, am I able to determine that I asked for it to be fetched ?
If no, how can I tell Hibernate that I want an eagerly loaded Set when loading a relation ?