I am having a problem with hibernate lazy collection initialization. When I call some method on a lazy initialized collection, size() or add(), it always throws out the LazyInitializationException. I set the "lazy" attribute in Set value "true" and "inverse" attribute "true" and "cascade" attribute "save-update". I debug into the Hibernate code and found the exception is throw on the statement "session.afterLoad();" in the "doQueryAndInitializeNonLazyCollections" method in Loader class. But the inner exception seems to be "ClassCastException" which is caught in the "initialize" method in "PersistentCollection" class. I am just confused about this.
|