Entity is not updated [message #1707046] |
Tue, 01 September 2015 15:39  |
Eclipse User |
|
|
|
Hi all,
I've an abstract Document entity which has a "deleted" attribute:
@Entity()
@Table(name = "FKT_DOCUMENT")
@Inheritance(strategy = InheritanceType.JOINED)
@EntityListeners(value = { EntityListener.class })
public abstract class Document extends ModelObject implements IEntity,
Serializable {
@Basic()
@Column(name = "DELETED")
private Boolean deleted = Boolean.FALSE;
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean newDeleted) {
firePropertyChange("deleted", this.deleted, newDeleted);
deleted = newDeleted;
}
// ... some additional getters and setters
}
Another class inherits from this entity:
@Entity()
@Table(name = "FKT_INVOICE")
@PrimaryKeyJoinColumns({ @PrimaryKeyJoinColumn(name =
"INVOICE_PARENT_ID") })
public class Invoice extends Document {
// ...some other getters and setters
}
Now, if I set the "deleted" attribute to another value and call save()
(or update()) with EntityManager, the entity is not updated (it seems
that the trigger for putting the object in the changeSet from
EclipseLink isn't called). There's no Exception or other error. The
update method is as follows:
EntityTransaction trx = getEntityManager().getTransaction();
trx.begin();
object = getEntityManager().merge(object);
getEntityManager().persist(object);
trx.commit();
This method works fine with other (non-abstract) entities. I don't have
any idea what's wrong with it.
Any hints are appreciated.
Ralf.
|
|
|
|
Re: Entity is not updated [message #1707416 is a reply to message #1707353] |
Fri, 04 September 2015 11:03  |
Eclipse User |
|
|
|
If the object is detached, how was it initially read in? EclipseLink should handle the merge correctly, so if refresh is required in your situation, then it must be that your detached object is not as detached as you may think. The only way for this to occur that I can think of is if you read your object from the shared cache, as a read-only instances are not cloned and not meant to be used for changes. The read-only instance is used underneath merges to build the managed instance to merge into.
[Updated on: Fri, 04 September 2015 11:08] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03692 seconds