-->
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.  [ 5 posts ] 
Author Message
 Post subject: Can not remove data after calling merge
PostPosted: Mon Jul 10, 2006 3:34 am 
Beginner
Beginner

Joined: Wed Jun 07, 2006 6:11 am
Posts: 20
Hibernate version: 3.2.0.cr2
Hibernate Annotations: 3.2.0.CR1
Hibernate Entity Manager: 3.2.0.CR1
EJB3 version: EJB-3.0 RC8-FD
JBoss version: 4.0.4.GA
Name and version of the database you are using: Ingres 3.0.105
Full stack trace of any exception that occurs:
Code:
13:22:20,140 WARN  [JDBCExceptionReporter] SQL Error: 4615, SQLState: 5000B
13:22:20,140 ERROR [JDBCExceptionReporter] An error occurred while deleting a record.
13:22:20,140 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not delete: [ams.uptoip.server.user.management.model.hibernate.rights.Login#224]
   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.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2384)
   at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2516)
   at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:73)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)
   at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:475)
   at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
   at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
   at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
   at org.jboss.tm.TxManager.commit(TxManager.java:240)
   at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
   at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
   at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
   at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
   at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
   at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
   at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
   at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
   at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227)
   at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
   at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
   at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
   at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
   at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
   at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
   at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
Caused by: ca.edbc.util.EdbcEx: An error occurred while deleting a record.
   at ca.edbc.jdbc.EdbcObj.readResults(EdbcObj.java:785)
   at ca.edbc.jdbc.EdbcObj.readResults(EdbcObj.java:576)
   at ca.edbc.jdbc.EdbcPrep.exec(EdbcPrep.java:795)
   at ca.edbc.jdbc.EdbcPrep.executeUpdate(EdbcPrep.java:466)
   at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
   at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
   at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2363)
   ... 36 more



Hi!
When I'm executing the following code, I can not remove the inserted data anymore (I tried it with Hibernate and with the database itself).

Code:
protected @PersistenceContext(unitName = "XY_Manager", type = PersistenceContextType.TRANSACTION)
  EntityManager em;
 
// Insert Domain
Domain domain = em.find(Domain.class, id);
if (domain == null) {
  domain = new Domain();
  domain.setName(name);
  domain.setAddress(getAddress(domain.getAddress()));
  em.persist(domain);
  em.flush();
}

// Insert Login
Login login = new Login();
login.setName(name);
login.setPassword(password);
login.setDomain(domain);
login = em.merge(login);
em.flush();

// Remove works fine
//em.remove(loginHib); // OK

// Modify Login
login.setName("NEW NAME");

// Merge Login
login = em.merge(login);
em.flush();

// Remove does not work
em.remove(loginHib);  // ERROR


What's wrong? The interesting thing is, that the remove works after the insert, but fails after the merge method.

This code does not work too (same error):

Code:
// Get Login
Login login = em.find(Login.class, 4);

// Modify Login
login.setName("NEW NAME");

// Merge Login
login = em.merge(login);
em.flush();

// Remove does not work
em.remove(loginHib);  // ERROR


Has anyone an idea?
Thx, Christian


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 9:37 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I don't understand your code : where is declared your loginHib instance ? Shouldn't you use the login instance instead ?

You seem to be aware of this, but it's better to remind it : merge() does not cache the given instance in parameter, but returns it, so
Code:
login = em.merge(login);
seems to be a good idea.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 10:46 am 
Beginner
Beginner

Joined: Wed Jun 07, 2006 6:11 am
Posts: 20
I'm sorry, the loginHib instance is the login instance. This is just an error in this code example (loginHib == login).
The correct one:

Code:
// Get Login
Login login = em.find(Login.class, 4);

// Modify Login
login.setName("NEW NAME");

// Merge Login
login = em.merge(login);
em.flush();

// Remove does not work
em.remove(login);  // ERROR


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 11:03 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Before and after flushing(), what gives em.contains(login) ?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 2:25 am 
Beginner
Beginner

Joined: Wed Jun 07, 2006 6:11 am
Posts: 20
Both true. But I think I got it. The database table has an attribute named 'user'. I changed it now to 'user_' and it works fine.


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