Hello, all
It seems I find a bug of <any> mapping. The bug occurs under such situations:
-- class Box has a property "basket" which is type of Object and can contain ANY Basket (AppleBasket, GrapeBasket, ......)
-- class AppleBasket has a set of Apple objects (one-to-many), and this set use lazy loading
and:
-- create some Apple instances
-- create an AppleBasket instance
-- put Apple instances into AppleBasket
-- put AppleBasket into the Box
-- commit the transaction
-- now all operations succeed
and:
-- load one existing AppleBasket instance (Note here that no apples are loaded because of lazy loading)
-- put AppleBasket into the Box
-- commit the transaction
an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: collection [test.AppleBasket.apples] was not processed by flush()
However, before we put AppleBasket into the Box, if we explicitly load the apples with:
Code:
basket.getApples();
the above operations can succeed.
Is this a bug? Or after the basket is loaded I have to de-lazy-load all properties of basket explicitly? And should I report this bug (if it is a bug) to Hibernate developers team?
Thank you for your help.