Hi akm,

you have 2 entity where ID isn't auto generated
the problem is: he set ID of the parent and ID of the children. you call
the save of the entityRepository
entityRepository.save call merge, because for it, it isn't a new Entity.

We use PersistenceUnitUtil for check it, but see the javadoc for it:
http://docs.oracle.com/javaee/6/api/javax/persistence/PersistenceUnitUtil.html#getIdentifier%28java.lang.Object%29

In discussion with Gerhard we found a solution for it:
i guess the only portable check is EntityManager#contains and if it returns
false a #load with the id >if< the id is available, the part with #contains
just to be faster with entities which are really loaded by the em, well -
instead of #load a count query would be better to avoid that it really
loads the entity.

you could use a specialized bean for
org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext and just
override #isNew if you can't wait for the next release.



On Wed, Jul 8, 2015 at 1:36 PM, Daniel Cunha <daniels...@gmail.com> wrote:

> Akm,
>
> I'm looking for it.
> Thank you. :)
>
>
>
> On Wed, Jul 8, 2015 at 12:59 PM, akm <ameh...@ford.com> wrote:
>
>> I have attached a simple gradle  CascadeRefreshGradleTestProject.zip
>> <
>> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/file/n4661005/CascadeRefreshGradleTestProject.zip
>> >
>> project with unit tests.
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/Cascade-persist-and-merge-with-Repository-tp4661002p4661005.html
>> Sent from the Apache DeltaSpike Incubator Discussions mailing list
>> archive at Nabble.com.
>>
>
>
>
> --
> Best regard,
> Daniel Cunha (soro)
>



-- 
Best regard,
Daniel Cunha (soro)

Reply via email to