upgrading API (throwing exception for all new methods) to JPA 2.1

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/openjpa_jpa-2.1@1683942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Romain Manni-Bucau 2015-06-06 19:19:11 +00:00
parent 692bc96d3c
commit b88cbdee93
25 changed files with 292 additions and 29 deletions

View File

@ -458,7 +458,7 @@ databaseName=${db.name}
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -32,6 +32,16 @@ public class DummyProvider1 implements PersistenceProvider {
return null;
}
@Override
public void generateSchema(PersistenceUnitInfo info, Map map) {
// no-op
}
@Override
public boolean generateSchema(String persistenceUnitName, Map map) {
return false;
}
public EntityManagerFactory createEntityManagerFactory(String s, Map map) {
return null;
}

View File

@ -32,6 +32,16 @@ public class DummyProvider2 implements PersistenceProvider {
return null;
}
@Override
public void generateSchema(PersistenceUnitInfo info, Map map) {
// no-op
}
@Override
public boolean generateSchema(String persistenceUnitName, Map map) {
return false;
}
public EntityManagerFactory createEntityManagerFactory(String s, Map map) {
return null;
}

View File

@ -44,7 +44,7 @@
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>

View File

@ -28,6 +28,8 @@ import javax.persistence.*;
import org.apache.openjpa.jdbc.meta.strats.*;
import org.apache.openjpa.persistence.*;
import org.apache.openjpa.persistence.jdbc.*;
import org.apache.openjpa.persistence.jdbc.ForeignKey;
import org.apache.openjpa.persistence.jdbc.Index;
import org.apache.openjpa.persistence.jdbc.OrderColumn;

View File

