diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity.java index 33a31887a..b335db13c 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity.java @@ -28,6 +28,7 @@ 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.OrderColumn; @Entity diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java index c668d7a61..a081ffc76 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java @@ -28,7 +28,10 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; + +import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; +import javax.persistence.QueryBuilder; import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.enhance.Reflection; @@ -332,4 +335,19 @@ public class EntityManagerFactoryImpl throw PersistenceExceptions.toPersistenceException(e); } } + + public Cache getCache() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public QueryBuilder getQueryBuilder() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public Set getSupportedProperties() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java index 3e87c6e16..021abebe9 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java @@ -34,10 +34,14 @@ import java.util.EnumSet; import java.util.Map; import java.util.HashMap; import java.util.IdentityHashMap; +import java.util.Set; + import javax.persistence.EntityManager; import javax.persistence.FlushModeType; import javax.persistence.LockModeType; import javax.persistence.Query; +import javax.persistence.QueryBuilder; +import javax.persistence.QueryDefinition; import org.apache.commons.lang.StringUtils; import org.apache.openjpa.conf.OpenJPAConfiguration; @@ -1380,4 +1384,59 @@ public class EntityManagerImpl } } } + + public void clear(Object entity) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public Query createQuery(QueryDefinition qdef) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public T find(Class entityClass, Object primaryKey, LockModeType lockMode) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public T find(Class entityClass, Object primaryKey, LockModeType lockMode, Map properties) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public Map getProperties() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public QueryBuilder getQueryBuilder() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public Set getSupportedProperties() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public void lock(Object entity, LockModeType lockMode, Map properties) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public void refresh(Object entity, LockModeType lockMode) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public void refresh(Object entity, LockModeType lockMode, Map properties) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public T unwrap(Class cls) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java index dee3ea853..0ba42d286 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java @@ -21,6 +21,7 @@ package org.apache.openjpa.persistence; import java.util.Calendar; import java.util.Collection; import java.util.Date; +import java.util.List; import java.util.Map; import javax.persistence.FlushModeType; import javax.persistence.Query; @@ -133,16 +134,18 @@ public interface OpenJPAQuery public boolean hasPositionalParameters(); /** - * The positional parameters for the query; empty array if none or + * The positional parameters for the query; empty list if none or * if query uses named parameters. + * Note: This method signature was changed in 2.0 to return a List + * instead of Object[] to match the JPA 2.0 spec. */ - public Object[] getPositionalParameters(); + public List getPositionalParameters(); /** * The named parameters for the query; empty map if none or * if query uses positional parameters. */ - public Map getNamedParameters(); + public Map getNamedParameters(); /** * Set parameters. diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java index a7a30128a..6f2d2a613 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java @@ -36,6 +36,7 @@ import java.util.Set; import java.util.TreeMap; import javax.persistence.FlushModeType; +import javax.persistence.LockModeType; import javax.persistence.Query; import javax.persistence.TemporalType; @@ -62,7 +63,7 @@ import org.apache.openjpa.util.RuntimeExceptionTranslator; */ public class QueryImpl implements OpenJPAQuerySPI, Serializable { - private static final Object[] EMPTY_ARRAY = new Object[0]; + private static final List EMPTY_LIST = new ArrayList(0); private static final Localizer _loc = Localizer.forPackage(QueryImpl.class); @@ -673,21 +674,21 @@ public class QueryImpl implements OpenJPAQuerySPI, Serializable { return _positional != null; } - /** - * Gets the array of positional parameter values. A value of - * GAP_FILLER indicates that user has not set the - * corresponding positional parameter. A value of null implies that user has - * set the value as null. - */ - public Object[] getPositionalParameters() { - _query.lock(); - try { - return (_positional == null) ? EMPTY_ARRAY : _positional.values() - .toArray(); - } finally { - _query.unlock(); - } - } + /** + * Gets the list of positional parameter values. A value of + * GAP_FILLER indicates that user has not set the + * corresponding positional parameter. A value of null implies that user has + * set the value as null. + */ + public List getPositionalParameters() { + _query.lock(); + try { + return (_positional == null) ? EMPTY_LIST : + new ArrayList(_positional.values()); + } finally { + _query.unlock(); + } + } public OpenJPAQuery setParameters(Object... params) { _query.assertOpen(); @@ -705,7 +706,7 @@ public class QueryImpl implements OpenJPAQuerySPI, Serializable { } } - public Map getNamedParameters() { + public Map getNamedParameters() { _query.lock(); try { return (_named == null) ? Collections.EMPTY_MAP : Collections @@ -751,4 +752,29 @@ public class QueryImpl implements OpenJPAQuerySPI, Serializable { return false; return _query.equals(((QueryImpl) other)._query); } + + public Map getHints() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public LockModeType getLockMode() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public Set getSupportedHints() { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public Query setLockMode(LockModeType lockMode) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } + + public T unwrap(Class cls) { + throw new UnsupportedOperationException( + "JPA 2.0 - Method not yet implemented"); + } } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java index 11fa908c2..7483a4257 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java @@ -84,7 +84,7 @@ public class QueryResultCacheImpl QueryImpl impl = (QueryImpl) q; if (impl.hasPositionalParameters()) return QueryKey.newInstance(impl.getDelegate(), - impl.getPositionalParameters()); + impl.getPositionalParameters().toArray()); return QueryKey.newInstance(impl.getDelegate(), impl.getNamedParameters()); }