-->
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: get integrity constraint violation on a delete - puzzeling
PostPosted: Thu Jun 12, 2008 4:32 pm 
Newbie

Joined: Sat Dec 02, 2006 1:09 am
Posts: 12
I have some code that is doing a bulkUpdate and the SQL statement is a "delete from..."

Then I get this stack trace indicating a data integrity constraint violation. Any ideas? I am not inserting anything and there is no insert statement in the code in any of the methods I have written (that are listed in the stack trace below).



---
ERROR [Worker # 0] JDBCExceptionReporter.java:78| Duplicate entry '302-2000-1' for key 1
ERROR [Worker # 0] AbstractFlushingEventListener.java:301| Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1136)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
at org.springframework.orm.hibernate3.HibernateTemplate$38.doInHibernate(HibernateTemplate.java:1068)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.bulkUpdate(HibernateTemplate.java:1059)
at com.mycompany.base.dao.hibernate.PtDaoBaseImpl.deleteBy(PtDaoBaseImpl.java:750)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 10:06 am 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
I see similar issues, while deleting the entries which are mapped to collections or hashmaps etc..

In case your need is to delete orphan ones due to data updates, try using @org.hibernate.annotations.Cascade(
value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)

Regards,
Nagendra

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


Top
 Profile  
 
 Post subject: ConstraintViolation on delete
PostPosted: Mon Jun 16, 2008 8:31 pm 
Newbie

Joined: Sat Dec 02, 2006 1:09 am
Posts: 12
I tried the annotation but still saw the error. I also disabled all constraints in my DB (MySQL) but still saw it.

I then recreated all the tables with no constraints (MySQL) and am still getting the error. The only constraints I have now are primary keys.

If there are any other ideas, please let me know.

---
To disable all constraints I issued a statement like this on each table
alter table collsn_archive disable keys;

I then started up tomcat which made it's own connection to MySQL.

I'm not sure what the solution is at this point or how to find it. I could find no article on how to show all constraints in my DB (MySQL).

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 4:10 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Quote:
I am not inserting anything


You may not be explicitly inserting anything, but is there a chance that you are loading something in a transaction, updating that POJO, and then later, the transaction gets committed without explicitly calling update or save? If that is the case, this might be causing the problem.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.