@ -44,7 +44,7 @@
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -25,9 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.persistence.Cache;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnitUtil;
import javax.persistence.*;
import javax.persistence.spi.LoadState;
import org.apache.commons.lang.StringUtils;
@ -150,7 +148,7 @@ public class EntityManagerFactoryImpl
}
public OpenJPAEntityManagerSPI createEntityManager() {
return createEntityManager(null);
return createEntityManager((Map) null);
}
/**
@ -242,7 +240,17 @@ public class EntityManagerFactoryImpl
}
return em;
}
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) {
throw new UnsupportedOperationException("JPA 2.1");
}
/**
* Create a new entity manager around the given broker.
*/
@ -354,6 +362,24 @@ public class EntityManagerFactoryImpl
return this;
}
@Override
public void addNamedQuery(String name, Query query) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <T> T unwrap(Class<T> cls) {
if (cls.isInstance(this)) {
return cls.cast(this);
}
throw new javax.persistence.PersistenceException(this + " is not a " + cls);
}
@Override
public <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph) {
throw new UnsupportedOperationException("JPA 2.1");
}
/**
* Get the identifier for the specified entity. If not managed by any
* of the em's in this PU or not persistence capable, return null.

View File

@ -36,18 +36,23 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.CacheRetrieveMode;
import javax.persistence.CacheStoreMode;
import javax.persistence.EntityGraph;
import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.PessimisticLockScope;
import javax.persistence.Query;
import javax.persistence.StoredProcedureQuery;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaDelete;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.CriteriaUpdate;
import javax.persistence.criteria.ParameterExpression;
import javax.persistence.metamodel.Metamodel;
@ -560,6 +565,12 @@ public class EntityManagerImpl
("no-managed-trans"), null, null, false);
}
@Override
public boolean isJoinedToTransaction() {
// throw new UnsupportedOperationException("JPA 2.1");
return false;
}
public void begin() {
_broker.begin();
}
@ -1066,6 +1077,26 @@ public class EntityManagerImpl
return newQueryImpl(kernelQuery, null);
}
@Override
public StoredProcedureQuery createNamedStoredProcedureQuery(String name) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public StoredProcedureQuery createStoredProcedureQuery(String procedureName) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) {
throw new UnsupportedOperationException("JPA 2.1");
}
protected <T> QueryImpl<T> newQueryImpl(org.apache.openjpa.kernel.Query kernelQuery, QueryMetaData qmd) {
return new QueryImpl<T>(this, _ret, kernelQuery, qmd);
}
@ -1622,7 +1653,17 @@ public class EntityManagerImpl
}
return facadeQuery;
}
@Override
public Query createQuery(CriteriaUpdate updateQuery) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public Query createQuery(CriteriaDelete deleteQuery) {
throw new UnsupportedOperationException("JPA 2.1");
}
public OpenJPAQuery createDynamicQuery(
org.apache.openjpa.persistence.query.QueryDefinition qdef) {
String jpql = _emf.getDynamicQueryBuilder().toJPQL(qdef);
@ -1779,6 +1820,26 @@ public class EntityManagerImpl
return _emf.getMetamodel();
}
@Override
public <T> EntityGraph<T> createEntityGraph(Class<T> rootType) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public EntityGraph<?> createEntityGraph(String graphName) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public EntityGraph<?> getEntityGraph(String graphName) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {
throw new UnsupportedOperationException("JPA 2.1");
}
/**
* Sets the given property to the given value, reflectively.
*

View File

@ -220,6 +220,16 @@ public class PersistenceProviderImpl
}
}
@Override
public void generateSchema(PersistenceUnitInfo info, Map map) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public boolean generateSchema(String persistenceUnitName, Map map) {
throw new UnsupportedOperationException("JPA 2.1");
}
public void setPersistenceEnvironmentInfo(OpenJPAConfiguration conf, PersistenceUnitInfo pui) {
// OPENJPA-1460 Fix scope visibility of orm.xml when it is packaged in both ear file and war file
if (conf instanceof OpenJPAConfigurationImpl) {

View File

@ -129,7 +129,15 @@ public class StoreCacheImpl
public void evictAll() {
_cache.clear();
}
@Override
public <T> T unwrap(Class<T> cls) {
if (cls.isInstance(this)) {
return cls.cast(this);
}
throw new javax.persistence.PersistenceException(cls.getName() + " not supported");
}
public CacheStatistics getStatistics() {
return (_cache == null) ? null : _cache.getStatistics();
}

View File

@ -29,13 +29,22 @@ import java.util.Map;
import java.util.Set;
import javax.persistence.Tuple;
import javax.persistence.criteria.CollectionJoin;
import javax.persistence.criteria.CompoundSelection;
import javax.persistence.criteria.CriteriaDelete;
import javax.persistence.criteria.CriteriaUpdate;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.ListJoin;
import javax.persistence.criteria.MapJoin;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.ParameterExpression;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Selection;
import javax.persistence.criteria.SetJoin;
import javax.persistence.criteria.Subquery;
import javax.persistence.criteria.Predicate.BooleanOperator;
import javax.persistence.metamodel.Attribute;
@ -108,6 +117,16 @@ public class CriteriaBuilderImpl implements OpenJPACriteriaBuilder, ExpressionPa
return new CriteriaQueryImpl<Tuple>(_model, Tuple.class);
}
@Override
public <T> CriteriaUpdate<T> createCriteriaUpdate(Class<T> targetEntity) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <T> CriteriaDelete<T> createCriteriaDelete(Class<T> targetEntity) {
throw new UnsupportedOperationException("JPA 2.1");
}
public Object parse(String ql, ExpressionStoreQuery query) {
throw new AbstractMethodError();
}
@ -252,6 +271,41 @@ public class CriteriaBuilderImpl implements OpenJPACriteriaBuilder, ExpressionPa
return new Expressions.DatabaseFunction(name, type, args);
}
@Override
public <X, T, V extends T> Join<X, V> treat(Join<X, T> join, Class<V> type) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <X, T, E extends T> CollectionJoin<X, E> treat(CollectionJoin<X, T> join, Class<E> type) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <X, T, E extends T> SetJoin<X, E> treat(SetJoin<X, T> join, Class<E> type) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <X, T, E extends T> ListJoin<X, E> treat(ListJoin<X, T> join, Class<E> type) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <X, K, T, V extends T> MapJoin<X, K, V> treat(MapJoin<X, K, T> join, Class<V> type) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <X, T extends X> Path<T> treat(Path<X> path, Class<T> type) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public <X, T extends X> Root<T> treat(Root<X> root, Class<T> type) {
throw new UnsupportedOperationException("JPA 2.1");
}
public Predicate ge(Expression<? extends Number> x,
Expression<? extends Number> y) {
return new Expressions.GreaterThanEqual(x,y);

View File

@ -29,6 +29,7 @@ import javax.persistence.criteria.ListJoin;
import javax.persistence.criteria.MapJoin;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.PluralJoin;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.SetJoin;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.CollectionAttribute;
@ -138,7 +139,22 @@ abstract class Joins {
public Member<? extends Z, X> getMember() {
return (Member<? extends Z, X>) _member;
}
@Override
public Join<Z, X> on(Expression<Boolean> restriction) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public Join<Z, X> on(Predicate... restrictions) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public Predicate getOn() {
throw new UnsupportedOperationException("JPA 2.1");
}
/**
* Return the metamodel attribute corresponding to the join.
* @return metamodel attribute type corresponding to the join
@ -495,7 +511,22 @@ abstract class Joins {
public Collection(FromImpl<?,Z> parent, Members.CollectionAttributeImpl<? super Z, E> member, JoinType jt) {
super(parent, member, jt);
}
@Override
public CollectionJoin<Z, E> on(Expression<Boolean> restriction) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public CollectionJoin<Z, E> on(Predicate... restrictions) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public Predicate getOn() {
throw new UnsupportedOperationException("JPA 2.1");
}
public CollectionAttribute<? super Z, E> getModel() {
return (CollectionAttribute<? super Z, E>)_member;
}
@ -512,7 +543,22 @@ abstract class Joins {
public Set(FromImpl<?,Z> parent, Members.SetAttributeImpl<? super Z, E> member, JoinType jt) {
super(parent, member, jt);
}
@Override
public SetJoin<Z, E> on(Expression<Boolean> restriction) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public SetJoin<Z, E> on(Predicate... restrictions) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public Predicate getOn() {
throw new UnsupportedOperationException("JPA 2.1");
}
public SetAttribute<? super Z, E> getModel() {
return (SetAttribute<? super Z, E>)_member;
}
@ -531,7 +577,22 @@ abstract class Joins {
public List(FromImpl<?,Z> parent, Members.ListAttributeImpl<? super Z, E> member, JoinType jt) {
super(parent, member, jt);
}
@Override
public ListJoin<Z, E> on(Expression<Boolean> restriction) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public ListJoin<Z, E> on(Predicate... restrictions) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public Predicate getOn() {
throw new UnsupportedOperationException("JPA 2.1");
}
public ListAttribute<? super Z, E> getModel() {
return (ListAttribute<? super Z, E>)_member;
}
@ -556,7 +617,22 @@ abstract class Joins {
public Map(FromImpl<?,Z> parent, Members.MapAttributeImpl<? super Z, K,V> member, JoinType jt) {
super(parent, member, jt);
}
@Override
public MapJoin<Z, K, V> on(Expression<Boolean> restriction) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public MapJoin<Z, K, V> on(Predicate... restrictions) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public Predicate getOn() {
throw new UnsupportedOperationException("JPA 2.1");
}
public MapAttribute<? super Z, K,V> getModel() {
return (MapAttribute<? super Z, K,V>) _member;
}

View File

@ -27,6 +27,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import javax.persistence.criteria.AbstractQuery;
import javax.persistence.criteria.CollectionJoin;
import javax.persistence.criteria.CommonAbstractCriteria;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.ListJoin;
@ -94,7 +95,12 @@ class SubqueryImpl<T> extends ExpressionImpl<T> implements Subquery<T> {
public AbstractQuery<?> getParent() {
return _parent;
}
@Override
public CommonAbstractCriteria getContainingQuery() {
return getParent();
}
/**
* Gets the captive query to which this subquery delegates.
*/

