mirror of https://github.com/apache/openjpa.git
OPENJPA-317. Changed OpenJPA published API pre-1.0. Reduced the scope of the dependencies in OpenJPAEntityManager and the other published interfaces; converted JDK1.4-style symbolic constant usage to new enums; changed some method names for clarity and consistency; removed old javax.resource dependencies; updated @published and @nojavadoc tags. The published interfaces should now only reference other published interfaces in method signatures, and it should be possible to build javadoc for just the published interfaces.
Removed getDelegate() calls from the published interfaces, as they expose internals. They are still available on the impl classes themselves, or the SPI ifaces when available. Added covariant return types to JDBCFetchPlan. Changed BrokerFactoryListener interface to not encode event types in the listener signature. Moved some methods from OpenJPAPersistence to JPAFacadeHelper. We will need to grow these published interfaces to provide access to some things in the internal interfaces. However, these interfaces will remain stable moving forward within the constraints of the OpenJPA deprecation policies. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@567838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
62f09afea9
commit
778ab2a393
|
@ -231,7 +231,7 @@ public class DataCacheStoreManager
|
|||
// if we were in largeTransaction mode, then we have recorded
|
||||
// the classes of updated/deleted objects and these now need to be
|
||||
// evicted
|
||||
if (_ctx.isLargeTransaction()) {
|
||||
if (_ctx.isTrackChangesByType()) {
|
||||
evictTypes(_ctx.getDeletedTypes());
|
||||
evictTypes(_ctx.getUpdatedTypes());
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ public class DataCacheStoreManager
|
|||
}
|
||||
|
||||
// if large transaction mode don't record individual changes
|
||||
if (_ctx.isLargeTransaction())
|
||||
if (_ctx.isTrackChangesByType())
|
||||
return exceps;
|
||||
|
||||
OpenJPAStateManager sm;
|
||||
|
|
|
@ -109,7 +109,7 @@ public class QueryCacheStoreQuery
|
|||
if (qk == null)
|
||||
return null;
|
||||
FetchConfiguration fetch = getContext().getFetchConfiguration();
|
||||
if (!fetch.getQueryCache())
|
||||
if (!fetch.getEnlistInQueryCache())
|
||||
return null;
|
||||
if (fetch.getReadLockLevel() > LockLevels.LOCK_NONE)
|
||||
return null;
|
||||
|
|
|
@ -30,7 +30,11 @@ import org.apache.openjpa.kernel.BrokerFactory;
|
|||
public class BrokerFactoryEvent
|
||||
extends EventObject {
|
||||
|
||||
public final static int BROKER_FACTORY_CREATED = 0;
|
||||
/**
|
||||
* Fired after a {@link BrokerFactory} has been fully created.
|
||||
* This happens after the factory has been made read-only.
|
||||
*/
|
||||
public static final int BROKER_FACTORY_CREATED = 0;
|
||||
|
||||
private int eventType;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class BrokerFactoryEventManager
|
|||
protected void fireEvent(Object event, Object listener) {
|
||||
try {
|
||||
BrokerFactoryEvent e = (BrokerFactoryEvent) event;
|
||||
((BrokerFactoryListener) listener).afterBrokerFactoryCreate(e);
|
||||
((BrokerFactoryListener) listener).eventFired(e);
|
||||
} catch (Exception e) {
|
||||
_conf.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn(
|
||||
_loc.get("broker-factory-listener-exception"), e);
|
||||
|
|
|
@ -31,5 +31,5 @@ public interface BrokerFactoryListener {
|
|||
* Invoked after a {@link BrokerFactory} has been fully created.
|
||||
* This happens after the factory has been made read-only.
|
||||
*/
|
||||
public void afterBrokerFactoryCreate(BrokerFactoryEvent event);
|
||||
public void eventFired(BrokerFactoryEvent event);
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public class RemoteCommitEventManager
|
|||
Collection updates = null;
|
||||
Collection deletes = null;
|
||||
|
||||
if (broker.isLargeTransaction()) {
|
||||
if (broker.isTrackChangesByType()) {
|
||||
payload = RemoteCommitEvent.PAYLOAD_EXTENTS;
|
||||
addClassNames = toClassNames(event.getPersistedTypes());
|
||||
updates = toClassNames(event.getUpdatedTypes());
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.apache.openjpa.kernel;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.resource.cci.Connection;
|
||||
import javax.resource.cci.LocalTransaction;
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
import org.apache.openjpa.ee.ManagedRuntime;
|
||||
|
@ -41,8 +39,7 @@ import org.apache.openjpa.util.RuntimeExceptionTranslator;
|
|||
* @author Abe White
|
||||
*/
|
||||
public interface Broker
|
||||
extends Synchronization, Connection, LocalTransaction,
|
||||
javax.resource.spi.LocalTransaction, Closeable, StoreContext,
|
||||
extends Synchronization, Closeable, StoreContext,
|
||||
ConnectionRetainModes, DetachState, LockLevels,
|
||||
RestoreState, AutoClear, AutoDetach, CallbackModes {
|
||||
|
||||
|
|
|
@ -33,16 +33,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.resource.NotSupportedException;
|
||||
import javax.resource.ResourceException;
|
||||
import javax.resource.cci.Connection;
|
||||
import javax.resource.cci.ConnectionMetaData;
|
||||
import javax.resource.cci.Interaction;
|
||||
import javax.resource.cci.InteractionSpec;
|
||||
import javax.resource.cci.LocalTransaction;
|
||||
import javax.resource.cci.Record;
|
||||
import javax.resource.cci.ResourceWarning;
|
||||
import javax.resource.cci.ResultSetInfo;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
|
@ -160,7 +150,6 @@ public class BrokerImpl
|
|||
private ManagedRuntime _runtime = null;
|
||||
private LockManager _lm = null;
|
||||
private InverseManager _im = null;
|
||||
private JCAHelper _jca = null;
|
||||
private ReentrantLock _lock = null;
|
||||
private OpCallbacks _call = null;
|
||||
private RuntimeExceptionTranslator _extrans = null;
|
||||
|
@ -231,7 +220,8 @@ public class BrokerImpl
|
|||
private int _lifeCallbackMode = 0;
|
||||
|
||||
private boolean _initializeWasInvoked = false;
|
||||
|
||||
private static final Object[] EMPTY_OBJECTS = new Object[0];
|
||||
|
||||
/**
|
||||
* Set the persistence manager's authentication. This is the first
|
||||
* method called after construction.
|
||||
|
@ -261,7 +251,6 @@ public class BrokerImpl
|
|||
_initializeWasInvoked = true;
|
||||
_loader = (ClassLoader) AccessController.doPrivileged(
|
||||
J2DoPrivHelper.getContextClassLoaderAction());
|
||||
_jca = new JCAHelper();
|
||||
_conf = factory.getConfiguration();
|
||||
_compat = _conf.getCompatibilityInstance();
|
||||
_factory = factory;
|
||||
|
@ -324,30 +313,6 @@ public class BrokerImpl
|
|||
return new ReferenceHashMap(ReferenceMap.HARD, ReferenceMap.SOFT);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Implementation of Connection interface
|
||||
//////////////////////////////////////////
|
||||
|
||||
public ConnectionMetaData getMetaData()
|
||||
throws ResourceException {
|
||||
return _jca;
|
||||
}
|
||||
|
||||
public Interaction createInteraction()
|
||||
throws ResourceException {
|
||||
return _jca;
|
||||
}
|
||||
|
||||
public LocalTransaction getLocalTransaction()
|
||||
throws ResourceException {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultSetInfo getResultSetInfo()
|
||||
throws ResourceException {
|
||||
return _jca;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Implementation of StoreContext
|
||||
//////////////////////////////////
|
||||
|
@ -585,11 +550,11 @@ public class BrokerImpl
|
|||
_populateDataCache = cache;
|
||||
}
|
||||
|
||||
public boolean isLargeTransaction() {
|
||||
public boolean isTrackChangesByType() {
|
||||
return _largeTransaction;
|
||||
}
|
||||
|
||||
public void setLargeTransaction(boolean largeTransaction) {
|
||||
public void setTrackChangesByType(boolean largeTransaction) {
|
||||
assertOpen();
|
||||
_largeTransaction = largeTransaction;
|
||||
}
|
||||
|
@ -3116,7 +3081,7 @@ public class BrokerImpl
|
|||
if (objs == null)
|
||||
return null;
|
||||
if (objs.isEmpty())
|
||||
return new Object[0];
|
||||
return EMPTY_OBJECTS;
|
||||
if (call == null)
|
||||
call = _call;
|
||||
|
||||
|
@ -3203,7 +3168,7 @@ public class BrokerImpl
|
|||
if (objs == null)
|
||||
return null;
|
||||
if (objs.isEmpty())
|
||||
return new Object[0];
|
||||
return EMPTY_OBJECTS;
|
||||
|
||||
beginOperation(true);
|
||||
try {
|
||||
|
@ -4898,106 +4863,4 @@ public class BrokerImpl
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to implement JCA interfaces. This is placed in a
|
||||
* separate class so that its methods do not interfere with the
|
||||
* persistence manager APIs.
|
||||
*/
|
||||
private class JCAHelper
|
||||
implements Interaction, ResultSetInfo, ConnectionMetaData {
|
||||
///////////////////////////////////////////
|
||||
// Implementation of Interaction interface
|
||||
///////////////////////////////////////////
|
||||
|
||||
public void clearWarnings() {
|
||||
}
|
||||
|
||||
public Record execute(InteractionSpec spec, Record input)
|
||||
throws ResourceException {
|
||||
throw new NotSupportedException("execute");
|
||||
}
|
||||
|
||||
public boolean execute(InteractionSpec spec, Record input,
|
||||
Record output)
|
||||
throws ResourceException {
|
||||
throw new NotSupportedException("execute");
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return BrokerImpl.this;
|
||||
}
|
||||
|
||||
public ResourceWarning getWarnings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Implementation of ResultSetInfo interface
|
||||
/////////////////////////////////////////////
|
||||
|
||||
public boolean deletesAreDetected(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean insertsAreDetected(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean othersDeletesAreVisible(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean othersInsertsAreVisible(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean othersUpdatesAreVisible(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean ownDeletesAreVisible(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean ownInsertsAreVisible(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean ownUpdatesAreVisible(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsResultSetType(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsResultTypeConcurrency(int type,
|
||||
int concurrency) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean updatesAreDetected(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// Implementation of ConnectionMetaData interface
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
public String getEISProductName() {
|
||||
return _conf.getConnectionDriverName();
|
||||
}
|
||||
|
||||
public String getEISProductVersion() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return _user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,6 @@ package org.apache.openjpa.kernel;
|
|||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import javax.resource.ResourceException;
|
||||
import javax.resource.cci.ConnectionMetaData;
|
||||
import javax.resource.cci.Interaction;
|
||||
import javax.resource.cci.LocalTransaction;
|
||||
import javax.resource.cci.ResultSetInfo;
|
||||
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.ee.ManagedRuntime;
|
||||
|
@ -749,17 +744,17 @@ public class DelegatingBroker
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isLargeTransaction() {
|
||||
public boolean isTrackChangesByType() {
|
||||
try {
|
||||
return _broker.isLargeTransaction();
|
||||
return _broker.isTrackChangesByType();
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLargeTransaction(boolean largeTransaction) {
|
||||
public void setTrackChangesByType(boolean largeTransaction) {
|
||||
try {
|
||||
_broker.setLargeTransaction(largeTransaction);
|
||||
_broker.setTrackChangesByType(largeTransaction);
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
|
@ -1358,42 +1353,6 @@ public class DelegatingBroker
|
|||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Implementation of Connection interface
|
||||
//////////////////////////////////////////
|
||||
|
||||
public ConnectionMetaData getMetaData()
|
||||
throws ResourceException {
|
||||
try {
|
||||
return _broker.getMetaData();
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
|
||||
public Interaction createInteraction()
|
||||
throws ResourceException {
|
||||
try {
|
||||
return _broker.createInteraction();
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
|
||||
public LocalTransaction getLocalTransaction()
|
||||
throws ResourceException {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultSetInfo getResultSetInfo()
|
||||
throws ResourceException {
|
||||
try {
|
||||
return _broker.getResultSetInfo();
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
|
||||
public Object newInstance(Class cls) {
|
||||
try {
|
||||
return _broker.newInstance(cls);
|
||||
|
|
|
@ -183,17 +183,17 @@ public class DelegatingFetchConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
public boolean getQueryCache() {
|
||||
public boolean getEnlistInQueryCache() {
|
||||
try {
|
||||
return _fetch.getQueryCache();
|
||||
return _fetch.getEnlistInQueryCache();
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
|
||||
public FetchConfiguration setQueryCache(boolean cache) {
|
||||
public FetchConfiguration setEnlistInQueryCache(boolean cache) {
|
||||
try {
|
||||
_fetch.setQueryCache(cache);
|
||||
_fetch.setEnlistInQueryCache(cache);
|
||||
return this;
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
|
|
|
@ -129,14 +129,14 @@ public interface FetchConfiguration
|
|||
* returns <code>false</code>, query caching will not be used
|
||||
* even if the datacache plugin is installed.
|
||||
*/
|
||||
public boolean getQueryCache();
|
||||
public boolean getEnlistInQueryCache();
|
||||
|
||||
/**
|
||||
* Control whether or not query caching is enabled. This has no effect
|
||||
* if the datacache plugin is not installed, or if the query cache size
|
||||
* is set to zero.
|
||||
*/
|
||||
public FetchConfiguration setQueryCache(boolean cache);
|
||||
public FetchConfiguration setEnlistInQueryCache(boolean cache);
|
||||
|
||||
/**
|
||||
* The query automatic flush configuration.
|
||||
|
|
|
@ -150,7 +150,7 @@ public class FetchConfigurationImpl
|
|||
public void copy(FetchConfiguration fetch) {
|
||||
setFetchBatchSize(fetch.getFetchBatchSize());
|
||||
setMaxFetchDepth(fetch.getMaxFetchDepth());
|
||||
setQueryCache(fetch.getQueryCache());
|
||||
setEnlistInQueryCache(fetch.getEnlistInQueryCache());
|
||||
setFlushBeforeQueries(fetch.getFlushBeforeQueries());
|
||||
setLockTimeout(fetch.getLockTimeout());
|
||||
clearFetchGroups();
|
||||
|
@ -191,11 +191,11 @@ public class FetchConfigurationImpl
|
|||
return this;
|
||||
}
|
||||
|
||||
public boolean getQueryCache() {
|
||||
public boolean getEnlistInQueryCache() {
|
||||
return _state.queryCache;
|
||||
}
|
||||
|
||||
public FetchConfiguration setQueryCache(boolean cache) {
|
||||
public FetchConfiguration setEnlistInQueryCache(boolean cache) {
|
||||
_state.queryCache = cache;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public interface StoreContext {
|
|||
* @param oids the oids of the objects to return
|
||||
* @return the objects that were looked up, in the same order as the oids
|
||||
* parameter
|
||||
* @see #find(Object,boolean,call)
|
||||
* @see #find(Object,boolean,FindCallbacks)
|
||||
*/
|
||||
public Object[] findAll(Collection oids, boolean validate,
|
||||
FindCallbacks call);
|
||||
|
@ -373,25 +373,28 @@ public interface StoreContext {
|
|||
|
||||
/**
|
||||
* Whether memory usage is reduced during this transaction at the expense
|
||||
* of possibly more aggressive data cache evictions.
|
||||
* of tracking changes at the type level instead of the instance level,
|
||||
* resulting in more aggressive cache invalidation.
|
||||
*
|
||||
* @since 0.3.4
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isLargeTransaction();
|
||||
public boolean isTrackChangesByType();
|
||||
|
||||
/**
|
||||
* If a large number of objects will be created, modified, or deleted
|
||||
* during this transaction setting this option to true will reduce memory
|
||||
* usage if you perform periodic flushes. Upon transaction commit the
|
||||
* data cache will have to more aggressively flush objects. The store cache
|
||||
* will have to flush instances of objects for each class of object
|
||||
* modified during the transaction. A side benefit of large transaction
|
||||
* mode is that smaller update messages can be used for
|
||||
* usage if you perform periodic flushes by tracking changes at the type
|
||||
* level instead of the instance level, resulting in more aggressive cache
|
||||
* invalidation. Upon transaction commit the data cache will have to
|
||||
* more aggressively flush objects. The store cache will have to flush
|
||||
* instances of objects for each class of object modified during the
|
||||
* transaction. A side benefit of large transaction mode is that smaller
|
||||
* update messages can be used for
|
||||
* {@link org.apache.openjpa.event.RemoteCommitEvent}s. Defaults to false.
|
||||
*
|
||||
* @since 0.3.4
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void setLargeTransaction(boolean largeTransaction);
|
||||
public void setTrackChangesByType(boolean largeTransaction);
|
||||
|
||||
/**
|
||||
* Whether this context is using managed transactions.
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -30,6 +30,7 @@ import javax.persistence.Column;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -18,14 +18,43 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
|
||||
|
||||
/**
|
||||
* Type of fetching to employ.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
public enum EagerFetchType {
|
||||
NONE(EagerFetchModes.EAGER_NONE),
|
||||
JOIN(EagerFetchModes.EAGER_JOIN),
|
||||
PARALLEL(EagerFetchModes.EAGER_PARALLEL);
|
||||
|
||||
NONE,
|
||||
JOIN,
|
||||
PARALLEL };
|
||||
private final int eagerFetchConstant;
|
||||
|
||||
private EagerFetchType(int value) {
|
||||
eagerFetchConstant = value;
|
||||
}
|
||||
|
||||
int toKernelConstant() {
|
||||
return eagerFetchConstant;
|
||||
}
|
||||
|
||||
static EagerFetchType fromKernelConstant(int kernelConstant) {
|
||||
switch (kernelConstant) {
|
||||
case EagerFetchModes.EAGER_NONE:
|
||||
return NONE;
|
||||
|
||||
case EagerFetchModes.EAGER_JOIN:
|
||||
return JOIN;
|
||||
|
||||
case EagerFetchModes.EAGER_PARALLEL:
|
||||
return PARALLEL;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(kernelConstant + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE, METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -23,10 +23,11 @@ package org.apache.openjpa.persistence.jdbc;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
public enum ForeignKeyAction {
|
||||
|
||||
RESTRICT,
|
||||
CASCADE,
|
||||
NULL,
|
||||
DEFAULT };
|
||||
DEFAULT
|
||||
};
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
|||
* Isolation levels for use in {@link JDBCFetchPlan#setIsolation}.
|
||||
*
|
||||
* @since 0.9.7
|
||||
* @published
|
||||
*/
|
||||
public enum IsolationLevel {
|
||||
DEFAULT(-1),
|
||||
|
@ -41,11 +42,11 @@ public enum IsolationLevel {
|
|||
_connectionConstant = connectionConstant;
|
||||
}
|
||||
|
||||
protected int getConnectionConstant() {
|
||||
public int getConnectionConstant() {
|
||||
return _connectionConstant;
|
||||
}
|
||||
|
||||
protected static IsolationLevel fromConnectionConstant(int constant) {
|
||||
public static IsolationLevel fromConnectionConstant(int constant) {
|
||||
switch(constant) {
|
||||
case -1:
|
||||
case JDBCFetchConfiguration.DEFAULT:
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
|
||||
import org.apache.openjpa.jdbc.kernel.LRSSizes;
|
||||
import java.util.Collection;
|
||||
import javax.persistence.LockModeType;
|
||||
|
||||
import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
|
||||
import org.apache.openjpa.persistence.FetchPlan;
|
||||
|
||||
|
@ -32,35 +33,27 @@ import org.apache.openjpa.persistence.FetchPlan;
|
|||
* @published
|
||||
*/
|
||||
public interface JDBCFetchPlan
|
||||
extends FetchPlan, EagerFetchModes, LRSSizes, JoinSyntaxes {
|
||||
extends FetchPlan {
|
||||
|
||||
/**
|
||||
* Eager fetch mode in loading relations.
|
||||
*
|
||||
* @see EagerFetchModes
|
||||
*/
|
||||
public int getEagerFetchMode();
|
||||
public EagerFetchType getEagerFetchMode();
|
||||
|
||||
/**
|
||||
* Eager fetch mode in loading relations.
|
||||
*
|
||||
* @see EagerFetchModes
|
||||
*/
|
||||
public JDBCFetchPlan setEagerFetchMode(int mode);
|
||||
public JDBCFetchPlan setEagerFetchMode(EagerFetchType type);
|
||||
|
||||
/**
|
||||
* Eager fetch mode in loading subclasses.
|
||||
*
|
||||
* @see EagerFetchModes
|
||||
*/
|
||||
public int getSubclassFetchMode();
|
||||
public EagerFetchType getSubclassFetchMode();
|
||||
|
||||
/**
|
||||
* Eager fetch mode in loading subclasses.
|
||||
*
|
||||
* @see EagerFetchModes
|
||||
*/
|
||||
public JDBCFetchPlan setSubclassFetchMode(int mode);
|
||||
public JDBCFetchPlan setSubclassFetchMode(EagerFetchType type);
|
||||
|
||||
/**
|
||||
* Type of JDBC result set to use for query results.
|
||||
|
@ -84,7 +77,7 @@ public interface JDBCFetchPlan
|
|||
public int getFetchDirection();
|
||||
|
||||
/**
|
||||
* Result set fetch direction.
|
||||
* Result set fetch direction. // ##### what to do here?
|
||||
*
|
||||
* @see java.sql.ResultSet
|
||||
*/
|
||||
|
@ -92,31 +85,23 @@ public interface JDBCFetchPlan
|
|||
|
||||
/**
|
||||
* How to determine the size of a large result set.
|
||||
*
|
||||
* @see LRSSizes
|
||||
*/
|
||||
public int getLRSSize();
|
||||
public LRSSizeType getLRSSize();
|
||||
|
||||
/**
|
||||
* How to determine the size of a large result set.
|
||||
*
|
||||
* @see LRSSizes
|
||||
*/
|
||||
public JDBCFetchPlan setLRSSize(int lrsSize);
|
||||
public JDBCFetchPlan setLRSSize(LRSSizeType lrsSize);
|
||||
|
||||
/**
|
||||
* SQL join syntax.
|
||||
*
|
||||
* @see JoinSyntaxes
|
||||
*/
|
||||
public int getJoinSyntax();
|
||||
public JoinSyntaxType getJoinSyntax();
|
||||
|
||||
/**
|
||||
* SQL join syntax.
|
||||
*
|
||||
* @see JoinSyntaxes
|
||||
*/
|
||||
public JDBCFetchPlan setJoinSyntax(int syntax);
|
||||
public JDBCFetchPlan setJoinSyntax(JoinSyntaxType syntax);
|
||||
|
||||
/**
|
||||
* The isolation level for queries issued to the database. This overrides
|
||||
|
@ -135,4 +120,35 @@ public interface JDBCFetchPlan
|
|||
* @since 0.9.7
|
||||
*/
|
||||
public JDBCFetchPlan setIsolation(IsolationLevel level);
|
||||
|
||||
|
||||
// covariant type support for return vals
|
||||
|
||||
public JDBCFetchPlan addFetchGroup(String group);
|
||||
public JDBCFetchPlan addFetchGroups(Collection groups);
|
||||
public JDBCFetchPlan addFetchGroups(String... groups);
|
||||
public JDBCFetchPlan addField(Class cls, String field);
|
||||
public JDBCFetchPlan addField(String field);
|
||||
public JDBCFetchPlan addFields(Class cls, Collection fields);
|
||||
public JDBCFetchPlan addFields(Class cls, String... fields);
|
||||
public JDBCFetchPlan addFields(Collection fields);
|
||||
public JDBCFetchPlan addFields(String... fields);
|
||||
public JDBCFetchPlan clearFetchGroups();
|
||||
public JDBCFetchPlan clearFields();
|
||||
public JDBCFetchPlan removeFetchGroup(String group);
|
||||
public JDBCFetchPlan removeFetchGroups(Collection groups);
|
||||
public JDBCFetchPlan removeFetchGroups(String... groups);
|
||||
public JDBCFetchPlan removeField(Class cls, String field);
|
||||
public JDBCFetchPlan removeField(String field);
|
||||
public JDBCFetchPlan removeFields(Class cls, Collection fields);
|
||||
public JDBCFetchPlan removeFields(Class cls, String... fields);
|
||||
public JDBCFetchPlan removeFields(String... fields);
|
||||
public JDBCFetchPlan removeFields(Collection fields);
|
||||
public JDBCFetchPlan resetFetchGroups();
|
||||
public JDBCFetchPlan setEnlistInQueryResultCache(boolean cache);
|
||||
public JDBCFetchPlan setFetchBatchSize(int fetchBatchSize);
|
||||
public JDBCFetchPlan setLockTimeout(int timeout);
|
||||
public JDBCFetchPlan setMaxFetchDepth(int depth);
|
||||
public JDBCFetchPlan setReadLockMode(LockModeType mode);
|
||||
public JDBCFetchPlan setWriteLockMode(LockModeType mode);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.persistence.LockModeType;
|
||||
|
||||
import org.apache.openjpa.jdbc.kernel.DelegatingJDBCFetchConfiguration;
|
||||
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
||||
import org.apache.openjpa.kernel.DelegatingFetchConfiguration;
|
||||
|
@ -45,28 +48,28 @@ public class JDBCFetchPlanImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DelegatingFetchConfiguration newDelegatingFetchConfiguration
|
||||
(FetchConfiguration fetch) {
|
||||
protected DelegatingFetchConfiguration newDelegatingFetchConfiguration(
|
||||
FetchConfiguration fetch) {
|
||||
_fetch = new DelegatingJDBCFetchConfiguration((JDBCFetchConfiguration)
|
||||
fetch, PersistenceExceptions.TRANSLATOR);
|
||||
return _fetch;
|
||||
}
|
||||
|
||||
public int getEagerFetchMode() {
|
||||
return _fetch.getEagerFetchMode();
|
||||
public EagerFetchType getEagerFetchMode() {
|
||||
return EagerFetchType.fromKernelConstant(_fetch.getEagerFetchMode());
|
||||
}
|
||||
|
||||
public JDBCFetchPlanImpl setEagerFetchMode(int mode) {
|
||||
_fetch.setEagerFetchMode(mode);
|
||||
public JDBCFetchPlanImpl setEagerFetchMode(EagerFetchType type) {
|
||||
_fetch.setEagerFetchMode(type.toKernelConstant());
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getSubclassFetchMode() {
|
||||
return _fetch.getSubclassFetchMode();
|
||||
public EagerFetchType getSubclassFetchMode() {
|
||||
return EagerFetchType.fromKernelConstant(_fetch.getSubclassFetchMode());
|
||||
}
|
||||
|
||||
public JDBCFetchPlanImpl setSubclassFetchMode(int mode) {
|
||||
_fetch.setSubclassFetchMode(mode);
|
||||
public JDBCFetchPlanImpl setSubclassFetchMode(EagerFetchType type) {
|
||||
_fetch.setSubclassFetchMode(type.toKernelConstant());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -88,21 +91,21 @@ public class JDBCFetchPlanImpl
|
|||
return this;
|
||||
}
|
||||
|
||||
public int getLRSSize() {
|
||||
return _fetch.getLRSSize();
|
||||
public LRSSizeType getLRSSize() {
|
||||
return LRSSizeType.fromKernelConstant(_fetch.getLRSSize());
|
||||
}
|
||||
|
||||
public JDBCFetchPlanImpl setLRSSize(int lrsSize) {
|
||||
_fetch.setLRSSize(lrsSize);
|
||||
public JDBCFetchPlanImpl setLRSSize(LRSSizeType lrsSize) {
|
||||
_fetch.setLRSSize(lrsSize.toKernelConstant());
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getJoinSyntax() {
|
||||
return _fetch.getJoinSyntax();
|
||||
public JoinSyntaxType getJoinSyntax() {
|
||||
return JoinSyntaxType.fromKernelConstant(_fetch.getJoinSyntax());
|
||||
}
|
||||
|
||||
public JDBCFetchPlanImpl setJoinSyntax(int syntax) {
|
||||
_fetch.setJoinSyntax(syntax);
|
||||
public JDBCFetchPlanImpl setJoinSyntax(JoinSyntaxType syntax) {
|
||||
_fetch.setJoinSyntax(syntax.toKernelConstant());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -114,4 +117,139 @@ public class JDBCFetchPlanImpl
|
|||
_fetch.setIsolation(level.getConnectionConstant());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addFetchGroup(String group) {
|
||||
return (JDBCFetchPlan) super.addFetchGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addFetchGroups(Collection groups) {
|
||||
return (JDBCFetchPlan) super.addFetchGroups(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addFetchGroups(String... groups) {
|
||||
return (JDBCFetchPlan) super.addFetchGroups(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addField(Class cls, String field) {
|
||||
return (JDBCFetchPlan) super.addField(cls, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addField(String field) {
|
||||
return (JDBCFetchPlan) super.addField(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addFields(Class cls, Collection fields) {
|
||||
return (JDBCFetchPlan) super.addFields(cls, fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addFields(Class cls, String... fields) {
|
||||
return (JDBCFetchPlan) super.addFields(cls, fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addFields(Collection fields) {
|
||||
return (JDBCFetchPlan) super.addFields(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan addFields(String... fields) {
|
||||
return (JDBCFetchPlan) super.addFields(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan clearFetchGroups() {
|
||||
return (JDBCFetchPlan) super.clearFetchGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan clearFields() {
|
||||
return (JDBCFetchPlan) super.clearFields();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeFetchGroup(String group) {
|
||||
return (JDBCFetchPlan) super.removeFetchGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeFetchGroups(Collection groups) {
|
||||
return (JDBCFetchPlan) super.removeFetchGroups(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeFetchGroups(String... groups) {
|
||||
return (JDBCFetchPlan) super.removeFetchGroups(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeField(Class cls, String field) {
|
||||
return (JDBCFetchPlan) super.removeField(cls, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeField(String field) {
|
||||
return (JDBCFetchPlan) super.removeField(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeFields(Class cls, Collection fields) {
|
||||
return (JDBCFetchPlan) super.removeFields(cls, fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeFields(Class cls, String... fields) {
|
||||
return (JDBCFetchPlan) super.removeFields(cls, fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeFields(Collection fields) {
|
||||
return (JDBCFetchPlan) super.removeFields(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan removeFields(String... fields) {
|
||||
return (JDBCFetchPlan) super.removeFields(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan resetFetchGroups() {
|
||||
return (JDBCFetchPlan) super.resetFetchGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan setEnlistInQueryResultCache(boolean cache) {
|
||||
return (JDBCFetchPlan) super.setEnlistInQueryResultCache(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan setFetchBatchSize(int fetchBatchSize) {
|
||||
return (JDBCFetchPlan) super.setFetchBatchSize(fetchBatchSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan setLockTimeout(int timeout) {
|
||||
return (JDBCFetchPlan) super.setLockTimeout(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan setMaxFetchDepth(int depth) {
|
||||
return (JDBCFetchPlan) super.setMaxFetchDepth(depth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan setReadLockMode(LockModeType mode) {
|
||||
return (JDBCFetchPlan) super.setReadLockMode(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDBCFetchPlan setWriteLockMode(LockModeType mode) {
|
||||
return (JDBCFetchPlan) super.setWriteLockMode(mode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
|
||||
|
||||
/**
|
||||
* Type of join syntax to use.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @published
|
||||
*/
|
||||
public enum JoinSyntaxType {
|
||||
SQL92(JoinSyntaxes.SYNTAX_SQL92),
|
||||
TRADITIONAL(JoinSyntaxes.SYNTAX_TRADITIONAL),
|
||||
DATABASE(JoinSyntaxes.SYNTAX_DATABASE);
|
||||
|
||||
private final int joinSyntaxConstant;
|
||||
|
||||
private JoinSyntaxType(int value) {
|
||||
joinSyntaxConstant = value;
|
||||
}
|
||||
|
||||
int toKernelConstant() {
|
||||
return joinSyntaxConstant;
|
||||
}
|
||||
|
||||
static JoinSyntaxType fromKernelConstant(int kernelConstant) {
|
||||
switch (kernelConstant) {
|
||||
case JoinSyntaxes.SYNTAX_SQL92:
|
||||
return SQL92;
|
||||
|
||||
case JoinSyntaxes.SYNTAX_TRADITIONAL:
|
||||
return TRADITIONAL;
|
||||
|
||||
case JoinSyntaxes.SYNTAX_DATABASE:
|
||||
return DATABASE;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(kernelConstant + "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import org.apache.openjpa.jdbc.kernel.LRSSizes;
|
||||
|
||||
/**
|
||||
* Algorithm to use for computing the size of an LRS relation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @published
|
||||
*/
|
||||
public enum LRSSizeType {
|
||||
UNKNOWN(LRSSizes.SIZE_UNKNOWN),
|
||||
LAST(LRSSizes.SIZE_LAST),
|
||||
QUERY(LRSSizes.SIZE_QUERY);
|
||||
|
||||
private final int lrsConstant;
|
||||
|
||||
private LRSSizeType(int value) {
|
||||
lrsConstant = value;
|
||||
}
|
||||
|
||||
int toKernelConstant() {
|
||||
return lrsConstant;
|
||||
}
|
||||
|
||||
static LRSSizeType fromKernelConstant(int kernelConstant) {
|
||||
switch (kernelConstant) {
|
||||
case LRSSizes.SIZE_UNKNOWN:
|
||||
return UNKNOWN;
|
||||
|
||||
case LRSSizes.SIZE_LAST:
|
||||
return LAST;
|
||||
|
||||
case LRSSizes.SIZE_QUERY:
|
||||
return QUERY;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(kernelConstant + "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ import javax.persistence.Column;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -23,9 +23,10 @@ package org.apache.openjpa.persistence.jdbc;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
public enum NonpolymorphicType {
|
||||
|
||||
EXACT,
|
||||
JOINABLE,
|
||||
FALSE };
|
||||
FALSE
|
||||
};
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE, METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -24,7 +24,6 @@ import javax.persistence.*;
|
|||
|
||||
import junit.framework.*;
|
||||
|
||||
import org.apache.openjpa.kernel.AutoDetach;
|
||||
import org.apache.openjpa.persistence.*;
|
||||
|
||||
public class TestAutoDetachProperty extends TestCase {
|
||||
|
@ -63,17 +62,20 @@ public class TestAutoDetachProperty extends TestCase {
|
|||
}
|
||||
|
||||
private boolean isAutoDetachingOnClose() {
|
||||
int autoDetachFlags = OpenJPAPersistence.cast(em).getAutoDetach();
|
||||
return (autoDetachFlags & AutoDetach.DETACH_CLOSE) > 0;
|
||||
EnumSet<AutoDetachType> autoDetachFlags =
|
||||
OpenJPAPersistence.cast(em).getAutoDetach();
|
||||
return autoDetachFlags.contains(AutoDetachType.CLOSE);
|
||||
}
|
||||
|
||||
private boolean isAutoDetachingOnCommit() {
|
||||
int autoDetachFlags = OpenJPAPersistence.cast(em).getAutoDetach();
|
||||
return (autoDetachFlags & AutoDetach.DETACH_COMMIT) > 0;
|
||||
EnumSet<AutoDetachType> autoDetachFlags =
|
||||
OpenJPAPersistence.cast(em).getAutoDetach();
|
||||
return autoDetachFlags.contains(AutoDetachType.COMMIT);
|
||||
}
|
||||
|
||||
private boolean isAutoDetachingOnNonTxRead() {
|
||||
int autoDetachFlags = OpenJPAPersistence.cast(em).getAutoDetach();
|
||||
return (autoDetachFlags & AutoDetach.DETACH_NONTXREAD) > 0;
|
||||
EnumSet<AutoDetachType> autoDetachFlags =
|
||||
OpenJPAPersistence.cast(em).getAutoDetach();
|
||||
return autoDetachFlags.contains(AutoDetachType.NON_TRANSACTIONAL_READ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,10 @@
|
|||
*/
|
||||
package org.apache.openjpa.conf;
|
||||
|
||||
import javax.persistence.Persistence;
|
||||
import org.apache.openjpa.persistence.test.*;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.lib.conf.Value;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
|
||||
/**
|
||||
* Tests dynamic modification of configuration property.
|
||||
|
@ -32,13 +30,13 @@ import org.apache.openjpa.persistence.OpenJPAPersistence;
|
|||
*
|
||||
*/
|
||||
public class TestDynamicConfiguration extends SingleEMFTestCase {
|
||||
|
||||
public void testConfigurationIsEqualByValueAndHashCode() {
|
||||
OpenJPAEntityManagerFactory emf1 = createEMF();
|
||||
|
||||
public void testConfigurationIsEqualByValueAndHashCode() {
|
||||
OpenJPAEntityManagerFactorySPI emf1 = createEMF();
|
||||
assertNotNull(emf1);
|
||||
OpenJPAConfiguration conf1 = emf1.getConfiguration();
|
||||
|
||||
OpenJPAEntityManagerFactory emf2 = createEMF();
|
||||
OpenJPAEntityManagerFactorySPI emf2 = createEMF();
|
||||
assertNotNull(emf2);
|
||||
OpenJPAConfiguration conf2 = emf2.getConfiguration();
|
||||
|
||||
|
@ -51,8 +49,6 @@ public class TestDynamicConfiguration extends SingleEMFTestCase {
|
|||
}
|
||||
|
||||
public void testConfigurationIsReadOnlyAfterFirstConstruction() {
|
||||
OpenJPAEntityManagerFactory emf = createEMF();
|
||||
assertNotNull(emf);
|
||||
OpenJPAConfiguration conf = emf.getConfiguration();
|
||||
assertFalse(conf.isReadOnly());
|
||||
emf.createEntityManager();
|
||||
|
@ -60,8 +56,6 @@ public class TestDynamicConfiguration extends SingleEMFTestCase {
|
|||
}
|
||||
|
||||
public void testDynamicValuesCanNotBeChangedDirectly() {
|
||||
OpenJPAEntityManagerFactory emf = createEMF();
|
||||
assertNotNull(emf);
|
||||
emf.createEntityManager();
|
||||
OpenJPAConfiguration conf = emf.getConfiguration();
|
||||
|
||||
|
@ -80,8 +74,6 @@ public class TestDynamicConfiguration extends SingleEMFTestCase {
|
|||
}
|
||||
|
||||
public void testDynamicValuesCanBeChanged() {
|
||||
OpenJPAEntityManagerFactory emf = createEMF();
|
||||
assertNotNull(emf);
|
||||
OpenJPAConfiguration conf = emf.getConfiguration();
|
||||
|
||||
Value[] dynamicValues = conf.getDynamicValues();
|
||||
|
@ -96,8 +88,6 @@ public class TestDynamicConfiguration extends SingleEMFTestCase {
|
|||
}
|
||||
|
||||
public void testDynamicValuesAreCorrectlySet() {
|
||||
OpenJPAEntityManagerFactory emf = createEMF();
|
||||
assertNotNull(emf);
|
||||
OpenJPAConfiguration conf = emf.getConfiguration();
|
||||
|
||||
Value[] dynamicValues = conf.getDynamicValues();
|
||||
|
@ -106,8 +96,6 @@ public class TestDynamicConfiguration extends SingleEMFTestCase {
|
|||
}
|
||||
|
||||
public void testDynamicChangeDoesNotChangeHashCode() {
|
||||
OpenJPAEntityManagerFactory emf = createEMF();
|
||||
assertNotNull(emf);
|
||||
OpenJPAConfiguration conf1 = emf.getConfiguration();
|
||||
|
||||
int oldValue = conf1.getLockTimeout();
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.lang.reflect.Field;
|
|||
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
import org.apache.openjpa.kernel.OpenJPAStateManager;
|
||||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
import org.apache.openjpa.util.ImplHelper;
|
||||
|
@ -68,7 +68,7 @@ public abstract class AbstractUnenhancedClassTest
|
|||
}
|
||||
|
||||
public void testMetaData() {
|
||||
ClassMetaData meta = OpenJPAPersistence.getMetaData(emf,
|
||||
ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
|
||||
getUnenhancedClass());
|
||||
assertEquals(ClassRedefiner.canRedefineClasses(),
|
||||
meta.isIntercepting());
|
||||
|
@ -567,18 +567,18 @@ public abstract class AbstractUnenhancedClassTest
|
|||
}
|
||||
|
||||
public void testGetMetaDataOfSubtype() {
|
||||
ClassMetaData meta = OpenJPAPersistence.getMetaData(emf,
|
||||
ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
|
||||
getUnenhancedClass());
|
||||
List<Class> subs = ManagedClassSubclasser.prepareUnenhancedClasses(
|
||||
emf.getConfiguration(),
|
||||
Collections.singleton(getUnenhancedClass()), null);
|
||||
assertSame(meta, OpenJPAPersistence.getMetaData(emf, subs.get(0)));
|
||||
assertSame(meta, JPAFacadeHelper.getMetaData(emf, subs.get(0)));
|
||||
|
||||
meta = OpenJPAPersistence.getMetaData(emf, getUnenhancedSubclass());
|
||||
meta = JPAFacadeHelper.getMetaData(emf, getUnenhancedSubclass());
|
||||
subs = ManagedClassSubclasser.prepareUnenhancedClasses(
|
||||
emf.getConfiguration(),
|
||||
Collections.singleton(getUnenhancedSubclass()), null);
|
||||
assertSame(meta, OpenJPAPersistence.getMetaData(emf, subs.get(0)));
|
||||
assertSame(meta, JPAFacadeHelper.getMetaData(emf, subs.get(0)));
|
||||
}
|
||||
|
||||
private class ListenerImpl
|
||||
|
|
|
@ -24,14 +24,15 @@ import java.util.Collections;
|
|||
import javax.persistence.Persistence;
|
||||
|
||||
import org.apache.openjpa.persistence.test.PersistenceTestCase;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
|
||||
public class TestSJVMRemoteCommitProvider
|
||||
extends PersistenceTestCase {
|
||||
|
||||
private OpenJPAEntityManagerFactory emf1;
|
||||
private OpenJPAEntityManagerFactory emf2;
|
||||
private OpenJPAEntityManagerFactorySPI emf1;
|
||||
private OpenJPAEntityManagerFactorySPI emf2;
|
||||
private ListenerImpl listen1;
|
||||
private ListenerImpl listen2;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class TestSJVMRemoteCommitProvider
|
|||
sjvm1.put("openjpa.RemoteCommitProvider", "sjvm");
|
||||
// set this to differentiate emf1 from the other emf below
|
||||
sjvm1.put("openjpa.DetachState", "true");
|
||||
emf1 = OpenJPAPersistence.cast(
|
||||
emf1 = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(
|
||||
Persistence.createEntityManagerFactory("test", sjvm1));
|
||||
emf1.getConfiguration().getRemoteCommitEventManager().addListener(
|
||||
listen1 = new ListenerImpl());
|
||||
|
@ -48,15 +49,15 @@ public class TestSJVMRemoteCommitProvider
|
|||
Map sjvm2 = new HashMap();
|
||||
sjvm2.put("openjpa.RemoteCommitProvider", "sjvm");
|
||||
sjvm2.put("openjpa.DetachState", "false"); // differentiate from above
|
||||
emf2 = OpenJPAPersistence.cast(
|
||||
emf2 = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(
|
||||
Persistence.createEntityManagerFactory("test", sjvm2));
|
||||
emf2.getConfiguration().getRemoteCommitEventManager().addListener(
|
||||
listen2 = new ListenerImpl());
|
||||
}
|
||||
|
||||
public void testSJVMRemoteCommitProvider() {
|
||||
assertNotSame(OpenJPAPersistence.toBrokerFactory(emf1),
|
||||
OpenJPAPersistence.toBrokerFactory(emf2));
|
||||
assertNotSame(JPAFacadeHelper.toBrokerFactory(emf1),
|
||||
JPAFacadeHelper.toBrokerFactory(emf2));
|
||||
|
||||
emf1.getConfiguration().getRemoteCommitEventManager()
|
||||
.getRemoteCommitProvider().broadcast(
|
||||
|
@ -82,4 +83,4 @@ public class TestSJVMRemoteCommitProvider
|
|||
public void close() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ import javax.persistence.Persistence;
|
|||
|
||||
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
||||
import org.apache.openjpa.jdbc.schema.SchemaTool;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -39,13 +39,13 @@ public class TestMappingToolAutoDelete
|
|||
extends TestCase {
|
||||
|
||||
private JDBCConfiguration _conf;
|
||||
private OpenJPAEntityManagerFactory emf;
|
||||
private OpenJPAEntityManagerFactorySPI emf;
|
||||
|
||||
public void setUp() {
|
||||
Map props = new HashMap(System.getProperties());
|
||||
props.put("openjpa.MetaDataFactory",
|
||||
"jpa(Types=" + AllFieldTypes.class.getName() + ")");
|
||||
emf = OpenJPAPersistence.cast(
|
||||
emf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(
|
||||
Persistence.createEntityManagerFactory("test", props));
|
||||
_conf = (JDBCConfiguration) emf.getConfiguration();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.simple.TemporalFieldTypes;
|
||||
import org.apache.openjpa.persistence.test.SingleEMTestCase;
|
||||
|
||||
|
@ -32,7 +33,8 @@ public class TestMappingToolTemporal extends SingleEMTestCase {
|
|||
}
|
||||
|
||||
public void testMappingToolTemporal() throws IOException, SQLException {
|
||||
ClassMapping mapping = (ClassMapping) OpenJPAPersistence.cast(emf)
|
||||
ClassMapping mapping = (ClassMapping)
|
||||
((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(emf))
|
||||
.getConfiguration().getMetaDataRepositoryInstance()
|
||||
.getMetaData("TemporalFieldTypes", getClass().getClassLoader(),
|
||||
true);
|
||||
|
|
|
@ -24,14 +24,15 @@ import junit.framework.TestCase;
|
|||
import org.apache.openjpa.event.BrokerFactoryListener;
|
||||
import org.apache.openjpa.event.BrokerFactoryEvent;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
|
||||
public class TestBrokerFactoryEventManager
|
||||
extends TestCase {
|
||||
|
||||
public void testCreateEvent() {
|
||||
OpenJPAEntityManagerFactory emf = OpenJPAPersistence.cast(
|
||||
Persistence.createEntityManagerFactory("test"));
|
||||
OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)
|
||||
OpenJPAPersistence.cast(
|
||||
Persistence.createEntityManagerFactory("test"));
|
||||
ListenerImpl listener = new ListenerImpl();
|
||||
emf.getConfiguration().getBrokerFactoryEventManager()
|
||||
.addListener(listener);
|
||||
|
@ -44,8 +45,10 @@ public class TestBrokerFactoryEventManager
|
|||
|
||||
boolean createEventReceived = false;
|
||||
|
||||
public void afterBrokerFactoryCreate(BrokerFactoryEvent event) {
|
||||
createEventReceived = true;
|
||||
public void eventFired(BrokerFactoryEvent event) {
|
||||
if (event.getEventType()
|
||||
== BrokerFactoryEvent.BROKER_FACTORY_CREATED)
|
||||
createEventReceived = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.persistence.EntityManager;
|
|||
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
||||
import org.apache.openjpa.event.AbstractLifecycleListener;
|
||||
import org.apache.openjpa.event.AbstractTransactionListener;
|
||||
|
@ -35,13 +36,13 @@ public class TestBrokerFactoryListenerRegistry
|
|||
private int beginCount = 0;
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
public void setUp() {
|
||||
super.setUp(AllFieldTypes.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OpenJPAEntityManagerFactory createEMF(Object... props) {
|
||||
OpenJPAEntityManagerFactory emf = super.createEMF(props);
|
||||
protected OpenJPAEntityManagerFactorySPI createEMF(Object... props) {
|
||||
OpenJPAEntityManagerFactorySPI emf = super.createEMF(props);
|
||||
emf.addLifecycleListener(new AbstractLifecycleListener() {
|
||||
@Override
|
||||
public void beforePersist(LifecycleEvent event) {
|
||||
|
|
|
@ -26,9 +26,9 @@ import javax.persistence.Persistence;
|
|||
import org.apache.openjpa.kernel.QueryImpl.Compilation;
|
||||
import org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.ParsedJPQL;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAQuery;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.simple.NamedEntity;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -41,8 +41,9 @@ public class TestQueryCompilationCache
|
|||
Map props = new HashMap(System.getProperties());
|
||||
props.put("openjpa.MetaDataFactory", "jpa(Types="
|
||||
+ NamedEntity.class.getName() + ")");
|
||||
OpenJPAEntityManagerFactory emf = OpenJPAPersistence.cast(
|
||||
Persistence.createEntityManagerFactory("test", props));
|
||||
OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)
|
||||
OpenJPAPersistence.cast(
|
||||
Persistence.createEntityManagerFactory("test", props));
|
||||
|
||||
Map cache = emf.getConfiguration().getQueryCompilationCacheInstance();
|
||||
cache.clear();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.datacache;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
|
@ -26,6 +25,8 @@ import org.apache.openjpa.datacache.DataCache;
|
|||
import org.apache.openjpa.kernel.PCData;
|
||||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.StoreCacheImpl;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
|
||||
|
@ -54,17 +55,18 @@ public class TestArrayFieldsInDataCache
|
|||
// get the external and internal forms of the ID for cache
|
||||
// interrogation and data validation
|
||||
jpaOid = OpenJPAPersistence.cast(em).getObjectId(aft);
|
||||
internalOid = OpenJPAPersistence.toBroker(em).getObjectId(aft);
|
||||
internalOid = JPAFacadeHelper.toBroker(em).getObjectId(aft);
|
||||
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testArrayOfStrings() {
|
||||
// check that the data cache contains an efficient representation
|
||||
DataCache cache = OpenJPAPersistence.cast(emf).getStoreCache()
|
||||
.getDelegate();
|
||||
StoreCacheImpl storeCache = (StoreCacheImpl)
|
||||
OpenJPAPersistence.cast(emf).getStoreCache();
|
||||
DataCache cache = storeCache.getDelegate();
|
||||
PCData data = cache.get(internalOid);
|
||||
ClassMetaData meta = OpenJPAPersistence.getMetaData(emf,
|
||||
ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
|
||||
AllFieldTypes.class);
|
||||
Object cachedFieldData =
|
||||
data.getData(meta.getField("arrayOfStrings").getIndex());
|
||||
|
@ -82,10 +84,11 @@ public class TestArrayFieldsInDataCache
|
|||
|
||||
public void testArrayOfInts() {
|
||||
// check that the data cache contains an efficient representation
|
||||
DataCache cache = OpenJPAPersistence.cast(emf).getStoreCache()
|
||||
.getDelegate();
|
||||
StoreCacheImpl storeCache = (StoreCacheImpl)
|
||||
OpenJPAPersistence.cast(emf).getStoreCache();
|
||||
DataCache cache = storeCache.getDelegate();
|
||||
PCData data = cache.get(internalOid);
|
||||
ClassMetaData meta = OpenJPAPersistence.getMetaData(emf,
|
||||
ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
|
||||
AllFieldTypes.class);
|
||||
Object cachedFieldData =
|
||||
data.getData(meta.getField("arrayOfInts").getIndex());
|
||||
|
|
|
@ -24,7 +24,7 @@ import javax.persistence.OptimisticLockException;
|
|||
import javax.persistence.RollbackException;
|
||||
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||
import org.apache.openjpa.jdbc.meta.FieldMapping;
|
||||
|
@ -54,7 +54,7 @@ public class TestBulkUpdatesAndVersionColumn
|
|||
}
|
||||
|
||||
public void testOplockFieldMapping() {
|
||||
ClassMapping cm = (ClassMapping) OpenJPAPersistence.getMetaData(
|
||||
ClassMapping cm = (ClassMapping) JPAFacadeHelper.getMetaData(
|
||||
emf, OptimisticLockInstance.class);
|
||||
FieldMapping fm = cm.getFieldMapping("oplock");
|
||||
assertEquals(1, fm.getColumns().length);
|
||||
|
|
|
@ -27,6 +27,8 @@ import javax.persistence.LockModeType;
|
|||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
import org.apache.openjpa.event.RemoteCommitListener;
|
||||
import org.apache.openjpa.event.RemoteCommitEvent;
|
||||
|
@ -78,8 +80,8 @@ public class TestDataCacheOptimisticLockRecovery
|
|||
em = emf.createEntityManager();
|
||||
em.getTransaction().begin();
|
||||
OptimisticLockInstance oli = em.find(OptimisticLockInstance.class, pk);
|
||||
Object oid = OpenJPAPersistence.toOpenJPAObjectId(
|
||||
OpenJPAPersistence.getMetaData(oli),
|
||||
Object oid = JPAFacadeHelper.toOpenJPAObjectId(
|
||||
JPAFacadeHelper.getMetaData(oli),
|
||||
OpenJPAPersistence.cast(em).getObjectId(oli));
|
||||
int firstOpLockValue = oli.getOpLock();
|
||||
em.lock(oli, LockModeType.READ);
|
||||
|
@ -88,8 +90,9 @@ public class TestDataCacheOptimisticLockRecovery
|
|||
// via direct SQL in a separate transaction
|
||||
int secondOpLockValue = firstOpLockValue + 1;
|
||||
|
||||
DataSource ds = (DataSource) OpenJPAPersistence.cast(em)
|
||||
.getEntityManagerFactory().getConfiguration()
|
||||
OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)
|
||||
OpenJPAPersistence.cast(em).getEntityManagerFactory();
|
||||
DataSource ds = (DataSource) emf.getConfiguration()
|
||||
.getConnectionFactory();
|
||||
Connection c = ds.getConnection();
|
||||
c.setAutoCommit(false);
|
||||
|
@ -120,7 +123,7 @@ public class TestDataCacheOptimisticLockRecovery
|
|||
// assert that the oplock column is set to the one that
|
||||
// happened in the out-of-band transaction
|
||||
em.close();
|
||||
em = emf.createEntityManager();
|
||||
em = this.emf.createEntityManager();
|
||||
oli = em.find(OptimisticLockInstance.class, pk);
|
||||
|
||||
// If this fails, then the data cache has the wrong value.
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.apache.openjpa.persistence.detachment;
|
|||
import javax.persistence.EntityManager;
|
||||
|
||||
import junit.textui.TestRunner;
|
||||
import org.apache.openjpa.kernel.AutoDetach;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.AutoDetachType;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,8 @@ public class TestDetachmentOneMany
|
|||
long id = createParentAndChildren();
|
||||
|
||||
EntityManager em = emf.createEntityManager();
|
||||
OpenJPAPersistence.cast(em).setAutoDetach(AutoDetach.DETACH_NONTXREAD);
|
||||
OpenJPAPersistence.cast(em).setAutoDetach(
|
||||
AutoDetachType.NON_TRANSACTIONAL_READ);
|
||||
DetachmentOneManyParent parent = em.find(DetachmentOneManyParent.class,
|
||||
id);
|
||||
assertNotNull(parent);
|
||||
|
@ -53,7 +54,8 @@ public class TestDetachmentOneMany
|
|||
long id = createParentAndChildren();
|
||||
|
||||
EntityManager em = emf.createEntityManager();
|
||||
OpenJPAPersistence.cast(em).setAutoDetach(AutoDetach.DETACH_NONTXREAD);
|
||||
OpenJPAPersistence.cast(em).setAutoDetach(
|
||||
AutoDetachType.NON_TRANSACTIONAL_READ);
|
||||
DetachmentOneManyParent parent = em.find(DetachmentOneManyParent.class,
|
||||
id);
|
||||
assertNotNull(parent);
|
||||
|
@ -74,7 +76,8 @@ public class TestDetachmentOneMany
|
|||
long id = createParentAndChildren();
|
||||
|
||||
EntityManager em = emf.createEntityManager();
|
||||
OpenJPAPersistence.cast(em).setAutoDetach(AutoDetach.DETACH_NONTXREAD);
|
||||
OpenJPAPersistence.cast(em).setAutoDetach(
|
||||
AutoDetachType.NON_TRANSACTIONAL_READ);
|
||||
DetachmentOneManyParent parent = em.find(DetachmentOneManyParent.class,
|
||||
id);
|
||||
assertNotNull(parent);
|
||||
|
|
|
@ -23,7 +23,6 @@ import javax.persistence.EntityManager;
|
|||
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||
import org.apache.openjpa.jdbc.meta.Discriminator;
|
||||
import org.apache.openjpa.meta.JavaTypes;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
|
||||
public class TestDiscriminatorTypes extends SingleEMFTestCase {
|
||||
|
@ -93,7 +92,7 @@ public class TestDiscriminatorTypes extends SingleEMFTestCase {
|
|||
}
|
||||
|
||||
private ClassMapping getMapping(String name) {
|
||||
return (ClassMapping) OpenJPAPersistence.cast(emf).getConfiguration()
|
||||
return (ClassMapping) emf.getConfiguration()
|
||||
.getMetaDataRepositoryInstance().getMetaData(name,
|
||||
getClass().getClassLoader(), true);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,9 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.fields;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||
|
||||
public class TestPersistentMapTableConfiguration
|
||||
|
@ -33,7 +31,7 @@ public class TestPersistentMapTableConfiguration
|
|||
}
|
||||
|
||||
public void testPersistentMapMetaData() {
|
||||
ClassMapping cm = (ClassMapping) OpenJPAPersistence.getMetaData(emf,
|
||||
ClassMapping cm = (ClassMapping) JPAFacadeHelper.getMetaData(emf,
|
||||
NonstandardMappingEntity.class);
|
||||
assertEquals("NONSTD_MAPPING_MAP",
|
||||
cm.getFieldMapping("map").getTable().getName());
|
||||
|
|
|
@ -22,10 +22,9 @@ import javax.persistence.Query;
|
|||
|
||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAQuery;
|
||||
import org.apache.openjpa.persistence.InvalidStateException;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
||||
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
||||
import org.apache.openjpa.jdbc.sql.DB2Dictionary;
|
||||
import org.apache.openjpa.jdbc.sql.HSQLDictionary;
|
||||
|
@ -54,8 +53,7 @@ public class TestIsolationLevelOverride
|
|||
|
||||
public void testIsolationLevelOverride(boolean useHintsAndQueries,
|
||||
boolean useStringHints) {
|
||||
OpenJPAEntityManager em =
|
||||
OpenJPAPersistence.cast(emf.createEntityManager());
|
||||
OpenJPAEntityManagerSPI em = emf.createEntityManager();
|
||||
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
||||
.getDBDictionaryInstance();
|
||||
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
|
||||
import org.apache.openjpa.jdbc.kernel.LRSSizes;
|
||||
import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
|
||||
|
||||
public class TestJDBCEnumToKernelConstantMappings
|
||||
extends TestCase {
|
||||
|
||||
public void testEagerFetchModes() {
|
||||
assertEquals(EagerFetchModes.EAGER_NONE,
|
||||
EagerFetchType.NONE.toKernelConstant());
|
||||
assertEquals(EagerFetchType.NONE,
|
||||
EagerFetchType.fromKernelConstant(
|
||||
EagerFetchModes.EAGER_NONE));
|
||||
assertEquals(EagerFetchType.NONE.toKernelConstant(),
|
||||
EagerFetchType.NONE.ordinal());
|
||||
|
||||
assertEquals(EagerFetchModes.EAGER_JOIN,
|
||||
EagerFetchType.JOIN.toKernelConstant());
|
||||
assertEquals(EagerFetchType.JOIN,
|
||||
EagerFetchType.fromKernelConstant(
|
||||
EagerFetchModes.EAGER_JOIN));
|
||||
assertEquals(EagerFetchType.JOIN.toKernelConstant(),
|
||||
EagerFetchType.JOIN.ordinal());
|
||||
|
||||
assertEquals(EagerFetchModes.EAGER_PARALLEL,
|
||||
EagerFetchType.PARALLEL.toKernelConstant());
|
||||
assertEquals(EagerFetchType.PARALLEL,
|
||||
EagerFetchType.fromKernelConstant(
|
||||
EagerFetchModes.EAGER_PARALLEL));
|
||||
assertEquals(EagerFetchType.PARALLEL.toKernelConstant(),
|
||||
EagerFetchType.PARALLEL.ordinal());
|
||||
|
||||
assertEquals(getConstantCount(EagerFetchModes.class),
|
||||
EagerFetchType.values().length);
|
||||
}
|
||||
|
||||
public void testLRSSizeType() {
|
||||
assertEquals(LRSSizes.SIZE_UNKNOWN,
|
||||
LRSSizeType.UNKNOWN.toKernelConstant());
|
||||
assertEquals(LRSSizeType.UNKNOWN,
|
||||
LRSSizeType.fromKernelConstant(
|
||||
LRSSizes.SIZE_UNKNOWN));
|
||||
assertEquals(LRSSizeType.UNKNOWN.toKernelConstant(),
|
||||
LRSSizeType.UNKNOWN.ordinal());
|
||||
|
||||
assertEquals(LRSSizes.SIZE_LAST,
|
||||
LRSSizeType.LAST.toKernelConstant());
|
||||
assertEquals(LRSSizeType.LAST,
|
||||
LRSSizeType.fromKernelConstant(
|
||||
LRSSizes.SIZE_LAST));
|
||||
assertEquals(LRSSizeType.LAST.toKernelConstant(),
|
||||
LRSSizeType.LAST.ordinal());
|
||||
|
||||
assertEquals(LRSSizes.SIZE_QUERY,
|
||||
LRSSizeType.QUERY.toKernelConstant());
|
||||
assertEquals(LRSSizeType.QUERY,
|
||||
LRSSizeType.fromKernelConstant(
|
||||
LRSSizes.SIZE_QUERY));
|
||||
assertEquals(LRSSizeType.QUERY.toKernelConstant(),
|
||||
LRSSizeType.QUERY.ordinal());
|
||||
|
||||
assertEquals(getConstantCount(LRSSizes.class),
|
||||
LRSSizeType.values().length);
|
||||
}
|
||||
|
||||
public void testJoinSyntaxType() {
|
||||
assertEquals(JoinSyntaxes.SYNTAX_SQL92,
|
||||
JoinSyntaxType.SQL92.toKernelConstant());
|
||||
assertEquals(JoinSyntaxType.SQL92,
|
||||
JoinSyntaxType.fromKernelConstant(
|
||||
JoinSyntaxes.SYNTAX_SQL92));
|
||||
assertEquals(JoinSyntaxType.SQL92.toKernelConstant(),
|
||||
JoinSyntaxType.SQL92.ordinal());
|
||||
|
||||
assertEquals(JoinSyntaxes.SYNTAX_TRADITIONAL,
|
||||
JoinSyntaxType.TRADITIONAL.toKernelConstant());
|
||||
assertEquals(JoinSyntaxType.TRADITIONAL,
|
||||
JoinSyntaxType.fromKernelConstant(
|
||||
JoinSyntaxes.SYNTAX_TRADITIONAL));
|
||||
assertEquals(JoinSyntaxType.TRADITIONAL.toKernelConstant(),
|
||||
JoinSyntaxType.TRADITIONAL.ordinal());
|
||||
|
||||
assertEquals(JoinSyntaxes.SYNTAX_DATABASE,
|
||||
JoinSyntaxType.DATABASE.toKernelConstant());
|
||||
assertEquals(JoinSyntaxType.DATABASE,
|
||||
JoinSyntaxType.fromKernelConstant(
|
||||
JoinSyntaxes.SYNTAX_DATABASE));
|
||||
assertEquals(JoinSyntaxType.DATABASE.toKernelConstant(),
|
||||
JoinSyntaxType.DATABASE.ordinal());
|
||||
|
||||
assertEquals(getConstantCount(JoinSyntaxes.class),
|
||||
JoinSyntaxType.values().length);
|
||||
}
|
||||
|
||||
private int getConstantCount(Class cls) {
|
||||
return cls.getDeclaredFields().length;
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import org.apache.openjpa.persistence.OpenJPAPersistence;
|
|||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAQuery;
|
||||
import org.apache.openjpa.persistence.InvalidStateException;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
||||
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
||||
import org.apache.openjpa.jdbc.sql.DB2Dictionary;
|
||||
import org.apache.openjpa.jdbc.sql.HSQLDictionary;
|
||||
|
@ -50,8 +51,7 @@ public class TestOptimizeForClause
|
|||
}
|
||||
public void testOptimizeForClause(boolean hint,
|
||||
boolean find, boolean queryHint) {
|
||||
OpenJPAEntityManager em =
|
||||
OpenJPAPersistence.cast(emf.createEntityManager());
|
||||
OpenJPAEntityManagerSPI em = emf.createEntityManager();
|
||||
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
||||
.getDBDictionaryInstance();
|
||||
|
||||
|
|
|
@ -18,14 +18,12 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.LockModeType;
|
||||
|
||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.FetchPlan;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
||||
import org.apache.openjpa.jdbc.sql.DB2Dictionary;
|
||||
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
||||
import org.apache.openjpa.jdbc.sql.HSQLDictionary;
|
||||
|
@ -42,7 +40,7 @@ public class TestSelectForUpdateOverride
|
|||
}
|
||||
|
||||
public void testSelectForUpdateOverride() {
|
||||
OpenJPAEntityManager em =
|
||||
OpenJPAEntityManagerSPI em = (OpenJPAEntityManagerSPI)
|
||||
OpenJPAPersistence.cast(emf.createEntityManager());
|
||||
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
||||
.getDBDictionaryInstance();
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.openjpa.persistence.simple;
|
||||
|
||||
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
|
||||
public class TestTableNamesDefaultToEntityNames
|
||||
|
@ -30,7 +30,7 @@ public class TestTableNamesDefaultToEntityNames
|
|||
}
|
||||
|
||||
public void testEntityNames() {
|
||||
ClassMapping cm = (ClassMapping) OpenJPAPersistence.getMetaData(
|
||||
ClassMapping cm = (ClassMapping) JPAFacadeHelper.getMetaData(
|
||||
emf, NamedEntity.class);
|
||||
assertEquals("named", cm.getTable().getName());
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ import junit.framework.TestCase;
|
|||
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
||||
import org.apache.openjpa.kernel.Broker;
|
||||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
|
||||
/**
|
||||
* Base test class providing persistence utilities.
|
||||
|
@ -55,7 +55,7 @@ public abstract class PersistenceTestCase
|
|||
* @param props list of persistent types used in testing and/or
|
||||
* configuration values in the form key,value,key,value...
|
||||
*/
|
||||
protected OpenJPAEntityManagerFactory createEMF(Object... props) {
|
||||
protected OpenJPAEntityManagerFactorySPI createEMF(Object... props) {
|
||||
Map map = new HashMap(System.getProperties());
|
||||
List<Class> types = new ArrayList<Class>();
|
||||
boolean prop = false;
|
||||
|
@ -84,7 +84,7 @@ public abstract class PersistenceTestCase
|
|||
"jpa(Types=" + buf.toString() + ")");
|
||||
}
|
||||
|
||||
return (OpenJPAEntityManagerFactory) Persistence.
|
||||
return (OpenJPAEntityManagerFactorySPI) Persistence.
|
||||
createEntityManagerFactory("test", map);
|
||||
}
|
||||
|
||||
|
@ -97,12 +97,12 @@ public abstract class PersistenceTestCase
|
|||
if (!emf.isOpen())
|
||||
return false;
|
||||
|
||||
for (Iterator iter = ((AbstractBrokerFactory) OpenJPAPersistence
|
||||
for (Iterator iter = ((AbstractBrokerFactory) JPAFacadeHelper
|
||||
.toBrokerFactory(emf)).getOpenBrokers().iterator();
|
||||
iter.hasNext(); ) {
|
||||
Broker b = (Broker) iter.next();
|
||||
if (b != null && !b.isClosed()) {
|
||||
EntityManager em = OpenJPAPersistence.toEntityManager(b);
|
||||
EntityManager em = JPAFacadeHelper.toEntityManager(b);
|
||||
if (em.getTransaction().isActive())
|
||||
em.getTransaction().rollback();
|
||||
em.close();
|
||||
|
@ -122,7 +122,7 @@ public abstract class PersistenceTestCase
|
|||
|
||||
List<ClassMetaData> metas = new ArrayList<ClassMetaData>(types.length);
|
||||
for (Class c : types) {
|
||||
ClassMetaData meta = OpenJPAPersistence.getMetaData(emf, c);
|
||||
ClassMetaData meta = JPAFacadeHelper.getMetaData(emf, c);
|
||||
if (meta != null)
|
||||
metas.add(meta);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public abstract class PersistenceTestCase
|
|||
protected void clear(EntityManagerFactory emf) {
|
||||
if (emf == null)
|
||||
return;
|
||||
clear(emf, ((OpenJPAEntityManagerFactory) emf).getConfiguration().
|
||||
clear(emf, ((OpenJPAEntityManagerFactorySPI) emf).getConfiguration().
|
||||
getMetaDataRepositoryInstance().getMetaDatas());
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ public abstract class PersistenceTestCase
|
|||
* Return the entity name for the given type.
|
||||
*/
|
||||
protected String entityName(EntityManagerFactory emf, Class c) {
|
||||
ClassMetaData meta = OpenJPAPersistence.getMetaData(emf, c);
|
||||
ClassMetaData meta = JPAFacadeHelper.getMetaData(emf, c);
|
||||
return (meta == null) ? null : meta.getTypeAlias();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,17 +18,21 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import javax.persistence.Persistence;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
|
||||
public abstract class SingleEMFTestCase
|
||||
extends PersistenceTestCase {
|
||||
|
||||
protected OpenJPAEntityManagerFactory emf;
|
||||
protected OpenJPAEntityManagerFactorySPI emf;
|
||||
|
||||
/**
|
||||
* Call {@link #setUp(Object...)} with no arguments so that the emf
|
||||
* set-up happens even if <code>setUp()</code> is not called from the
|
||||
* subclass.
|
||||
*/
|
||||
protected void setUp() {
|
||||
setUp(new Object[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize entity manager factory. Put {@link #CLEAR_TABLES} in
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.apache.openjpa.jdbc.sql.SQLServerDictionary;
|
|||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||
import org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress.*;
|
||||
import org.apache.openjpa.persistence.xmlmapping.entities.*;
|
||||
|
@ -52,7 +54,7 @@ public class TestXMLCustomerOrder
|
|||
private boolean enabled = false;
|
||||
|
||||
public void setUp() {
|
||||
OpenJPAEntityManagerFactory emf = createEMF();
|
||||
OpenJPAEntityManagerFactorySPI emf = createEMF();
|
||||
DBDictionary dict = ((JDBCConfiguration) emf.getConfiguration())
|
||||
.getDBDictionaryInstance();
|
||||
|
||||
|
@ -79,8 +81,7 @@ public class TestXMLCustomerOrder
|
|||
if (!enabled)
|
||||
return;
|
||||
|
||||
OpenJPAEntityManager em =
|
||||
OpenJPAPersistence.cast(emf.createEntityManager());
|
||||
OpenJPAEntityManagerSPI em = emf.createEntityManager();
|
||||
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
||||
.getDBDictionaryInstance();
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
*
|
||||
* @author Gokhan Ergul
|
||||
* @since 1.0.0
|
||||
* @nojavadoc
|
||||
*/
|
||||
public class AnnotationBuilder {
|
||||
|
||||
|
@ -155,46 +156,45 @@ public class AnnotationBuilder {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
class AnnotationEntry {
|
||||
|
||||
class AnnotationEntry {
|
||||
String key;
|
||||
Object value;
|
||||
|
||||
String key;
|
||||
Object value;
|
||||
|
||||
AnnotationEntry(String key, Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void toString(StringBuilder sb) {
|
||||
if (null != key)
|
||||
sb.append(key).append("=");
|
||||
|
||||
List.class.getTypeParameters();
|
||||
if (value instanceof List) {
|
||||
sb.append("{");
|
||||
List<AnnotationBuilder> l = (List<AnnotationBuilder>) value;
|
||||
for (Iterator<AnnotationBuilder> i = l.iterator(); i.hasNext();) {
|
||||
AnnotationBuilder ab = i.next();
|
||||
sb.append(ab.toString());
|
||||
if (i.hasNext())
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("}");
|
||||
} else if (value instanceof Class) {
|
||||
String cls = ((Class) value).getName().replace('$', '.');
|
||||
sb.append(cls).append(".class");
|
||||
} else if (value instanceof String) {
|
||||
sb.append('"').append(value).append('"');
|
||||
} else if (value instanceof Enum) {
|
||||
sb.append(AnnotationBuilder.enumToString((Enum) value));
|
||||
} else if (value instanceof EnumSet) {
|
||||
sb.append(AnnotationBuilder.enumSetToString((EnumSet) value));
|
||||
} else {
|
||||
sb.append(value);
|
||||
AnnotationEntry(String key, Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
void toString(StringBuilder sb) {
|
||||
if (null != key)
|
||||
sb.append(key).append("=");
|
||||
|
||||
List.class.getTypeParameters();
|
||||
if (value instanceof List) {
|
||||
sb.append("{");
|
||||
List<AnnotationBuilder> l = (List<AnnotationBuilder>) value;
|
||||
for (Iterator<AnnotationBuilder> i = l.iterator(); i.hasNext();) {
|
||||
AnnotationBuilder ab = i.next();
|
||||
sb.append(ab.toString());
|
||||
if (i.hasNext())
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("}");
|
||||
} else if (value instanceof Class) {
|
||||
String cls = ((Class) value).getName().replace('$', '.');
|
||||
sb.append(cls).append(".class");
|
||||
} else if (value instanceof String) {
|
||||
sb.append('"').append(value).append('"');
|
||||
} else if (value instanceof Enum) {
|
||||
sb.append(AnnotationBuilder.enumToString((Enum) value));
|
||||
} else if (value instanceof EnumSet) {
|
||||
sb.append(AnnotationBuilder.enumSetToString((EnumSet) value));
|
||||
} else {
|
||||
sb.append(value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence;
|
||||
|
||||
import org.apache.openjpa.kernel.AutoClear;
|
||||
|
||||
/**
|
||||
* The possible settings for the auto-clear behavior of an
|
||||
* {@link OpenJPAEntityManager}.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @published
|
||||
*/
|
||||
public enum AutoClearType {
|
||||
DATASTORE(AutoClear.CLEAR_DATASTORE),
|
||||
ALL(AutoClear.CLEAR_ALL);
|
||||
|
||||
private final int autoClearConstant;
|
||||
|
||||
private AutoClearType(int value) {
|
||||
autoClearConstant = value;
|
||||
}
|
||||
|
||||
int toKernelConstant() {
|
||||
return autoClearConstant;
|
||||
}
|
||||
|
||||
static AutoClearType fromKernelConstant(int kernelConstant) {
|
||||
switch (kernelConstant) {
|
||||
case AutoClear.CLEAR_DATASTORE:
|
||||
return DATASTORE;
|
||||
|
||||
case AutoClear.CLEAR_ALL:
|
||||
return ALL;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(kernelConstant + "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.apache.openjpa.kernel.AutoDetach;
|
||||
|
||||
/**
|
||||
* The possible settings for the auto-detach behavior of an
|
||||
* {@link OpenJPAEntityManager}.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @published
|
||||
*/
|
||||
public enum AutoDetachType {
|
||||
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_CLOSE) != 0)
|
||||
types.add(CLOSE);
|
||||
if ((autoDetach & AutoDetach.DETACH_COMMIT) != 0)
|
||||
types.add(COMMIT);
|
||||
if ((autoDetach & AutoDetach.DETACH_NONTXREAD) != 0)
|
||||
types.add(NON_TRANSACTIONAL_READ);
|
||||
if ((autoDetach & AutoDetach.DETACH_ROLLBACK) != 0)
|
||||
types.add(ROLLBACK);
|
||||
return types;
|
||||
}
|
||||
|
||||
public static int fromEnumSet(EnumSet<AutoDetachType> types) {
|
||||
int autoDetach = 0;
|
||||
for (AutoDetachType type : types)
|
||||
autoDetach |= type.autoDetachConstant;
|
||||
return autoDetach;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.apache.openjpa.event.CallbackModes;
|
||||
|
||||
/**
|
||||
* The possible settings for the callback behavior of an
|
||||
* {@link OpenJPAEntityManager}.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @published
|
||||
*/
|
||||
public enum CallbackType {
|
||||
FAIL_FAST(CallbackModes.CALLBACK_FAIL_FAST),
|
||||
IGNORE(CallbackModes.CALLBACK_IGNORE),
|
||||
LOG(CallbackModes.CALLBACK_LOG),
|
||||
RETHROW(CallbackModes.CALLBACK_RETHROW),
|
||||
ROLLBACK(CallbackModes.CALLBACK_ROLLBACK);
|
||||
|
||||
private final int callbackMode;
|
||||
|
||||
private CallbackType(int value) {
|
||||
callbackMode = value;
|
||||
}
|
||||
|
||||
public static EnumSet<CallbackType> toEnumSet(int callback) {
|
||||
EnumSet<CallbackType> types = EnumSet.noneOf(CallbackType.class);
|
||||
if ((callback & CallbackModes.CALLBACK_FAIL_FAST) != 0)
|
||||
types.add(FAIL_FAST);
|
||||
if ((callback & CallbackModes.CALLBACK_IGNORE) != 0)
|
||||
types.add(IGNORE);
|
||||
if ((callback & CallbackModes.CALLBACK_LOG) != 0)
|
||||
types.add(LOG);
|
||||
if ((callback & CallbackModes.CALLBACK_RETHROW) != 0)
|
||||
types.add(RETHROW);
|
||||
if ((callback & CallbackModes.CALLBACK_ROLLBACK) != 0)
|
||||
types.add(ROLLBACK);
|
||||
return types;
|
||||
}
|
||||
|
||||
public static int fromEnumSet(EnumSet<CallbackType> types) {
|
||||
int callback = 0;
|
||||
for (CallbackType type : types)
|
||||
callback |= type.callbackMode;
|
||||
return callback;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence;
|
||||
|
||||
import org.apache.openjpa.kernel.ConnectionRetainModes;
|
||||
|
||||
/**
|
||||
* The possible values for use when configuring the connection retain
|
||||
* behavior for an {@link OpenJPAEntityManager}.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @published
|
||||
*/
|
||||
public enum ConnectionRetainType {
|
||||
ON_DEMAND(ConnectionRetainModes.CONN_RETAIN_DEMAND),
|
||||
TRANSACTION(ConnectionRetainModes.CONN_RETAIN_TRANS),
|
||||
ALWAYS(ConnectionRetainModes.CONN_RETAIN_ALWAYS);
|
||||
|
||||
private final int connectionRetainConstant;
|
||||
|
||||
private ConnectionRetainType(int value) {
|
||||
connectionRetainConstant = value;
|
||||
}
|
||||
|
||||
int toKernelConstant() {
|
||||
return connectionRetainConstant;
|
||||
}
|
||||
|
||||
static ConnectionRetainType fromKernelConstant(int kernelConstant) {
|
||||
switch (kernelConstant) {
|
||||
case ConnectionRetainModes.CONN_RETAIN_DEMAND:
|
||||
return ON_DEMAND;
|
||||
|
||||
case ConnectionRetainModes.CONN_RETAIN_ALWAYS:
|
||||
return ALWAYS;
|
||||
|
||||
case ConnectionRetainModes.CONN_RETAIN_TRANS:
|
||||
return TRANSACTION;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(kernelConstant + "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import javax.persistence.GenerationType;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence;
|
||||
|
||||
import org.apache.openjpa.kernel.DetachState;
|
||||
|
||||
/**
|
||||
* The possible settings for the detachment behavior of an
|
||||
* {@link OpenJPAEntityManager}.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @published
|
||||
*/
|
||||
public enum DetachStateType {
|
||||
FETCH_GROUPS(DetachState.DETACH_FETCH_GROUPS),
|
||||
LOADED(DetachState.DETACH_LOADED),
|
||||
ALL(DetachState.DETACH_ALL);
|
||||
|
||||
private final int detachStateConstant;
|
||||
|
||||
private DetachStateType(int value) {
|
||||
detachStateConstant = value;
|
||||
}
|
||||
|
||||
int toKernelConstant() {
|
||||
return detachStateConstant;
|
||||
}
|
||||
|
||||
static DetachStateType fromKernelConstant(int kernelConstant) {
|
||||
switch (kernelConstant) {
|
||||
case DetachState.DETACH_FETCH_GROUPS:
|
||||
return FETCH_GROUPS;
|
||||
|
||||
case DetachState.DETACH_LOADED:
|
||||
return LOADED;
|
||||
|
||||
case DetachState.DETACH_ALL:
|
||||
return ALL;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(kernelConstant + "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.openjpa.lib.conf.Configurations;
|
|||
import org.apache.openjpa.lib.conf.ProductDerivations;
|
||||
import org.apache.openjpa.lib.conf.Value;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.lib.util.Closeable;
|
||||
import org.apache.openjpa.util.OpenJPAException;
|
||||
import serp.util.Strings;
|
||||
|
||||
|
@ -53,7 +54,8 @@ import serp.util.Strings;
|
|||
* @nojavadoc
|
||||
*/
|
||||
public class EntityManagerFactoryImpl
|
||||
implements OpenJPAEntityManagerFactory {
|
||||
implements OpenJPAEntityManagerFactory, OpenJPAEntityManagerFactorySPI,
|
||||
Closeable {
|
||||
|
||||
private static final Localizer _loc = Localizer.forPackage
|
||||
(EntityManagerFactoryImpl.class);
|
||||
|
@ -139,11 +141,11 @@ public class EntityManagerFactoryImpl
|
|||
}
|
||||
}
|
||||
|
||||
public OpenJPAEntityManager createEntityManager() {
|
||||
public OpenJPAEntityManagerSPI createEntityManager() {
|
||||
return createEntityManager(null);
|
||||
}
|
||||
|
||||
public OpenJPAEntityManager createEntityManager(Map props) {
|
||||
public OpenJPAEntityManagerSPI createEntityManager(Map props) {
|
||||
if (props == null)
|
||||
props = Collections.EMPTY_MAP;
|
||||
else if (!props.isEmpty())
|
||||
|
@ -195,12 +197,12 @@ public class EntityManagerFactoryImpl
|
|||
broker.setAutoDetach(AutoDetach.DETACH_ROLLBACK, true);
|
||||
|
||||
broker.setDetachedNew(false);
|
||||
OpenJPAEntityManager em = newEntityManagerImpl(broker);
|
||||
OpenJPAEntityManagerSPI em = newEntityManagerImpl(broker);
|
||||
|
||||
// allow setting of other bean properties of EM
|
||||
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
|
||||
List<RuntimeException> errs = null;
|
||||
Method setter = null;
|
||||
Method setter;
|
||||
String prop, prefix;
|
||||
Object val;
|
||||
for (Map.Entry entry : (Set<Map.Entry>) props.entrySet()) {
|
||||
|
@ -251,7 +253,7 @@ public class EntityManagerFactoryImpl
|
|||
if (errs.size() == 1)
|
||||
throw errs.get(0);
|
||||
throw new ArgumentException(_loc.get("bad-em-props"),
|
||||
(Throwable[]) errs.toArray(new Throwable[errs.size()]),
|
||||
errs.toArray(new Throwable[errs.size()]),
|
||||
null, true);
|
||||
}
|
||||
return em;
|
||||
|
@ -308,9 +310,8 @@ public class EntityManagerFactoryImpl
|
|||
if (fetch == null)
|
||||
return null;
|
||||
|
||||
FetchConfiguration inner = fetch;
|
||||
if (inner instanceof DelegatingFetchConfiguration)
|
||||
inner = ((DelegatingFetchConfiguration) inner).
|
||||
if (fetch instanceof DelegatingFetchConfiguration)
|
||||
fetch = ((DelegatingFetchConfiguration) fetch).
|
||||
getInnermostDelegate();
|
||||
|
||||
try {
|
||||
|
|
|
@ -21,16 +21,11 @@ package org.apache.openjpa.persistence;
|
|||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityTransaction;
|
||||
import javax.persistence.FlushModeType;
|
||||
import javax.persistence.LockModeType;
|
||||
import javax.persistence.Query;
|
||||
import javax.resource.ResourceException;
|
||||
import javax.resource.cci.ConnectionMetaData;
|
||||
import javax.resource.cci.Interaction;
|
||||
import javax.resource.cci.LocalTransaction;
|
||||
import javax.resource.cci.ResultSetInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
|
@ -46,6 +41,7 @@ import org.apache.openjpa.kernel.QueryLanguages;
|
|||
import org.apache.openjpa.kernel.Seq;
|
||||
import org.apache.openjpa.kernel.jpql.JPQLParser;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.lib.util.Closeable;
|
||||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
import org.apache.openjpa.meta.FieldMetaData;
|
||||
import org.apache.openjpa.meta.QueryMetaData;
|
||||
|
@ -63,7 +59,8 @@ import org.apache.openjpa.util.UserException;
|
|||
* @nojavadoc
|
||||
*/
|
||||
public class EntityManagerImpl
|
||||
implements OpenJPAEntityManager, FindCallbacks, OpCallbacks {
|
||||
implements OpenJPAEntityManagerSPI,
|
||||
FindCallbacks, OpCallbacks, Closeable, OpenJPAEntityTransaction {
|
||||
|
||||
private static final Localizer _loc = Localizer.forPackage
|
||||
(EntityManagerImpl.class);
|
||||
|
@ -71,6 +68,7 @@ public class EntityManagerImpl
|
|||
private final DelegatingBroker _broker;
|
||||
private final EntityManagerFactoryImpl _emf;
|
||||
private FetchPlan _fetch = null;
|
||||
private static final Object[] EMPTY_OBJECTS = new Object[0];
|
||||
|
||||
/**
|
||||
* Constructor; supply factory and delegate.
|
||||
|
@ -91,27 +89,6 @@ public class EntityManagerImpl
|
|||
return _broker.getDelegate();
|
||||
}
|
||||
|
||||
public ConnectionMetaData getMetaData()
|
||||
throws ResourceException {
|
||||
return _broker.getMetaData();
|
||||
}
|
||||
|
||||
public Interaction createInteraction()
|
||||
throws ResourceException {
|
||||
assertNotCloseInvoked();
|
||||
return _broker.createInteraction();
|
||||
}
|
||||
|
||||
public LocalTransaction getLocalTransaction()
|
||||
throws ResourceException {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultSetInfo getResultSetInfo()
|
||||
throws ResourceException {
|
||||
return _broker.getResultSetInfo();
|
||||
}
|
||||
|
||||
public OpenJPAEntityManagerFactory getEntityManagerFactory() {
|
||||
return _emf;
|
||||
}
|
||||
|
@ -133,8 +110,9 @@ public class EntityManagerImpl
|
|||
}
|
||||
}
|
||||
|
||||
public int getConnectionRetainMode() {
|
||||
return _broker.getConnectionRetainMode();
|
||||
public ConnectionRetainType getConnectionRetainMode() {
|
||||
return ConnectionRetainType.fromKernelConstant(
|
||||
_broker.getConnectionRetainMode());
|
||||
}
|
||||
|
||||
public boolean isManaged() {
|
||||
|
@ -211,13 +189,13 @@ public class EntityManagerImpl
|
|||
_broker.setOptimistic(val);
|
||||
}
|
||||
|
||||
public int getRestoreState() {
|
||||
return _broker.getRestoreState();
|
||||
public RestoreStateType getRestoreState() {
|
||||
return RestoreStateType.fromKernelConstant(_broker.getRestoreState());
|
||||
}
|
||||
|
||||
public void setRestoreState(int val) {
|
||||
public void setRestoreState(RestoreStateType val) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setRestoreState(val);
|
||||
_broker.setRestoreState(val.toKernelConstant());
|
||||
}
|
||||
|
||||
public boolean getRetainState() {
|
||||
|
@ -229,31 +207,36 @@ public class EntityManagerImpl
|
|||
_broker.setRetainState(val);
|
||||
}
|
||||
|
||||
public int getAutoClear() {
|
||||
return _broker.getAutoClear();
|
||||
public AutoClearType getAutoClear() {
|
||||
return AutoClearType.fromKernelConstant(_broker.getAutoClear());
|
||||
}
|
||||
|
||||
public void setAutoClear(int val) {
|
||||
public void setAutoClear(AutoClearType val) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setAutoClear(val);
|
||||
_broker.setAutoClear(val.toKernelConstant());
|
||||
}
|
||||
|
||||
public int getDetachState() {
|
||||
return _broker.getDetachState();
|
||||
public DetachStateType getDetachState() {
|
||||
return DetachStateType.fromKernelConstant(_broker.getDetachState());
|
||||
}
|
||||
|
||||
public void setDetachState(int mode) {
|
||||
public void setDetachState(DetachStateType type) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setDetachState(mode);
|
||||
_broker.setDetachState(type.toKernelConstant());
|
||||
}
|
||||
|
||||
public int getAutoDetach() {
|
||||
return _broker.getAutoDetach();
|
||||
public EnumSet<AutoDetachType> getAutoDetach() {
|
||||
return AutoDetachType.toEnumSet(_broker.getAutoDetach());
|
||||
}
|
||||
|
||||
public void setAutoDetach(int flags) {
|
||||
public void setAutoDetach(AutoDetachType flag) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setAutoDetach(flags);
|
||||
_broker.setAutoDetach(AutoDetachType.fromEnumSet(EnumSet.of(flag)));
|
||||
}
|
||||
|
||||
public void setAutoDetach(EnumSet<AutoDetachType> flags) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setAutoDetach(AutoDetachType.fromEnumSet(flags));
|
||||
}
|
||||
|
||||
public void setAutoDetach(int flag, boolean on) {
|
||||
|
@ -279,13 +262,13 @@ public class EntityManagerImpl
|
|||
_broker.setPopulateDataCache(cache);
|
||||
}
|
||||
|
||||
public boolean isLargeTransaction() {
|
||||
return _broker.isLargeTransaction();
|
||||
public boolean isTrackChangesByType() {
|
||||
return _broker.isTrackChangesByType();
|
||||
}
|
||||
|
||||
public void setLargeTransaction(boolean largeTransaction) {
|
||||
public void setTrackChangesByType(boolean trackByType) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setLargeTransaction(largeTransaction);
|
||||
_broker.setTrackChangesByType(trackByType);
|
||||
}
|
||||
|
||||
public Object getUserObject(Object key) {
|
||||
|
@ -307,13 +290,21 @@ public class EntityManagerImpl
|
|||
_broker.removeTransactionListener(listener);
|
||||
}
|
||||
|
||||
public int getTransactionListenerCallbackMode() {
|
||||
return _broker.getTransactionListenerCallbackMode();
|
||||
public EnumSet<CallbackType> getTransactionListenerCallbackMode() {
|
||||
return CallbackType.toEnumSet(
|
||||
_broker.getTransactionListenerCallbackMode());
|
||||
}
|
||||
|
||||
public void setTransactionListenerCallbackMode(int mode) {
|
||||
public void setTransactionListenerCallbackMode(CallbackType type) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setTransactionListenerCallbackMode(mode);
|
||||
_broker.setTransactionListenerCallbackMode(
|
||||
CallbackType.fromEnumSet(EnumSet.of(type)));
|
||||
}
|
||||
|
||||
public void setTransactionListenerCallbackMode(EnumSet<CallbackType> types){
|
||||
assertNotCloseInvoked();
|
||||
_broker.setTransactionListenerCallbackMode(
|
||||
CallbackType.fromEnumSet(types));
|
||||
}
|
||||
|
||||
public void addLifecycleListener(Object listener, Class... classes) {
|
||||
|
@ -326,13 +317,21 @@ public class EntityManagerImpl
|
|||
_broker.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
public int getLifecycleListenerCallbackMode() {
|
||||
return _broker.getLifecycleListenerCallbackMode();
|
||||
public EnumSet<CallbackType> getLifecycleListenerCallbackMode() {
|
||||
return CallbackType.toEnumSet(
|
||||
_broker.getLifecycleListenerCallbackMode());
|
||||
}
|
||||
|
||||
public void setLifecycleListenerCallbackMode(int mode) {
|
||||
public void setLifecycleListenerCallbackMode(CallbackType type) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setLifecycleListenerCallbackMode(mode);
|
||||
_broker.setLifecycleListenerCallbackMode(
|
||||
CallbackType.fromEnumSet(EnumSet.of(type)));
|
||||
}
|
||||
|
||||
public void setLifecycleListenerCallbackMode(EnumSet<CallbackType> types) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.setLifecycleListenerCallbackMode(
|
||||
CallbackType.fromEnumSet(types));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -382,11 +381,11 @@ public class EntityManagerImpl
|
|||
assertNotCloseInvoked();
|
||||
if (cls == null)
|
||||
return null;
|
||||
return OpenJPAPersistence.fromOpenJPAObjectIdClass
|
||||
return JPAFacadeHelper.fromOpenJPAObjectIdClass
|
||||
(_broker.getObjectIdType(cls));
|
||||
}
|
||||
|
||||
public EntityTransaction getTransaction() {
|
||||
public OpenJPAEntityTransaction getTransaction() {
|
||||
if (_broker.isManaged())
|
||||
throw new InvalidStateException(_loc.get("get-managed-trans"),
|
||||
null, null, false);
|
||||
|
@ -640,7 +639,7 @@ public class EntityManagerImpl
|
|||
|
||||
public void evictAll(Extent extent) {
|
||||
assertNotCloseInvoked();
|
||||
_broker.evictAll(extent.getDelegate(), this);
|
||||
_broker.evictAll(((ExtentImpl) extent).getDelegate(), this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -667,7 +666,7 @@ public class EntityManagerImpl
|
|||
|
||||
public Object[] mergeAll(Object... entities) {
|
||||
if (entities.length == 0)
|
||||
return new Object[0];
|
||||
return EMPTY_OBJECTS;
|
||||
return mergeAll(Arrays.asList(entities)).toArray();
|
||||
}
|
||||
|
||||
|
@ -1019,7 +1018,7 @@ public class EntityManagerImpl
|
|||
|
||||
public Object getObjectId(Object o) {
|
||||
assertNotCloseInvoked();
|
||||
return OpenJPAPersistence.fromOpenJPAObjectId(_broker.getObjectId(o));
|
||||
return JPAFacadeHelper.fromOpenJPAObjectId(_broker.getObjectId(o));
|
||||
}
|
||||
|
||||
public boolean isDirty(Object o) {
|
||||
|
|
|
@ -30,11 +30,6 @@ import java.util.List;
|
|||
public interface Extent<T>
|
||||
extends Iterable<T> {
|
||||
|
||||
/**
|
||||
* Delegate.
|
||||
*/
|
||||
public org.apache.openjpa.kernel.Extent getDelegate();
|
||||
|
||||
/**
|
||||
* The extent's element type.
|
||||
*/
|
||||
|
|
|
@ -47,6 +47,9 @@ public class ExtentImpl<T>
|
|||
PersistenceExceptions.getRollbackTranslator(em));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegate.
|
||||
*/
|
||||
public org.apache.openjpa.kernel.Extent getDelegate() {
|
||||
return _extent.getDelegate();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ METHOD, FIELD })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({})
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Abe White
|
||||
* @since 0.4.0
|
||||
* @published
|
||||
*/
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
|
|
@ -55,11 +55,6 @@ public interface FetchPlan {
|
|||
*/
|
||||
public static final int DEFAULT = FetchConfiguration.DEFAULT;
|
||||
|
||||
/**
|
||||
* Delegate.
|
||||
*/
|
||||
public FetchConfiguration getDelegate();
|
||||
|
||||
/**
|
||||
* The maximum fetch depth when loading an object.
|
||||
*/
|
||||
|
@ -90,15 +85,19 @@ public interface FetchPlan {
|
|||
* will not be enabled. If this
|
||||
* returns <code>false</code>, query caching will not be used
|
||||
* even if the datacache plugin is installed.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean getQueryResultCache();
|
||||
public boolean isEnlistInQueryResultCache();
|
||||
|
||||
/**
|
||||
* Control whether or not query caching is enabled. This has no effect
|
||||
* if the datacache plugin is not installed, or if the query cache size
|
||||
* is set to zero.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public FetchPlan setQueryResultCache(boolean cache);
|
||||
public FetchPlan setEnlistInQueryResultCache(boolean cache);
|
||||
|
||||
/**
|
||||
* Returns the names of the fetch groups that this component will use
|
||||
|
|
|
@ -82,12 +82,12 @@ public class FetchPlanImpl
|
|||
return this;
|
||||
}
|
||||
|
||||
public boolean getQueryResultCache() {
|
||||
return _fetch.getQueryCache();
|
||||
public boolean isEnlistInQueryResultCache() {
|
||||
return _fetch.getEnlistInQueryCache();
|
||||
}
|
||||
|
||||
public FetchPlan setQueryResultCache(boolean cache) {
|
||||
_fetch.setQueryCache(cache);
|
||||
public FetchPlan setEnlistInQueryResultCache(boolean cache) {
|
||||
_fetch.setEnlistInQueryCache(cache);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,6 @@ public interface Generator {
|
|||
public static final String UUID_HEX = "uuid-hex";
|
||||
public static final String UUID_STRING = "uuid-string";
|
||||
|
||||
/**
|
||||
* Delegate.
|
||||
*/
|
||||
public Seq getDelegate();
|
||||
|
||||
/**
|
||||
* The sequence name.
|
||||
*/
|
||||
|
|
|
@ -49,6 +49,9 @@ public class GeneratorImpl
|
|||
_meta = meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegate.
|
||||
*/
|
||||
public Seq getDelegate() {
|
||||
return _seq.getDelegate();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue