Hi to all!
Just got a delete problem with collection mapping of a self referencing entity. For the many-to-many relationship we are using a database view called 'virtual_dir_map' as the middle table. We are using this view to hide some complex parent-child relationships.
If I delete a 'Directory' object, Hibernate try to delete the corrosponding entry in the view too. Since the the view is not updatable, I get an Exception. Is there a way to set the 'childDirectories' collection or the underlying view to readonly? Or is there another way to avoid the update access to a view?
Thanks in advance!
regards NewTee
Hibernate version:
Hibernate-Version: 3.2.4.sp1
Mapping documents:
Code:
<subclass name="com.basix.hibernate.mappings.Directory" extends="com.basix.hibernate.mappings.AbstractFile" discriminator-value="D">
...
<set name="childDirectories" table="virtual_dir_map" cascade="none" optimistic-lock="false">
<key column="parent_id" />
<many-to-many column="child_id" class="com.basix.hibernate.mappings.Directory"/>
</set>
</subclass>
Name and version of the database you are using:
MySQL 5.0.41 InnoDB Tables
The generated SQL (show_sql=true):
Hibernate: delete from virtual_dir_map where parent_id=?
Full stack trace of any exception that occurs:
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:222)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1030)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:28)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateTemplate$28.doInHibernate(HibernateTemplate.java:837)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:835)
at com.basix.hibernate.daos.GenericDAO.delete(GenericDAO.java:81)
at com.basix.services.PersistenceService.delete(PersistenceService.java:69)
at com.basix.remote.webdav.DataBaseFileSystem.removeObject(DataBaseFileSystem.java:252)
at com.basix.remote.webdav.DataBaseFileSystem.removeObject(DataBaseFileSystem.java:240)
at com.basix.remote.webdav.WebdavServlet.doDelete(WebdavServlet.java:977)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
at com.basix.remote.webdav.WebdavServlet.service(WebdavServlet.java:2455)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.BatchUpdateException: The target table virtual_dir_map of the DELETE is not updatable
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1237)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:936)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 41 more