-->
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.  [ 6 posts ] 
Author Message
 Post subject: annotations : delete is not working?
PostPosted: Sat Jan 22, 2005 10:57 am 
Beginner
Beginner

Joined: Fri Jun 11, 2004 3:42 am
Posts: 22
This does not seem to work for me. Can someone help please!

Code:
try {
   DatabaseManager.registerClassToThePool(Node1.class);

   DatabaseManager.getSession();
   DatabaseManager.beginTransaction();

   Node1 AFFS_NodeEnvObj1 = new Node1();
   AFFS_NodeEnvObj1.ID = "1";
   AFFS_NodeEnvObj1.description = "1";
   DatabaseManager.getSession().saveOrUpdate(AFFS_NodeEnvObj1);

   Node1 AFFS_NodeEnvObj2 = new Node1();
   AFFS_NodeEnvObj2.ID = "2";
   AFFS_NodeEnvObj2.description = "2";
   AFFS_NodeEnvObj2.parent = AFFS_NodeEnvObj1;
   DatabaseManager.getSession().saveOrUpdate(AFFS_NodeEnvObj2);

   //OOPS !!!!
   DatabaseManager.getSession().delete(AFFS_NodeEnvObj2);

   DatabaseManager.commitTransaction();
} catch (Exception ExceptionObj) {
   DatabaseManager.rollbackTransaction();
   ExceptionObj.printStackTrace();
} finally {
   DatabaseManager.closeSession();
}



Code:
import javax.ejb.*;

import java.io.Serializable;

/**
* @author Emmanuel Bernard
*/
@Entity(name="Node1", access = AccessType.FIELD)
public class Node1 implements Serializable {
   
   @Id
   @Column(name="`NodeID`", length=100)
   public String ID;
   
   public String description;
   
   @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
   @JoinColumn(name="ParentID")
   public Node1 parent;

   public boolean equals(Object o) {
      if (this == o) return true;
      if (!(o instanceof Node1)) return false;

      final Node1 node = (Node1) o;

      if (!ID.equals(node.ID)) return false;

      return true;
   }

   public int hashCode() {
      return ID.hashCode();
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 10:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
"Does not work for me" is not a very helpful description of your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:03 am 
Beginner
Beginner

Joined: Fri Jun 11, 2004 3:42 am
Posts: 22
Sorry. I have appended the Stack Trace here now.

Code:
WARNING: SQL Error: 335544333, SQLState: HY000
Jan 22, 2005 8:20:06 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: GDS Exception. 335544333. internal gds software consistency check (partner index description not found (175))
Jan 22, 2005 8:20:06 PM org.hibernate.event.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not delete: [NodeTest.Node1#2]
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.persister.BasicEntityPersister.delete(BasicEntityPersister.java:1898)
   at org.hibernate.persister.BasicEntityPersister.delete(BasicEntityPersister.java:2025)
   at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:44)
   at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:232)
   at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:142)
   at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:255)
   at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:814)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:75)
   at com.agileflow.common.DatabaseManager.commitTransaction(DatabaseManager.java:136)
   at NodeTest.Test_Node.testCreation(Test_Node.java:35)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544333. internal gds software consistency check (partner index description not found (175))
   at org.firebirdsql.jdbc.AbstractPreparedStatement.internalExecute(AbstractPreparedStatement.java:503)
   at org.firebirdsql.jdbc.AbstractPreparedStatement.executeUpdate(AbstractPreparedStatement.java:144)
   at com.mchange.v2.sql.filter.FilterPreparedStatement.executeUpdate(FilterPreparedStatement.java:71)
   at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
   at org.hibernate.persister.BasicEntityPersister.delete(BasicEntityPersister.java:1881)
   ... 25 more


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Rather looks like a Firebird bug/problem to me ...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 12:10 pm 
Beginner
Beginner

Joined: Fri Jun 11, 2004 3:42 am
Posts: 22
I have managed to get this work now.

A different error now. Please guide me on what this means!

Code:
Caused by: org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): 2, of class: com.tc.affs.Node1


The code is as before

Code:
try {
   DatabaseManager.getSession();
   DatabaseManager.beginTransaction();

   Node1 Node1Obj = new Node1();
   Node1Obj.ID = "1";
   Node1Obj.description = "1";
   DatabaseManager.getSession().saveOrUpdate(Node1Obj);

   Node1 Node2Obj = new Node1();
   Node2Obj.ID = "2";
   Node2Obj.description = "2";
   Node2Obj.parent = Node1Obj;
   DatabaseManager.getSession().saveOrUpdate(Node2Obj);

   //OOPS !!!!
   DatabaseManager.getSession().delete(Node2Obj);

   DatabaseManager.commitTransaction();
} catch (Exception ExceptionObj) {
   DatabaseManager.rollbackTransaction();
   ExceptionObj.printStackTrace();
} finally {
   DatabaseManager.closeSession();
}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 12:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This has been answered numerous times already. Please us the forum search.


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