-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Error running bulk delete
PostPosted: Sat Nov 05, 2005 2:32 pm 
Beginner
Beginner

Joined: Wed Jun 15, 2005 2:00 pm
Posts: 38
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Mapping documents:
Code:
<class name="ACLEntry" table="OBJECTSECURITY" lazy="false">
        <composite-id name="id" class="ACLEntryKey">
           <key-property name="entityClassID" type="integer" column="entityClassID"/>
           <key-property name="entityID" type="integer" column="entityID"/>
           <key-property name="objectClassID" type="integer" column="objectClassID"/>
           <key-property name="objectID" type="integer" column="objectID"/>
        </composite-id>

               <property name="accessLevel" column="accessLevel" type="integer" not-null="true"/>
                <property name="readOnly" column="readOnly" type="boolean" not-null="true" />
       
    </class>


Code between sessionFactory.openSession() and session.close():
Code:
Query q = session.createQuery("delete from ACLEntry where id.objectClassID=:objectClassID and id.objectID=:objectID");
      q.setInteger("objectClassID", ACLListArray[0].getId().getObjectClassID());
      q.setInteger("objectID", ACLListArray[0].getId().getObjectID());
      q.executeUpdate();
      session.flush();


Full stack trace of any exception that occurs:
Code:
org.hibernate.exception.SQLGrammarException: could not execute update query
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.hql.ast.UpdateStatementExecutor.execute(UpdateStatementExecutor.java:99)
   at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:297)
   at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:871)
   at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89)
   at project.hibernate.PermissionDAO.saveACLList(PermissionDAO.java:57)
   at project.helpers.PermissionHelper.saveACLList(PermissionHelper.java:38)
   at project.struts.actions.ObjectSecurityActions.doEditSecurity(ObjectSecurityActions.java:44)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at project.struts.actions.BaseDispatchAction.dispatchMethod(BaseDispatchAction.java:255)
   at project.struts.actions.BaseDispatchAction.executeAction(BaseDispatchAction.java:175)
   at project.struts.actions.BaseDispatchAction.execute(BaseDispatchAction.java:112)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
   at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: Unknown column 'aclentry0_.objectClassID' in 'where clause'
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2921)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1570)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
   at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:930)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1159)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1076)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1061)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
   at org.hibernate.hql.ast.UpdateStatementExecutor.execute(UpdateStatementExecutor.java:76)
   ... 48 more


Name and version of the database you are using: MySQL 5.0

The generated SQL (show_sql=true):
Code:
Hibernate: delete from OBJECTSECURITY where aclentry0_.objectClassID=? and aclentry0_.objectID=?


Hi,

As per above, I have a class with a composite id, and I want to do a bulk delete based on 2 fields of the composite id.
I'm using the functionality described in Section 14.3 of the documentation (http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#batch-direct).

However when I tried to run this, I got the JDBC error. Looking at the generated SQL, seems like a bug to me.

Anyone any ideas how to resolve this? Or should I raise this as a bug formally?

In the meantime, I'll probably have to use a native SQL query for this.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 05, 2005 2:41 pm 
Beginner
Beginner

Joined: Wed Jun 15, 2005 2:00 pm
Posts: 38
Seems that I can't use a native SQL query either, because native SQL query does not support updates/deletes :-(

Does anyone have any other ideas how to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 05, 2005 3:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Try the newer 3.1 releases. I am pretty sure this was already fixed. If you still find problems with the newer versions, submit a report to JIRA.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 05, 2005 9:59 pm 
Beginner
Beginner

Joined: Wed Jun 15, 2005 2:00 pm
Posts: 38
Hi,

I've actually found something that works?!

Seems like the following query will work:
Code:
delete from ACLEntry where objectClassID=:objectClassID and objectID=:objectID


i.e. it's the same query, but I dropped the id prefix. It sounds odd that this work though.

Switching to 3.1 will be slightly cumbersome coz I'm using MyEclipse and their current Hibernate version is on 3.0.5. Am checking to see when they will switch to 3.1.

Thanks for the tip on this!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.