[
http://jira.jboss.com/jira/browse/JBCACHE-835?page=all ]
Jason T. Greene closed JBCACHE-835.
-----------------------------------
Resolution: Rejected
This isnt needed because technically attach does the same thing, it replaces the state in
the store with the object.
PojoCache need merge api?
-------------------------
Key: JBCACHE-835
URL:
http://jira.jboss.com/jira/browse/JBCACHE-835
Project: JBoss Cache
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: PojoCache
Reporter: Ben Wang
Assigned To: Jason T. Greene
Fix For: PojoCache
Currently, PojoCache attach api will override the current pojo in the cache. It
doesn't really have a merge functionality. Question is do we really need to have a
merge api?
The following is the spec for the ejb3 entity manager merge api. However, the ejb3 em api
doesn't quite apply in the case of PojoCache. You can see the object identity is by PK
instead of reference. So during merge, a copy of Pojo is created instead.
The TravelAgentBean.updateCabin() method takes its cabin parameter and merges it back
into the current persistence context of the entity manager by calling the merge()
operation:
@PersistenceContext EntityManager entityManager;
@TransactionAttribute(REQUIRED)
public void updateCabin(Cabin cabin) {
Cabin copy = entityManager.merge(cabin);
}
The changes made by the remote Swing client will now be reflected in persistence storage
when the entity manager decides to flush to the database. The following rules apply when
merging in the cabin parameter of the updateCabin() method:
? If the entity manager isn't already managing a Cabin instance with the same ID, a
full copy of the parameter is made and returned from the merge() method. This copy is
managed by the entity manager, and any additional setter methods called on this copy will
be synchronized with the database when the EntityManager decides to flush. The cabin
parameter remains detached and unmanaged.
? If the entity manager is already managing a Cabin instance with the same primary key,
then the contents of the parameter are copied into this managed object instance. The
merge() operation will return this managed instance. The cabin parameter remains detached
and unmanaged.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira