From c4f8a37d911c97314a22c82432a3274bfbec6888 Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Fri, 19 Oct 2007 07:02:22 +0000 Subject: [PATCH] OPENJPA-404 git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@586284 13f79535-47bb-0310-9956-ffa450edef68 --- .../persistence/jdbc/JDBCFetchPlan.java | 84 ++++++ .../persistence/jdbc/JDBCFetchPlanImpl.java | 34 +++ .../persistence/EntityManagerImpl.java | 54 +++- .../apache/openjpa/persistence/Extent.java | 6 + .../apache/openjpa/persistence/FetchPlan.java | 16 + .../openjpa/persistence/FetchPlanImpl.java | 8 + .../apache/openjpa/persistence/Generator.java | 6 + .../persistence/OpenJPAEntityManager.java | 279 +++++++++++++++++- .../OpenJPAEntityManagerFactory.java | 45 +++ .../persistence/OpenJPAEntityManagerSPI.java | 8 +- .../persistence/OpenJPAPersistence.java | 119 ++++++++ .../openjpa/persistence/OpenJPAQuery.java | 61 ++++ .../openjpa/persistence/QueryResultCache.java | 6 + .../openjpa/persistence/StoreCache.java | 6 + 14 files changed, 725 insertions(+), 7 deletions(-) diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java index e36fed0f1..d8bc48c2a 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java @@ -21,6 +21,9 @@ package org.apache.openjpa.persistence.jdbc; import java.util.Collection; import javax.persistence.LockModeType; +import org.apache.openjpa.jdbc.kernel.EagerFetchModes; +import org.apache.openjpa.jdbc.kernel.LRSSizes; +import org.apache.openjpa.jdbc.sql.JoinSyntaxes; import org.apache.openjpa.persistence.FetchPlan; /** @@ -142,4 +145,85 @@ public interface JDBCFetchPlan public JDBCFetchPlan setMaxFetchDepth(int depth); public JDBCFetchPlan setReadLockMode(LockModeType mode); public JDBCFetchPlan setWriteLockMode(LockModeType mode); + + /** + * @deprecated use the {@link FetchMode} enum instead. + */ + public static final int EAGER_NONE = EagerFetchModes.EAGER_NONE; + + /** + * @deprecated use the {@link FetchMode} enum instead. + */ + public static final int EAGER_JOIN = EagerFetchModes.EAGER_JOIN; + + /** + * @deprecated use the {@link FetchMode} enum instead. + */ + public static final int EAGER_PARALLEL = EagerFetchModes.EAGER_PARALLEL; + + /** + * @deprecated use the {@link LRSSizeAlgorithm} enum instead. + */ + public static final int SIZE_UNKNOWN = LRSSizes.SIZE_UNKNOWN; + + /** + * @deprecated use the {@link LRSSizeAlgorithm} enum instead. + */ + public static final int SIZE_LAST = LRSSizes.SIZE_LAST; + + /** + * @deprecated use the {@link LRSSizeAlgorithm} enum instead. + */ + public static final int SIZE_QUERY = LRSSizes.SIZE_QUERY; + + /** + * @deprecated use the {@link JoinSyntax} enum instead. + */ + public static final int SYNTAX_SQL92 = JoinSyntaxes.SYNTAX_SQL92; + + /** + * @deprecated use the {@link JoinSyntax} enum instead. + */ + public static final int SYNTAX_TRADITIONAL = + JoinSyntaxes.SYNTAX_TRADITIONAL; + + /** + * @deprecated use the {@link JoinSyntax} enum instead. + */ + public static final int SYNTAX_DATABASE = JoinSyntaxes.SYNTAX_DATABASE; + + /** + * @deprecated use {@link #setEagerFetchMode(FetchMode)} instead. + */ + public JDBCFetchPlan setEagerFetchMode(int mode); + + /** + * @deprecated use {@link #setSubclassFetchMode(FetchMode)} instead. + */ + public JDBCFetchPlan setSubclassFetchMode(int mode); + + /** + * @deprecated use {@link #setResultSetType(ResultSetType)} instead. + */ + public JDBCFetchPlan setResultSetType(int mode); + + /** + * @deprecated use {@link #setFetchDirection(FetchDirection)} instead. + */ + public JDBCFetchPlan setFetchDirection(int direction); + + /** + * @deprecated use {@link #getLRSSizeAlgorithm()} instead. + */ + public int getLRSSize(); + + /** + * @deprecated use {@link #setLRSSizeAlgorithm(LRSSizeAlgorithm)} instead. + */ + public JDBCFetchPlan setLRSSize(int lrsSizeMode); + + /** + * @deprecated use {@link #setJoinSyntax(JoinSyntax)} instead. + */ + public JDBCFetchPlan setJoinSyntax(int syntax); } diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java index e8448f4d2..1b6e9ec38 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java @@ -65,6 +65,11 @@ public class JDBCFetchPlanImpl return this; } + public JDBCFetchPlan setEagerFetchMode(int mode) { + _fetch.setEagerFetchMode(mode); + return this; + } + public FetchMode getSubclassFetchMode() { return FetchMode.fromKernelConstant(_fetch.getSubclassFetchMode()); } @@ -74,6 +79,11 @@ public class JDBCFetchPlanImpl return this; } + public JDBCFetchPlan setSubclassFetchMode(int mode) { + _fetch.setSubclassFetchMode(mode); + return this; + } + public ResultSetType getResultSetType() { return ResultSetType.fromKernelConstant(_fetch.getResultSetType()); } @@ -83,6 +93,11 @@ public class JDBCFetchPlanImpl return this; } + public JDBCFetchPlan setResultSetType(int mode) { + _fetch.setResultSetType(mode); + return this; + } + public FetchDirection getFetchDirection() { return FetchDirection.fromKernelConstant(_fetch.getFetchDirection()); } @@ -92,6 +107,11 @@ public class JDBCFetchPlanImpl return this; } + public JDBCFetchPlan setFetchDirection(int direction) { + _fetch.setFetchDirection(direction); + return this; + } + public LRSSizeAlgorithm getLRSSizeAlgorithm() { return LRSSizeAlgorithm.fromKernelConstant(_fetch.getLRSSize()); } @@ -101,6 +121,15 @@ public class JDBCFetchPlanImpl return this; } + public int getLRSSize() { + return _fetch.getLRSSize(); + } + + public JDBCFetchPlan setLRSSize(int lrsSizeMode) { + _fetch.setLRSSize(lrsSizeMode); + return this; + } + public JoinSyntax getJoinSyntax() { return JoinSyntax.fromKernelConstant(_fetch.getJoinSyntax()); } @@ -110,6 +139,11 @@ public class JDBCFetchPlanImpl return this; } + public JDBCFetchPlan setJoinSyntax(int syntax) { + _fetch.setJoinSyntax(syntax); + return this; + } + public IsolationLevel getIsolation() { return IsolationLevel.fromConnectionConstant(_fetch.getIsolation()); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java index 1f32790a3..de8ea6de9 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java @@ -198,6 +198,11 @@ public class EntityManagerImpl _broker.setRestoreState(val.toKernelConstant()); } + public void setRestoreState(int restore) { + assertNotCloseInvoked(); + _broker.setRestoreState(restore); + } + public boolean getRetainState() { return _broker.getRetainState(); } @@ -216,6 +221,11 @@ public class EntityManagerImpl _broker.setAutoClear(val.toKernelConstant()); } + public void setAutoClear(int autoClear) { + assertNotCloseInvoked(); + _broker.setAutoClear(autoClear); + } + public DetachStateType getDetachState() { return DetachStateType.fromKernelConstant(_broker.getDetachState()); } @@ -225,6 +235,11 @@ public class EntityManagerImpl _broker.setDetachState(type.toKernelConstant()); } + public void setDetachState(int detach) { + assertNotCloseInvoked(); + _broker.setDetachState(detach); + } + public EnumSet getAutoDetach() { return AutoDetachType.toEnumSet(_broker.getAutoDetach()); } @@ -239,6 +254,16 @@ public class EntityManagerImpl _broker.setAutoDetach(AutoDetachType.fromEnumSet(flags)); } + public void setAutoDetach(int autoDetachFlags) { + assertNotCloseInvoked(); + _broker.setAutoDetach(autoDetachFlags); + } + + public void setAutoDetach(AutoDetachType value, boolean on) { + assertNotCloseInvoked(); + _broker.setAutoDetach(AutoDetachType.fromEnumSet(EnumSet.of(value)),on); + } + public void setAutoDetach(int flag, boolean on) { assertNotCloseInvoked(); _broker.setAutoDetach(flag, on); @@ -271,6 +296,14 @@ public class EntityManagerImpl _broker.setTrackChangesByType(trackByType); } + public boolean isLargeTransaction() { + return isTrackChangesByType(); + } + + public void setLargeTransaction(boolean value) { + setTrackChangesByType(value); + } + public Object getUserObject(Object key) { return _broker.getUserObject(key); } @@ -290,7 +323,7 @@ public class EntityManagerImpl _broker.removeTransactionListener(listener); } - public EnumSet getTransactionListenerCallbackMode() { + public EnumSet getTransactionListenerCallbackModes() { return CallbackMode.toEnumSet( _broker.getTransactionListenerCallbackMode()); } @@ -307,6 +340,14 @@ public class EntityManagerImpl CallbackMode.fromEnumSet(modes)); } + public int getTransactionListenerCallbackMode() { + return _broker.getTransactionListenerCallbackMode(); + } + + public void setTransactionListenerCallbackMode(int callbackMode) { + throw new UnsupportedOperationException(); + } + public void addLifecycleListener(Object listener, Class... classes) { assertNotCloseInvoked(); _broker.addLifecycleListener(listener, classes); @@ -317,7 +358,7 @@ public class EntityManagerImpl _broker.removeLifecycleListener(listener); } - public EnumSet getLifecycleListenerCallbackMode() { + public EnumSet getLifecycleListenerCallbackModes() { return CallbackMode.toEnumSet( _broker.getLifecycleListenerCallbackMode()); } @@ -334,6 +375,15 @@ public class EntityManagerImpl CallbackMode.fromEnumSet(modes)); } + public int getLifecycleListenerCallbackMode() { + return _broker.getLifecycleListenerCallbackMode(); + } + + public void setLifecycleListenerCallbackMode(int callbackMode) { + assertNotCloseInvoked(); + _broker.setLifecycleListenerCallbackMode(callbackMode); + } + @SuppressWarnings("unchecked") public T getReference(Class cls, Object oid) { assertNotCloseInvoked(); diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java index 68d7bc14a..cd39a683e 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java @@ -69,4 +69,10 @@ public interface Extent * Close all open iterators that are consuming database resources. */ public void closeAll(); + + /** + * @deprecated cast to {@link ExtentImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public org.apache.openjpa.kernel.Extent getDelegate(); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java index 3bc5fb1d3..0890bbe75 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java @@ -99,6 +99,16 @@ public interface FetchPlan { */ public FetchPlan setQueryResultCacheEnabled(boolean cache); + /** + * @deprecated use {@link #getQueryResultCacheEnabled()} instead. + */ + public boolean getQueryResultCache(); + + /** + * @deprecated use {@link #setQueryResultCacheEnabled} instead. + */ + public FetchPlan setQueryResultCache(boolean cache); + /** * Returns the names of the fetch groups that this component will use * when loading objects. Defaults to the @@ -278,4 +288,10 @@ public interface FetchPlan { * The lock level to use for locking dirtied objects. */ public FetchPlan setWriteLockMode(LockModeType mode); + + /** + * @deprecated cast to {@link FetchPlanImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public org.apache.openjpa.kernel.FetchConfiguration getDelegate(); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java index 339ddc128..93f6fb151 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java @@ -91,6 +91,14 @@ public class FetchPlanImpl return this; } + public boolean getQueryResultCache() { + return getQueryResultCacheEnabled(); + } + + public FetchPlan setQueryResultCache(boolean cache) { + return setQueryResultCacheEnabled(cache); + } + public Collection getFetchGroups() { return _fetch.getFetchGroups(); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java index d53481d66..40a501c18 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java @@ -51,4 +51,10 @@ public interface Generator { * efficiency. */ public void allocate(int additional); + + /** + * @deprecated cast to {@link GeneratorImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public org.apache.openjpa.kernel.Seq getDelegate(); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java index d1da259b6..d66c7b1c9 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java @@ -21,18 +21,29 @@ package org.apache.openjpa.persistence; import java.util.Collection; import java.util.EnumSet; import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; import javax.persistence.LockModeType; import javax.persistence.Query; +import org.apache.openjpa.event.CallbackModes; +import org.apache.openjpa.kernel.AutoClear; +import org.apache.openjpa.kernel.AutoDetach; +import org.apache.openjpa.kernel.ConnectionRetainModes; +import org.apache.openjpa.kernel.DetachState; +import org.apache.openjpa.kernel.RestoreState; + /** * Interface implemented by OpenJPA entity managers. * + * This interface extends {@link EntityTransaction}, but this extension is + * deprecated. + * * @since 0.4.0 * @author Abe White * @published */ public interface OpenJPAEntityManager - extends EntityManager { + extends EntityManager, EntityTransaction /* deprecated */ { /** * Return the factory that produced this entity manager. @@ -202,8 +213,10 @@ public interface OpenJPAEntityManager /** * Bit flags marked in {@link AutoDetachType} which indicate when persistent * managed objects should be automatically detached in-place. + * + * @since 1.1.0 */ - public void setAutoDetach(int flag, boolean on); + public void setAutoDetach(AutoDetachType value, boolean on); /** * Whether to also evict an object from the store cache when it is @@ -251,7 +264,7 @@ public interface OpenJPAEntityManager * * @since 1.0.0 */ - public void setTrackChangesByType(boolean largeTransaction); + public void setTrackChangesByType(boolean track); /** * Put the specified key-value pair into the map of user objects. Use @@ -820,4 +833,264 @@ public interface OpenJPAEntityManager * Returns the current version indicator for o. */ public Object getVersion (Object o); + + /** + * @deprecated use the {@link ConnectionRetainMode} enum instead. + */ + public static final int CONN_RETAIN_DEMAND = + ConnectionRetainModes.CONN_RETAIN_DEMAND; + + /** + * @deprecated use the {@link ConnectionRetainMode} enum instead. + */ + public static final int CONN_RETAIN_TRANS = + ConnectionRetainModes.CONN_RETAIN_TRANS; + + /** + * @deprecated use the {@link ConnectionRetainMode} enum instead. + */ + public static final int CONN_RETAIN_ALWAYS = + ConnectionRetainModes.CONN_RETAIN_ALWAYS; + + /** + * @deprecated use the {@link DetachStateType} enum instead. + */ + public static final int DETACH_FETCH_GROUPS = + DetachState.DETACH_FETCH_GROUPS; + + /** + * @deprecated use the {@link DetachStateType} enum instead. + */ + public static final int DETACH_FGS = DetachState.DETACH_FGS; + + /** + * @deprecated use the {@link DetachStateType} enum instead. + */ + public static final int DETACH_LOADED = DetachState.DETACH_LOADED; + + /** + * @deprecated use the {@link DetachStateType} enum instead. + */ + public static final int DETACH_ALL = DetachState.DETACH_ALL; + + /** + * @deprecated use the {@link RestoreStateType} enum instead. + */ + public static final int RESTORE_NONE = RestoreState.RESTORE_NONE; + + /** + * @deprecated use the {@link RestoreStateType} enum instead. + */ + public static final int RESTORE_IMMUTABLE = RestoreState.RESTORE_IMMUTABLE; + + /** + * @deprecated use the {@link RestoreStateType} enum instead. + */ + public static final int RESTORE_ALL = RestoreState.RESTORE_ALL; + + /** + * @deprecated use the {@link AutoDetachType} enum instead. + */ + public static final int DETACH_CLOSE = AutoDetach.DETACH_CLOSE; + + /** + * @deprecated use the {@link AutoDetachType} enum instead. + */ + public static final int DETACH_COMMIT = AutoDetach.DETACH_COMMIT; + + /** + * @deprecated use the {@link AutoDetachType} enum instead. + */ + public static final int DETACH_NONTXREAD = AutoDetach.DETACH_NONTXREAD; + + /** + * @deprecated use the {@link AutoDetachType} enum instead. + */ + public static final int DETACH_ROLLBACK = AutoDetach.DETACH_ROLLBACK; + + /** + * @deprecated use the {@link AutoClearType} enum instead. + */ + public static final int CLEAR_DATASTORE = AutoClear.CLEAR_DATASTORE; + + /** + * @deprecated use the {@link AutoClearType} enum instead. + */ + public static final int CLEAR_ALL = AutoClear.CLEAR_ALL; + + /** + * @deprecated use the {@link CallbackMode} enum instead. + */ + public static final int CALLBACK_FAIL_FAST = + CallbackModes.CALLBACK_FAIL_FAST; + + /** + * @deprecated use the {@link CallbackMode} enum instead. + */ + public static final int CALLBACK_IGNORE = CallbackModes.CALLBACK_IGNORE; + + /** + * @deprecated use the {@link CallbackMode} enum instead. + */ + public static final int CALLBACK_LOG = CallbackModes.CALLBACK_LOG; + + /** + * @deprecated use the {@link CallbackMode} enum instead. + */ + public static final int CALLBACK_RETHROW = CallbackModes.CALLBACK_RETHROW; + + /** + * @deprecated use the {@link CallbackMode} enum instead. + */ + public static final int CALLBACK_ROLLBACK = CallbackModes.CALLBACK_ROLLBACK; + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public org.apache.openjpa.conf.OpenJPAConfiguration getConfiguration(); + + /** + * @deprecated use {@link #setRestoreState(RestoreStateType)} instead. + */ + public void setRestoreState(int restore); + + /** + * @deprecated use {@link #setDetachState(DetachStateType)} instead. + */ + public void setDetachState(int detach); + + /** + * @deprecated use {@link #setAutoClear(AutoClearType)} instead. + */ + public void setAutoClear(int autoClear); + + /** + * @deprecated use {@link #setAutoDetach(AutoDetachType)} or + * {@link #setAutoDetach(java.util.EnumSet)} instead. + */ + public void setAutoDetach(int autoDetachFlags); + + /** + * @deprecated use {@link #setAutoDetach(AutoDetachType, boolean)} instead. + */ + public void setAutoDetach(int flag, boolean on); + + /** + * @deprecated use {@link #isTrackChangesByType()} instead. + */ + public boolean isLargeTransaction(); + + /** + * @deprecated use {@link #setTrackChangesByType(boolean)} instead. + */ + public void setLargeTransaction(boolean value); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void addTransactionListener(Object listener); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void removeTransactionListener(Object listener); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public int getTransactionListenerCallbackMode(); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void setTransactionListenerCallbackMode(int callbackMode); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void addLifecycleListener(Object listener, Class... classes); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void removeLifecycleListener(Object listener); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public int getLifecycleListenerCallbackMode(); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerSPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void setLifecycleListenerCallbackMode(int callbackMode); + + /** + * @deprecated use {@link EntityTransaction#begin} + * instead: em.getTransaction().begin() + */ + public void begin(); + + /** + * @deprecated use {@link EntityTransaction#commit} + * instead: em.getTransaction().commit() + */ + public void commit(); + + /** + * @deprecated use {@link EntityTransaction#rollback} + * instead: em.getTransaction().rollback() + */ + public void rollback(); + + /** + * @deprecated use {@link EntityTransaction#isActive} + * instead: em.getTransaction().isActive() + */ + public boolean isActive(); + + /** + * @deprecated use {@link OpenJPAEntityTransaction#commitAndResume} instead: + * em.getTransaction().commitAndResume() + */ + public void commitAndResume(); + + /** + * @deprecated use {@link OpenJPAEntityTransaction#rollbackAndResume} + * instead: em.getTransaction().rollbackAndResume() + */ + public void rollbackAndResume(); + + /** + * @deprecated use {@link EntityTransaction#setRollbackOnly} + * instead: em.getTransaction().setRollbackOnly() + */ + public void setRollbackOnly(); + + /** + * @deprecated use {@link OpenJPAEntityTransaction#setRollbackOnly} + * instead: em.getTransaction().setRollbackOnly() + */ + public void setRollbackOnly(Throwable cause); + + /** + * @deprecated use {@link OpenJPAEntityTransaction#getRollbackCause} + * instead: em.getTransaction().getRollbackCause() + */ + public Throwable getRollbackCause(); + + /** + * @deprecated use {@link EntityTransaction#getRollbackOnly} + * instead: em.getTransaction().getRollbackOnly() + */ + public boolean getRollbackOnly(); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java index 4f01dc32b..452381573 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java @@ -78,4 +78,49 @@ public interface OpenJPAEntityManagerFactory * */ public OpenJPAEntityManager createEntityManager(Map props); + + /** + * @deprecated use {@link ConnectionRetainMode} enums instead. + */ + public static final int CONN_RETAIN_DEMAND = 0; + + /** + * @deprecated use {@link ConnectionRetainMode} enums instead. + */ + public static final int CONN_RETAIN_TRANS = 1; + + /** + * @deprecated use {@link ConnectionRetainMode} enums instead. + */ + public static final int CONN_RETAIN_ALWAYS = 2; + + /** + * @deprecated cast to {@link OpenJPAEntityManagerFactorySPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public org.apache.openjpa.conf.OpenJPAConfiguration getConfiguration(); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerFactorySPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void addLifecycleListener(Object listener, Class... classes); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerFactorySPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void removeLifecycleListener(Object listener); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerFactorySPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void addTransactionListener(Object listener); + + /** + * @deprecated cast to {@link OpenJPAEntityManagerFactorySPI} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public void removeTransactionListener(Object listener); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerSPI.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerSPI.java index 9197b6857..db052acdb 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerSPI.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerSPI.java @@ -53,8 +53,10 @@ public interface OpenJPAEntityManagerSPI /** * The {@link CallbackMode} flags for handling transaction listener * exceptions. + * + * @since 1.1.0 */ - public EnumSet getTransactionListenerCallbackMode(); + public EnumSet getTransactionListenerCallbackModes(); /** * The {@link CallbackMode} flag for handling transaction listener @@ -85,8 +87,10 @@ public interface OpenJPAEntityManagerSPI /** * The {@link CallbackMode} flags for handling lifecycle listener * exceptions. + * + * @since 1.1.0 */ - public EnumSet getLifecycleListenerCallbackMode(); + public EnumSet getLifecycleListenerCallbackModes(); /** * The {@link CallbackMode} flag for handling lifecycle listener diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java index 0d9278c94..c511ced06 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java @@ -18,6 +18,7 @@ */ package org.apache.openjpa.persistence; +import java.util.Collection; import java.util.Map; import javax.naming.Context; import javax.naming.InitialContext; @@ -197,4 +198,122 @@ public class OpenJPAPersistence { throw PersistenceExceptions.toPersistenceException(e); } } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static final String EM_KEY = + "org.apache.openjpa.persistence.EntityManager"; + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static final String EMF_KEY = + "org.apache.openjpa.persistence.EntityManagerFactory"; + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static OpenJPAEntityManagerFactory toEntityManagerFactory( + org.apache.openjpa.kernel.BrokerFactory factory) { + return JPAFacadeHelper.toEntityManagerFactory(factory); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static org.apache.openjpa.kernel.BrokerFactory toBrokerFactory( + EntityManagerFactory factory) { + return JPAFacadeHelper.toBrokerFactory(factory); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static OpenJPAEntityManager toEntityManager( + org.apache.openjpa.kernel.Broker broker) { + return JPAFacadeHelper.toEntityManager(broker); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static Broker toBroker(EntityManager em) { + return JPAFacadeHelper.toBroker(em); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static org.apache.openjpa.meta.ClassMetaData getMetaData(Object o) { + return JPAFacadeHelper.getMetaData(o); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static org.apache.openjpa.meta.ClassMetaData getMetaData( + EntityManager em, Class cls) { + return JPAFacadeHelper.getMetaData(em, cls); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static org.apache.openjpa.meta.ClassMetaData getMetaData( + EntityManagerFactory factory, Class cls) { + return JPAFacadeHelper.getMetaData(factory, cls); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static Object fromOpenJPAObjectId(Object oid) { + return JPAFacadeHelper.fromOpenJPAObjectId(oid); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static Object toOpenJPAObjectId( + org.apache.openjpa.meta.ClassMetaData meta, Object oid) { + return JPAFacadeHelper.toOpenJPAObjectId(meta, oid); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static Object[] toOpenJPAObjectIds( + org.apache.openjpa.meta.ClassMetaData meta, Object... oids) { + return JPAFacadeHelper.toOpenJPAObjectIds(meta, oids); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static Collection toOpenJPAObjectIds( + org.apache.openjpa.meta.ClassMetaData meta, Collection oids) { + return JPAFacadeHelper.toOpenJPAObjectIds(meta, oids); + } + + /** + * @deprecated use {@link JPAFacadeHelper} instead. This method pierces + * the published-API boundary, as does the JPAFacadeHelper utilization. + */ + public static Class fromOpenJPAObjectIdClass(Class oidClass) { + return JPAFacadeHelper.fromOpenJPAObjectIdClass(oidClass); + } } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java index 917443ef7..836dd1771 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java @@ -26,7 +26,9 @@ import javax.persistence.FlushModeType; import javax.persistence.Query; import javax.persistence.TemporalType; +import org.apache.openjpa.kernel.QueryFlushModes; import org.apache.openjpa.kernel.QueryHints; +import org.apache.openjpa.kernel.QueryOperations; /** * Interface implemented by OpenJPA queries. @@ -194,4 +196,63 @@ public interface OpenJPAQuery * Return the current flush mode. */ public FlushModeType getFlushMode (); + + /** + * @deprecated use the {@link QueryOperationType} instead. + */ + public static final int OP_SELECT = QueryOperations.OP_SELECT; + + /** + * @deprecated use the {@link QueryOperationType} instead. + */ + public static final int OP_DELETE = QueryOperations.OP_DELETE; + + /** + * @deprecated use the {@link QueryOperationType} instead. + */ + public static final int OP_UPDATE = QueryOperations.OP_DELETE; + + /** + * @deprecated use the {@link FlushModeType} enum instead. + */ + public static final int FLUSH_TRUE = QueryFlushModes.FLUSH_TRUE; + + /** + * @deprecated use the {@link FlushModeType} enum instead. + */ + public static final int FLUSH_FALSE = QueryFlushModes.FLUSH_FALSE; + + /** + * @deprecated use the {@link FlushModeType} enum instead. + */ + public static final int FLUSH_WITH_CONNECTION = + QueryFlushModes.FLUSH_WITH_CONNECTION; + + /** + * @deprecated cast to {@link QueryImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public OpenJPAQuery addFilterListener( + org.apache.openjpa.kernel.exps.FilterListener listener); + + /** + * @deprecated cast to {@link QueryImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public OpenJPAQuery removeFilterListener( + org.apache.openjpa.kernel.exps.FilterListener listener); + + /** + * @deprecated cast to {@link QueryImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public OpenJPAQuery addAggregateListener( + org.apache.openjpa.kernel.exps.AggregateListener listener); + + /** + * @deprecated cast to {@link QueryImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public OpenJPAQuery removeAggregateListener( + org.apache.openjpa.kernel.exps.AggregateListener listener); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java index 2cb172dad..5713d64f4 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java @@ -55,4 +55,10 @@ public interface QueryResultCache { * Evict all result for queries involving the given class. */ public void evictAll(Class cls); + + /** + * @deprecated cast to {@link QueryResultCacheImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public QueryCache getDelegate(); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java index 5692350bd..dbe381a1a 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java @@ -96,4 +96,10 @@ public interface StoreCache { * Clear the cache. */ public void evictAll(); + + /** + * @deprecated cast to {@link StoreCacheImpl} instead. This + * method pierces the published-API boundary, as does the SPI cast. + */ + public DataCache getDelegate(); }