-->
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.  [ 3 posts ] 
Author Message
 Post subject: EXception during deletion
PostPosted: Thu Jun 16, 2005 6:27 am 
Beginner
Beginner

Joined: Thu Mar 24, 2005 6:29 am
Posts: 24
Hi,

I am a newbie , When i delete an object i am getting

"org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
"


I am using criteria query for deleting

my code is:
Code:
       public static boolean delete(String[] categoryids)
    {
       System.out.println("Inside the delete"); 
         Category cat = new Category();
         // cat.setId(categoryids[0]);
           cat.setId("2");
         try{
        HibernateUtil.beginTransaction();
       
       
       HibernateUtil.getSession().delete(cat);
         HibernateUtil.commitTransaction();
         HibernateUtil.closeSession();
          }catch(Exception ex)
        {
             System.out.println("jdjdjddjd...."+ex.getMessage());
             ex.printStackTrace();
        }
        System.out.println("after deletion" );
        return true;
    } // end delete


<p>Exception goes like this </p><br>
Hibernate: delete from dm_category where pk_category_id=?
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch updat
e
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificExceptio
n(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter
.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
161)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)

at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio
ns(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus
hEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:293)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java
:86)
at com.transversalnet.hibernate.HibernateUtil.commitTransaction(Hibernat
eUtil.java:182)
at com.transversalnet.docmanager.category.CategoryManager.delete(Categor
yManager.java:205)
at org.apache.jsp.docmanager.jtree_jsp._jspService(jtree_jsp.java:161)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
92)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:16
0)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.BatchUpdateException: General error, message from server: "
Cannot delete or update a parent row: a foreign key constraint fails"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:
1446)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.jav
a:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
154)
... 40 more








Thankz in advance
Arun [/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 6:47 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
The hint is in:
Code:
Cannot delete or update a parent row: a foreign key constraint fails


Something is referring to the entity being deleted. If you don't think this is the reason, check that your key constraints are all correct - have you accidentally got multiple constraints on a single column?


Top
 Profile  
 
 Post subject: Exception
PostPosted: Thu Jun 16, 2005 6:57 am 
Beginner
Beginner

Joined: Thu Mar 24, 2005 6:29 am
Posts: 24
Hi,

I check that also but nothing like that


is there any other reasons for this.

Thankz in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.