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.  [ 1 post ] 
Author Message
 Post subject: Deadlock Exception with Composite-element
PostPosted: Wed Jan 28, 2009 2:25 pm 
Newbie

Joined: Wed Jan 28, 2009 12:45 pm
Posts: 2
In nutshell, our application creates pakages. A package can have one or many source file revisions. There is a package class and SourceFileRevision class. The problem is users see deadlock error every now and then.
The error says:
-----------------------------------------------
The following error has occured: Hibernate operation: could not delete collection rows:[businessObject.Package.sourceFileRevision#2];
uncategorized SQLException for SQL [delete from package_source_file_xref where package_id=? and source_file_id=? and revision_id=?]; SQL state [40001]; error code
[1205]; Your server command (family id #0, process id #598) encountered a deadlock situation. Please re-run your command.
-------------------------------------------------

The error is seen also when a user is trying to do a read-only operation like listing the packages (not saving). I suspect when user one is saving a package, during that time if any other user
try to even list the packages (read-only) they get this dead lock error. I have read that we should avoind using composite keys/elements. But I do not know any other way to get the data for corresponding id from xref table.

It will be great if someone throw some light on this issue. Thank you guys in advance. Below is part of mapping file and java class files if that helps to undestand the problem.

package.hbm.xml:
<class name="businessObject.Package" table="package">
<id name="packageID" column="package_id"
type="java.lang.Integer" unsaved-value="-1">
<generator class="increment"></generator>
</id>

<set name="sourceFileRevision" table="package_source_file_xref"
lazy="true" cascade="save-update" order-by="source_file_id asc">

<key column="package_id"></key>
<composite-element class="businessObject.SourceFileRevision">
<many-to-one name="sourceFile" column="source_file_id" class="businessObject.SourceFile"
<many-to-one name="revision" column="revision_id" class="businessObject.Revision" />
</composite-element>

</set>
</class>

package.java. these files have declarations and getters and setters.
public class Package
{
private Integer packageID;
private Set sourceFileRevision;
}

SourceFileRevision has this declarations.
public class SourceFileRevision {

private SourceFile sourceFile;
private Revision revision;
}

SourceFile.java
public class SourceFile
{
private static final long serialVersionUID = 1L;
private Integer sourceFileID = new Integer(1);
private String filename = "";
private List revisions = new ArrayList();
}

Revision.java
public class Revision
{
private static final long serialVersionUID = 1L;
private Integer revisionID = new Integer(1);
private String versionNumber = "";
}

package_source_file_xref table sample
Code:
package_id        source_file_id        revision_id
  1                        2                          30
  1                        5                          35
  1                        9                          34
  2                        10                        90
  2                        50                        70


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

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.