I have a bi-directional many-to-many where I basically want lazy loading only from "one side". My Product class has a set of services, and my Service class has a set of products.
The code I develop here is used as a library, one client is a web client, and we use the opensessioninviewinterceptor mechanism in Spring. The other client is a standalone Java app (where we do not want laziness). The Java App will never call product.getServices(), so it should not be a problem.
Here is an exctract from my mappings.
product mapping:
Code:
<set name="services" lazy="true" inverse="true" .......
<key column....
<many-to-many colu....
</set>
service mapping:
Code:
<set name="products" lazy="false" .......
<key column....
<many-to-many colu....
</set>
If I access service.getProducts() I get a LazyInitializationException in my standalone JavaApp.
My question is: Is it posssible with a bi-directional many-to-many to have lazy=true on one side, and lazy=false on the other side? Does it make sense?