View File

@ -140,7 +140,7 @@
<include>commons-dbcp:commons-dbcp</include>
<include>org.apache.geronimo.specs:geronimo-jta_1.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-jpa_2.0_spec</include>
<include>org.apache.geronimo.specs:geronimo-jpa_2.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-jms_1.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-validation_1.0_spec</include>
<include>org.apache.bval:org.apache.bval.bundle</include>

View File

@ -79,7 +79,7 @@
<include>commons-dbcp:commons-dbcp</include>
<include>org.apache.geronimo.specs:geronimo-jta_1.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-jpa_2.0_spec</include>
<include>org.apache.geronimo.specs:geronimo-jpa_2.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-jms_1.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-validation_1.0_spec</include>
<include>org.apache.bval:org.apache.bval.bundle</include>

View File

@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -30,7 +30,7 @@
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -109,7 +109,7 @@
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -43,7 +43,7 @@
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -36,7 +36,7 @@
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -36,7 +36,7 @@
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -36,7 +36,7 @@
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -523,8 +523,8 @@
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
<artifactId>geronimo-jpa_2.1_spec</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>

View File

@ -40,7 +40,7 @@ set JAVAC=%JAVA_HOME%\bin\javac
@rem Compiler classpath shown for a typical OpenJPA development environment in Windows.
@rem The essential aspect is openjpa libraries must be in the compiler's classpath.
set M_REPO="%USERPROFILE%\.m2\repository"
set SPEC=geronimo-jpa_2.0_spec
set SPEC=geronimo-jpa_2.1_spec
set VERSION=1.0-EA9-SNAPSHOT
set JPA_LIB=%M_REPO%\org\apache\geronimo\specs\%SPEC%\%VERSION%\%SPEC%-%VERSION%.jar