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) {
|
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 {
|
try {
|
||||||
assertOpen();
|
assertOpen();
|
||||||
makeReadOnly();
|
makeReadOnly();
|
||||||
|
@ -200,7 +205,7 @@ public abstract class AbstractBrokerFactory
|
||||||
broker = findBroker(user, pass, managed);
|
broker = findBroker(user, pass, managed);
|
||||||
if (broker == null) {
|
if (broker == null) {
|
||||||
broker = newBrokerImpl(user, pass);
|
broker = newBrokerImpl(user, pass);
|
||||||
initializeBroker(managed, connRetainMode, broker, false);
|
initializeBroker(managed, connRetainMode, broker, false, writeBehindCallback);
|
||||||
}
|
}
|
||||||
return broker;
|
return broker;
|
||||||
} catch (OpenJPAException ke) {
|
} catch (OpenJPAException ke) {
|
||||||
|
@ -211,12 +216,18 @@ public abstract class AbstractBrokerFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializeBroker(boolean managed, int connRetainMode, Broker broker, boolean fromDeserialization) {
|
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();
|
assertOpen();
|
||||||
makeReadOnly();
|
makeReadOnly();
|
||||||
|
|
||||||
DelegatingStoreManager dsm = createDelegatingStoreManager();
|
DelegatingStoreManager dsm = createDelegatingStoreManager();
|
||||||
|
|
||||||
((BrokerImpl) broker).initialize(this, dsm, managed, connRetainMode, fromDeserialization);
|
((BrokerImpl) broker).initialize(this, dsm, managed, connRetainMode, fromDeserialization,
|
||||||
|
fromWriteBehindCallback);
|
||||||
if (!fromDeserialization)
|
if (!fromDeserialization)
|
||||||
addListeners(broker);
|
addListeners(broker);
|
||||||
|
|
||||||
|
@ -873,7 +884,7 @@ public abstract class AbstractBrokerFactory
|
||||||
_conf.getConnectionPassword(),
|
_conf.getConnectionPassword(),
|
||||||
false, // WriteBehind broker is always unmanaged.
|
false, // WriteBehind broker is always unmanaged.
|
||||||
_conf.getConnectionRetainModeConstant(),
|
_conf.getConnectionRetainModeConstant(),
|
||||||
false);
|
false, true);
|
||||||
|
|
||||||
// The Broker used by the WriteBehind cache should not be tracked
|
// The Broker used by the WriteBehind cache should not be tracked
|
||||||
// by the factory - we'll manually clean up when the factory is
|
// by the factory - we'll manually clean up when the factory is
|
||||||
|
|
|
@ -248,6 +248,7 @@ public class BrokerImpl
|
||||||
private int _lifeCallbackMode = 0;
|
private int _lifeCallbackMode = 0;
|
||||||
|
|
||||||
private transient boolean _initializeWasInvoked = false;
|
private transient boolean _initializeWasInvoked = false;
|
||||||
|
private transient boolean _fromWriteBehindCallback = false;
|
||||||
private LinkedList _fcs;
|
private LinkedList _fcs;
|
||||||
|
|
||||||
// Set of supported property keys. The keys in this set correspond to bean-style setter methods
|
// 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,
|
public void initialize(AbstractBrokerFactory factory,
|
||||||
DelegatingStoreManager sm, boolean managed, int connMode,
|
DelegatingStoreManager sm, boolean managed, int connMode,
|
||||||
boolean fromDeserialization) {
|
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;
|
_initializeWasInvoked = true;
|
||||||
_loader = AccessController.doPrivileged(
|
_loader = AccessController.doPrivileged(
|
||||||
J2DoPrivHelper.getContextClassLoaderAction());
|
J2DoPrivHelper.getContextClassLoaderAction());
|
||||||
|
@ -4449,9 +4457,10 @@ public class BrokerImpl
|
||||||
boolean assertThisContext) {
|
boolean assertThisContext) {
|
||||||
if (ImplHelper.isManageable(obj)) {
|
if (ImplHelper.isManageable(obj)) {
|
||||||
PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
|
PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
|
||||||
if (pc.pcGetGenericContext() == this)
|
BrokerImpl pcBroker = (BrokerImpl)pc.pcGetGenericContext();
|
||||||
|
if (pcBroker == this || isFromWriteBehindCallback())
|
||||||
return (StateManagerImpl) pc.pcGetStateManager();
|
return (StateManagerImpl) pc.pcGetStateManager();
|
||||||
if (assertThisContext && pc.pcGetGenericContext() != null)
|
if (assertThisContext && pcBroker != null)
|
||||||
throw new UserException(_loc.get("not-managed",
|
throw new UserException(_loc.get("not-managed",
|
||||||
Exceptions.toString(obj))).setFailedObject(obj);
|
Exceptions.toString(obj))).setFailedObject(obj);
|
||||||
}
|
}
|
||||||
|
@ -4938,4 +4947,8 @@ public class BrokerImpl
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFromWriteBehindCallback() {
|
||||||
|
return _fromWriteBehindCallback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue