DomainObjectContainer.persistIfNotAlready(domainObject) causing invoked of JDO
InstanceCallbacks.jdoPreStore() method even if JDO persistent(managed) domain
object is not modified.
Code snippet:
isisJdocontainer is of type DomainObjectContainer .
OmScaServiceMap is JDO persistence capable entity.
OmScaServiceMap scaServiceMap = isisJdocontainer.firstMatch(new
QueryDefault<OmScaServiceMap>(
OmScaServiceMap.class,
"fetch_OmScaServiceMap_by_sca_service_map", "scaUid", scaUid, "serviceUid",
serviceUid));
if (scaServiceMap == null) {
scaServiceMap =
isisJdocontainer.newTransientInstance(OmScaServiceMap.class);
scaServiceMap.setScaUid(scaUid);
scaServiceMap.setServiceUid(serviceUid);
scaServiceMap.setChangeBy(isisJdocontainer.getUser().getName());
scaServiceMap.setChangeDt(new Date());
}
scaServiceMap.setOrgId(orgId);
isisJdocontainer.persistIfNotAlready(scaServiceMap);
invoked Here I am trying to find OmScaServiceMap by its composite PK. If not
exists, create it with newTransientInstance and set the required attribtes
while creating a new instance.
Otherwise just set the remaining attributes, that is orgId.
OmScaServiceMap implements InstanceCallbacks and has overridden the method
jdoPreStore() which is defined as follows:
public void jdoPreStore() {
this.setChangeBy(this.container.getUser().getName());
this.setChangeDt(new Date());
}
Problem:
In case of managed entity(OmScaServiceMap already existing case): even if value
of orgId is the same one(as that in the database) that is trying to be set,
jdoPreStore is getting called and modifying the changeDt
attribute(this.setChangeDt(new Date());) and causing Update query issued to the
database.
persistIfNotAlready should not cause invoke of InstanceCallBack.jdoPreStore
when domainObject properties are not modified.
Please help on this issue.
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not the
intended recipient, you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately and destroy all copies of this message and
any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.
www.wipro.com