[
https://issues.apache.org/jira/browse/DELTASPIKE-965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14643178#comment-14643178
]
Daniel Cunha (soro) commented on DELTASPIKE-965:
------------------------------------------------
Yes, really necessary.
Before we used PersistecenUnitUtil#getIdentify
We had this problem:
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/file/n4661005/CascadeRefreshGradleTestProject.zip
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 used 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.
then we changed it.
For me works fine, I didn't have any problem with it. ATM.
But, your change is cool, more expressive, please.. push direct in repository
or I can do it, if you prefer. :)
> EntityRepository.save() is broken for entities with String ID
> -------------------------------------------------------------
>
> Key: DELTASPIKE-965
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-965
> Project: DeltaSpike
> Issue Type: Bug
> Components: Data-Module
> Affects Versions: 1.4.2
> Reporter: Harald Wellmann
> Assignee: Daniel Cunha (soro)
> Priority: Blocker
> Fix For: 1.4.3
>
>
> EntityRepository.save() generates illegal SQL when the entity identity is of
> String type.
> This is a regression introduced in 1.4.2 with
> {{org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext.countCheck(Object)}}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)