Harald Wellmann created DELTASPIKE-627:
------------------------------------------
Summary: 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
Priority: Critical
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)