Viritin MTable with lazy hibernate JPA loading


I follow the CDI example at

My datasource is a database, which is accessed via JPA/Hibernate.

I have the following case:

Class A {
/* JPA entity class */

Set<B> manyinstances = ...


The instances of Class A are shown in a MTable (so that they can be selected and edited in an AbstractForm).
However, I am not interested in the “manyinstances” property.
Therefore, I want to use lazy loading (in JPA/Hibernate terms) on that property.

However, my impression is that JTable accesses the “manyinstances” property somehow, dispite that it is loaded lazy in JPA/Hibernate

I get the following exception:
caused by
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:

Is there a way to load the “manyinstances” property lazy while using MTable (and AbstractForm)?




Instantiate MTable so that it only lists the desired properties, not those that would need a lazy loaded relations. An example:

If you (in some other case) want to list this manyinstances field in any kind of listing, I suggest to use a join query instead of “lazy loading” as it will be much better performing (1 query vs. 1+n).