mirror of
https://github.com/apache/openjpa.git
synced 2025-02-20 17:05:15 +00:00
OPENJPA-2017: Changes cause test failures in openjpa-lib. Reverting for now.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1137645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
db960fbeae
commit
f0fbbaa26a
@ -43,24 +43,4 @@ public interface AutoDetach {
|
||||
* Detach context on failed transaction commit / rollback.
|
||||
*/
|
||||
public static final int DETACH_ROLLBACK = 2 << 3;
|
||||
|
||||
/**
|
||||
* Never Detach. Useful for batch loading where user application is not
|
||||
* concerned about the referenced objects after the persistent operation.
|
||||
*/
|
||||
public static final int DETACH_NONE = 2 << 4;
|
||||
|
||||
/**
|
||||
* Available integer values of AutoDetach options.
|
||||
*/
|
||||
public static final int[] values = {DETACH_NONE, DETACH_CLOSE, DETACH_COMMIT, DETACH_NONTXREAD,
|
||||
DETACH_ROLLBACK};
|
||||
|
||||
/**
|
||||
* Available user-visible names of AutoDetach options.
|
||||
* Order corresponds to integer values of the options.
|
||||
*/
|
||||
public static final String[] names = {"NONE", "CLOSE", "COMMIT", "NON-TX-READ", "ROLLBACK"};
|
||||
|
||||
|
||||
}
|
||||
|
@ -183,27 +183,20 @@ public interface Broker
|
||||
/**
|
||||
* Bit flags marked in {@link AutoDetach} which indicate when persistent
|
||||
* managed objects should be automatically detached in-place.
|
||||
* <br>
|
||||
* {@link AutoDetach#DETACH_NONE} is exclusive i.e. can not be specified
|
||||
* with any other option.
|
||||
*/
|
||||
public void setAutoDetach(int flags);
|
||||
|
||||
/**
|
||||
* Bit flags marked in {@link AutoDetach} which indicate when persistent
|
||||
* managed objects should be automatically detached in-place.
|
||||
* <br>
|
||||
* {@link AutoDetach#DETACH_NONE} is exclusive i.e. can not be specified
|
||||
* with any other option.
|
||||
*
|
||||
*/
|
||||
public void setAutoDetach(int flag, boolean on);
|
||||
|
||||
/**
|
||||
* Retrieve the current properties for this broker. Some of these properties
|
||||
* Retrieve the current properties for this broker Some of these properties
|
||||
* may have been changed from the original configuration.
|
||||
*
|
||||
* @return the set of properties currently used by this broker.
|
||||
* @return the changed properties
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
@ -33,7 +33,6 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -619,27 +618,18 @@ public class BrokerImpl
|
||||
return _autoDetach;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets automatic detachment option.
|
||||
* <br>
|
||||
* If the given flag contains {@link AutoDetach#DETACH_NONE} option,
|
||||
* then no other option can be specified.
|
||||
*/
|
||||
public void setAutoDetach(int detachFlags) {
|
||||
assertOpen();
|
||||
assertAutoDetachValue(detachFlags);
|
||||
_autoDetach = detachFlags;
|
||||
}
|
||||
|
||||
public void setAutoDetach(int detachFlag, boolean on) {
|
||||
assertOpen();
|
||||
assertAutoDetachValue(on ? _autoDetach | detachFlag : _autoDetach & ~detachFlag);
|
||||
if (on)
|
||||
_autoDetach |= detachFlag;
|
||||
else
|
||||
_autoDetach &= ~detachFlag;
|
||||
}
|
||||
|
||||
|
||||
public int getDetachState() {
|
||||
return _detachState;
|
||||
@ -1827,10 +1817,12 @@ public class BrokerImpl
|
||||
|
||||
// make sure the runtime supports it
|
||||
if (!_conf.supportedOptions().contains(OpenJPAConfiguration.OPTION_INC_FLUSH))
|
||||
throw new UnsupportedException(_loc.get("incremental-flush-not-supported"));
|
||||
throw new UnsupportedException(_loc.get
|
||||
("incremental-flush-not-supported"));
|
||||
if (_savepoints != null && !_savepoints.isEmpty()
|
||||
&& !_spm.supportsIncrementalFlush())
|
||||
throw new UnsupportedException(_loc.get("savepoint-flush-not-supported"));
|
||||
throw new UnsupportedException(_loc.get
|
||||
("savepoint-flush-not-supported"));
|
||||
|
||||
try {
|
||||
flushSafe(FLUSH_INC);
|
||||
@ -5189,28 +5181,5 @@ public class BrokerImpl
|
||||
protected boolean isFlushing() {
|
||||
return ((_flags & FLAG_FLUSHING) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts consistencey of given automatic detachment option value.
|
||||
*/
|
||||
private void assertAutoDetachValue(int value) {
|
||||
if (((value & AutoDetach.DETACH_NONE) != 0) && (value != AutoDetach.DETACH_NONE)) {
|
||||
throw new UserException(_loc.get("detach-none-exclusive", toAutoDetachString(value)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a user-readable String from the given integral value of AutoDetach options.
|
||||
*/
|
||||
private String toAutoDetachString(int value) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
for (int i = 0; i < AutoDetach.values.length; i++) {
|
||||
if ((value & AutoDetach.values[i]) != 0) {
|
||||
result.add(AutoDetach.names[i]);
|
||||
}
|
||||
}
|
||||
return Arrays.toString(result.toArray(new String[result.size()]));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2892,12 +2892,8 @@ public class StateManagerImpl
|
||||
/**
|
||||
* Replaces all second class object fields with fresh proxied instances
|
||||
* containing the same information as the originals.
|
||||
* <br>
|
||||
* <B>Note:</B> Proxying is bypassed if AutoDetach option is set to {@link AutoDetach#DETACH_NONE}.
|
||||
*/
|
||||
void proxyFields(boolean reset, boolean replaceNull) {
|
||||
if (getBroker().getAutoDetach() == AutoDetach.DETACH_NONE)
|
||||
return;
|
||||
// we only replace nulls if the runtime can't differentiate between
|
||||
// null and empty containers. we replace nulls in this case to
|
||||
// maintain consistency whether values are being retained or not
|
||||
|
@ -454,6 +454,4 @@ fill-factory-error: Error while fill data with factory strategy. The error \
|
||||
See nested exception for details.
|
||||
writebehind-cfg-err: Missing required WriteBehind configuration parameter "{0}"
|
||||
bad-lock-scope: This lock manager does not recognize lock scope "{0}".
|
||||
detach-none-exclusive: Configured AutoDetach option "{0}" is incorrect because \
|
||||
NONE option can not be specified with any other option other than CLOSE.
|
||||
|
||||
|
@ -37,7 +37,6 @@ public class TestLibService extends SingleEMFTestCase
|
||||
public EntityManager getTransactionalEntityManager() {
|
||||
// return a transactionally scoped entity manager
|
||||
OpenJPAEntityManager em = emf.createEntityManager();
|
||||
txScope.remove(AutoDetachType.NONE);
|
||||
em.setAutoDetach(txScope);
|
||||
return em;
|
||||
}
|
||||
|
@ -30,22 +30,19 @@ import org.apache.openjpa.kernel.AutoDetach;
|
||||
* @published
|
||||
*/
|
||||
public enum AutoDetachType {
|
||||
NONE(AutoDetach.DETACH_NONE),
|
||||
CLOSE(AutoDetach.DETACH_CLOSE),
|
||||
COMMIT(AutoDetach.DETACH_COMMIT),
|
||||
NON_TRANSACTIONAL_READ(AutoDetach.DETACH_NONTXREAD),
|
||||
ROLLBACK(AutoDetach.DETACH_ROLLBACK);
|
||||
|
||||
private final int autoDetachConstant;
|
||||
|
||||
|
||||
private AutoDetachType(int value) {
|
||||
autoDetachConstant = value;
|
||||
}
|
||||
|
||||
public static EnumSet<AutoDetachType> toEnumSet(int autoDetach) {
|
||||
EnumSet<AutoDetachType> types = EnumSet.noneOf(AutoDetachType.class);
|
||||
if ((autoDetach & AutoDetach.DETACH_NONE) != 0)
|
||||
types.add(NONE);
|
||||
if ((autoDetach & AutoDetach.DETACH_CLOSE) != 0)
|
||||
types.add(CLOSE);
|
||||
if ((autoDetach & AutoDetach.DETACH_COMMIT) != 0)
|
||||
@ -54,7 +51,6 @@ public enum AutoDetachType {
|
||||
types.add(NON_TRANSACTIONAL_READ);
|
||||
if ((autoDetach & AutoDetach.DETACH_ROLLBACK) != 0)
|
||||
types.add(ROLLBACK);
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
|
@ -1828,14 +1828,6 @@ public class EntityManagerImpl
|
||||
} else {
|
||||
return Strings.parse((String) value, targetType);
|
||||
}
|
||||
} else if (value instanceof AutoDetachType) {
|
||||
EnumSet<AutoDetachType> autoDetachFlags = EnumSet.noneOf(AutoDetachType.class);
|
||||
autoDetachFlags.add((AutoDetachType)value);
|
||||
return autoDetachFlags;
|
||||
} else if (value instanceof AutoDetachType[]) {
|
||||
EnumSet<AutoDetachType> autoDetachFlags = EnumSet.noneOf(AutoDetachType.class);
|
||||
autoDetachFlags.addAll(Arrays.asList((AutoDetachType[])value));
|
||||
return autoDetachFlags;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -571,21 +571,13 @@ AutoDetach</literal>
|
||||
</para>
|
||||
<para>
|
||||
<emphasis role="bold">Possible values: </emphasis><literal>close</literal>,
|
||||
<literal>commit</literal>, <literal>nontx-read</literal>, <literal>rollback</literal>, <literal>none</literal>
|
||||
<literal>commit</literal>, <literal>nontx-read</literal>, <literal>rollback</literal>
|
||||
</para>
|
||||
<para>
|
||||
<emphasis role="bold">Description:</emphasis> A comma-separated list of events
|
||||
when managed instances will be automatically detached. When using the OpenJPA EntityManager this defaults to
|
||||
<literal>close</literal>, and <literal>rollback</literal> per the JPA spec. If you need to change this setting, you
|
||||
need to set it directly on an instantiated EntityManager.
|
||||
|
||||
<para>
|
||||
<literal>none</literal> option is exclusive. It can not be specified with any other option.
|
||||
<literal>none</literal> option implies that managed objects will not be detached from the persistence context,
|
||||
the second-class object fields such as collections or date will <emphasis>not</emphasis> be proxied unlike normal
|
||||
circumstances. This option is relevant for specific use cases where the user application would not refer to the
|
||||
managed objects after the transaction and/or the context ends e.g. typical batch insertion scenario.
|
||||
</para>
|
||||
</para>
|
||||
</section>
|
||||
<section id="openjpa.BrokerFactory">
|
||||
|
Loading…
x
Reference in New Issue
Block a user