--- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Strategy.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Strategy.java Tue Aug 14 18:19:35 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE, METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementJoinColumn.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementJoinColumn.java Tue Aug 14 18:19:35 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementForeignKey.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementForeignKey.java Tue Aug 14 18:19:35 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/EagerFetchMode.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/EagerFetchMode.java Tue Aug 14 18:19:35 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java Tue Aug 14 18:19:35 PDT 2007 @@ -82,12 +82,12 @@ 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; } --- openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Broker.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Broker.java Tue Aug 14 18:19:35 PDT 2007 @@ -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 @@ * @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 { --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java Tue Aug 14 18:19:35 PDT 2007 @@ -26,6 +26,7 @@ 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 void testOptimizeForClause(boolean hint, boolean find, boolean queryHint) { - OpenJPAEntityManager em = - OpenJPAPersistence.cast(emf.createEntityManager()); + OpenJPAEntityManagerSPI em = emf.createEntityManager(); DBDictionary dict = ((JDBCConfiguration) em.getConfiguration()) .getDBDictionaryInstance(); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java Tue Aug 14 18:19:35 PDT 2007 @@ -24,7 +24,6 @@ import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; import javax.persistence.spi.ClassTransformer; import javax.persistence.spi.PersistenceProvider; import javax.persistence.spi.PersistenceUnitInfo; @@ -47,7 +46,8 @@ * Bootstrapping class that allows the creation of a stand-alone * {@link EntityManager}. * - * @see Persistence#createEntityManagerFactory(String,Map) + * @see javax.persistence.Persistence#createEntityManagerFactory(String,Map) + * @published */ public class PersistenceProviderImpl implements PersistenceProvider { --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java Tue Aug 14 18:19:35 PDT 2007 @@ -22,10 +22,9 @@ 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 void testIsolationLevelOverride(boolean useHintsAndQueries, boolean useStringHints) { - OpenJPAEntityManager em = - OpenJPAPersistence.cast(emf.createEntityManager()); + OpenJPAEntityManagerSPI em = emf.createEntityManager(); DBDictionary dict = ((JDBCConfiguration) em.getConfiguration()) .getDBDictionaryInstance(); --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ContainerTable.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ContainerTable.java Tue Aug 14 18:19:35 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java Tue Aug 14 18:19:35 PDT 2007 @@ -47,6 +47,9 @@ PersistenceExceptions.getRollbackTranslator(em)); } + /** + * Delegate. + */ public org.apache.openjpa.kernel.Extent getDelegate() { return _extent.getDelegate(); } --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java Tue Aug 14 18:19:35 PDT 2007 @@ -46,6 +46,9 @@ PersistenceExceptions.TRANSLATOR); } + /** + * Delegate. + */ public QueryCache getDelegate() { return _cache.getDelegate(); } --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/VersionStrategy.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/VersionStrategy.java Tue Aug 14 18:19:35 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConnectionRetainMode.java Tue Aug 14 18:19:35 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConnectionRetainMode.java Tue Aug 14 18:19:35 PDT 2007 @@ -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 ConnectionRetainMode { + ON_DEMAND(ConnectionRetainModes.CONN_RETAIN_DEMAND), + TRANSACTION(ConnectionRetainModes.CONN_RETAIN_TRANS), + ALWAYS(ConnectionRetainModes.CONN_RETAIN_ALWAYS); + + private final int connectionRetainConstant; + + private ConnectionRetainMode(int value) { + connectionRetainConstant = value; + } + + int toKernelConstant() { + return connectionRetainConstant; + } + + static ConnectionRetainMode 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 + ""); + } + } +} --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ForeignKeyAction.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ForeignKeyAction.java Tue Aug 14 18:19:35 PDT 2007 @@ -23,10 +23,11 @@ * * @author Abe White * @since 0.4.0 + * @published */ public enum ForeignKeyAction { - RESTRICT, CASCADE, NULL, - DEFAULT }; + DEFAULT +}; --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java Wed Aug 15 10:58:15 PDT 2007 @@ -56,11 +56,6 @@ public static final int DEFAULT = FetchConfiguration.DEFAULT; /** - * Delegate. - */ - public FetchConfiguration getDelegate(); - - /** * The maximum fetch depth when loading an object. */ public int getMaxFetchDepth(); @@ -90,15 +85,19 @@ * will not be enabled. If this * returns false, 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 --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/DataStoreIdColumn.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/DataStoreIdColumn.java Tue Aug 14 18:19:35 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java Tue Aug 14 18:19:35 PDT 2007 @@ -32,11 +32,6 @@ public interface QueryResultCache { /** - * Delegate. - */ - public QueryCache getDelegate(); - - /** * Pin the given query's result to the cache. */ public void pin(Query q); --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/DiscriminatorStrategy.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/DiscriminatorStrategy.java Tue Aug 14 18:19:35 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java Tue Aug 14 18:19:35 PDT 2007 @@ -129,14 +129,14 @@ * returns false, 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. --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RestoreStateMode.java Tue Aug 14 18:19:35 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RestoreStateMode.java Tue Aug 14 18:19:35 PDT 2007 @@ -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.RestoreState; + +/** + * The possible settings for the restore behavior after transaction rollback + * of an {@link OpenJPAEntityManager}. + * + * @since 1.0.0 + * @published + */ +public enum RestoreStateMode { + NONE(RestoreState.RESTORE_NONE), + IMMUTABLE(RestoreState.RESTORE_IMMUTABLE), + ALL(RestoreState.RESTORE_ALL); + + private final int restoreStateConstant; + + private RestoreStateMode(int value) { + restoreStateConstant = value; + } + + int toKernelConstant() { + return restoreStateConstant; + } + + static RestoreStateMode fromKernelConstant(int kernelConstant) { + switch (kernelConstant) { + case RestoreState.RESTORE_NONE: + return NONE; + + case RestoreState.RESTORE_IMMUTABLE: + return IMMUTABLE; + + case RestoreState.RESTORE_ALL: + return ALL; + + default: + throw new IllegalArgumentException(kernelConstant + ""); + } + } +} --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryOperationType.java Wed Aug 15 11:18:12 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryOperationType.java Wed Aug 15 11:18:12 PDT 2007 @@ -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; + +import org.apache.openjpa.kernel.QueryOperations; + +/** + * The possible operations that a query can perform. + * + * @since 1.0.0 + * @published + */ +public enum QueryOperationType { + SELECT(QueryOperations.OP_SELECT), + DELETE(QueryOperations.OP_DELETE), + UPDATE(QueryOperations.OP_UPDATE); + + private final int queryOperationConstant; + + private QueryOperationType(int value) { + queryOperationConstant = value; + } + + int toKernelConstant() { + return queryOperationConstant; + } + + static QueryOperationType fromKernelConstant(int kernelConstant) { + switch (kernelConstant) { + case QueryOperations.OP_SELECT: + return SELECT; + + case QueryOperations.OP_UPDATE: + return UPDATE; + + case QueryOperations.OP_DELETE: + return DELETE; + + default: + throw new IllegalArgumentException(kernelConstant + ""); + } + } +} --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java Wed Aug 15 11:21:01 PDT 2007 @@ -38,6 +38,7 @@ import org.apache.openjpa.kernel.DelegatingQuery; import org.apache.openjpa.kernel.DelegatingResultList; import org.apache.openjpa.kernel.Filters; +import org.apache.openjpa.kernel.QueryOperations; import org.apache.openjpa.kernel.exps.AggregateListener; import org.apache.openjpa.kernel.exps.FilterListener; import org.apache.openjpa.lib.rop.ResultList; @@ -52,7 +53,7 @@ * @nojavadoc */ public class QueryImpl - implements OpenJPAQuery, Serializable { + implements OpenJPAQuerySPI, Serializable { private static final Object[] EMPTY_ARRAY = new Object[0]; @@ -91,8 +92,8 @@ return _query.getLanguage(); } - public int getOperation() { - return _query.getOperation(); + public QueryOperationType getOperation() { + return QueryOperationType.fromKernelConstant(_query.getOperation()); } public FetchPlan getFetchPlan() { @@ -167,7 +168,7 @@ public OpenJPAQuery setResultClass(Class cls) { _em.assertNotCloseInvoked(); - if (OpenJPAPersistence.isManagedType(_em, cls)) + if (OpenJPAPersistence.isManagedType(cls)) _query.setCandidateType(cls, true); else _query.setResultType(cls); @@ -222,7 +223,7 @@ } private Object execute() { - if (_query.getOperation() != OP_SELECT) + if (_query.getOperation() != QueryOperations.OP_SELECT) throw new InvalidStateException(_loc.get("not-select-query", _query.getQueryString()), null, null, false); @@ -303,7 +304,7 @@ public int executeUpdate() { _em.assertNotCloseInvoked(); - if (_query.getOperation() == OP_DELETE) { + if (_query.getOperation() == QueryOperations.OP_DELETE) { // handle which types of parameters we are using, if any if (_positional != null) return asInt(_query.deleteAll(_positional.toArray())); @@ -311,7 +312,7 @@ return asInt(_query.deleteAll(_named)); return asInt(_query.deleteAll()); } - if (_query.getOperation() == OP_UPDATE) { + if (_query.getOperation() == QueryOperations.OP_UPDATE) { // handle which types of parameters we are using, if any if (_positional != null) return asInt(_query.updateAll(_positional.toArray())); @@ -415,12 +416,12 @@ public OpenJPAQuery setParameter(int position, Calendar value, TemporalType t) { - return setParameter(position, (Object) value); + return setParameter(position, value); } public OpenJPAQuery setParameter(int position, Date value, TemporalType type) { - return setParameter(position, (Object) value); + return setParameter(position, value); } public OpenJPAQuery setParameter(int position, Object value) { @@ -456,12 +457,12 @@ public OpenJPAQuery setParameter(String name, Calendar value, TemporalType t) { - return setParameter(name, (Object) value); + return setParameter(name, value); } public OpenJPAQuery setParameter(String name, Date value, TemporalType type) { - return setParameter(name, (Object) value); + return setParameter(name, value); } public OpenJPAQuery setParameter(String name, Object value) { --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/query/TestXMLCustomerOrder.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/query/TestXMLCustomerOrder.java Tue Aug 14 18:19:36 PDT 2007 @@ -35,6 +35,8 @@ 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 @@ private boolean enabled = false; public void setUp() { - OpenJPAEntityManagerFactory emf = createEMF(); + OpenJPAEntityManagerFactorySPI emf = createEMF(); DBDictionary dict = ((JDBCConfiguration) emf.getConfiguration()) .getDBDictionaryInstance(); @@ -79,8 +81,7 @@ if (!enabled) return; - OpenJPAEntityManager em = - OpenJPAPersistence.cast(emf.createEntityManager()); + OpenJPAEntityManagerSPI em = emf.createEntityManager(); DBDictionary dict = ((JDBCConfiguration) em.getConfiguration()) .getDBDictionaryInstance(); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuerySPI.java Wed Aug 15 11:21:01 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuerySPI.java Wed Aug 15 11:21:01 PDT 2007 @@ -0,0 +1,46 @@ +/* + * 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.exps.FilterListener; +import org.apache.openjpa.kernel.exps.AggregateListener; + +public interface OpenJPAQuerySPI + extends OpenJPAQuery { + + /** + * Register a filter listener for the query. + */ + public OpenJPAQuery addFilterListener(FilterListener listener); + + /** + * Remove a filter listener from the query. + */ + public OpenJPAQuery removeFilterListener(FilterListener listener); + + /** + * Register an aggregate listener for the query. + */ + public OpenJPAQuery addAggregateListener(AggregateListener listener); + + /** + * Remove an aggregate listener from the query. + */ + public OpenJPAQuery removeAggregateListener(AggregateListener listener); +} --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationBuilder.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationBuilder.java Tue Aug 14 18:19:36 PDT 2007 @@ -33,6 +33,7 @@ * * @author Gokhan Ergul * @since 1.0.0 + * @nojavadoc */ public class AnnotationBuilder { @@ -155,46 +156,45 @@ 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; - } + AnnotationEntry(String key, Object value) { + this.key = key; + this.value = value; + } - @SuppressWarnings("unchecked") - void toString(StringBuilder sb) { - if (null != key) - sb.append(key).append("="); + @SuppressWarnings("unchecked") + void toString(StringBuilder sb) { + if (null != key) + sb.append(key).append("="); - List.class.getTypeParameters(); - if (value instanceof List) { - sb.append("{"); - List l = (List) value; - for (Iterator 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); - } - } + List.class.getTypeParameters(); + if (value instanceof List) { + sb.append("{"); + List l = (List) value; + for (Iterator 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); + } + } -} + } +} \ No newline at end of file --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolTemporal.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolTemporal.java Tue Aug 14 18:19:36 PDT 2007 @@ -22,6 +22,7 @@ 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 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); --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/VersionColumns.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/VersionColumns.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementClassCriteria.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementClassCriteria.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java Tue Aug 14 18:19:36 PDT 2007 @@ -109,7 +109,7 @@ 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; --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ElementDependent.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ElementDependent.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingOverride.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingOverride.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/VersionColumn.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/VersionColumn.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/LRS.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/LRS.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBroker.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBroker.java Tue Aug 14 18:19:36 PDT 2007 @@ -21,11 +21,6 @@ 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 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 @@ } } - ////////////////////////////////////////// - // 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); --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolAutoDelete.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolAutoDelete.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,8 +28,8 @@ 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 @@ 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(); --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XSecondaryTables.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XSecondaryTables.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingOverrides.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingOverrides.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestArrayFieldsInDataCache.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestArrayFieldsInDataCache.java Tue Aug 14 18:19:36 PDT 2007 @@ -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,7 @@ 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.simple.AllFieldTypes; import org.apache.openjpa.persistence.test.SingleEMFTestCase; @@ -61,8 +61,9 @@ 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, AllFieldTypes.class); @@ -82,8 +83,9 @@ 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, AllFieldTypes.class); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/GeneratorImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/GeneratorImpl.java Tue Aug 14 18:19:36 PDT 2007 @@ -49,6 +49,9 @@ _meta = meta; } + /** + * Delegate. + */ public Seq getDelegate() { return _seq.getDelegate(); } --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java Tue Aug 14 18:19:36 PDT 2007 @@ -27,7 +27,6 @@ import javax.naming.NamingException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; import javax.persistence.Query; import javax.rmi.PortableRemoteObject; @@ -59,8 +58,7 @@ * @published * @since 0.4.0 */ -public class OpenJPAPersistence - extends Persistence { +public class OpenJPAPersistence { public static final String EM_KEY = "org.apache.openjpa.persistence.EntityManager"; @@ -304,7 +302,7 @@ if (em == null) throw new NullPointerException("em == null"); - OpenJPAEntityManager kem = cast(em); + OpenJPAEntityManagerSPI kem = (OpenJPAEntityManagerSPI) cast(em); try { return kem.getConfiguration().getMetaDataRepositoryInstance(). getMetaData(cls, kem.getClassLoader(), false); @@ -322,9 +320,10 @@ if (emf == null) throw new NullPointerException("emf == null"); - OpenJPAEntityManagerFactory kemf = cast(emf); + OpenJPAEntityManagerFactorySPI emfSPI = + (OpenJPAEntityManagerFactorySPI) cast(emf); try { - return kemf.getConfiguration().getMetaDataRepositoryInstance(). + return emfSPI.getConfiguration().getMetaDataRepositoryInstance(). getMetaData(cls, null, false); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); @@ -347,7 +346,7 @@ /** * Returns true if the specified class is an entity or embeddable type. */ - public static boolean isManagedType(EntityManager em, Class cls) { + public static boolean isManagedType(Class cls) { try { return ImplHelper.isManagedType(cls); } catch (Exception e) { @@ -356,17 +355,6 @@ } /** - * Returns true if the specified class is an entity or embeddable type. - */ - public static boolean isManagedType(EntityManagerFactory emf, Class cls) { - try { - return ImplHelper.isManagedType(cls); - } catch (Exception e) { - throw PersistenceExceptions.toPersistenceException(e); - } - } - - /** * Translate from a OpenJPA identity object to a Persistence one. */ public static Object fromOpenJPAObjectId(Object oid) { --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Unique.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Unique.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/OrderColumn.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/OrderColumn.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchGroups.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchGroups.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Dependent.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Dependent.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DetachedState.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DetachedState.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/EmbeddedMapping.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/EmbeddedMapping.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ElementType.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ElementType.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchGroup.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchGroup.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java Tue Aug 14 18:19:36 PDT 2007 @@ -21,16 +21,12 @@ 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 +42,7 @@ 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 +60,8 @@ * @nojavadoc */ public class EntityManagerImpl - implements OpenJPAEntityManager, FindCallbacks, OpCallbacks { + implements OpenJPAEntityManager, OpenJPAEntityManagerSPI, + FindCallbacks, OpCallbacks, Closeable, OpenJPAEntityTransaction { private static final Localizer _loc = Localizer.forPackage (EntityManagerImpl.class); @@ -71,6 +69,7 @@ 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 +90,6 @@ 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 +111,9 @@ } } - public int getConnectionRetainMode() { - return _broker.getConnectionRetainMode(); + public ConnectionRetainMode getConnectionRetainMode() { + return ConnectionRetainMode.fromKernelConstant( + _broker.getConnectionRetainMode()); } public boolean isManaged() { @@ -211,13 +190,13 @@ _broker.setOptimistic(val); } - public int getRestoreState() { - return _broker.getRestoreState(); + public RestoreStateMode getRestoreState() { + return RestoreStateMode.fromKernelConstant(_broker.getRestoreState()); } - public void setRestoreState(int val) { + public void setRestoreState(RestoreStateMode val) { assertNotCloseInvoked(); - _broker.setRestoreState(val); + _broker.setRestoreState(val.toKernelConstant()); } public boolean getRetainState() { @@ -229,33 +208,38 @@ _broker.setRetainState(val); } - public int getAutoClear() { - return _broker.getAutoClear(); + public AutoClearMode getAutoClear() { + return AutoClearMode.fromKernelConstant(_broker.getAutoClear()); } - public void setAutoClear(int val) { + public void setAutoClear(AutoClearMode val) { assertNotCloseInvoked(); - _broker.setAutoClear(val); + _broker.setAutoClear(val.toKernelConstant()); } - public int getDetachState() { - return _broker.getDetachState(); + public DetachStateMode getDetachState() { + return DetachStateMode.fromKernelConstant(_broker.getDetachState()); } - public void setDetachState(int mode) { + public void setDetachState(DetachStateMode mode) { assertNotCloseInvoked(); - _broker.setDetachState(mode); + _broker.setDetachState(mode.toKernelConstant()); } - public int getAutoDetach() { - return _broker.getAutoDetach(); + public EnumSet getAutoDetach() { + return AutoDetachMode.toEnumSet(_broker.getAutoDetach()); } - public void setAutoDetach(int flags) { + public void setAutoDetach(AutoDetachMode flag) { assertNotCloseInvoked(); - _broker.setAutoDetach(flags); + _broker.setAutoDetach(AutoDetachMode.fromEnumSet(EnumSet.of(flag))); } + public void setAutoDetach(EnumSet flags) { + assertNotCloseInvoked(); + _broker.setAutoDetach(AutoDetachMode.fromEnumSet(flags)); + } + public void setAutoDetach(int flag, boolean on) { assertNotCloseInvoked(); _broker.setAutoDetach(flag, on); @@ -279,13 +263,13 @@ _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,15 +291,23 @@ _broker.removeTransactionListener(listener); } - public int getTransactionListenerCallbackMode() { - return _broker.getTransactionListenerCallbackMode(); + public EnumSet getTransactionListenerCallbackMode() { + return CallbackMode.toEnumSet( + _broker.getTransactionListenerCallbackMode()); } - public void setTransactionListenerCallbackMode(int mode) { + public void setTransactionListenerCallbackMode(CallbackMode mode) { assertNotCloseInvoked(); - _broker.setTransactionListenerCallbackMode(mode); + _broker.setTransactionListenerCallbackMode( + CallbackMode.fromEnumSet(EnumSet.of(mode))); } + public void setTransactionListenerCallbackMode(EnumSet modes){ + assertNotCloseInvoked(); + _broker.setTransactionListenerCallbackMode( + CallbackMode.fromEnumSet(modes)); + } + public void addLifecycleListener(Object listener, Class... classes) { assertNotCloseInvoked(); _broker.addLifecycleListener(listener, classes); @@ -326,15 +318,23 @@ _broker.removeLifecycleListener(listener); } - public int getLifecycleListenerCallbackMode() { - return _broker.getLifecycleListenerCallbackMode(); + public EnumSet getLifecycleListenerCallbackMode() { + return CallbackMode.toEnumSet( + _broker.getLifecycleListenerCallbackMode()); } - public void setLifecycleListenerCallbackMode(int mode) { + public void setLifecycleListenerCallbackMode(CallbackMode mode) { assertNotCloseInvoked(); - _broker.setLifecycleListenerCallbackMode(mode); + _broker.setLifecycleListenerCallbackMode( + CallbackMode.fromEnumSet(EnumSet.of(mode))); } + public void setLifecycleListenerCallbackMode(EnumSet modes) { + assertNotCloseInvoked(); + _broker.setLifecycleListenerCallbackMode( + CallbackMode.fromEnumSet(modes)); + } + @SuppressWarnings("unchecked") public T getReference(Class cls, Object oid) { assertNotCloseInvoked(); @@ -386,7 +386,7 @@ (_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 +640,7 @@ public void evictAll(Extent extent) { assertNotCloseInvoked(); - _broker.evictAll(extent.getDelegate(), this); + _broker.evictAll(((ExtentImpl) extent).getDelegate(), this); } @SuppressWarnings("unchecked") @@ -667,7 +667,7 @@ public Object[] mergeAll(Object... entities) { if (entities.length == 0) - return new Object[0]; + return EMPTY_OBJECTS; return mergeAll(Arrays.asList(entities)).toArray(); } --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java Wed Aug 15 11:23:37 PDT 2007 @@ -26,11 +26,7 @@ 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; -import org.apache.openjpa.kernel.exps.AggregateListener; -import org.apache.openjpa.kernel.exps.FilterListener; /** * Interface implemented by OpenJPA queries. @@ -40,10 +36,10 @@ * @published */ public interface OpenJPAQuery - extends Query, QueryOperations, QueryFlushModes, QueryHints { + extends Query, QueryHints { /** - * The owning entity manage. + * The owning entity manager. */ public OpenJPAEntityManager getEntityManager(); @@ -55,7 +51,7 @@ /** * Query operation type. */ - public int getOperation(); + public QueryOperationType getOperation(); /** * Fetch plan for controlling the loading of results. @@ -78,26 +74,6 @@ public OpenJPAQuery setIgnoreChanges(boolean ignore); /** - * Register a filter listener for the query. - */ - public OpenJPAQuery addFilterListener(FilterListener listener); - - /** - * Remove a filter listener from the query. - */ - public OpenJPAQuery removeFilterListener(FilterListener listener); - - /** - * Register an aggregate listener for the query. - */ - public OpenJPAQuery addAggregateListener(AggregateListener listener); - - /** - * Remove an aggregate listener from the query. - */ - public OpenJPAQuery removeAggregateListener(AggregateListener listener); - - /** * Return the candidate collection, or null if an * extent was specified instead of a collection. */ --- openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java Tue Aug 14 18:19:36 PDT 2007 @@ -150,7 +150,7 @@ 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 @@ 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; } --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/InverseLogical.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/InverseLogical.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/LoadFetchGroup.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/LoadFetchGroup.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,8 @@ * Fetch group loaded when the annotated field/property is loaded. * * @author Pinaki Poddar + * @since 1.0.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestEnumToKernelConstantMappings.java Wed Aug 15 11:18:41 PDT 2007 +++ openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestEnumToKernelConstantMappings.java Wed Aug 15 11:18:41 PDT 2007 @@ -0,0 +1,270 @@ +/* + * 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 junit.framework.TestCase; +import org.apache.openjpa.kernel.ConnectionRetainModes; +import org.apache.openjpa.kernel.DetachState; +import org.apache.openjpa.kernel.RestoreState; +import org.apache.openjpa.kernel.AutoClear; +import org.apache.openjpa.kernel.AutoDetach; +import org.apache.openjpa.kernel.QueryOperations; +import org.apache.openjpa.event.CallbackModes; + +public class TestEnumToKernelConstantMappings + extends TestCase { + + public void testConnectionRetainModes() { + assertEquals(ConnectionRetainModes.CONN_RETAIN_ALWAYS, + ConnectionRetainMode.ALWAYS.toKernelConstant()); + assertEquals(ConnectionRetainMode.ALWAYS, + ConnectionRetainMode.fromKernelConstant( + ConnectionRetainModes.CONN_RETAIN_ALWAYS)); + assertEquals(ConnectionRetainMode.ALWAYS.toKernelConstant(), + ConnectionRetainMode.ALWAYS.ordinal()); + + assertEquals(ConnectionRetainModes.CONN_RETAIN_DEMAND, + ConnectionRetainMode.ON_DEMAND.toKernelConstant()); + assertEquals(ConnectionRetainMode.ON_DEMAND, + ConnectionRetainMode.fromKernelConstant( + ConnectionRetainModes.CONN_RETAIN_DEMAND)); + assertEquals(ConnectionRetainMode.ON_DEMAND.toKernelConstant(), + ConnectionRetainMode.ON_DEMAND.ordinal()); + + assertEquals(ConnectionRetainModes.CONN_RETAIN_TRANS, + ConnectionRetainMode.TRANSACTION.toKernelConstant()); + assertEquals(ConnectionRetainMode.TRANSACTION, + ConnectionRetainMode.fromKernelConstant( + ConnectionRetainModes.CONN_RETAIN_TRANS)); + assertEquals(ConnectionRetainMode.TRANSACTION.toKernelConstant(), + ConnectionRetainMode.TRANSACTION.ordinal()); + + assertEquals(getConstantCount(ConnectionRetainModes.class), + ConnectionRetainMode.values().length); + } + + public void testDetachState() { + assertEquals(DetachState.DETACH_ALL, + DetachStateMode.ALL.toKernelConstant()); + assertEquals(DetachStateMode.ALL, + DetachStateMode.fromKernelConstant(DetachState.DETACH_ALL)); + assertEquals(DetachStateMode.ALL.toKernelConstant(), + DetachStateMode.ALL.ordinal()); + + assertEquals(DetachState.DETACH_FETCH_GROUPS, + DetachStateMode.FETCH_GROUPS.toKernelConstant()); + assertEquals(DetachStateMode.FETCH_GROUPS, + DetachStateMode.fromKernelConstant( + DetachState.DETACH_FETCH_GROUPS)); + assertEquals(DetachStateMode.FETCH_GROUPS.toKernelConstant(), + DetachStateMode.FETCH_GROUPS.ordinal()); + + assertEquals(DetachState.DETACH_LOADED, + DetachStateMode.LOADED.toKernelConstant()); + assertEquals(DetachStateMode.LOADED, + DetachStateMode.fromKernelConstant(DetachState.DETACH_LOADED)); + assertEquals(DetachStateMode.LOADED.toKernelConstant(), + DetachStateMode.LOADED.ordinal()); + + // subtract 1 for DetachState.DETACH_FGS, which is deprecated + assertEquals(getConstantCount(DetachState.class) - 1, + DetachStateMode.values().length); + } + + public void testRestoreState() { + assertEquals(RestoreState.RESTORE_ALL, + RestoreStateMode.ALL.toKernelConstant()); + assertEquals(RestoreStateMode.ALL, + RestoreStateMode.fromKernelConstant(RestoreState.RESTORE_ALL)); + assertEquals(RestoreStateMode.ALL.toKernelConstant(), + RestoreStateMode.ALL.ordinal()); + + assertEquals(RestoreState.RESTORE_IMMUTABLE, + RestoreStateMode.IMMUTABLE.toKernelConstant()); + assertEquals(RestoreStateMode.IMMUTABLE, + RestoreStateMode.fromKernelConstant( + RestoreState.RESTORE_IMMUTABLE)); + assertEquals(RestoreStateMode.IMMUTABLE.toKernelConstant(), + RestoreStateMode.IMMUTABLE.ordinal()); + + assertEquals(RestoreState.RESTORE_NONE, + RestoreStateMode.NONE.toKernelConstant()); + assertEquals(RestoreStateMode.NONE, + RestoreStateMode.fromKernelConstant(RestoreState.RESTORE_NONE)); + assertEquals(RestoreStateMode.NONE.toKernelConstant(), + RestoreStateMode.NONE.ordinal()); + + assertEquals(getConstantCount(RestoreState.class), + RestoreStateMode.values().length); + } + + public void testAutoClear() { + assertEquals(AutoClear.CLEAR_ALL, AutoClearMode.ALL.toKernelConstant()); + assertEquals(AutoClearMode.ALL, + AutoClearMode.fromKernelConstant(AutoClear.CLEAR_ALL)); + assertEquals(AutoClearMode.ALL.toKernelConstant(), + AutoClearMode.ALL.ordinal()); + + assertEquals(AutoClear.CLEAR_DATASTORE, + AutoClearMode.DATASTORE.toKernelConstant()); + assertEquals(AutoClearMode.DATASTORE, + AutoClearMode.fromKernelConstant(AutoClear.CLEAR_DATASTORE)); + assertEquals(AutoClearMode.DATASTORE.toKernelConstant(), + AutoClearMode.DATASTORE.ordinal()); + + assertEquals(getConstantCount(AutoClear.class), + AutoClearMode.values().length); + } + + public void testAutoDetach() { + assertEquals(getConstantCount(AutoDetach.class), + AutoDetachMode.values().length); + + assertEquals(EnumSet.of(AutoDetachMode.CLOSE), + AutoDetachMode.toEnumSet(AutoDetach.DETACH_CLOSE)); + assertEquals(AutoDetach.DETACH_CLOSE, + AutoDetachMode.fromEnumSet(EnumSet.of(AutoDetachMode.CLOSE))); + + assertEquals(EnumSet.of(AutoDetachMode.COMMIT), + AutoDetachMode.toEnumSet(AutoDetach.DETACH_COMMIT)); + assertEquals(AutoDetach.DETACH_COMMIT, + AutoDetachMode.fromEnumSet(EnumSet.of(AutoDetachMode.COMMIT))); + + assertEquals(EnumSet.of(AutoDetachMode.NON_TRANSACTIONAL_READ), + AutoDetachMode.toEnumSet(AutoDetach.DETACH_NONTXREAD)); + assertEquals(AutoDetach.DETACH_NONTXREAD, + AutoDetachMode.fromEnumSet( + EnumSet.of(AutoDetachMode.NON_TRANSACTIONAL_READ))); + + assertEquals(EnumSet.of(AutoDetachMode.ROLLBACK), + AutoDetachMode.toEnumSet(AutoDetach.DETACH_ROLLBACK)); + assertEquals(AutoDetach.DETACH_ROLLBACK, + AutoDetachMode.fromEnumSet(EnumSet.of(AutoDetachMode.ROLLBACK))); + + + assertEquals(EnumSet.of(AutoDetachMode.CLOSE, AutoDetachMode.COMMIT), + AutoDetachMode.toEnumSet( + AutoDetach.DETACH_CLOSE | AutoDetach.DETACH_COMMIT)); + assertEquals(AutoDetach.DETACH_ROLLBACK | AutoDetach.DETACH_CLOSE, + AutoDetachMode.fromEnumSet( + EnumSet.of(AutoDetachMode.ROLLBACK, AutoDetachMode.CLOSE))); + + + assertEquals(EnumSet.allOf(AutoDetachMode.class), + AutoDetachMode.toEnumSet( + AutoDetach.DETACH_CLOSE + | AutoDetach.DETACH_COMMIT + | AutoDetach.DETACH_NONTXREAD + | AutoDetach.DETACH_ROLLBACK)); + assertEquals(AutoDetach.DETACH_CLOSE + | AutoDetach.DETACH_COMMIT + | AutoDetach.DETACH_NONTXREAD + | AutoDetach.DETACH_ROLLBACK, + AutoDetachMode.fromEnumSet(EnumSet.allOf(AutoDetachMode.class))); + } + + public void testCallbackMode() { + assertEquals(getConstantCount(CallbackModes.class), + CallbackMode.values().length); + + assertEquals(EnumSet.of(CallbackMode.FAIL_FAST), + CallbackMode.toEnumSet(CallbackModes.CALLBACK_FAIL_FAST)); + assertEquals(CallbackModes.CALLBACK_FAIL_FAST, + CallbackMode.fromEnumSet(EnumSet.of(CallbackMode.FAIL_FAST))); + + assertEquals(EnumSet.of(CallbackMode.IGNORE), + CallbackMode.toEnumSet(CallbackModes.CALLBACK_IGNORE)); + assertEquals(CallbackModes.CALLBACK_IGNORE, + CallbackMode.fromEnumSet(EnumSet.of(CallbackMode.IGNORE))); + + assertEquals(EnumSet.of(CallbackMode.LOG), + CallbackMode.toEnumSet(CallbackModes.CALLBACK_LOG)); + assertEquals(CallbackModes.CALLBACK_LOG, + CallbackMode.fromEnumSet(EnumSet.of(CallbackMode.LOG))); + + assertEquals(EnumSet.of(CallbackMode.RETHROW), + CallbackMode.toEnumSet(CallbackModes.CALLBACK_RETHROW)); + assertEquals(CallbackModes.CALLBACK_RETHROW, + CallbackMode.fromEnumSet(EnumSet.of(CallbackMode.RETHROW))); + + assertEquals(EnumSet.of(CallbackMode.ROLLBACK), + CallbackMode.toEnumSet(CallbackModes.CALLBACK_ROLLBACK)); + assertEquals(CallbackModes.CALLBACK_ROLLBACK, + CallbackMode.fromEnumSet(EnumSet.of(CallbackMode.ROLLBACK))); + + + assertEquals(EnumSet.of(CallbackMode.ROLLBACK, CallbackMode.IGNORE), + CallbackMode.toEnumSet(CallbackModes.CALLBACK_ROLLBACK + | CallbackModes.CALLBACK_IGNORE)); + assertEquals( + CallbackModes.CALLBACK_ROLLBACK | CallbackModes.CALLBACK_IGNORE, + CallbackMode.fromEnumSet( + EnumSet.of(CallbackMode.ROLLBACK, CallbackMode.IGNORE))); + + + assertEquals(EnumSet.allOf(CallbackMode.class), + CallbackMode.toEnumSet( + CallbackModes.CALLBACK_FAIL_FAST + | CallbackModes.CALLBACK_IGNORE + | CallbackModes.CALLBACK_LOG + | CallbackModes.CALLBACK_RETHROW + | CallbackModes.CALLBACK_ROLLBACK)); + assertEquals(CallbackModes.CALLBACK_FAIL_FAST + | CallbackModes.CALLBACK_IGNORE + | CallbackModes.CALLBACK_LOG + | CallbackModes.CALLBACK_RETHROW + | CallbackModes.CALLBACK_ROLLBACK, + CallbackMode.fromEnumSet(EnumSet.allOf(CallbackMode.class))); + } + + public void testQueryOperationTypes() { + assertEquals(QueryOperations.OP_SELECT, + QueryOperationType.SELECT.toKernelConstant()); + assertEquals(QueryOperationType.SELECT, + QueryOperationType.fromKernelConstant( + QueryOperations.OP_SELECT)); + assertEquals(QueryOperationType.SELECT.toKernelConstant(), + QueryOperationType.SELECT.ordinal() + 1); + + assertEquals(QueryOperations.OP_UPDATE, + QueryOperationType.UPDATE.toKernelConstant()); + assertEquals(QueryOperationType.UPDATE, + QueryOperationType.fromKernelConstant( + QueryOperations.OP_UPDATE)); + assertEquals(QueryOperationType.UPDATE.toKernelConstant(), + QueryOperationType.UPDATE.ordinal() + 1); + + assertEquals(QueryOperations.OP_DELETE, + QueryOperationType.DELETE.toKernelConstant()); + assertEquals(QueryOperationType.DELETE, + QueryOperationType.fromKernelConstant( + QueryOperations.OP_DELETE)); + assertEquals(QueryOperationType.DELETE.toKernelConstant(), + QueryOperationType.DELETE.ordinal() + 1); + + assertEquals(getConstantCount(QueryOperations.class), + QueryOperationType.values().length); + } + + private int getConstantCount(Class cls) { + return cls.getDeclaredFields().length; + } +} --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Nonpolymorphic.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Nonpolymorphic.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ForeignKey.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ForeignKey.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE, METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java Tue Aug 14 18:19:36 PDT 2007 @@ -33,16 +33,6 @@ 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 @@ 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 @@ 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 @@ _initializeWasInvoked = true; _loader = (ClassLoader) AccessController.doPrivileged( J2DoPrivHelper.getContextClassLoaderAction()); - _jca = new JCAHelper(); _conf = factory.getConfiguration(); _compat = _conf.getCompatibilityInstance(); _factory = factory; @@ -324,30 +313,6 @@ 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 @@ _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 @@ if (objs == null) return null; if (objs.isEmpty()) - return new Object[0]; + return EMPTY_OBJECTS; if (call == null) call = _call; @@ -3203,7 +3168,7 @@ if (objs == null) return null; if (objs.isEmpty()) - return new Object[0]; + return EMPTY_OBJECTS; beginOperation(true); try { @@ -4898,106 +4863,4 @@ }; } } - - /** - * 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; - } - } -} --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Type.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Type.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DataCache.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DataCache.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistentCollection.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistentCollection.java Tue Aug 14 18:19:36 PDT 2007 @@ -33,6 +33,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java Tue Aug 14 18:19:36 PDT 2007 @@ -31,11 +31,6 @@ extends Iterable { /** - * Delegate. - */ - public org.apache.openjpa.kernel.Extent getDelegate(); - - /** * The extent's element type. */ public Class getElementClass(); --- openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java Tue Aug 14 18:19:36 PDT 2007 @@ -120,7 +120,7 @@ * @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 @@ /** * 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. --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/KeyType.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/KeyType.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ReadOnly.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ReadOnly.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQueryCompilationCache.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQueryCompilationCache.java Tue Aug 14 18:19:36 PDT 2007 @@ -26,9 +26,9 @@ 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 @@ Map props = new HashMap(System.getProperties()); props.put("openjpa.MetaDataFactory", "jpa(Types=" + NamedEntity.class.getName() + ")"); - OpenJPAEntityManagerFactory emf = OpenJPAPersistence.cast( + OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI) + OpenJPAPersistence.cast( - Persistence.createEntityManagerFactory("test", props)); + Persistence.createEntityManagerFactory("test", props)); Map cache = emf.getConfiguration().getQueryCompilationCacheInstance(); cache.clear(); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java Tue Aug 14 18:19:36 PDT 2007 @@ -34,11 +34,6 @@ public static final String NAME_DEFAULT = DataCache.NAME_DEFAULT; /** - * Delegate. - */ - public DataCache getDelegate(); - - /** * Whether the cache contains data for the given oid. */ public boolean contains(Class cls, Object oid); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerSPI.java Tue Aug 14 18:19:36 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerSPI.java Tue Aug 14 18:19:36 PDT 2007 @@ -0,0 +1,104 @@ +/* + * 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.conf.OpenJPAConfiguration; +import org.apache.openjpa.ee.ManagedRuntime; + +public interface OpenJPAEntityManagerSPI + extends OpenJPAEntityManager { + + /** + * Return the configuration associated with this entity manager. + */ + public OpenJPAConfiguration getConfiguration(); + + /** + * Return the managed runtime in use. + */ + public ManagedRuntime getManagedRuntime(); + + ////////// + // Events + ////////// + + /** + * Register a listener for transaction-related events. + */ + public void addTransactionListener(Object listener); + + /** + * Remove a listener for transaction-related events. + */ + public void removeTransactionListener(Object listener); + + /** + * The {@link CallbackMode} flags for handling transaction listener + * exceptions. + */ + public EnumSet getTransactionListenerCallbackMode(); + + /** + * The {@link CallbackMode} flag for handling transaction listener + * exceptions. + */ + // ##### check for overwrite behavior; javadoc + public void setTransactionListenerCallbackMode(CallbackMode mode); + + /** + * The {@link CallbackMode} flags for handling transaction listener + * exceptions. + */ + // ##### check for overwrite behavior; javadoc + public void setTransactionListenerCallbackMode(EnumSet modes); + + /** + * Register a listener for lifecycle-related events on the specified + * classes. If the classes are null, all events will be propagated to + * the listener. + */ + public void addLifecycleListener(Object listener, Class... classes); + + /** + * Remove a listener for lifecycle-related events. + */ + public void removeLifecycleListener(Object listener); + + /** + * The {@link CallbackMode} flags for handling lifecycle listener + * exceptions. + */ + public EnumSet getLifecycleListenerCallbackMode(); + + /** + * The {@link CallbackMode} flag for handling lifecycle listener + * exceptions. + */ + // ##### check for overwrite behavior; javadoc + public void setLifecycleListenerCallbackMode(CallbackMode mode); + + /** + * The {@link CallbackMode} flags for handling lifecycle listener + * exceptions. + */ + // ##### check for overwrite behavior; javadoc + public void setLifecycleListenerCallbackMode(EnumSet modes); +} --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/KeyDependent.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/KeyDependent.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/CallbackMode.java Tue Aug 14 18:19:36 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/CallbackMode.java Tue Aug 14 18:19:36 PDT 2007 @@ -0,0 +1,67 @@ +/* + * 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; +import org.apache.openjpa.event.CallbackModes; + +/** + * The possible settings for the callback behavior of an + * {@link OpenJPAEntityManager}. + * + * @since 1.0.0 + * @published + */ +public enum CallbackMode { + 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 CallbackMode(int value) { + callbackMode = value; + } + + public static EnumSet toEnumSet(int callback) { + EnumSet modes = EnumSet.noneOf(CallbackMode.class); + if ((callback & CallbackModes.CALLBACK_FAIL_FAST) != 0) + modes.add(FAIL_FAST); + if ((callback & CallbackModes.CALLBACK_IGNORE) != 0) + modes.add(IGNORE); + if ((callback & CallbackModes.CALLBACK_LOG) != 0) + modes.add(LOG); + if ((callback & CallbackModes.CALLBACK_RETHROW) != 0) + modes.add(RETHROW); + if ((callback & CallbackModes.CALLBACK_ROLLBACK) != 0) + modes.add(ROLLBACK); + return modes; + } + + public static int fromEnumSet(EnumSet modes) { + int callback = 0; + for (CallbackMode mode : modes) + callback |= mode.callbackMode; + return callback; + } +} --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Columns.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Columns.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XTable.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XTable.java Tue Aug 14 18:19:36 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DetachStateMode.java Tue Aug 14 18:19:36 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DetachStateMode.java Tue Aug 14 18:19:36 PDT 2007 @@ -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 DetachStateMode { + FETCH_GROUPS(DetachState.DETACH_FETCH_GROUPS), + LOADED(DetachState.DETACH_LOADED), + ALL(DetachState.DETACH_ALL); + + private final int detachStateConstant; + + private DetachStateMode(int value) { + detachStateConstant = value; + } + + int toKernelConstant() { + return detachStateConstant; + } + + static DetachStateMode 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 + ""); + } + } +} --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XSecondaryTable.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XSecondaryTable.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Factory.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Factory.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Externalizer.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Externalizer.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Persistent.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Persistent.java Tue Aug 14 18:19:36 PDT 2007 @@ -31,6 +31,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Index.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/Index.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java Tue Aug 14 18:19:36 PDT 2007 @@ -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 void testSelectForUpdateOverride() { - OpenJPAEntityManager em = + OpenJPAEntityManagerSPI em = (OpenJPAEntityManagerSPI) OpenJPAPersistence.cast(emf.createEntityManager()); DBDictionary dict = ((JDBCConfiguration) em.getConfiguration()) .getDBDictionaryInstance(); --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java Tue Aug 14 18:19:36 PDT 2007 @@ -32,8 +32,8 @@ 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; /** * Base test class providing persistence utilities. @@ -55,7 +55,7 @@ * @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 types = new ArrayList(); boolean prop = false; @@ -84,7 +84,7 @@ "jpa(Types=" + buf.toString() + ")"); } - return (OpenJPAEntityManagerFactory) Persistence. + return (OpenJPAEntityManagerFactorySPI) Persistence. createEntityManagerFactory("test", map); } @@ -136,7 +136,7 @@ protected void clear(EntityManagerFactory emf) { if (emf == null) return; - clear(emf, ((OpenJPAEntityManagerFactory) emf).getConfiguration(). + clear(emf, ((OpenJPAEntityManagerFactorySPI) emf).getConfiguration(). getMetaDataRepositoryInstance().getMetaDatas()); } --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XJoinColumn.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XJoinColumn.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementNonpolymorphic.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementNonpolymorphic.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java Tue Aug 14 18:19:36 PDT 2007 @@ -231,7 +231,7 @@ // 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 @@ } // if large transaction mode don't record individual changes - if (_ctx.isLargeTransaction()) + if (_ctx.isTrackChangesByType()) return exceps; OpenJPAStateManager sm; --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AutoDetachMode.java Tue Aug 14 18:19:36 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AutoDetachMode.java Tue Aug 14 18:19:36 PDT 2007 @@ -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 AutoDetachMode { + CLOSE(AutoDetach.DETACH_CLOSE), + COMMIT(AutoDetach.DETACH_COMMIT), + NON_TRANSACTIONAL_READ(AutoDetach.DETACH_NONTXREAD), + ROLLBACK(AutoDetach.DETACH_ROLLBACK); + + private final int autoDetachConstant; + + private AutoDetachMode(int value) { + autoDetachConstant = value; + } + + public static EnumSet toEnumSet(int autoDetach) { + EnumSet modes = EnumSet.noneOf(AutoDetachMode.class); + if ((autoDetach & AutoDetach.DETACH_CLOSE) != 0) + modes.add(CLOSE); + if ((autoDetach & AutoDetach.DETACH_COMMIT) != 0) + modes.add(COMMIT); + if ((autoDetach & AutoDetach.DETACH_NONTXREAD) != 0) + modes.add(NON_TRANSACTIONAL_READ); + if ((autoDetach & AutoDetach.DETACH_ROLLBACK) != 0) + modes.add(ROLLBACK); + return modes; + } + + public static int fromEnumSet(EnumSet modes) { + int autoDetach = 0; + for (AutoDetachMode mode : modes) + autoDetach |= mode.autoDetachConstant; + return autoDetach; + } +} --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/EagerFetchType.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/EagerFetchType.java Tue Aug 14 18:19:36 PDT 2007 @@ -23,9 +23,10 @@ * * @author Abe White * @since 0.4.0 + * @published */ public enum EagerFetchType { - NONE, JOIN, - PARALLEL }; + PARALLEL +}; --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementJoinColumns.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementJoinColumns.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java Thu Aug 16 06:46:23 PDT 2007 @@ -84,7 +84,7 @@ public int getFetchDirection(); /** - * Result set fetch direction. + * Result set fetch direction. // ##### what to do here? * * @see java.sql.ResultSet */ --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ClassCriteria.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ClassCriteria.java Tue Aug 14 18:19:36 PDT 2007 @@ -30,6 +30,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java Tue Aug 14 18:19:36 PDT 2007 @@ -23,10 +23,6 @@ import java.util.Properties; import javax.persistence.EntityManagerFactory; -import org.apache.openjpa.conf.OpenJPAConfiguration; -import org.apache.openjpa.kernel.ConnectionRetainModes; -import org.apache.openjpa.lib.util.Closeable; - /** * Interface implemented by OpenJPA entity manager factories. * @@ -35,15 +31,9 @@ * @published */ public interface OpenJPAEntityManagerFactory - extends EntityManagerFactory, ConnectionRetainModes, Closeable, - Serializable { + extends EntityManagerFactory, Serializable { /** - * Return the configuration for this factory. - */ - public OpenJPAConfiguration getConfiguration(); - - /** * Return properties describing this runtime. */ public Properties getProperties(); @@ -88,39 +78,4 @@ * */ public OpenJPAEntityManager createEntityManager(Map props); - - /** - * Register a listener for lifecycle-related events on the specified - * classes. If the classes are null, all events will be propagated to - * the listener. The listener will be passed on to all new entity - * managers. See the org.apache.openjpa.event package for - * listener types. - * - * @since 0.3.3 - */ - public void addLifecycleListener(Object listener, Class... classes); - - /** - * Remove a listener for lifecycle-related events. - * - * @since 0.3.3 - */ - public void removeLifecycleListener (Object listener); - - /** - * Register a listener for transaction-related events on the specified - * classes. The listener will be passed on to all new entity - * managers. See the org.apache.openjpa.event package for - * listener types. - * - * @since 1.0.0 - */ - public void addTransactionListener(Object listener); - - /** - * Remove a listener for transaction-related events. - * - * @since 1.0.0 - */ - public void removeTransactionListener (Object listener); } --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java Wed Aug 15 11:17:00 PDT 2007 @@ -63,8 +63,8 @@ && !throwing) { try { throwing = true; - if (em.isOpen() && em.isActive()) - em.setRollbackOnly(re); + if (em.isOpen() && ((EntityManagerImpl) em).isActive()) + ((EntityManagerImpl) em).setRollbackOnly(re); } finally { // handle re-entrancy throwing = false; --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementIndex.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ElementIndex.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XJoinColumns.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XJoinColumns.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/NonpolymorphicType.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/NonpolymorphicType.java Tue Aug 14 18:19:36 PDT 2007 @@ -23,9 +23,10 @@ * * @author Abe White * @since 0.4.0 + * @published */ public enum NonpolymorphicType { - EXACT, JOINABLE, - FALSE }; + FALSE +}; --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/IsolationLevel.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/IsolationLevel.java Tue Aug 14 18:19:36 PDT 2007 @@ -26,6 +26,7 @@ * Isolation levels for use in {@link JDBCFetchPlan#setIsolation}. * * @since 0.9.7 + * @published */ public enum IsolationLevel { DEFAULT(-1), @@ -41,11 +42,11 @@ _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: --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DataStoreId.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/DataStoreId.java Tue Aug 14 18:19:36 PDT 2007 @@ -29,6 +29,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java Wed Aug 15 11:27:56 PDT 2007 @@ -19,21 +19,11 @@ 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.conf.OpenJPAConfiguration; -import org.apache.openjpa.ee.ManagedRuntime; -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; -import org.apache.openjpa.lib.util.Closeable; - /** * Interface implemented by OpenJPA entity managers. * @@ -42,22 +32,16 @@ * @published */ public interface OpenJPAEntityManager - extends EntityManager, EntityTransaction, javax.resource.cci.Connection, - javax.resource.cci.LocalTransaction, javax.resource.spi.LocalTransaction, - Closeable, ConnectionRetainModes, DetachState, RestoreState, AutoDetach, - AutoClear, CallbackModes { + extends EntityManager { + // ##### covariant types? + /** * Return the factory that produced this entity manager. */ public OpenJPAEntityManagerFactory getEntityManagerFactory(); /** - * Return the configuration associated with this entity manager. - */ - public OpenJPAConfiguration getConfiguration(); - - /** * Return the (mutable) fetch plan for loading objects from this * entity manager. */ @@ -65,10 +49,8 @@ /** * Return the connection retain mode for this entity manager. - * - * @see ConnectionRetainModes */ - public int getConnectionRetainMode(); + public ConnectionRetainMode getConnectionRetainMode(); /** * Whether this entity manager is using managed transactions. @@ -76,11 +58,6 @@ public boolean isManaged(); /** - * Return the managed runtime in use. - */ - public ManagedRuntime getManagedRuntime(); - - /** * Whether to check for a global transaction upon every managed, * non-transactional operation. Defaults to false. */ @@ -164,17 +141,13 @@ /** * Whether to restore an object's original state on rollback. - * - * @see RestoreState */ - public int getRestoreState(); + public RestoreStateMode getRestoreState(); /** * Whether to restore an object's original state on rollback. - * - * @see RestoreState */ - public void setRestoreState(int restore); + public void setRestoreState(RestoreStateMode restoreMode); /** * Whether objects retain their persistent state on transaction commit. @@ -189,49 +162,49 @@ /** * Detach mode constant to determine which fields are part of the * detached graph. - * - * @see DetachState */ - public int getDetachState(); + public DetachStateMode getDetachState(); /** * Detach mode constant to determine which fields are part of the * detached graph. - * - * @see DetachState */ - public void setDetachState(int mode); + public void setDetachState(DetachStateMode mode); /** * Whether to clear state when entering a transaction. - * - * @see AutoClear */ - public int getAutoClear(); + public AutoClearMode getAutoClear(); /** * Whether to clear state when entering a transaction. - * - * @see AutoClear */ - public void setAutoClear(int clear); + public void setAutoClear(AutoClearMode clearMode); /** - * Bit flags marked in {@link AutoDetach} which indicate when persistent + * {@link AutoDetachMode} values which indicate when persistent * managed objects should be automatically detached in-place. */ - public int getAutoDetach(); + public EnumSet getAutoDetach(); /** - * Bit flags marked in {@link AutoDetach} which indicate when persistent + * {@link AutoDetachMode} values which indicate when persistent * managed objects should be automatically detached in-place. + * The current value is replaced in its entirety. */ - public void setAutoDetach(int flags); + public void setAutoDetach(AutoDetachMode value); /** - * Bit flags marked in {@link AutoDetach} which indicate when persistent + * {@link AutoDetachMode} values which indicate when persistent * managed objects should be automatically detached in-place. + * The current value is replaced in its entirety. */ + public void setAutoDetach(EnumSet values); + + /** + * Bit flags marked in {@link AutoDetachMode} which indicate when persistent + * managed objects should be automatically detached in-place. + */ public void setAutoDetach(int flag, boolean on); /** @@ -264,20 +237,23 @@ /** * 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. + * usage if you perform periodic flushes by 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 void setLargeTransaction(boolean largeTransaction); + public void setTrackChangesByType(boolean largeTransaction); /** * Put the specified key-value pair into the map of user objects. Use @@ -290,56 +266,6 @@ */ public Object getUserObject(Object key); - ////////// - // Events - ////////// - - /** - * Register a listener for transaction-related events. - */ - public void addTransactionListener(Object listener); - - /** - * Remove a listener for transaction-related events. - */ - public void removeTransactionListener(Object listener); - - /** - * The {@link CallbackModes} flags for handling transaction listener - * exceptions. - */ - public int getTransactionListenerCallbackMode(); - - /** - * The {@link CallbackModes} flags for handling transaction listener - * exceptions. - */ - public void setTransactionListenerCallbackMode(int callbackMode); - - /** - * Register a listener for lifecycle-related events on the specified - * classes. If the classes are null, all events will be propagated to - * the listener. - */ - public void addLifecycleListener(Object listener, Class... classes); - - /** - * Remove a listener for lifecycle-related events. - */ - public void removeLifecycleListener(Object listener); - - /** - * The {@link CallbackModes} flags for handling lifecycle listener - * exceptions. - */ - public int getLifecycleListenerCallbackMode(); - - /** - * The {@link CallbackModes} flags for handling lifecycle listener - * exceptions. - */ - public void setLifecycleListenerCallbackMode(int callbackMode); - /////////// // Lookups /////////// @@ -383,57 +309,9 @@ // Transactions //////////////// - /** - * Issue a commit and then start a new transaction. This is identical to: - *
 manager.commit (); manager.begin ();
-     * 
except that the entity manager's internal atomic lock is utilized, - * so this method can be safely executed from multiple threads. - * - * @see #commit() - * @see #begin() - */ - public void commitAndResume(); + public OpenJPAEntityTransaction getTransaction(); /** - * Issue a rollback and then start a new transaction. This is identical to: - *
 manager.rollback (); manager.begin ();
-     * 
except that the entity manager's internal atomic lock is utilized, - * so this method can be safely executed from multiple threads. - * - * @see #rollback() - * @see #begin() - */ - public void rollbackAndResume(); - - /** - * Mark the current transaction for rollback. - */ - public void setRollbackOnly(); - - /** - * Mark the current transaction for rollback with the specified cause - * of the rollback. - * - * @since 0.9.7 - */ - public void setRollbackOnly(Throwable cause); - - /** - * Returns the Throwable that caused the transaction to be - * marked for rollback. - * - * @return the Throwable, or null if none was given - * - * @since 0.9.7 - */ - public Throwable getRollbackCause(); - - /** - * Return whether the current transaction has been marked for rollback. - */ - public boolean getRollbackOnly(); - - /** * Set a transactional savepoint where operations after this savepoint * will be rolled back. */ --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheOptimisticLockRecovery.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheOptimisticLockRecovery.java Tue Aug 14 18:19:37 PDT 2007 @@ -27,6 +27,7 @@ import javax.sql.DataSource; import org.apache.openjpa.persistence.OpenJPAPersistence; +import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; import org.apache.openjpa.persistence.test.SingleEMFTestCase; import org.apache.openjpa.event.RemoteCommitListener; import org.apache.openjpa.event.RemoteCommitEvent; @@ -88,8 +89,9 @@ // 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 +122,7 @@ // 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. --- openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitEventManager.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitEventManager.java Tue Aug 14 18:19:37 PDT 2007 @@ -168,7 +168,7 @@ Collection updates = null; Collection deletes = null; - if (broker.isLargeTransaction()) { + if (broker.isTrackChangesByType()) { payload = RemoteCommitEvent.PAYLOAD_EXTENTS; addClassNames = toClassNames(event.getPersistedTypes()); updates = toClassNames(event.getUpdatedTypes()); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/UpdateAction.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/UpdateAction.java Tue Aug 14 18:19:37 PDT 2007 @@ -23,8 +23,9 @@ * * @author Abe White * @since 0.4.0 + * @published */ public enum UpdateAction { - IGNORE, - RESTRICT }; + RESTRICT +} --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchAttribute.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchAttribute.java Tue Aug 14 18:19:37 PDT 2007 @@ -27,6 +27,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({}) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java Tue Aug 14 18:19:37 PDT 2007 @@ -42,6 +42,7 @@ 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 @@ * @nojavadoc */ public class EntityManagerFactoryImpl - implements OpenJPAEntityManagerFactory { + implements OpenJPAEntityManagerFactory, OpenJPAEntityManagerFactorySPI, + Closeable { private static final Localizer _loc = Localizer.forPackage (EntityManagerFactoryImpl.class); @@ -139,11 +141,11 @@ } } - 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 @@ 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 errs = null; - Method setter = null; + Method setter; String prop, prefix; Object val; for (Map.Entry entry : (Set) props.entrySet()) { @@ -251,7 +253,7 @@ 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 @@ if (fetch == null) return null; - FetchConfiguration inner = fetch; - if (inner instanceof DelegatingFetchConfiguration) - inner = ((DelegatingFetchConfiguration) inner). + if (fetch instanceof DelegatingFetchConfiguration) + fetch = ((DelegatingFetchConfiguration) fetch). getInnermostDelegate(); try { --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/event/TestSJVMRemoteCommitProvider.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/event/TestSJVMRemoteCommitProvider.java Tue Aug 14 18:19:37 PDT 2007 @@ -24,14 +24,14 @@ 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; 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 +40,7 @@ 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,7 +48,7 @@ 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()); @@ -82,4 +82,4 @@ public void close() { } } -} \ No newline at end of file +} --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactorySPI.java Wed Aug 15 11:30:24 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactorySPI.java Wed Aug 15 11:30:24 PDT 2007 @@ -0,0 +1,71 @@ +/* + * 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.Map; + +import org.apache.openjpa.conf.OpenJPAConfiguration; + +public interface OpenJPAEntityManagerFactorySPI + extends OpenJPAEntityManagerFactory { + + /** + * Register a listener for lifecycle-related events on the specified + * classes. If the classes are null, all events will be propagated to + * the listener. The listener will be passed on to all new entity + * managers. See the org.apache.openjpa.event package for + * listener types. + * + * @since 0.3.3 + */ + public void addLifecycleListener(Object listener, Class... classes); + + /** + * Remove a listener for lifecycle-related events. + * + * @since 0.3.3 + */ + public void removeLifecycleListener (Object listener); + + /** + * Register a listener for transaction-related events on the specified + * classes. The listener will be passed on to all new entity + * managers. See the org.apache.openjpa.event package for + * listener types. + * + * @since 1.0.0 + */ + public void addTransactionListener(Object listener); + + /** + * Remove a listener for transaction-related events. + * + * @since 1.0.0 + */ + public void removeTransactionListener (Object listener); + + /** + * Return the configuration for this factory. + */ + public OpenJPAConfiguration getConfiguration(); + + public OpenJPAEntityManagerSPI createEntityManager(); + + public OpenJPAEntityManagerSPI createEntityManager(Map props); +} --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestAutoDetachProperty.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestAutoDetachProperty.java Tue Aug 14 18:19:37 PDT 2007 @@ -63,17 +63,20 @@ } private boolean isAutoDetachingOnClose() { - int autoDetachFlags = OpenJPAPersistence.cast(em).getAutoDetach(); - return (autoDetachFlags & AutoDetach.DETACH_CLOSE) > 0; + EnumSet autoDetachFlags = + OpenJPAPersistence.cast(em).getAutoDetach(); + return autoDetachFlags.contains(AutoDetachMode.CLOSE); } private boolean isAutoDetachingOnCommit() { - int autoDetachFlags = OpenJPAPersistence.cast(em).getAutoDetach(); - return (autoDetachFlags & AutoDetach.DETACH_COMMIT) > 0; + EnumSet autoDetachFlags = + OpenJPAPersistence.cast(em).getAutoDetach(); + return autoDetachFlags.contains(AutoDetachMode.COMMIT); } private boolean isAutoDetachingOnNonTxRead() { - int autoDetachFlags = OpenJPAPersistence.cast(em).getAutoDetach(); - return (autoDetachFlags & AutoDetach.DETACH_NONTXREAD) > 0; + EnumSet autoDetachFlags = + OpenJPAPersistence.cast(em).getAutoDetach(); + return autoDetachFlags.contains(AutoDetachMode.NON_TRANSACTIONAL_READ); } } --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExternalValues.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExternalValues.java Tue Aug 14 18:19:37 PDT 2007 @@ -31,6 +31,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityTransaction.java Wed Aug 15 11:26:39 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityTransaction.java Wed Aug 15 11:26:39 PDT 2007 @@ -0,0 +1,71 @@ +/* + * 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 javax.persistence.EntityTransaction; + +/** + * Extension of the JPA {@link EntityTransaction} interface. + * + * @since 1.0.0 + * @published + */ +public interface OpenJPAEntityTransaction + extends EntityTransaction { + + /** + * Issue a commit and then start a new transaction. This is identical to: + *
 manager.commit (); manager.begin ();
+     * 
except that the entity manager's internal atomic lock is utilized, + * so this method can be safely executed from multiple threads. + * + * @see javax.persistence.EntityTransaction#commit() + * @see javax.persistence.EntityTransaction#begin() + */ + public void commitAndResume(); + + /** + * Issue a rollback and then start a new transaction. This is identical to: + *
 manager.rollback (); manager.begin ();
+     * 
except that the entity manager's internal atomic lock is utilized, + * so this method can be safely executed from multiple threads. + * + * @see javax.persistence.EntityTransaction#rollback() + * @see javax.persistence.EntityTransaction#begin() + */ + public void rollbackAndResume(); + + /** + * Mark the current transaction for rollback with the specified cause + * of the rollback. + * + * @since 0.9.7 + */ + public void setRollbackOnly(Throwable cause); + + /** + * Returns the Throwable that caused the transaction to be + * marked for rollback. + * + * @return the Throwable, or null if none was given + * + * @since 0.9.7 + */ + public Throwable getRollbackCause(); +} --- openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/SubclassFetchMode.java (revision 565999) +++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/SubclassFetchMode.java Tue Aug 14 18:19:37 PDT 2007 @@ -28,6 +28,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ TYPE }) @Retention(RUNTIME) --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java Tue Aug 14 18:19:37 PDT 2007 @@ -50,6 +50,9 @@ PersistenceExceptions.TRANSLATOR); } + /** + * Delegate. + */ public DataCache getDelegate() { return _cache.getDelegate(); } --- openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java (revision 565999) +++ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java Tue Aug 14 18:19:37 PDT 2007 @@ -183,17 +183,17 @@ } } - 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); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java Tue Aug 14 18:19:37 PDT 2007 @@ -33,11 +33,6 @@ public static final String UUID_STRING = "uuid-string"; /** - * Delegate. - */ - public Seq getDelegate(); - - /** * The sequence name. */ public String getName(); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AutoClearMode.java Tue Aug 14 18:19:37 PDT 2007 +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AutoClearMode.java Tue Aug 14 18:19:37 PDT 2007 @@ -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 AutoClearMode { + DATASTORE(AutoClear.CLEAR_DATASTORE), + ALL(AutoClear.CLEAR_ALL); + + private final int autoClearConstant; + + private AutoClearMode(int value) { + autoClearConstant = value; + } + + int toKernelConstant() { + return autoClearConstant; + } + + static AutoClearMode fromKernelConstant(int kernelConstant) { + switch (kernelConstant) { + case AutoClear.CLEAR_DATASTORE: + return DATASTORE; + + case AutoClear.CLEAR_ALL: + return ALL; + + default: + throw new IllegalArgumentException(kernelConstant + ""); + } + } +} --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachmentOneMany.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachmentOneMany.java Tue Aug 14 18:19:37 PDT 2007 @@ -21,8 +21,8 @@ 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.AutoDetachMode; import org.apache.openjpa.persistence.test.SingleEMFTestCase; /** @@ -41,7 +41,8 @@ long id = createParentAndChildren(); EntityManager em = emf.createEntityManager(); - OpenJPAPersistence.cast(em).setAutoDetach(AutoDetach.DETACH_NONTXREAD); + OpenJPAPersistence.cast(em).setAutoDetach( + AutoDetachMode.NON_TRANSACTIONAL_READ); DetachmentOneManyParent parent = em.find(DetachmentOneManyParent.class, id); assertNotNull(parent); @@ -53,7 +54,8 @@ long id = createParentAndChildren(); EntityManager em = emf.createEntityManager(); - OpenJPAPersistence.cast(em).setAutoDetach(AutoDetach.DETACH_NONTXREAD); + OpenJPAPersistence.cast(em).setAutoDetach( + AutoDetachMode.NON_TRANSACTIONAL_READ); DetachmentOneManyParent parent = em.find(DetachmentOneManyParent.class, id); assertNotNull(parent); @@ -74,7 +76,8 @@ long id = createParentAndChildren(); EntityManager em = emf.createEntityManager(); - OpenJPAPersistence.cast(em).setAutoDetach(AutoDetach.DETACH_NONTXREAD); + OpenJPAPersistence.cast(em).setAutoDetach( + AutoDetachMode.NON_TRANSACTIONAL_READ); DetachmentOneManyParent parent = em.find(DetachmentOneManyParent.class, id); assertNotNull(parent); --- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistentMap.java (revision 565999) +++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistentMap.java Tue Aug 14 18:19:37 PDT 2007 @@ -31,6 +31,7 @@ * * @author Abe White * @since 0.4.0 + * @published */ @Target({ METHOD, FIELD }) @Retention(RUNTIME) --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestBrokerFactoryListenerRegistry.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestBrokerFactoryListenerRegistry.java Wed Aug 15 11:21:52 PDT 2007 @@ -22,6 +22,7 @@ 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 @@ 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) { --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestBrokerFactoryEventManager.java (revision 565999) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestBrokerFactoryEventManager.java Tue Aug 14 18:19:37 PDT 2007 @@ -24,14 +24,15 @@ 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( + OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI) + OpenJPAPersistence.cast( - Persistence.createEntityManagerFactory("test")); + Persistence.createEntityManagerFactory("test")); ListenerImpl listener = new ListenerImpl(); emf.getConfiguration().getBrokerFactoryEventManager() .addListener(listener);