Hi!

The entity not exists but the merge persist if not exists. Long
initialized with null but if I set the id to new Long(0) I get same
result...
merge operation:

For a given entity A, the merge method behaves as follows:
    *      If A is a detached entity, its state is copied into
existing managed instance A' of the same entity identity, or a new
managed copy of A is created.
    *      If A is a new entity, a new managed entity A' is created
and the state of A is copied into A'.
    *      If A is an existing managed entity, it is ignored. However,
the merge operation still cascades as defined below.
    *      If A is a removed entity, an IllegalArgumentException is thrown.
    *      The merge operation recurses on all relation fields of A
whose cascades include CascadeType.MERGE.


On Jan 10, 2008 7:59 AM, klaasjan elzinga <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Does the entity exists? long is initialized with 0 which may be a
> valid entity in the store, and Long with null (indicating a new
> object...) does not exists.
>
> KlaasJan
>
>
> On Jan 10, 2008 12:21 AM, Janos Haber <[EMAIL PROTECTED]> wrote:
> > Hi!
> >
> > I have a little Entity.
> >
> > @Entity
> > @Table(name = "users")
> > public class User {
> >
> >     @Id
> >     @GeneratedValue
> >     private Long id;
> >
> >     private String name;
> >     private String password;
> > ....
> > Setters and getters
> > ....
> >
> > If I use long primitive type, it's work, because if I use Long object
> > I get EntityException (I use merge NOT persist).
> >
> > <openjpa-1.0.1-r420667:592145 nonfatal store error>
> > org.apache.openjpa.persistence.EntityExistsException: Attempt to
> > persist detached object .....
> >  ....
> >  hu.javaportal.web.data.dao.UserDAO.merge(UserDAO.java:22)
> > ...
> >
> > UserDAO line 22: return em.merge(obj);
> >
> > Any idea?
> >
> > Cow
> >
>

Reply via email to