mirror of https://github.com/apache/openjpa.git
OPENJPA-1348 Embeddable data not persisted when using WriteBehind cache flush operation. Patch from Fay Wang.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@888497 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c1e0b6bd1c
commit
45bc22baa3
|
@ -191,6 +191,11 @@ public abstract class AbstractBrokerFactory
|
|||
}
|
||||
|
||||
public Broker newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting) {
|
||||
return newBroker(user, pass, managed, connRetainMode, findExisting, false);
|
||||
}
|
||||
|
||||
public Broker newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting,
|
||||
boolean writeBehindCallback) {
|
||||
try {
|
||||
assertOpen();
|
||||
makeReadOnly();
|
||||
|
@ -200,7 +205,7 @@ public abstract class AbstractBrokerFactory
|
|||
broker = findBroker(user, pass, managed);
|
||||
if (broker == null) {
|
||||
broker = newBrokerImpl(user, pass);
|
||||
initializeBroker(managed, connRetainMode, broker, false);
|
||||
initializeBroker(managed, connRetainMode, broker, false, writeBehindCallback);
|
||||
}
|
||||
return broker;
|
||||
} catch (OpenJPAException ke) {
|
||||
|
@ -211,12 +216,18 @@ public abstract class AbstractBrokerFactory
|
|||
}
|
||||
|
||||
void initializeBroker(boolean managed, int connRetainMode, Broker broker, boolean fromDeserialization) {
|
||||
initializeBroker(managed, connRetainMode, broker, fromDeserialization, false);
|
||||
}
|
||||
|
||||
void initializeBroker(boolean managed, int connRetainMode, Broker broker, boolean fromDeserialization,
|
||||
boolean fromWriteBehindCallback) {
|
||||
assertOpen();
|
||||
makeReadOnly();
|
||||
|
||||
DelegatingStoreManager dsm = createDelegatingStoreManager();
|
||||
|
||||
((BrokerImpl) broker).initialize(this, dsm, managed, connRetainMode, fromDeserialization);
|
||||
((BrokerImpl) broker).initialize(this, dsm, managed, connRetainMode, fromDeserialization,
|
||||
fromWriteBehindCallback);
|
||||
if (!fromDeserialization)
|
||||
addListeners(broker);
|
||||
|
||||
|
@ -873,7 +884,7 @@ public abstract class AbstractBrokerFactory
|
|||
_conf.getConnectionPassword(),
|
||||
false, // WriteBehind broker is always unmanaged.
|
||||
_conf.getConnectionRetainModeConstant(),
|
||||
false);
|
||||
false, true);
|
||||
|
||||
// The Broker used by the WriteBehind cache should not be tracked
|
||||
// by the factory - we'll manually clean up when the factory is
|
||||
|
|
|
@ -248,6 +248,7 @@ public class BrokerImpl
|
|||
private int _lifeCallbackMode = 0;
|
||||
|
||||
private transient boolean _initializeWasInvoked = false;
|
||||
private transient boolean _fromWriteBehindCallback = false;
|
||||
private LinkedList _fcs;
|
||||
|
||||
// Set of supported property keys. The keys in this set correspond to bean-style setter methods
|
||||
|
@ -304,6 +305,13 @@ public class BrokerImpl
|
|||
public void initialize(AbstractBrokerFactory factory,
|
||||
DelegatingStoreManager sm, boolean managed, int connMode,
|
||||
boolean fromDeserialization) {
|
||||
initialize(factory, sm, managed, connMode, fromDeserialization, false);
|
||||
}
|
||||
|
||||
public void initialize(AbstractBrokerFactory factory,
|
||||
DelegatingStoreManager sm, boolean managed, int connMode,
|
||||
boolean fromDeserialization, boolean fromWriteBehindCallback) {
|
||||
_fromWriteBehindCallback = fromWriteBehindCallback;
|
||||
_initializeWasInvoked = true;
|
||||
_loader = AccessController.doPrivileged(
|
||||
J2DoPrivHelper.getContextClassLoaderAction());
|
||||
|
@ -4449,9 +4457,10 @@ public class BrokerImpl
|
|||
boolean assertThisContext) {
|
||||
if (ImplHelper.isManageable(obj)) {
|
||||
PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
|
||||
if (pc.pcGetGenericContext() == this)
|
||||
BrokerImpl pcBroker = (BrokerImpl)pc.pcGetGenericContext();
|
||||
if (pcBroker == this || isFromWriteBehindCallback())
|
||||
return (StateManagerImpl) pc.pcGetStateManager();
|
||||
if (assertThisContext && pc.pcGetGenericContext() != null)
|
||||
if (assertThisContext && pcBroker != null)
|
||||
throw new UserException(_loc.get("not-managed",
|
||||
Exceptions.toString(obj))).setFailedObject(obj);
|
||||
}
|
||||
|
@ -4938,4 +4947,8 @@ public class BrokerImpl
|
|||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFromWriteBehindCallback() {
|
||||
return _fromWriteBehindCallback;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue