-->
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.  [ 2 posts ] 
Author Message
 Post subject: Row was updated or deleted by another transaction
PostPosted: Thu Dec 15, 2005 4:05 pm 
Hi,

I'm having issues with a Joined-Subclass.
There is an object called Task and a subclass of this class is AssignedTask.

If I create an instance of Task, save it, then delete it and check the logs I see that during the deletion process it calls

"DELETE FROM AssignedTask WHERE TaskID = $p$"

All well and good.

However, if I create an instance of AssignedTask, save it, then delete it I get an exception with the message: "Row was updated or deleted by another transaction".
Returning to my log file I see:

"DELETE FROM AssignedTask WHERE TaskID = $p$"
"DELETE FROM AssignedTask WHERE TaskID = $p$"

It's been called twice thus leading to this problem.
I tried to incorperate into the delete mechanism.........

Code:
public class AssignedTask
{
...
public override void Delete()
{
     Task task = data.GetObject(typeof(Task), this.ID) as Task;
     task.Delete();
}
...
}

// data.GetObject is as follows.
public TTObject GetObject(Type type, int id)
{
    IList list = null;
    ITransaction tx = null;

    lock(sessionLock)
    {
       try
       {
          tx = session.BeginTransaction();
          list = session.Find(String.Format("FROM {0} AS a "+
                        WHERE a.ID = ?",
                        type.ToString()),
                        id, TypeFactory.GetInt32Type());
          tx.Commit();
       }
       catch (Exception ex)
       {
          if(tx != null)
          tx.Rollback();
          throw ex;
       }
    }

    if(list.Count == 0)
    {
   return null;
    }
    else if(list.Count > 1)
    {
   throw new InvalidOperationException
   ("A Search on ID returned more than one TTObject in DataStore.GetObject");
    }
    else
    {
   return (TTObject)list[0];
    }
}


However I find that when I try to get this task object via the GetObject method it instead returns to me an instance of AssignedTask instead of an instance of task.
I assume this is because it sees the entry in AssignedTask and assumes the object must be an AssignedTask.

The subclass mapping in Task.xml.hbm is as follows:

Code:
<joined-subclass table="AssignedTask" name="TTLibrary.Object.AssignedTask, TTLibrary">
   <key column="TaskID"/>
   <property name="X" column="X" type="Int32"/> 
   <many-to-one class="TTLibrary.Object.User, TTLibrary" column="UserID" foreign-key="UserID" name="User" cascade="none"/>
</joined-subclass>


Could someone please point me towards the right direction on this one because i'm really struggling.
Many thanks in advance if you can. :)


Top
  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 6:54 pm 
Newbie

Joined: Thu Dec 15, 2005 4:30 pm
Posts: 3
Sorry this was a mapping issue.
I still had a many-to-many collection mapped to AssignedTask.

Apologies for anyone's time i've wasted with this post.


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