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-jdbc/src/test/java/org/apache/openjpa/persistence/fields/TestPersistentMapTableConfiguration.java (revision 565999)
+++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/TestPersistentMapTableConfiguration.java Sun Aug 19 23:33:50 PDT 2007
@@ -18,11 +18,9 @@
*/
package org.apache.openjpa.persistence.fields;
-import javax.persistence.EntityManager;
-
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.JPAFacadeHelper;
import org.apache.openjpa.jdbc.meta.ClassMapping;
public class TestPersistentMapTableConfiguration
@@ -33,7 +31,7 @@
}
public void testPersistentMapMetaData() {
- ClassMapping cm = (ClassMapping) OpenJPAPersistence.getMetaData(emf,
+ ClassMapping cm = (ClassMapping) JPAFacadeHelper.getMetaData(emf,
NonstandardMappingEntity.class);
assertEquals("NONSTD_MAPPING_MAP",
cm.getFieldMapping("map").getTable().getName());
--- 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/ConnectionRetainType.java Fri Aug 17 19:12:50 PDT 2007
+++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConnectionRetainType.java Fri Aug 17 19:12:50 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 ConnectionRetainType {
+ ON_DEMAND(ConnectionRetainModes.CONN_RETAIN_DEMAND),
+ TRANSACTION(ConnectionRetainModes.CONN_RETAIN_TRANS),
+ ALWAYS(ConnectionRetainModes.CONN_RETAIN_ALWAYS);
+
+ private final int connectionRetainConstant;
+
+ private ConnectionRetainType(int value) {
+ connectionRetainConstant = value;
+ }
+
+ int toKernelConstant() {
+ return connectionRetainConstant;
+ }
+
+ static ConnectionRetainType fromKernelConstant(int kernelConstant) {
+ switch (kernelConstant) {
+ case ConnectionRetainModes.CONN_RETAIN_DEMAND:
+ return ON_DEMAND;
+
+ case ConnectionRetainModes.CONN_RETAIN_ALWAYS:
+ return ALWAYS;
+
+ case ConnectionRetainModes.CONN_RETAIN_TRANS:
+ return TRANSACTION;
+
+ default:
+ throw new IllegalArgumentException(kernelConstant + "");
+ }
+ }
+}
--- 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("{");
- Listo.
+ */
+ public static ClassMetaData getMetaData(Object o) {
+ if (o == null)
+ return null;
+ EntityManager em = OpenJPAPersistence.getEntityManager(o);
+ return (em == null) ? null : getMetaData(em,
+ ImplHelper.getManagedInstance(o).getClass());
+ }
+
+ /**
+ * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated
+ * with the persistent type cls.
+ */
+ public static ClassMetaData getMetaData(EntityManager em, Class cls) {
+ if (em == null)
+ throw new NullPointerException("em == null");
+
+ OpenJPAEntityManagerSPI kem = (OpenJPAEntityManagerSPI)
+ OpenJPAPersistence.cast(em);
+ try {
+ return kem.getConfiguration().getMetaDataRepositoryInstance().
+ getMetaData(cls, kem.getClassLoader(), false);
+ } catch (Exception e) {
+ throw PersistenceExceptions.toPersistenceException(e);
+ }
+ }
+
+ /**
+ * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated
+ * with the persistent type cls.
+ */
+ public static ClassMetaData getMetaData(EntityManagerFactory emf,
+ Class cls) {
+ if (emf == null)
+ throw new NullPointerException("emf == null");
+
+ OpenJPAEntityManagerFactorySPI emfSPI =
+ (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(emf);
+ try {
+ return emfSPI.getConfiguration().getMetaDataRepositoryInstance().
+ getMetaData(cls, null, false);
+ } catch (Exception e) {
+ throw PersistenceExceptions.toPersistenceException(e);
+ }
+ }
+
+ /**
+ * Translate from a OpenJPA identity object to a Persistence one.
+ */
+ public static Object fromOpenJPAObjectId(Object oid) {
+ if (oid instanceof OpenJPAId)
+ return ((OpenJPAId) oid).getIdObject();
+ return oid;
+ }
+
+ /**
+ * Translate from a Persistence identity object to a OpenJPA one.
+ */
+ public static Object toOpenJPAObjectId(ClassMetaData meta, Object oid) {
+ if (oid == null || meta == null)
+ return null;
+
+ Class cls = meta.getDescribedType();
+ if (meta.getIdentityType() == ClassMetaData.ID_DATASTORE)
+ return new Id(cls, ((Number) oid).longValue());
+
+ if (oid instanceof Byte)
+ return new ByteId(cls, (Byte) oid);
+ if (oid instanceof Character)
+ return new CharId(cls, (Character) oid);
+ if (oid instanceof Double)
+ return new DoubleId(cls, (Double) oid);
+ if (oid instanceof Float)
+ return new FloatId(cls, (Float) oid);
+ if (oid instanceof Integer)
+ return new IntId(cls, (Integer) oid);
+ if (oid instanceof Long)
+ return new LongId(cls, (Long) oid);
+ if (oid instanceof Short)
+ return new ShortId(cls, (Short) oid);
+ if (oid instanceof String)
+ return new StringId(cls, (String) oid);
+ return new ObjectId(cls, oid);
+ }
+
+ /**
+ * Return an array of OpenJPA oids for the given native oid array.
+ */
+ public static Object[] toOpenJPAObjectIds(ClassMetaData meta,
+ Object... oids) {
+ if (oids == null || oids.length == 0)
+ return oids;
+
+ // since the class if fixed for all oids, we can tell if we have to
+ // translate the array based on whether the first oid needs translating
+ Object oid = toOpenJPAObjectId(meta, oids[0]);
+ if (oid == oids[0])
+ return oids;
+
+ Object[] copy = new Object[oids.length];
+ copy[0] = oid;
+ for (int i = 1; i < oids.length; i++)
+ copy[i] = toOpenJPAObjectId(meta, oids[i]);
+ return copy;
+ }
+
+ /**
+ * Return a collection of OpenJPA oids for the given native oid collection.
+ */
+ public static Collection toOpenJPAObjectIds(ClassMetaData meta,
+ Collection oids) {
+ if (oids == null || oids.isEmpty())
+ return oids;
+
+ // since the class if fixed for all oids, we can tell if we have to
+ // translate the array based on whether the first oid needs translating
+ Iterator itr = oids.iterator();
+ Object orig = itr.next();
+ Object oid = toOpenJPAObjectId(meta, orig);
+ if (oid == orig)
+ return oids;
+
+ Collection copy = new ArrayList(oids.size());
+ copy.add(oid);
+ while (itr.hasNext())
+ copy.add(toOpenJPAObjectId(meta, itr.next()));
+ return copy;
+ }
+
+ /**
+ * Translate from a OpenJPA identity class to a native one.
+ */
+ public static Class fromOpenJPAObjectIdClass(Class oidClass) {
+ if (oidClass == null)
+ return null;
+ if (oidClass == Id.class)
+ return Long.class;
+ if (oidClass == ByteId.class)
+ return Byte.class;
+ if (oidClass == CharId.class)
+ return Character.class;
+ if (oidClass == DoubleId.class)
+ return Double.class;
+ if (oidClass == FloatId.class)
+ return Float.class;
+ if (oidClass == IntId.class)
+ return Integer.class;
+ if (oidClass == LongId.class)
+ return Long.class;
+ if (oidClass == ShortId.class)
+ return Short.class;
+ if (oidClass == StringId.class)
+ return String.class;
+ return oidClass;
+ }
+}
--- 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-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-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/src/main/java/org/apache/openjpa/persistence/CallbackType.java Fri Aug 17 19:12:50 PDT 2007
+++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/CallbackType.java Fri Aug 17 19:12:50 PDT 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence;
+
+import java.util.EnumSet;
+
+import org.apache.openjpa.event.CallbackModes;
+
+/**
+ * The possible settings for the callback behavior of an
+ * {@link OpenJPAEntityManager}.
+ *
+ * @since 1.0.0
+ * @published
+ */
+public enum CallbackType {
+ FAIL_FAST(CallbackModes.CALLBACK_FAIL_FAST),
+ IGNORE(CallbackModes.CALLBACK_IGNORE),
+ LOG(CallbackModes.CALLBACK_LOG),
+ RETHROW(CallbackModes.CALLBACK_RETHROW),
+ ROLLBACK(CallbackModes.CALLBACK_ROLLBACK);
+
+ private final int callbackMode;
+
+ private CallbackType(int value) {
+ callbackMode = value;
+ }
+
+ public static EnumSeto.
- */
- public static ClassMetaData getMetaData(Object o) {
- if (o == null)
- return null;
- EntityManager em = getEntityManager(o);
- return (em == null) ? null : getMetaData(em,
- ImplHelper.getManagedInstance(o).getClass());
- }
-
- /**
- * Returns the {@link ClassMetaData} associated with the
- * persistent type cls.
- */
- public static ClassMetaData getMetaData(EntityManager em, Class cls) {
- if (em == null)
- throw new NullPointerException("em == null");
-
- OpenJPAEntityManager kem = cast(em);
- try {
- return kem.getConfiguration().getMetaDataRepositoryInstance().
- getMetaData(cls, kem.getClassLoader(), false);
- } catch (Exception e) {
- throw PersistenceExceptions.toPersistenceException(e);
- }
- }
-
- /**
- * Returns the {@link ClassMetaData} associated with the
- * persistent type cls.
- */
- public static ClassMetaData getMetaData(EntityManagerFactory emf,
- Class cls) {
- if (emf == null)
- throw new NullPointerException("emf == null");
-
- OpenJPAEntityManagerFactory kemf = cast(emf);
- try {
- return kemf.getConfiguration().getMetaDataRepositoryInstance().
- getMetaData(cls, null, false);
- } catch (Exception e) {
- throw PersistenceExceptions.toPersistenceException(e);
- }
- }
-
- /**
* Close the given resource. The resource can be an extent iterator,
* query result, large result set relation, or any closeable OpenJPA
* component.
@@ -347,132 +189,11 @@
/**
* 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) {
throw PersistenceExceptions.toPersistenceException(e);
}
}
-
- /**
- * 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) {
- if (oid instanceof OpenJPAId)
- return ((OpenJPAId) oid).getIdObject();
- return oid;
- }
-
- /**
- * Translate from a Persistence identity object to a OpenJPA one.
- */
- public static Object toOpenJPAObjectId(ClassMetaData meta, Object oid) {
- if (oid == null || meta == null)
- return null;
-
- Class cls = meta.getDescribedType();
- if (meta.getIdentityType() == ClassMetaData.ID_DATASTORE)
- return new Id(cls, ((Number) oid).longValue());
-
- if (oid instanceof Byte)
- return new ByteId(cls, (Byte) oid);
- if (oid instanceof Character)
- return new CharId(cls, (Character) oid);
- if (oid instanceof Double)
- return new DoubleId(cls, (Double) oid);
- if (oid instanceof Float)
- return new FloatId(cls, (Float) oid);
- if (oid instanceof Integer)
- return new IntId(cls, (Integer) oid);
- if (oid instanceof Long)
- return new LongId(cls, (Long) oid);
- if (oid instanceof Short)
- return new ShortId(cls, (Short) oid);
- if (oid instanceof String)
- return new StringId(cls, (String) oid);
- return new ObjectId(cls, oid);
- }
-
- /**
- * Return an array of OpenJPA oids for the given native oid array.
- */
- public static Object[] toOpenJPAObjectIds(ClassMetaData meta,
- Object... oids) {
- if (oids == null || oids.length == 0)
- return oids;
-
- // since the class if fixed for all oids, we can tell if we have to
- // translate the array based on whether the first oid needs translating
- Object oid = toOpenJPAObjectId(meta, oids[0]);
- if (oid == oids[0])
- return oids;
-
- Object[] copy = new Object[oids.length];
- copy[0] = oid;
- for (int i = 1; i < oids.length; i++)
- copy[i] = toOpenJPAObjectId(meta, oids[i]);
- return copy;
- }
-
- /**
- * Return a collection of OpenJPA oids for the given native oid collection.
- */
- public static Collection toOpenJPAObjectIds(ClassMetaData meta,
- Collection oids) {
- if (oids == null || oids.isEmpty())
- return oids;
-
- // since the class if fixed for all oids, we can tell if we have to
- // translate the array based on whether the first oid needs translating
- Iterator itr = oids.iterator();
- Object orig = itr.next();
- Object oid = toOpenJPAObjectId(meta, orig);
- if (oid == orig)
- return oids;
-
- Collection copy = new ArrayList(oids.size());
- copy.add(oid);
- while (itr.hasNext())
- copy.add(toOpenJPAObjectId(meta, itr.next()));
- return copy;
- }
-
- /**
- * Translate from a OpenJPA identity class to a native one.
- */
- public static Class fromOpenJPAObjectIdClass(Class oidClass) {
- if (oidClass == null)
- return null;
- if (oidClass == Id.class)
- return Long.class;
- if (oidClass == ByteId.class)
- return Byte.class;
- if (oidClass == CharId.class)
- return Character.class;
- if (oidClass == DoubleId.class)
- return Double.class;
- if (oidClass == FloatId.class)
- return Float.class;
- if (oidClass == IntId.class)
- return Integer.class;
- if (oidClass == LongId.class)
- return Long.class;
- if (oidClass == ShortId.class)
- return Short.class;
- if (oidClass == StringId.class)
- return String.class;
- return oidClass;
- }
-}
--- 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-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEventManager.java (revision 565999)
+++ openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEventManager.java Fri Aug 17 19:35:07 PDT 2007
@@ -44,7 +44,7 @@
protected void fireEvent(Object event, Object listener) {
try {
BrokerFactoryEvent e = (BrokerFactoryEvent) event;
- ((BrokerFactoryListener) listener).afterBrokerFactoryCreate(e);
+ ((BrokerFactoryListener) listener).eventFired(e);
} catch (Exception e) {
_conf.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn(
_loc.get("broker-factory-listener-exception"), e);
--- 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 Sun Aug 19 23:33:50 PDT 2007
@@ -21,16 +21,11 @@
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
+import java.util.EnumSet;
import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.Query;
-import javax.resource.ResourceException;
-import javax.resource.cci.ConnectionMetaData;
-import javax.resource.cci.Interaction;
-import javax.resource.cci.LocalTransaction;
-import javax.resource.cci.ResultSetInfo;
import org.apache.commons.lang.StringUtils;
import org.apache.openjpa.conf.OpenJPAConfiguration;
@@ -46,6 +41,7 @@
import org.apache.openjpa.kernel.Seq;
import org.apache.openjpa.kernel.jpql.JPQLParser;
import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.Closeable;
import org.apache.openjpa.meta.ClassMetaData;
import org.apache.openjpa.meta.FieldMetaData;
import org.apache.openjpa.meta.QueryMetaData;
@@ -63,7 +59,8 @@
* @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 +68,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 +89,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 +110,9 @@
}
}
- public int getConnectionRetainMode() {
- return _broker.getConnectionRetainMode();
+ public ConnectionRetainType getConnectionRetainMode() {
+ return ConnectionRetainType.fromKernelConstant(
+ _broker.getConnectionRetainMode());
}
public boolean isManaged() {
@@ -211,13 +189,13 @@
_broker.setOptimistic(val);
}
- public int getRestoreState() {
- return _broker.getRestoreState();
+ public RestoreStateType getRestoreState() {
+ return RestoreStateType.fromKernelConstant(_broker.getRestoreState());
}
- public void setRestoreState(int val) {
+ public void setRestoreState(RestoreStateType val) {
assertNotCloseInvoked();
- _broker.setRestoreState(val);
+ _broker.setRestoreState(val.toKernelConstant());
}
public boolean getRetainState() {
@@ -229,33 +207,38 @@
_broker.setRetainState(val);
}
- public int getAutoClear() {
- return _broker.getAutoClear();
+ public AutoClearType getAutoClear() {
+ return AutoClearType.fromKernelConstant(_broker.getAutoClear());
}
- public void setAutoClear(int val) {
+ public void setAutoClear(AutoClearType val) {
assertNotCloseInvoked();
- _broker.setAutoClear(val);
+ _broker.setAutoClear(val.toKernelConstant());
}
- public int getDetachState() {
- return _broker.getDetachState();
+ public DetachStateType getDetachState() {
+ return DetachStateType.fromKernelConstant(_broker.getDetachState());
}
- public void setDetachState(int mode) {
+ public void setDetachState(DetachStateType type) {
assertNotCloseInvoked();
- _broker.setDetachState(mode);
+ _broker.setDetachState(type.toKernelConstant());
}
- public int getAutoDetach() {
- return _broker.getAutoDetach();
+ public EnumSetnull 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-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryListener.java (revision 565999)
+++ openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryListener.java Fri Aug 17 19:35:07 PDT 2007
@@ -31,5 +31,5 @@
* Invoked after a {@link BrokerFactory} has been fully created.
* This happens after the factory has been made read-only.
*/
- public void afterBrokerFactoryCreate(BrokerFactoryEvent event);
+ public void eventFired(BrokerFactoryEvent event);
}
--- 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/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/test/java/org/apache/openjpa/persistence/TestEnumToKernelConstantMappings.java Fri Aug 17 19:12:50 PDT 2007
+++ openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestEnumToKernelConstantMappings.java Fri Aug 17 19:12:50 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,
+ ConnectionRetainType.ALWAYS.toKernelConstant());
+ assertEquals(ConnectionRetainType.ALWAYS,
+ ConnectionRetainType.fromKernelConstant(
+ ConnectionRetainModes.CONN_RETAIN_ALWAYS));
+ assertEquals(ConnectionRetainType.ALWAYS.toKernelConstant(),
+ ConnectionRetainType.ALWAYS.ordinal());
+
+ assertEquals(ConnectionRetainModes.CONN_RETAIN_DEMAND,
+ ConnectionRetainType.ON_DEMAND.toKernelConstant());
+ assertEquals(ConnectionRetainType.ON_DEMAND,
+ ConnectionRetainType.fromKernelConstant(
+ ConnectionRetainModes.CONN_RETAIN_DEMAND));
+ assertEquals(ConnectionRetainType.ON_DEMAND.toKernelConstant(),
+ ConnectionRetainType.ON_DEMAND.ordinal());
+
+ assertEquals(ConnectionRetainModes.CONN_RETAIN_TRANS,
+ ConnectionRetainType.TRANSACTION.toKernelConstant());
+ assertEquals(ConnectionRetainType.TRANSACTION,
+ ConnectionRetainType.fromKernelConstant(
+ ConnectionRetainModes.CONN_RETAIN_TRANS));
+ assertEquals(ConnectionRetainType.TRANSACTION.toKernelConstant(),
+ ConnectionRetainType.TRANSACTION.ordinal());
+
+ assertEquals(getConstantCount(ConnectionRetainModes.class),
+ ConnectionRetainType.values().length);
+ }
+
+ public void testDetachState() {
+ assertEquals(DetachState.DETACH_ALL,
+ DetachStateType.ALL.toKernelConstant());
+ assertEquals(DetachStateType.ALL,
+ DetachStateType.fromKernelConstant(DetachState.DETACH_ALL));
+ assertEquals(DetachStateType.ALL.toKernelConstant(),
+ DetachStateType.ALL.ordinal());
+
+ assertEquals(DetachState.DETACH_FETCH_GROUPS,
+ DetachStateType.FETCH_GROUPS.toKernelConstant());
+ assertEquals(DetachStateType.FETCH_GROUPS,
+ DetachStateType.fromKernelConstant(
+ DetachState.DETACH_FETCH_GROUPS));
+ assertEquals(DetachStateType.FETCH_GROUPS.toKernelConstant(),
+ DetachStateType.FETCH_GROUPS.ordinal());
+
+ assertEquals(DetachState.DETACH_LOADED,
+ DetachStateType.LOADED.toKernelConstant());
+ assertEquals(DetachStateType.LOADED,
+ DetachStateType.fromKernelConstant(DetachState.DETACH_LOADED));
+ assertEquals(DetachStateType.LOADED.toKernelConstant(),
+ DetachStateType.LOADED.ordinal());
+
+ // subtract 1 for DetachState.DETACH_FGS, which is deprecated
+ assertEquals(getConstantCount(DetachState.class) - 1,
+ DetachStateType.values().length);
+ }
+
+ public void testRestoreState() {
+ assertEquals(RestoreState.RESTORE_ALL,
+ RestoreStateType.ALL.toKernelConstant());
+ assertEquals(RestoreStateType.ALL,
+ RestoreStateType.fromKernelConstant(RestoreState.RESTORE_ALL));
+ assertEquals(RestoreStateType.ALL.toKernelConstant(),
+ RestoreStateType.ALL.ordinal());
+
+ assertEquals(RestoreState.RESTORE_IMMUTABLE,
+ RestoreStateType.IMMUTABLE.toKernelConstant());
+ assertEquals(RestoreStateType.IMMUTABLE,
+ RestoreStateType.fromKernelConstant(
+ RestoreState.RESTORE_IMMUTABLE));
+ assertEquals(RestoreStateType.IMMUTABLE.toKernelConstant(),
+ RestoreStateType.IMMUTABLE.ordinal());
+
+ assertEquals(RestoreState.RESTORE_NONE,
+ RestoreStateType.NONE.toKernelConstant());
+ assertEquals(RestoreStateType.NONE,
+ RestoreStateType.fromKernelConstant(RestoreState.RESTORE_NONE));
+ assertEquals(RestoreStateType.NONE.toKernelConstant(),
+ RestoreStateType.NONE.ordinal());
+
+ assertEquals(getConstantCount(RestoreState.class),
+ RestoreStateType.values().length);
+ }
+
+ public void testAutoClear() {
+ assertEquals(AutoClear.CLEAR_ALL, AutoClearType.ALL.toKernelConstant());
+ assertEquals(AutoClearType.ALL,
+ AutoClearType.fromKernelConstant(AutoClear.CLEAR_ALL));
+ assertEquals(AutoClearType.ALL.toKernelConstant(),
+ AutoClearType.ALL.ordinal());
+
+ assertEquals(AutoClear.CLEAR_DATASTORE,
+ AutoClearType.DATASTORE.toKernelConstant());
+ assertEquals(AutoClearType.DATASTORE,
+ AutoClearType.fromKernelConstant(AutoClear.CLEAR_DATASTORE));
+ assertEquals(AutoClearType.DATASTORE.toKernelConstant(),
+ AutoClearType.DATASTORE.ordinal());
+
+ assertEquals(getConstantCount(AutoClear.class),
+ AutoClearType.values().length);
+ }
+
+ public void testAutoDetach() {
+ assertEquals(getConstantCount(AutoDetach.class),
+ AutoDetachType.values().length);
+
+ assertEquals(EnumSet.of(AutoDetachType.CLOSE),
+ AutoDetachType.toEnumSet(AutoDetach.DETACH_CLOSE));
+ assertEquals(AutoDetach.DETACH_CLOSE,
+ AutoDetachType.fromEnumSet(EnumSet.of(AutoDetachType.CLOSE)));
+
+ assertEquals(EnumSet.of(AutoDetachType.COMMIT),
+ AutoDetachType.toEnumSet(AutoDetach.DETACH_COMMIT));
+ assertEquals(AutoDetach.DETACH_COMMIT,
+ AutoDetachType.fromEnumSet(EnumSet.of(AutoDetachType.COMMIT)));
+
+ assertEquals(EnumSet.of(AutoDetachType.NON_TRANSACTIONAL_READ),
+ AutoDetachType.toEnumSet(AutoDetach.DETACH_NONTXREAD));
+ assertEquals(AutoDetach.DETACH_NONTXREAD,
+ AutoDetachType.fromEnumSet(
+ EnumSet.of(AutoDetachType.NON_TRANSACTIONAL_READ)));
+
+ assertEquals(EnumSet.of(AutoDetachType.ROLLBACK),
+ AutoDetachType.toEnumSet(AutoDetach.DETACH_ROLLBACK));
+ assertEquals(AutoDetach.DETACH_ROLLBACK,
+ AutoDetachType.fromEnumSet(EnumSet.of(AutoDetachType.ROLLBACK)));
+
+
+ assertEquals(EnumSet.of(AutoDetachType.CLOSE, AutoDetachType.COMMIT),
+ AutoDetachType.toEnumSet(
+ AutoDetach.DETACH_CLOSE | AutoDetach.DETACH_COMMIT));
+ assertEquals(AutoDetach.DETACH_ROLLBACK | AutoDetach.DETACH_CLOSE,
+ AutoDetachType.fromEnumSet(
+ EnumSet.of(AutoDetachType.ROLLBACK, AutoDetachType.CLOSE)));
+
+
+ assertEquals(EnumSet.allOf(AutoDetachType.class),
+ AutoDetachType.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,
+ AutoDetachType.fromEnumSet(EnumSet.allOf(AutoDetachType.class)));
+ }
+
+ public void testCallbackMode() {
+ assertEquals(getConstantCount(CallbackModes.class),
+ CallbackType.values().length);
+
+ assertEquals(EnumSet.of(CallbackType.FAIL_FAST),
+ CallbackType.toEnumSet(CallbackModes.CALLBACK_FAIL_FAST));
+ assertEquals(CallbackModes.CALLBACK_FAIL_FAST,
+ CallbackType.fromEnumSet(EnumSet.of(CallbackType.FAIL_FAST)));
+
+ assertEquals(EnumSet.of(CallbackType.IGNORE),
+ CallbackType.toEnumSet(CallbackModes.CALLBACK_IGNORE));
+ assertEquals(CallbackModes.CALLBACK_IGNORE,
+ CallbackType.fromEnumSet(EnumSet.of(CallbackType.IGNORE)));
+
+ assertEquals(EnumSet.of(CallbackType.LOG),
+ CallbackType.toEnumSet(CallbackModes.CALLBACK_LOG));
+ assertEquals(CallbackModes.CALLBACK_LOG,
+ CallbackType.fromEnumSet(EnumSet.of(CallbackType.LOG)));
+
+ assertEquals(EnumSet.of(CallbackType.RETHROW),
+ CallbackType.toEnumSet(CallbackModes.CALLBACK_RETHROW));
+ assertEquals(CallbackModes.CALLBACK_RETHROW,
+ CallbackType.fromEnumSet(EnumSet.of(CallbackType.RETHROW)));
+
+ assertEquals(EnumSet.of(CallbackType.ROLLBACK),
+ CallbackType.toEnumSet(CallbackModes.CALLBACK_ROLLBACK));
+ assertEquals(CallbackModes.CALLBACK_ROLLBACK,
+ CallbackType.fromEnumSet(EnumSet.of(CallbackType.ROLLBACK)));
+
+
+ assertEquals(EnumSet.of(CallbackType.ROLLBACK, CallbackType.IGNORE),
+ CallbackType.toEnumSet(CallbackModes.CALLBACK_ROLLBACK
+ | CallbackModes.CALLBACK_IGNORE));
+ assertEquals(
+ CallbackModes.CALLBACK_ROLLBACK | CallbackModes.CALLBACK_IGNORE,
+ CallbackType.fromEnumSet(
+ EnumSet.of(CallbackType.ROLLBACK, CallbackType.IGNORE)));
+
+
+ assertEquals(EnumSet.allOf(CallbackType.class),
+ CallbackType.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,
+ CallbackType.fromEnumSet(EnumSet.allOf(CallbackType.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/src/main/java/org/apache/openjpa/persistence/RestoreStateType.java Fri Aug 17 19:12:50 PDT 2007
+++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RestoreStateType.java Fri Aug 17 19:12:50 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 RestoreStateType {
+ NONE(RestoreState.RESTORE_NONE),
+ IMMUTABLE(RestoreState.RESTORE_IMMUTABLE),
+ ALL(RestoreState.RESTORE_ALL);
+
+ private final int restoreStateConstant;
+
+ private RestoreStateType(int value) {
+ restoreStateConstant = value;
+ }
+
+ int toKernelConstant() {
+ return restoreStateConstant;
+ }
+
+ static RestoreStateType 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-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-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/LRSSizeType.java Fri Aug 17 19:30:38 PDT 2007
+++ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/LRSSizeType.java Fri Aug 17 19:30:38 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.jdbc;
+
+import org.apache.openjpa.jdbc.kernel.LRSSizes;
+
+/**
+ * Algorithm to use for computing the size of an LRS relation.
+ *
+ * @since 1.0.0
+ * @published
+ */
+public enum LRSSizeType {
+ UNKNOWN(LRSSizes.SIZE_UNKNOWN),
+ LAST(LRSSizes.SIZE_LAST),
+ QUERY(LRSSizes.SIZE_QUERY);
+
+ private final int lrsConstant;
+
+ private LRSSizeType(int value) {
+ lrsConstant = value;
+ }
+
+ int toKernelConstant() {
+ return lrsConstant;
+ }
+
+ static LRSSizeType fromKernelConstant(int kernelConstant) {
+ switch (kernelConstant) {
+ case LRSSizes.SIZE_UNKNOWN:
+ return UNKNOWN;
+
+ case LRSSizes.SIZE_LAST:
+ return LAST;
+
+ case LRSSizes.SIZE_QUERY:
+ return QUERY;
+
+ default:
+ throw new IllegalArgumentException(kernelConstant + "");
+ }
+ }
+}
\ No newline at end of file
--- 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-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java (revision 565999)
+++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java Fri Aug 17 19:49:15 PDT 2007
@@ -18,17 +18,12 @@
*/
package org.apache.openjpa.persistence.test;
-import java.util.Map;
-import java.util.HashMap;
-import javax.persistence.Persistence;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
-import junit.framework.TestCase;
-import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
-
public abstract class SingleEMFTestCase
extends PersistenceTestCase {
- protected OpenJPAEntityManagerFactory emf;
+ protected OpenJPAEntityManagerFactorySPI emf;
/**
* Initialize entity manager factory. Put {@link #CLEAR_TABLES} in
--- 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 Iterableorg.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 Sun Aug 19 23:33:50 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;
@@ -243,8 +243,8 @@
if (o == null)
return null;
if (o instanceof Broker)
- return OpenJPAPersistence.toEntityManager((Broker) o);
- return OpenJPAPersistence.fromOpenJPAObjectId(o);
+ return JPAFacadeHelper.toEntityManager((Broker) o);
+ return JPAFacadeHelper.fromOpenJPAObjectId(o);
}
/**
--- 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/AutoDetachType.java Fri Aug 17 19:12:50 PDT 2007
+++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AutoDetachType.java Fri Aug 17 19:12:50 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 AutoDetachType {
+ CLOSE(AutoDetach.DETACH_CLOSE),
+ COMMIT(AutoDetach.DETACH_COMMIT),
+ NON_TRANSACTIONAL_READ(AutoDetach.DETACH_NONTXREAD),
+ ROLLBACK(AutoDetach.DETACH_ROLLBACK);
+
+ private final int autoDetachConstant;
+
+ private AutoDetachType(int value) {
+ autoDetachConstant = value;
+ }
+
+ public static EnumSetmanager.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 Sun Aug 19 23:33:50 PDT 2007 @@ -27,6 +27,8 @@ import javax.sql.DataSource; import org.apache.openjpa.persistence.OpenJPAPersistence; +import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; +import org.apache.openjpa.persistence.JPAFacadeHelper; import org.apache.openjpa.persistence.test.SingleEMFTestCase; import org.apache.openjpa.event.RemoteCommitListener; import org.apache.openjpa.event.RemoteCommitEvent; @@ -78,8 +80,8 @@ em = emf.createEntityManager(); em.getTransaction().begin(); OptimisticLockInstance oli = em.find(OptimisticLockInstance.class, pk); - Object oid = OpenJPAPersistence.toOpenJPAObjectId( - OpenJPAPersistence.getMetaData(oli), + Object oid = JPAFacadeHelper.toOpenJPAObjectId( + JPAFacadeHelper.getMetaData(oli), OpenJPAPersistence.cast(em).getObjectId(oli)); int firstOpLockValue = oli.getOpLock(); em.lock(oli, LockModeType.READ); @@ -88,8 +90,9 @@ // via direct SQL in a separate transaction int secondOpLockValue = firstOpLockValue + 1; - DataSource ds = (DataSource) OpenJPAPersistence.cast(em) - .getEntityManagerFactory().getConfiguration() + OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI) + OpenJPAPersistence.cast(em).getEntityManagerFactory(); + DataSource ds = (DataSource) emf.getConfiguration() .getConnectionFactory(); Connection c = ds.getConnection(); c.setAutoCommit(false); @@ -120,7 +123,7 @@ // 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
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 Fri Aug 17 19:12:50 PDT 2007
@@ -24,7 +24,6 @@
import junit.framework.*;
-import org.apache.openjpa.kernel.AutoDetach;
import org.apache.openjpa.persistence.*;
public class TestAutoDetachProperty extends TestCase {
@@ -63,17 +62,20 @@
}
private boolean isAutoDetachingOnClose() {
- int autoDetachFlags = OpenJPAPersistence.cast(em).getAutoDetach();
- return (autoDetachFlags & AutoDetach.DETACH_CLOSE) > 0;
+ EnumSetmanager.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 Sun Aug 19 23:33:50 PDT 2007 @@ -50,13 +50,16 @@ PersistenceExceptions.TRANSLATOR); } + /** + * Delegate. + */ public DataCache getDelegate() { return _cache.getDelegate(); } public boolean contains(Class cls, Object oid) { return _cache.getDelegate() != null && _cache.contains - (OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls), oid)); + (JPAFacadeHelper.toOpenJPAObjectId(getMetaData(cls), oid)); } public boolean containsAll(Class cls, Object... oids) { @@ -67,7 +70,7 @@ if (_cache.getDelegate() == null) return oids.isEmpty(); - BitSet set = _cache.containsAll(OpenJPAPersistence.toOpenJPAObjectIds + BitSet set = _cache.containsAll(JPAFacadeHelper.toOpenJPAObjectIds (getMetaData(cls), oids)); for (int i = 0; i < oids.size(); i++) if (!set.get(i)) @@ -77,7 +80,7 @@ public void pin(Class cls, Object oid) { if (_cache.getDelegate() != null) - _cache.pin(OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls), + _cache.pin(JPAFacadeHelper.toOpenJPAObjectId(getMetaData(cls), oid)); } @@ -87,13 +90,13 @@ public void pinAll(Class cls, Collection oids) { if (_cache.getDelegate() != null) - _cache.pinAll(OpenJPAPersistence.toOpenJPAObjectIds + _cache.pinAll(JPAFacadeHelper.toOpenJPAObjectIds (getMetaData(cls), oids)); } public void unpin(Class cls, Object oid) { if (_cache.getDelegate() != null) - _cache.unpin(OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls), + _cache.unpin(JPAFacadeHelper.toOpenJPAObjectId(getMetaData(cls), oid)); } @@ -103,13 +106,13 @@ public void unpinAll(Class cls, Collection oids) { if (_cache.getDelegate() != null) - _cache.unpinAll(OpenJPAPersistence.toOpenJPAObjectIds + _cache.unpinAll(JPAFacadeHelper.toOpenJPAObjectIds (getMetaData(cls), oids)); } public void evict(Class cls, Object oid) { if (_cache.getDelegate() != null) - _cache.remove(OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls), + _cache.remove(JPAFacadeHelper.toOpenJPAObjectId(getMetaData(cls), oid)); } @@ -119,7 +122,7 @@ public void evictAll(Class cls, Collection oids) { if (_cache.getDelegate() != null) - _cache.removeAll(OpenJPAPersistence.toOpenJPAObjectIds + _cache.removeAll(JPAFacadeHelper.toOpenJPAObjectIds (getMetaData(cls), oids)); } --- 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-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-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 Fri Aug 17 19:12:50 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.AutoDetachType; 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( + AutoDetachType.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( + AutoDetachType.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( + AutoDetachType.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 Fri Aug 17 19:36:24 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); @@ -44,8 +45,10 @@ boolean createEventReceived = false; - public void afterBrokerFactoryCreate(BrokerFactoryEvent event) { + public void eventFired(BrokerFactoryEvent event) { + if (event.getEventType() + == BrokerFactoryEvent.BROKER_FACTORY_CREATED) - createEventReceived = true; + createEventReceived = true; } } }