Hi Marc Schipperheyn, after taking a closer look I realized the error isn't raised from within the discriminator but from your custom class bridge where you access the comments collection.
That exception actually makes sense, as you invoke EntityManager#clear() prior to accessing it from within the class bridge, which makes the Post entity unmanaged. As the comment collection hasn't been initialized before (just adding an element doesn't load the collection's state from the database) the exception is rightfully raised.
I adapted the test to actually navigate the lazy assocation from Country to Language within the discriminator and that worked as expected, i.e. the language entity is fetched from the database.
So I'm going to close this issue as "Cannot re-produce". Feel free to re-open if you have a test case which actually causes a LazyInitializationException within the discriminator (and which is not caused by manually detaching objects with unloaded lazy references). Thx!
|