[ 
https://issues.apache.org/jira/browse/DELTASPIKE-627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Hug resolved DELTASPIKE-627.
-----------------------------------

    Resolution: Fixed

Javadoc of save updated. The distinction can be made using 
EntityManagerDelegate.

> Distinguish saves and updates
> -----------------------------
>
>                 Key: DELTASPIKE-627
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-627
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: Data-Module
>    Affects Versions: 0.7
>            Reporter: Harald Wellmann
>            Assignee: Thomas Hug
>
> JPA {{EntityManager}} has distinct {{persist()}} and {{merge()}} methods, and 
> there's a reason for that.
> DeltaSpike {{EntityRepository}} hides both behind a {{save()}} method which 
> loses information and does not always do the right thing.
> Example:
> Take an entity with a user-defined ID of type String, e.g.
> {code}
> @Entity
> public class Language {
>     @Id
>     private String id;
>     private String name;
> }
> {code}
> Using {{EntityManager.persist()}}, we get an {{EntityExistsException}}:
> {code}
> em.persist(new Language("de", "Deutsch"));
> em.persist(new Language("de", "Doitsch"));
> {code}
> Using {{EntityRepository.save()}}, the first entity is silently overwritten 
> by the second one.
> {code}
> repository.save(new Language("de", "Deutsch"));
> repository.save(new Language("de", "Doitsch"));
> {code}
> Goals:
> * Clarify semantics of save() in the Javadoc.
> * Add a create() method with persist() semantics.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to