See description in the "Code between..." section. Thanks.
Hibernate version:
2.1.4
Mapping documents:
SubscriberImpl has a lazy map, named emailingProperties :
Code:
<map
name="emailingProperties"
table="subscriberemailingproperties"
lazy="true"
sort="unsorted"
inverse="false"
cascade="all"
>
<key
column="subscriber"
>
</key>
<index-many-to-many
class="com.fullsix.newsletter.impl.EmailingImpl"
column="emailing"
/>
<one-to-many
class="com.fullsix.newsletter.impl.BaseSubscriberEmailingPropertiesImpl"
/>
</map>
BaseSubscriberEmailingPropertiesImpl has some properties, including a boolean property named "import_xls".
Code between sessionFactory.openSession() and session.close():I'm just calling session.delete() on an instance of a SubscriberImpl object, which emailingProperties map has not yet been initialized.
Here my problem is that my "import_xls" property is not present in the database (this property has been added later, the database has not been altered yet). Of course, hibernate throws an exception (because of an underlying SQLException).
However, I would expect an HibernateException here (because Hibernate did not succeeded in deleting my object), instead of a LazyInitializationException (which is the reason why my object didn't get deleted). I think that Hibernate should convert the LazyInitializationException to an HibernateException.
Full stack trace of any exception that occurs:Code:
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
at net.sf.hibernate.collection.Map.values(Map.java:166)
at net.sf.hibernate.type.MapType.getElementsIterator(MapType.java:28)
at net.sf.hibernate.engine.Cascades.getAllElementsIterator(Cascades.java:570)
at net.sf.hibernate.engine.Cascades.access$100(Cascades.java:28)
at net.sf.hibernate.engine.Cascades$1.getCascadableChildrenIterator(Cascades.java:65)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:525)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1237)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1172)
... 54 more
Caused by: net.sf.hibernate.JDBCException: could not initialize collection: [com.fullsix.newsletter.impl.SubscriberImpl.emailingProperties#00000005]
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:287)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3264)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
... 66 more
Caused by: org.postgresql.util.PSQLException: ERROR: column emailingpr0_.import_xls does not exist
at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:231)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
... 68 more
Name and version of the database you are using:
PostgreSQL 7.4.2
Debug level Hibernate log excerpt:
None.