Hi,

on trying to udpate a detached instance, i am getting:

<openjpa-1.1.0-r422266:657916 nonfatal store error> org.apache.openjpa.persistence.EntityExistsException: Attempt to persist detached object "de.logentis.bwh.model.Box-1". If this is a new instance, make sure any versino and/or auto-generated primary key fields are null/default when persisting.

Code is pretty easy:

// find box for current order
Box box = boxDao.findNextFreeBox(BoxType.STANDARD); // use express for lowInv ???
            box.setOrderId(o.getId());
            box.setLastUsed(new Date());
            boxDao.save(box);

where boxDao.save() is only a wrapper to em.persist(object). The code above is non-transactional, only the DAO ist. Below my entity definition:

@Entity
@VersionColumn(name = "_version")
@Table(name = "boxes")
public class Box {

    @XmlTransient
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    String oid;

    @Column(name = "id")
    String id;

    @Column(name = "orderid")
    String orderId;

    @Column(name = "lastused")
    Date lastUsed;

    @Basic
    @Enumerated(EnumType.STRING)
    @Column(name = "boxtype")
    BoxType type;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public Date getLastUsed() {
        return lastUsed;
    }

    public void setLastUsed(Date lastUsed) {
        this.lastUsed = lastUsed;
    }

    public BoxType getType() {
        return type;
    }

    public void setType(BoxType type) {
        this.type = type;
    }
}


Can you see anything wrong here?

Thanks.


--
Marc Logemann
blog http://logemannreloaded.blogspot.com
privat http://www.logemann.org



Reply via email to