deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John D. Ament" <johndam...@apache.org>
Subject Re: having problem with remove entity in data module
Date Tue, 10 May 2016 17:55:07 GMT
That's normal JPA behavior.  You have to have a managed entity to do this.
Simple way is to do something like

Something something = new Something();
something.setName( "Name" );
Something saved = somethingDao.save( something );
somethingDao.remove( saved );

Otherwise you should extend from EntityManagerAware and use the find method
there.

John

On Tue, May 10, 2016 at 11:40 AM <Pawel.Maczka@b-m.pl> wrote:

> Hi Team,
>
> Almost I succeeded to use data module except 'remove' method of my
> repository. Having simple test:
>
>         @org.junit.Test
>         public void test2(){
>                 Something something = new Something();
>                 something.setName( "Name" );
>                 somethingDao.save( something );
>                 log.info( something.getId() );
>                 somethingDao.remove( somethingDao.findBy(
> something.getId() ) );
>         }
>
> fails with
>
> test2(test.DeltaspikeTest)  Time elapsed: 0.016 sec  <<< ERROR!
> org.apache.deltaspike.data.api.QueryInvocationException: Failed calling
> Repository:
>
> [Repository=pack1.SomethingDao,entity=pack1.Something,method=remove,exception=class
> org.apache.deltaspike.data.api.QueryInvocationException,message=Failed
> calling Repository:
>
> [Repository=pack1.SomethingDao,entity=pack1.Something,method=remove,exception=class
> org.apache.deltaspike.data.api.QueryInvocationException,message=Failed
> calling Repository:
>
> [Repository=pack1.SomethingDao,entity=pack1.Something,method=remove,exception=class
> java.lang.reflect.InvocationTargetException,message=null
>         at test.DeltaspikeTest.test2(DeltaspikeTest.java:36)
> Caused by: org.apache.deltaspike.data.api.QueryInvocationException: Failed
> calling Repository:
>
> [Repository=pack1.SomethingDao,entity=pack1.Something,method=remove,exception=class
> org.apache.deltaspike.data.api.QueryInvocationException,message=Failed
> calling Repository:
>
> [Repository=pack1.SomethingDao,entity=pack1.Something,method=remove,exception=class
> java.lang.reflect.InvocationTargetException,message=null
>         at test.DeltaspikeTest.test2(DeltaspikeTest.java:36)
> Caused by: org.apache.deltaspike.data.api.QueryInvocationException: Failed
> calling Repository:
>
> [Repository=pack1.SomethingDao,entity=pack1.Something,method=remove,exception=class
> java.lang.reflect.InvocationTargetException,message=null
>         at test.DeltaspikeTest.test2(DeltaspikeTest.java:36)
> Caused by: java.lang.reflect.InvocationTargetException
>         at test.DeltaspikeTest.test2(DeltaspikeTest.java:36)
> Caused by: java.lang.IllegalArgumentException: Entity must be managed to
> call remove: Name, try merging the detached and try the remove again.
>         at test.DeltaspikeTest.test2(DeltaspikeTest.java:36)
>
>
> For me it should obviously work. To regenerate the proble I made a GitHub
> project : https://github.com/p4w3l/deltaspikeTest
>
> Simple call: mvn
>
> and you will see
>
> best regards
> PaweĊ‚

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