-->
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: Hibernate waits long time, cause of DB constraint
PostPosted: Wed Oct 17, 2007 11:36 am 
Newbie

Joined: Wed Oct 17, 2007 11:01 am
Posts: 3
Hi guys,

About issue:

I have next tables:
Code:
CREATE TABLE `const_streets` (
  `street_id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(45) NOT NULL,
  PRIMARY KEY  (`street_id`)
);

CREATE TABLE `adr_obj1` (
  `adr_id` int(10) unsigned NOT NULL auto_increment,
  `street_id` int(10) unsigned NOT NULL default '0',
  `name` varchar(45) default NULL,
  PRIMARY KEY  (`adr_id`),
  KEY `street_id_obj1` (`street_id`),
  CONSTRAINT `street_id_obj1` FOREIGN KEY (`street_id`) REFERENCES `const_streets` (`street_id`) ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE `adr_obj2` (
  `adr_id` int(10) unsigned NOT NULL auto_increment,
  `street_id` int(10) unsigned NOT NULL default '0',
  `name` varchar(45) default NULL,
  PRIMARY KEY  (`adr_id`),
  KEY `street_id_obj2` (`street_id`),
  CONSTRAINT `street_id_obj2` FOREIGN KEY (`street_id`) REFERENCES `const_streets` (`street_id`) ON DELETE CASCADE ON UPDATE CASCADE
);


Each address table has a foreign key constraint to a STREET table.

I need to delete street. But when it is coupled to any address, DB constraint doesn't allow to do it. Hibernate wait for a long time, when throws an exception.


Is it possible to throw exception immediately?
There are possible a lot of address tables.

hibernate version 3.2.2, Java 5.0 and MySQL 5.0 are used.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 11:42 am 
Newbie

Joined: Wed Oct 17, 2007 11:01 am
Posts: 3
StackTrace:

Caused by: 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:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
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.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.xx.db.hbm.HibernateUtil.commit(HibernateUtil.java:62)
at com.xx.db.hbm.DAOHbmHelper.deleteObject(DAOHbmHelper.java:91)
... 23 more
Caused by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:828)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 32 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 6:56 am 
Newbie

Joined: Wed Oct 17, 2007 11:01 am
Posts: 3
Issue is fixed!

I rebuilt SessionFactory several times and connections weren't closed. :-)


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.