You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Pinaki Poddar <pp...@apache.org> on 2008/05/08 01:46:36 UTC

Changing lifecycle state of StateManagers forcibly and dangerously

While exploring possibility to build a feature that allows migrating
instances/graphs from one database another, I needed to change the life
cycle state of a StateManager. 


openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java

-    private void setPCState(PCState state) {
+    public void setPCState(PCState state) {

Though the change is on implentation and not on the interface, I understand
that this is not a 'safe' change. And hence will like to hear some other way
to solve the following problem:

The way I approached the 'migration' problem is having a 'read' and a
'write' connection to two separate database -- and flush the StateManagers
to the target database. However, if the target database does not have the
instance the begin with, a PDIRTY StateManager (fetched from the 'source'
database) is  PNEW from the perspective of 'target' database. During 
StoreManager.flush(), forcefully changing lifecycle state to PDIRTY works as
a 'dirty' solution.



-- 
View this message in context: http://www.nabble.com/Changing-lifecycle-state-of-StateManagers-forcibly-and-dangerously-tp17117083p17117083.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.