openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "AlexD." <alex.derevi...@btelligent.de>
Subject Cannot perform operation delete on detached object
Date Mon, 22 Oct 2007 16:03:39 GMT

Hallo all,

I have the problem that I cannot delete a detached object. 

My source codes are (I'm using the spring framework):

    public void delete(final int id) {
        final JpaTemplate t = getJpaTemplate();
        T obj = t.find(getObjectClass(), id);
        if (obj != null) {
            obj = t.merge(obj);
            t.remove(obj);
        }
    }


Looks strange, but obj what I got as result is also detached object... What
I'm doing wrong?

stack trace:

 org.apache.openjpa.persistence.ArgumentException: You cannot perform
operation delete on detached object
"org.apache.openjpa.enhance.com$btelligent$erp$domain$persistence$WorkTime$pcsubclass@5ee6a6".
This operation only applies to managed objects.
FailedObject:
org.apache.openjpa.enhance.com$btelligent$erp$domain$persistence$WorkTime$pcsubclass@5ee6a6
	at
org.apache.openjpa.kernel.BrokerImpl.newDetachedException(BrokerImpl.java:2521)
	at org.apache.openjpa.kernel.BrokerImpl.delete(BrokerImpl.java:2512)
	at org.apache.openjpa.kernel.BrokerImpl.delete(BrokerImpl.java:2474)
	at
org.apache.openjpa.kernel.DelegatingBroker.delete(DelegatingBroker.java:1030)
	at
org.apache.openjpa.persistence.EntityManagerImpl.remove(EntityManagerImpl.java:555)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:340)
	at $Proxy48.remove(Unknown Source)
	at org.springframework.orm.jpa.JpaTemplate$7.doInJpa(JpaTemplate.java:280)
	at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:191)
	at org.springframework.orm.jpa.JpaTemplate.remove(JpaTemplate.java:278)
	at com.btelligent.erp.dao.jpa.AbstarctJpaDao.delete(AbstarctJpaDao.java:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
	at $Proxy20.delete(Unknown Source)


Best regards,

Alex
-- 
View this message in context: http://www.nabble.com/Cannot-perform-operation-delete-on-detached-object-tf4670739.html#a13342865
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message