Update jpa-api to 2.0-cr-1

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17768 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2009-10-15 18:50:41 +00:00
parent 36dbd3a06e
commit bbe65a9be4
33 changed files with 441 additions and 158 deletions

View File

@ -97,9 +97,15 @@ public class IndexColumn
String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition(); String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition();
String name = BinderHelper.isDefault( ann.name() ) ? inferredData.getPropertyName() + "_ORDER" : ann.name(); String name = BinderHelper.isDefault( ann.name() ) ? inferredData.getPropertyName() + "_ORDER" : ann.name();
//TODO move it to a getter based system and remove the constructor //TODO move it to a getter based system and remove the constructor
// The JPA OrderColumn annotation defines no table element...
// column = new IndexColumn(
// false, sqlType, 0, 0, 0, name, ann.nullable(),
// false, ann.insertable(), ann.updatable(), ann.table(),
// secondaryTables, propertyHolder, mappings
// );
column = new IndexColumn( column = new IndexColumn(
false, sqlType, 0, 0, 0, name, ann.nullable(), false, sqlType, 0, 0, 0, name, ann.nullable(),
false, ann.insertable(), ann.updatable(), ann.table(), false, ann.insertable(), ann.updatable(), /*ann.table()*/null,
secondaryTables, propertyHolder, mappings secondaryTables, propertyHolder, mappings
); );
} }

View File

@ -269,15 +269,15 @@ public abstract class AbstractQueryImpl<X> implements TypedQuery<X> {
private Map parameterBindings; private Map parameterBindings;
protected void registerParameterBinding(Parameter parameter, Object value) { protected void registerParameterBinding(Parameter parameter, Object value) {
if ( value != null && parameter.getJavaType() != null ) { if ( value != null && parameter.getParameterType() != null ) {
if ( Collection.class.isInstance( value ) ) { if ( Collection.class.isInstance( value ) ) {
final Collection collection = (Collection) value; final Collection collection = (Collection) value;
// validate the elements... // validate the elements...
for ( Object element : collection ) { for ( Object element : collection ) {
if ( ! parameter.getJavaType().isInstance( element ) ) { if ( ! parameter.getParameterType().isInstance( element ) ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Parameter value [" + element + "] was not matching type [" + "Parameter value [" + element + "] was not matching type [" +
parameter.getJavaType().getName() + "]" parameter.getParameterType().getName() + "]"
); );
} }
} }
@ -285,19 +285,19 @@ public abstract class AbstractQueryImpl<X> implements TypedQuery<X> {
else if ( value.getClass().isArray() ) { else if ( value.getClass().isArray() ) {
final Object[] array = (Object[]) value; final Object[] array = (Object[]) value;
for ( Object element : array ) { for ( Object element : array ) {
if ( ! parameter.getJavaType().isInstance( element ) ) { if ( ! parameter.getParameterType().isInstance( element ) ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Parameter value [" + element + "] was not matching type [" + "Parameter value [" + element + "] was not matching type [" +
parameter.getJavaType().getName() + "]" parameter.getParameterType().getName() + "]"
); );
} }
} }
} }
else { else {
if ( ! parameter.getJavaType().isInstance( value ) ) { if ( ! parameter.getParameterType().isInstance( value ) ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Parameter value [" + value + "] was not matching type [" + "Parameter value [" + value + "] was not matching type [" +
parameter.getJavaType().getName() + "]" parameter.getParameterType().getName() + "]"
); );
} }
} }

View File

@ -30,7 +30,7 @@ import javax.persistence.PersistenceContextType;
import javax.persistence.Cache; import javax.persistence.Cache;
import javax.persistence.PersistenceUnitUtil; import javax.persistence.PersistenceUnitUtil;
import javax.persistence.metamodel.Metamodel; import javax.persistence.metamodel.Metamodel;
import javax.persistence.criteria.QueryBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.spi.PersistenceUnitTransactionType; import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.persistence.spi.LoadState; import javax.persistence.spi.LoadState;
@ -93,7 +93,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
); );
} }
public QueryBuilder getQueryBuilder() { public CriteriaBuilder getCriteriaBuilder() {
return criteriaQueryBuilder; return criteriaQueryBuilder;
} }

View File

@ -27,6 +27,7 @@ import java.util.Map;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
import javax.persistence.spi.LoadState; import javax.persistence.spi.LoadState;
import javax.persistence.spi.PersistenceUnitInfo; import javax.persistence.spi.PersistenceUnitInfo;
import javax.persistence.spi.ProviderUtil;
import org.hibernate.ejb.util.PersistenceUtilHelper; import org.hibernate.ejb.util.PersistenceUtilHelper;
@ -157,24 +158,30 @@ public class HibernatePersistence implements javax.persistence.spi.PersistencePr
return configured != null ? configured.buildEntityManagerFactory() : null; return configured != null ? configured.buildEntityManagerFactory() : null;
} }
public LoadState isLoadedWithoutReference(Object proxy, String property) { private final ProviderUtil providerUtil = new ProviderUtil() {
return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property ); public LoadState isLoadedWithoutReference(Object proxy, String property) {
} return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property );
}
public LoadState isLoadedWithReference(Object proxy, String property) { public LoadState isLoadedWithReference(Object proxy, String property) {
return PersistenceUtilHelper.isLoadedWithReference( proxy, property ); return PersistenceUtilHelper.isLoadedWithReference( proxy, property );
} }
public LoadState isLoaded(Object o) { public LoadState isLoaded(Object o) {
return PersistenceUtilHelper.isLoaded(o); return PersistenceUtilHelper.isLoaded(o);
}
};
public ProviderUtil getProviderUtil() {
return providerUtil;
} }
/** /**
* create a factory from a canonical version * create a factory from a canonical version
* @deprecated * @deprecated
*/ */
// This is used directly by JBoss so don't remove until further notice. bill@jboss.org
public EntityManagerFactory createEntityManagerFactory(Map properties) { public EntityManagerFactory createEntityManagerFactory(Map properties) {
// This is used directly by JBoss so don't remove until further notice. bill@jboss.org
Ejb3Configuration cfg = new Ejb3Configuration(); Ejb3Configuration cfg = new Ejb3Configuration();
return cfg.createEntityManagerFactory( properties ); return cfg.createEntityManagerFactory( properties );
} }

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria; package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.CollectionAttribute; import javax.persistence.metamodel.CollectionAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.CollectionJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.CollectionJoinImplementor;
@ -66,7 +67,23 @@ public class BasicCollectionJoinImpl<O,E>
getJoinType() getJoinType()
); );
correlation.defineJoinScope( subquery.getJoinScope() ); correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation; return correlation;
} }
private From<O, E> correlationParent;
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return false;
}
/**
* {@inheritDoc}
*/
public From<O, E> getCorrelationParent() {
return null;
}
} }

View File

@ -25,6 +25,7 @@ package org.hibernate.ejb.criteria;
import javax.persistence.criteria.Expression; import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.ListAttribute; import javax.persistence.metamodel.ListAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.ListJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.ListJoinImplementor;
import org.hibernate.ejb.criteria.expression.ListIndexExpression; import org.hibernate.ejb.criteria.expression.ListIndexExpression;
@ -72,7 +73,23 @@ public class BasicListJoinImpl<O,E>
getJoinType() getJoinType()
); );
correlation.defineJoinScope( subquery.getJoinScope() ); correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation; return correlation;
} }
private From<O, E> correlationParent;
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
}
/**
* {@inheritDoc}
*/
public From<O, E> getCorrelationParent() {
return correlationParent;
}
} }

View File

@ -29,6 +29,7 @@ import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join; import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.MapAttribute; import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.Type.PersistenceType; import javax.persistence.metamodel.Type.PersistenceType;
import org.hibernate.ejb.criteria.JoinImplementors.MapJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.MapJoinImplementor;
@ -47,6 +48,7 @@ public class BasicMapJoinImpl<O,K,V>
extends AbstractBasicPluralJoin<O,java.util.Map<K,V>,V> extends AbstractBasicPluralJoin<O,java.util.Map<K,V>,V>
implements JoinImplementors.MapJoinImplementor<O,K,V> { implements JoinImplementors.MapJoinImplementor<O,K,V> {
public BasicMapJoinImpl( public BasicMapJoinImpl(
QueryBuilderImpl queryBuilder, QueryBuilderImpl queryBuilder,
Class<V> javaType, Class<V> javaType,
@ -56,19 +58,6 @@ public class BasicMapJoinImpl<O,K,V>
super( queryBuilder, javaType, lhs, joinProperty, joinType ); super( queryBuilder, javaType, lhs, joinProperty, joinType );
} }
@Override
public MapJoinImplementor<O, K, V> correlateTo(CriteriaSubqueryImpl subquery) {
BasicMapJoinImpl<O,K,V> correlation = new BasicMapJoinImpl<O,K,V>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
return correlation;
}
@Override @Override
public MapAttribute<? super O, K, V> getAttribute() { public MapAttribute<? super O, K, V> getAttribute() {
return (MapAttribute<? super O, K, V>) super.getAttribute(); return (MapAttribute<? super O, K, V>) super.getAttribute();
@ -148,4 +137,33 @@ public class BasicMapJoinImpl<O,K,V>
return new MapKeyHelpers.MapEntryExpression( queryBuilder(), Map.Entry.class, getAttribute() ); return new MapKeyHelpers.MapEntryExpression( queryBuilder(), Map.Entry.class, getAttribute() );
} }
private From<O, V> correlationParent;
@Override
public MapJoinImplementor<O, K, V> correlateTo(CriteriaSubqueryImpl subquery) {
BasicMapJoinImpl<O,K,V> correlation = new BasicMapJoinImpl<O,K,V>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation;
}
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
}
/**
* {@inheritDoc}
*/
public From<O, V> getCorrelationParent() {
return correlationParent;
}
} }

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria; package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.SetAttribute; import javax.persistence.metamodel.SetAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.SetJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.SetJoinImplementor;
@ -46,6 +47,16 @@ public class BasicSetJoinImpl<O,E>
super( queryBuilder, javaType, lhs, joinProperty, joinType ); super( queryBuilder, javaType, lhs, joinProperty, joinType );
} }
@Override
public SetAttribute<? super O, E> getAttribute() {
return (SetAttribute<? super O, E>) super.getAttribute();
}
@Override
public SetAttribute<? super O, E> getModel() {
return getAttribute();
}
@Override @Override
public SetJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) { public SetJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
BasicSetJoinImpl<O,E> correlation = new BasicSetJoinImpl<O,E>( BasicSetJoinImpl<O,E> correlation = new BasicSetJoinImpl<O,E>(
@ -56,16 +67,23 @@ public class BasicSetJoinImpl<O,E>
getJoinType() getJoinType()
); );
correlation.defineJoinScope( subquery.getJoinScope() ); correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation; return correlation;
} }
@Override private From<O, E> correlationParent;
public SetAttribute<? super O, E> getAttribute() {
return (SetAttribute<? super O, E>) super.getAttribute(); /**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
} }
@Override /**
public SetAttribute<? super O, E> getModel() { * {@inheritDoc}
return getAttribute(); */
} public From<O, E> getCorrelationParent() {
return correlationParent;
}
} }

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria; package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.CollectionAttribute; import javax.persistence.metamodel.CollectionAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.CollectionJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.CollectionJoinImplementor;
@ -46,19 +47,6 @@ public class CollectionJoinImpl<O,E>
super(queryBuilder, javaType, lhs, joinProperty, joinType); super(queryBuilder, javaType, lhs, joinProperty, joinType);
} }
@Override
public CollectionJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
CollectionJoinImpl<O,E> correlation = new CollectionJoinImpl<O,E>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
return correlation;
}
@Override @Override
public CollectionAttribute<? super O, E> getAttribute() { public CollectionAttribute<? super O, E> getAttribute() {
return (CollectionAttribute<? super O, E>) super.getAttribute(); return (CollectionAttribute<? super O, E>) super.getAttribute();
@ -69,4 +57,34 @@ public class CollectionJoinImpl<O,E>
return getAttribute(); return getAttribute();
} }
@Override
public CollectionJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
CollectionJoinImpl<O,E> correlation = new CollectionJoinImpl<O,E>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation;
}
private From<O, E> correlationParent;
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return false;
}
/**
* {@inheritDoc}
*/
public From<O, E> getCorrelationParent() {
return null;
}
} }

View File

@ -39,6 +39,7 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import javax.persistence.criteria.SetJoin; import javax.persistence.criteria.SetJoin;
import javax.persistence.criteria.Subquery; import javax.persistence.criteria.Subquery;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.EntityType; import javax.persistence.metamodel.EntityType;
import org.hibernate.ejb.criteria.FromImpl.JoinScope; import org.hibernate.ejb.criteria.FromImpl.JoinScope;
import org.hibernate.ejb.criteria.expression.ExpressionImpl; import org.hibernate.ejb.criteria.expression.ExpressionImpl;
@ -64,6 +65,14 @@ public class CriteriaSubqueryImpl<T> extends ExpressionImpl<T> implements Subque
public void addFetch(Fetch fetch) { public void addFetch(Fetch fetch) {
throw new UnsupportedOperationException( "Cannot define fetch from a subquery correlation" ); throw new UnsupportedOperationException( "Cannot define fetch from a subquery correlation" );
} }
public boolean isCorrelated() {
return true;
}
public From getCorrelationParent() {
return null;
}
}; };
public CriteriaSubqueryImpl( public CriteriaSubqueryImpl(

View File

@ -67,6 +67,8 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
public static interface JoinScope<X> { public static interface JoinScope<X> {
public void addJoin(Join<X, ?> join); public void addJoin(Join<X, ?> join);
public void addFetch(Fetch<X,?> fetch); public void addFetch(Fetch<X,?> fetch);
public boolean isCorrelated();
public From<?, X> getCorrelationParent();
} }
private final Expression<Class<? extends X>> type; private final Expression<Class<? extends X>> type;
@ -87,13 +89,21 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
} }
fetches.add( fetch ); fetches.add( fetch );
} }
public boolean isCorrelated() {
return false;
}
public From<?, X> getCorrelationParent() {
return null;
}
}; };
/** /**
* Special constructor for {@link RootImpl}. * Special constructor for {@link RootImpl}.
* *
* @param queryBuilder * @param queryBuilder The query build
* @param entityType * @param entityType The entity defining this root
*/ */
protected FromImpl(QueryBuilderImpl queryBuilder, EntityType<X> entityType) { protected FromImpl(QueryBuilderImpl queryBuilder, EntityType<X> entityType) {
super( queryBuilder, entityType.getBindableJavaType(), null, null, entityType ); super( queryBuilder, entityType.getBindableJavaType(), null, null, entityType );

View File

@ -55,7 +55,7 @@ public class JoinImpl<Z, X> extends FromImpl<Z, X> implements JoinImplementors.J
javaType, javaType,
lhs, lhs,
joinProperty, joinProperty,
(ManagedType<X>)queryBuilder.getEntityManagerFactory().getMetamodel().type( javaType ) (ManagedType<X>)queryBuilder.getEntityManagerFactory().getMetamodel().managedType( javaType )
); );
this.managedType = (ManagedType<X>) getModel(); this.managedType = (ManagedType<X>) getModel();
this.joinType = joinType; this.joinType = joinType;
@ -95,8 +95,24 @@ public class JoinImpl<Z, X> extends FromImpl<Z, X> implements JoinImplementors.J
getJoinType() getJoinType()
); );
correlation.defineJoinScope( subquery.getJoinScope() ); correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation; return correlation;
} }
private From<Z,X> correlationParent;
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return false;
}
/**
* {@inheritDoc}
*/
public From<Z,X> getCorrelationParent() {
return null;
}
} }

View File

@ -29,6 +29,7 @@ import javax.persistence.criteria.Join;
import javax.persistence.criteria.ListJoin; import javax.persistence.criteria.ListJoin;
import javax.persistence.criteria.MapJoin; import javax.persistence.criteria.MapJoin;
import javax.persistence.criteria.SetJoin; import javax.persistence.criteria.SetJoin;
import javax.persistence.criteria.From;
/** /**
* Consolidates the {@link Join} and {@link Fetch} hierarchies since that is how we implement them. * Consolidates the {@link Join} and {@link Fetch} hierarchies since that is how we implement them.

View File

@ -25,6 +25,7 @@ package org.hibernate.ejb.criteria;
import javax.persistence.criteria.Expression; import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.ListAttribute; import javax.persistence.metamodel.ListAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.ListJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.ListJoinImplementor;
import org.hibernate.ejb.criteria.expression.ListIndexExpression; import org.hibernate.ejb.criteria.expression.ListIndexExpression;
@ -45,19 +46,6 @@ public class ListJoinImpl<O,E> extends JoinImpl<O,E> implements JoinImplementors
super( queryBuilder, javaType, lhs, joinProperty, joinType ); super( queryBuilder, javaType, lhs, joinProperty, joinType );
} }
@Override
public ListJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
ListJoinImpl<O,E> correlation = new ListJoinImpl<O,E>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
return correlation;
}
@Override @Override
public ListAttribute<? super O, E> getAttribute() { public ListAttribute<? super O, E> getAttribute() {
return (ListAttribute<? super O, E>) super.getAttribute(); return (ListAttribute<? super O, E>) super.getAttribute();
@ -68,7 +56,40 @@ public class ListJoinImpl<O,E> extends JoinImpl<O,E> implements JoinImplementors
return (ListAttribute<? super O, E>) getAttribute(); return (ListAttribute<? super O, E>) getAttribute();
} }
/**
* {@inheritDoc}
*/
public Expression<Integer> index() { public Expression<Integer> index() {
return new ListIndexExpression( queryBuilder(), getAttribute() ); return new ListIndexExpression( queryBuilder(), getAttribute() );
} }
@Override
public ListJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
ListJoinImpl<O,E> correlation = new ListJoinImpl<O,E>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation;
}
private From<O, E> correlationParent;
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
}
/**
* {@inheritDoc}
*/
public From<O, E> getCorrelationParent() {
return correlationParent;
}
} }

View File

@ -29,6 +29,7 @@ import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join; import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.MapAttribute; import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.Type.PersistenceType; import javax.persistence.metamodel.Type.PersistenceType;
import org.hibernate.ejb.criteria.JoinImplementors.MapJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.MapJoinImplementor;
@ -52,19 +53,6 @@ public class MapJoinImpl<O,K,V>
super(queryBuilder, javaType, lhs, joinProperty, joinType); super(queryBuilder, javaType, lhs, joinProperty, joinType);
} }
@Override
public MapJoinImplementor<O, K, V> correlateTo(CriteriaSubqueryImpl subquery) {
MapJoinImpl<O, K, V> correlation = new MapJoinImpl<O, K, V>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
return correlation;
}
@Override @Override
public MapAttribute<? super O, K, V> getAttribute() { public MapAttribute<? super O, K, V> getAttribute() {
return (MapAttribute<? super O, K, V>) super.getAttribute(); return (MapAttribute<? super O, K, V>) super.getAttribute();
@ -141,4 +129,34 @@ public class MapJoinImpl<O,K,V>
return new MapKeyHelpers.MapEntryExpression( queryBuilder(), Map.Entry.class, getAttribute() ); return new MapKeyHelpers.MapEntryExpression( queryBuilder(), Map.Entry.class, getAttribute() );
} }
private From<O, V> correlationParent;
@Override
public MapJoinImplementor<O, K, V> correlateTo(CriteriaSubqueryImpl subquery) {
MapJoinImpl<O, K, V> correlation = new MapJoinImpl<O, K, V>(
queryBuilder(),
getJavaType(),
(PathImpl<O>) getParentPath(),
getAttribute(),
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation;
}
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
}
/**
* {@inheritDoc}
*/
public From<O, V> getCorrelationParent() {
return correlationParent;
}
} }

View File

@ -31,6 +31,7 @@ import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.MapJoin; import javax.persistence.criteria.MapJoin;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.Attribute; import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.Bindable.BindableType; import javax.persistence.metamodel.Bindable.BindableType;
import javax.persistence.metamodel.ManagedType; import javax.persistence.metamodel.ManagedType;
@ -75,6 +76,13 @@ public class MapKeyHelpers {
throw new UnsupportedOperationException( "Map key join cannot be used as a correlation" ); throw new UnsupportedOperationException( "Map key join cannot be used as a correlation" );
} }
public boolean isCorrelated() {
return false;
}
public From<Map<K, V>, K> getCorrelationParent() {
return null;
}
} }
/** /**

View File

@ -31,7 +31,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import javax.persistence.criteria.QueryBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Selection; import javax.persistence.criteria.Selection;
import javax.persistence.criteria.CompoundSelection; import javax.persistence.criteria.CompoundSelection;
@ -87,7 +87,7 @@ import static org.hibernate.ejb.criteria.predicate.ComparisonPredicate.Compariso
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class QueryBuilderImpl implements QueryBuilder, Serializable { public class QueryBuilderImpl implements CriteriaBuilder, Serializable {
private final EntityManagerFactoryImpl entityManagerFactory; private final EntityManagerFactoryImpl entityManagerFactory;
public QueryBuilderImpl(EntityManagerFactoryImpl entityManagerFactory) { public QueryBuilderImpl(EntityManagerFactoryImpl entityManagerFactory) {
@ -260,7 +260,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public Predicate not(Expression<Boolean> expression) { public Predicate not(Expression<Boolean> expression) {
return wrap( expression ).negate(); return wrap( expression ).not();
} }
/** /**
@ -318,7 +318,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public Predicate isFalse(Expression<Boolean> x) { public Predicate isFalse(Expression<Boolean> x) {
return wrap( x ).negate(); return wrap( x ).not();
// TODO : the correct thing here depends on response to #5 on my wiki page // TODO : the correct thing here depends on response to #5 on my wiki page
// return new ExplicitTruthValueCheck( this, x, TruthValue.FALSE ); // return new ExplicitTruthValueCheck( this, x, TruthValue.FALSE );
} }
@ -334,7 +334,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public Predicate isNotNull(Expression<?> x) { public Predicate isNotNull(Expression<?> x) {
return isNull( x ).negate(); return isNull( x ).not();
} }
/** /**
@ -366,13 +366,13 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
*/ */
public Predicate notEqual(Expression<?> x, Object y) { public Predicate notEqual(Expression<?> x, Object y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
return new ComparisonPredicate( this, ComparisonOperator.NOT_EQUAL, x, y ).negate(); return new ComparisonPredicate( this, ComparisonOperator.NOT_EQUAL, x, y ).not();
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Expression<? extends Y> y) { public <Y extends Comparable<? super Y>> Predicate greaterThan(Expression<? extends Y> x, Expression<? extends Y> y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
return new ComparisonPredicate( this, ComparisonOperator.GREATER_THAN, x, y ); return new ComparisonPredicate( this, ComparisonOperator.GREATER_THAN, x, y );
} }
@ -380,7 +380,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate lessThan( public <Y extends Comparable<? super Y>> Predicate lessThan(
Expression<? extends Y> x, Expression<? extends Y> x,
Expression<? extends Y> y) { Expression<? extends Y> y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
@ -390,7 +390,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo( public <Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(
Expression<? extends Y> x, Expression<? extends Y> x,
Expression<? extends Y> y) { Expression<? extends Y> y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
@ -400,7 +400,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate lessThanOrEqualTo( public <Y extends Comparable<? super Y>> Predicate lessThanOrEqualTo(
Expression<? extends Y> x, Expression<? extends Y> x,
Expression<? extends Y> y) { Expression<? extends Y> y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
@ -410,7 +410,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate greaterThan( public <Y extends Comparable<? super Y>> Predicate greaterThan(
Expression<? extends Y> x, Expression<? extends Y> x,
Y y) { Y y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
@ -420,7 +420,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate lessThan( public <Y extends Comparable<? super Y>> Predicate lessThan(
Expression<? extends Y> x, Expression<? extends Y> x,
Y y) { Y y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
@ -430,7 +430,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo( public <Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(
Expression<? extends Y> x, Expression<? extends Y> x,
Y y) { Y y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
@ -440,7 +440,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate lessThanOrEqualTo( public<Y extends Comparable<? super Y>> Predicate lessThanOrEqualTo(
Expression<? extends Y> x, Expression<? extends Y> x,
Y y) { Y y) {
//noinspection SuspiciousNameCombination //noinspection SuspiciousNameCombination
@ -514,7 +514,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate between( public <Y extends Comparable<? super Y>> Predicate between(
Expression<? extends Y> expression, Expression<? extends Y> expression,
Y lowerBound, Y lowerBound,
Y upperBound) { Y upperBound) {
@ -524,7 +524,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y extends Comparable<Y>> Predicate between( public <Y extends Comparable<? super Y>> Predicate between(
Expression<? extends Y> expression, Expression<? extends Y> expression,
Expression<? extends Y> lowerBound, Expression<? extends Y> lowerBound,
Expression<? extends Y> upperBound) { Expression<? extends Y> upperBound) {
@ -575,27 +575,27 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
} }
public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern) { public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern) {
return like( matchExpression, pattern ).negate(); return like( matchExpression, pattern ).not();
} }
public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern, Expression<Character> escapeCharacter) { public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern, Expression<Character> escapeCharacter) {
return like( matchExpression, pattern, escapeCharacter ).negate(); return like( matchExpression, pattern, escapeCharacter ).not();
} }
public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern, char escapeCharacter) { public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern, char escapeCharacter) {
return like( matchExpression, pattern, escapeCharacter ).negate(); return like( matchExpression, pattern, escapeCharacter ).not();
} }
public Predicate notLike(Expression<String> matchExpression, String pattern) { public Predicate notLike(Expression<String> matchExpression, String pattern) {
return like( matchExpression, pattern ).negate(); return like( matchExpression, pattern ).not();
} }
public Predicate notLike(Expression<String> matchExpression, String pattern, Expression<Character> escapeCharacter) { public Predicate notLike(Expression<String> matchExpression, String pattern, Expression<Character> escapeCharacter) {
return like( matchExpression, pattern, escapeCharacter ).negate(); return like( matchExpression, pattern, escapeCharacter ).not();
} }
public Predicate notLike(Expression<String> matchExpression, String pattern, char escapeCharacter) { public Predicate notLike(Expression<String> matchExpression, String pattern, char escapeCharacter) {
return like( matchExpression, pattern, escapeCharacter ).negate(); return like( matchExpression, pattern, escapeCharacter ).not();
} }
@ -622,6 +622,13 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
return new LiteralExpression<T>( this, value ); return new LiteralExpression<T>( this, value );
} }
/**
* {@inheritDoc}
*/
public <T> Expression<T> nullLiteral(Class<T> resultClass) {
return new LiteralExpression<T>( this, resultClass, null );
}
// aggregate functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // aggregate functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -639,6 +646,20 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
return new AggregationFunction.SUM<N>( this, x ); return new AggregationFunction.SUM<N>( this, x );
} }
/**
* {@inheritDoc}
*/
public Expression<Long> sumAsLong(Expression<Integer> x) {
return new AggregationFunction.SUM<Long>( this, x, Long.class );
}
/**
* {@inheritDoc}
*/
public Expression<Double> sumAsDouble(Expression<Float> x) {
return new AggregationFunction.SUM<Double>( this, x, Double.class );
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -656,15 +677,17 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <X extends Comparable<X>> Expression<X> greatest(Expression<X> x) { @SuppressWarnings({ "unchecked" })
return new AggregationFunction.GREATEST<X>( this, x ); public <X extends Comparable<? super X>> Expression<X> greatest(Expression<X> x) {
return new AggregationFunction.GREATEST( this, x );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <X extends Comparable<X>> Expression<X> least(Expression<X> x) { @SuppressWarnings({ "unchecked" })
return new AggregationFunction.LEAST<X>( this, x ); public <X extends Comparable<? super X>> Expression<X> least(Expression<X> x) {
return new AggregationFunction.LEAST( this, x );
} }
/** /**
@ -697,8 +720,6 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* @param name The function name. * @param name The function name.
* @param returnType The return type. * @param returnType The return type.
* *
* @param <T> The type of the function return.
*
* @return The function expression * @return The function expression
*/ */
public <T> Expression<T> function(String name, Class<T> returnType) { public <T> Expression<T> function(String name, Class<T> returnType) {
@ -816,6 +837,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> sum(Expression<? extends N> expression1, Expression<? extends N> expression2) { public <N extends Number> Expression<N> sum(Expression<? extends N> expression1, Expression<? extends N> expression2) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression1 ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression1 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 );
@ -831,6 +853,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> prod(Expression<? extends N> expression1, Expression<? extends N> expression2) { public <N extends Number> Expression<N> prod(Expression<? extends N> expression1, Expression<? extends N> expression2) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression1 ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression1 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 );
@ -846,12 +869,13 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> diff(Expression<? extends N> expression1, Expression<? extends N> expression2) { public <N extends Number> Expression<N> diff(Expression<? extends N> expression1, Expression<? extends N> expression2) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression1 ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression1 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 );
return new BinaryArithmeticOperation<N>( return new BinaryArithmeticOperation<N>(
this, this,
(Class<N>) expression1.getJavaType(), type,
BinaryArithmeticOperation.Operation.SUBTRACT, BinaryArithmeticOperation.Operation.SUBTRACT,
expression1, expression1,
expression2 expression2
@ -861,6 +885,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> sum(Expression<? extends N> expression, N n) { public <N extends Number> Expression<N> sum(Expression<? extends N> expression, N n) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -876,6 +901,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> prod(Expression<? extends N> expression, N n) { public <N extends Number> Expression<N> prod(Expression<? extends N> expression, N n) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -891,6 +917,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> diff(Expression<? extends N> expression, N n) { public <N extends Number> Expression<N> diff(Expression<? extends N> expression, N n) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -906,6 +933,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> sum(N n, Expression<? extends N> expression) { public <N extends Number> Expression<N> sum(N n, Expression<? extends N> expression) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -921,6 +949,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> prod(N n, Expression<? extends N> expression) { public <N extends Number> Expression<N> prod(N n, Expression<? extends N> expression) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -936,6 +965,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <N extends Number> Expression<N> diff(N n, Expression<? extends N> expression) { public <N extends Number> Expression<N> diff(N n, Expression<? extends N> expression) {
Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression ); Class<N> type = (Class<N>)BinaryArithmeticOperation.determineReturnType( (Class)Number.class, (Expression)expression );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n ); type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -1094,7 +1124,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
public <Y> Expression<Y> all(Subquery<Y> subquery) { public <Y> Expression<Y> all(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>( return new SubqueryComparisonModifierExpression<Y>(
this, this,
subquery.getJavaType(), (Class)subquery.getJavaType(),
subquery, subquery,
SubqueryComparisonModifierExpression.Modifier.ALL SubqueryComparisonModifierExpression.Modifier.ALL
); );
@ -1106,7 +1136,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
public <Y> Expression<Y> some(Subquery<Y> subquery) { public <Y> Expression<Y> some(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>( return new SubqueryComparisonModifierExpression<Y>(
this, this,
subquery.getJavaType(), (Class)subquery.getJavaType(),
subquery, subquery,
SubqueryComparisonModifierExpression.Modifier.SOME SubqueryComparisonModifierExpression.Modifier.SOME
); );
@ -1118,7 +1148,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
public <Y> Expression<Y> any(Subquery<Y> subquery) { public <Y> Expression<Y> any(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>( return new SubqueryComparisonModifierExpression<Y>(
this, this,
subquery.getJavaType(), (Class)subquery.getJavaType(),
subquery, subquery,
SubqueryComparisonModifierExpression.Modifier.ANY SubqueryComparisonModifierExpression.Modifier.ANY
); );
@ -1185,7 +1215,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> Expression<Y> nullif(Expression<Y> exp1, Expression<?> exp2) { public <Y> Expression<Y> nullif(Expression<Y> exp1, Expression<?> exp2) {
return nullif( (Class<Y>)null, exp1, exp2 ); return nullif( null, exp1, exp2 );
} }
public <Y> Expression<Y> nullif(Class<Y> type, Expression<Y> exp1, Expression<?> exp2) { public <Y> Expression<Y> nullif(Class<Y> type, Expression<Y> exp1, Expression<?> exp2) {
@ -1196,7 +1226,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> Expression<Y> nullif(Expression<Y> exp1, Y exp2) { public <Y> Expression<Y> nullif(Expression<Y> exp1, Y exp2) {
return nullif( (Class<Y>)null, exp1, exp2 ); return nullif( null, exp1, exp2 );
} }
public <Y> Expression<Y> nullif(Class<Y> type, Expression<Y> exp1, Y exp2) { public <Y> Expression<Y> nullif(Class<Y> type, Expression<Y> exp1, Y exp2) {
@ -1241,7 +1271,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
return size( ( (LiteralExpression<C>) exp ).getLiteral() ); return size( ( (LiteralExpression<C>) exp ).getLiteral() );
} }
else if ( CollectionExpression.class.isInstance(exp) ) { else if ( CollectionExpression.class.isInstance(exp) ) {
return new SizeOfCollectionExpression<C>(this, (CollectionExpression<C>)null); return new SizeOfCollectionExpression<C>(this, null);
} }
// TODO : what other specific types? any? // TODO : what other specific types? any?
throw new IllegalArgumentException("unknown collection expression type [" + exp.getClass().getName() + "]" ); throw new IllegalArgumentException("unknown collection expression type [" + exp.getClass().getName() + "]" );
@ -1265,6 +1295,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings({ "unchecked" })
public <C extends Collection<?>> Predicate isEmpty(Expression<C> collectionExpression) { public <C extends Collection<?>> Predicate isEmpty(Expression<C> collectionExpression) {
if ( CollectionExpression.class.isInstance(collectionExpression) ) { if ( CollectionExpression.class.isInstance(collectionExpression) ) {
return new IsEmptyPredicate( return new IsEmptyPredicate(
@ -1282,7 +1313,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public <C extends Collection<?>> Predicate isNotEmpty(Expression<C> collectionExpression) { public <C extends Collection<?>> Predicate isNotEmpty(Expression<C> collectionExpression) {
return isEmpty( collectionExpression ).negate(); return isEmpty( collectionExpression ).not();
} }
/** /**
@ -1305,7 +1336,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public <E, C extends Collection<E>> Predicate isNotMember(E e, Expression<C> cExpression) { public <E, C extends Collection<E>> Predicate isNotMember(E e, Expression<C> cExpression) {
return isMember(e, cExpression).negate(); return isMember(e, cExpression).not();
} }
/** /**
@ -1328,6 +1359,6 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public <E, C extends Collection<E>> Predicate isNotMember(Expression<E> eExpression, Expression<C> cExpression) { public <E, C extends Collection<E>> Predicate isNotMember(Expression<E> eExpression, Expression<C> cExpression) {
return isMember(eExpression, cExpression).negate(); return isMember(eExpression, cExpression).not();
} }
} }

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria; package org.hibernate.ejb.criteria;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.Attribute; import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.EntityType; import javax.persistence.metamodel.EntityType;
@ -33,6 +34,8 @@ import javax.persistence.metamodel.EntityType;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class RootImpl<X> extends FromImpl<X,X> implements Root<X> { public class RootImpl<X> extends FromImpl<X,X> implements Root<X> {
private RootImpl<X> correlationParent;
public RootImpl( public RootImpl(
QueryBuilderImpl queryBuilder, QueryBuilderImpl queryBuilder,
EntityType<X> model) { EntityType<X> model) {
@ -49,9 +52,18 @@ public class RootImpl<X> extends FromImpl<X,X> implements Root<X> {
return (Attribute<X, ?>) getModel().getAttribute( name ); return (Attribute<X, ?>) getModel().getAttribute( name );
} }
public boolean isCorrelated() {
return getCorrelationParent() != null;
}
public From<X, X> getCorrelationParent() {
return correlationParent;
}
public RootImpl<X> correlateTo(CriteriaSubqueryImpl subquery) { public RootImpl<X> correlateTo(CriteriaSubqueryImpl subquery) {
RootImpl<X> correlation = new RootImpl<X>( queryBuilder(), getModel() ); RootImpl<X> correlation = new RootImpl<X>( queryBuilder(), getModel() );
correlation.defineJoinScope( subquery.getJoinScope() ); correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation; return correlation;
} }
} }

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria; package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.SetAttribute; import javax.persistence.metamodel.SetAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.SetJoinImplementor; import org.hibernate.ejb.criteria.JoinImplementors.SetJoinImplementor;
@ -46,6 +47,16 @@ public class SetJoinImpl<O,E>
super(queryBuilder, javaType, lhs, joinProperty, joinType); super(queryBuilder, javaType, lhs, joinProperty, joinType);
} }
@Override
public SetAttribute<? super O, E> getAttribute() {
return (SetAttribute<? super O, E>) super.getAttribute();
}
@Override
public SetAttribute<? super O, E> getModel() {
return getAttribute();
}
@Override @Override
public SetJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) { public SetJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
SetJoinImpl<O,E> correlation = new SetJoinImpl<O,E>( SetJoinImpl<O,E> correlation = new SetJoinImpl<O,E>(
@ -56,16 +67,23 @@ public class SetJoinImpl<O,E>
getJoinType() getJoinType()
); );
correlation.defineJoinScope( subquery.getJoinScope() ); correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation; return correlation;
} }
@Override private From<O, E> correlationParent;
public SetAttribute<? super O, E> getAttribute() {
return (SetAttribute<? super O, E>) super.getAttribute(); /**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
} }
@Override /**
public SetAttribute<? super O, E> getModel() { * {@inheritDoc}
return getAttribute(); */
public From<O, E> getCorrelationParent() {
return correlationParent;
} }
} }

View File

@ -26,8 +26,7 @@ package org.hibernate.ejb.criteria.expression;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.criteria.Expression; import javax.persistence.criteria.Expression;
import javax.persistence.criteria.QueryBuilder.Coalesce; import javax.persistence.criteria.CriteriaBuilder.Coalesce;
import org.hibernate.ejb.criteria.ParameterContainer;
import org.hibernate.ejb.criteria.ParameterRegistry; import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.QueryBuilderImpl; import org.hibernate.ejb.criteria.QueryBuilderImpl;
@ -61,6 +60,7 @@ public class CoalesceExpression<T> extends ExpressionImpl<T> implements Coalesce
return value( new LiteralExpression<T>( queryBuilder(), value ) ); return value( new LiteralExpression<T>( queryBuilder(), value ) );
} }
@SuppressWarnings({ "unchecked" })
public Coalesce<T> value(Expression<? extends T> value) { public Coalesce<T> value(Expression<? extends T> value) {
expressions.add( value ); expressions.add( value );
if ( javaType == null ) { if ( javaType == null ) {

View File

@ -72,6 +72,10 @@ public class ParameterExpressionImpl<T> extends ExpressionImpl<T> implements Par
return position; return position;
} }
public Class<T> getParameterType() {
return getJavaType();
}
public void registerParameters(ParameterRegistry registry) { public void registerParameters(ParameterRegistry registry) {
registry.registerParameter( this ); registry.registerParameter( this );
} }

View File

@ -26,8 +26,7 @@ package org.hibernate.ejb.criteria.expression;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.criteria.Expression; import javax.persistence.criteria.Expression;
import javax.persistence.criteria.QueryBuilder.Case; import javax.persistence.criteria.CriteriaBuilder.Case;
import org.hibernate.ejb.criteria.ParameterContainer;
import org.hibernate.ejb.criteria.ParameterRegistry; import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.QueryBuilderImpl; import org.hibernate.ejb.criteria.QueryBuilderImpl;
@ -70,10 +69,11 @@ public class SearchedCaseExpression<R> extends ExpressionImpl<R> implements Case
return when( condition, buildLiteral(result) ); return when( condition, buildLiteral(result) );
} }
@SuppressWarnings({ "unchecked" })
private LiteralExpression<R> buildLiteral(R result) { private LiteralExpression<R> buildLiteral(R result) {
final Class<R> type = result != null final Class<R> type = result != null
? (Class<R>) result.getClass() ? (Class<R>) result.getClass()
: (Class<R>) getJavaType(); : getJavaType();
return new LiteralExpression<R>( queryBuilder(), type, result ); return new LiteralExpression<R>( queryBuilder(), type, result );
} }
@ -84,6 +84,7 @@ public class SearchedCaseExpression<R> extends ExpressionImpl<R> implements Case
return this; return this;
} }
@SuppressWarnings({ "unchecked" })
private void adjustJavaType(Expression<? extends R> exp) { private void adjustJavaType(Expression<? extends R> exp) {
if ( javaType == null ) { if ( javaType == null ) {
javaType = (Class<R>) exp.getJavaType(); javaType = (Class<R>) exp.getJavaType();

View File

@ -26,8 +26,7 @@ package org.hibernate.ejb.criteria.expression;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.criteria.Expression; import javax.persistence.criteria.Expression;
import javax.persistence.criteria.QueryBuilder.SimpleCase; import javax.persistence.criteria.CriteriaBuilder.SimpleCase;
import org.hibernate.ejb.criteria.ParameterContainer;
import org.hibernate.ejb.criteria.ParameterRegistry; import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.QueryBuilderImpl; import org.hibernate.ejb.criteria.QueryBuilderImpl;
@ -70,6 +69,7 @@ public class SimpleCaseExpression<C,R> extends ExpressionImpl<R> implements Simp
this.expression = expression; this.expression = expression;
} }
@SuppressWarnings({ "unchecked" })
public Expression<C> getExpression() { public Expression<C> getExpression() {
return (Expression<C>) expression; return (Expression<C>) expression;
} }
@ -78,10 +78,11 @@ public class SimpleCaseExpression<C,R> extends ExpressionImpl<R> implements Simp
return when( condition, buildLiteral(result) ); return when( condition, buildLiteral(result) );
} }
@SuppressWarnings({ "unchecked" })
private LiteralExpression<R> buildLiteral(R result) { private LiteralExpression<R> buildLiteral(R result) {
final Class<R> type = result != null final Class<R> type = result != null
? (Class<R>) result.getClass() ? (Class<R>) result.getClass()
: (Class<R>) getJavaType(); : getJavaType();
return new LiteralExpression<R>( queryBuilder(), type, result ); return new LiteralExpression<R>( queryBuilder(), type, result );
} }
@ -92,6 +93,7 @@ public class SimpleCaseExpression<C,R> extends ExpressionImpl<R> implements Simp
return this; return this;
} }
@SuppressWarnings({ "unchecked" })
private void adjustJavaType(Expression<? extends R> exp) { private void adjustJavaType(Expression<? extends R> exp) {
if ( javaType == null ) { if ( javaType == null ) {
javaType = (Class<R>) exp.getJavaType(); javaType = (Class<R>) exp.getJavaType();

View File

@ -34,7 +34,7 @@ import org.hibernate.ejb.criteria.QueryBuilderImpl;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class SubqueryComparisonModifierExpression<Y> extends ExpressionImpl<Y> { public class SubqueryComparisonModifierExpression<Y> extends ExpressionImpl<Y> {
public static enum Modifier { ALL, SOME, ANY }; public static enum Modifier { ALL, SOME, ANY }
private final Subquery<Y> subquery; private final Subquery<Y> subquery;
private final Modifier modifier; private final Modifier modifier;

View File

@ -47,7 +47,7 @@ public class UnaryArithmeticOperation<T>
QueryBuilderImpl queryBuilder, QueryBuilderImpl queryBuilder,
Operation operation, Operation operation,
Expression<T> operand) { Expression<T> operand) {
super( queryBuilder, operand.getJavaType() ); super( queryBuilder, (Class)operand.getJavaType() );
this.operation = operation; this.operation = operation;
this.operand = operand; this.operand = operand;
} }

View File

@ -36,7 +36,7 @@ public class AbsFunction<N extends Number>
public static final String NAME = "abs"; public static final String NAME = "abs";
public AbsFunction(QueryBuilderImpl queryBuilder, Expression<N> expression) { public AbsFunction(QueryBuilderImpl queryBuilder, Expression expression) {
super( queryBuilder, expression.getJavaType(), NAME, expression ); super( queryBuilder, expression.getJavaType(), NAME, expression );
} }
} }

View File

@ -41,6 +41,7 @@ public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
* @param functionName The name of the function. * @param functionName The name of the function.
* @param argument The literal argument * @param argument The literal argument
*/ */
@SuppressWarnings({ "unchecked" })
public AggregationFunction( public AggregationFunction(
QueryBuilderImpl queryBuilder, QueryBuilderImpl queryBuilder,
Class<T> returnType, Class<T> returnType,
@ -114,8 +115,13 @@ public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
public static class SUM<N extends Number> extends AggregationFunction<N> { public static class SUM<N extends Number> extends AggregationFunction<N> {
public static final String NAME = "sum"; public static final String NAME = "sum";
@SuppressWarnings({ "unchecked" })
public SUM(QueryBuilderImpl queryBuilder, Expression<N> expression) { public SUM(QueryBuilderImpl queryBuilder, Expression<N> expression) {
super( queryBuilder, expression.getJavaType(), NAME , expression); super( queryBuilder, (Class<N>)expression.getJavaType(), NAME , expression);
}
public SUM(QueryBuilderImpl queryBuilder, Expression<? extends Number> expression, Class<N> returnType) {
super( queryBuilder, returnType, NAME , expression);
} }
} }
@ -128,8 +134,9 @@ public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
public static class MIN<N extends Number> extends AggregationFunction<N> { public static class MIN<N extends Number> extends AggregationFunction<N> {
public static final String NAME = "min"; public static final String NAME = "min";
@SuppressWarnings({ "unchecked" })
public MIN(QueryBuilderImpl queryBuilder, Expression<N> expression) { public MIN(QueryBuilderImpl queryBuilder, Expression<N> expression) {
super( queryBuilder, expression.getJavaType(), NAME , expression); super( queryBuilder, ( Class<N> ) expression.getJavaType(), NAME , expression);
} }
} }
@ -142,8 +149,9 @@ public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
public static class MAX<N extends Number> extends AggregationFunction<N> { public static class MAX<N extends Number> extends AggregationFunction<N> {
public static final String NAME = "max"; public static final String NAME = "max";
@SuppressWarnings({ "unchecked" })
public MAX(QueryBuilderImpl queryBuilder, Expression<N> expression) { public MAX(QueryBuilderImpl queryBuilder, Expression<N> expression) {
super( queryBuilder, expression.getJavaType(), NAME , expression); super( queryBuilder, ( Class<N> ) expression.getJavaType(), NAME , expression);
} }
} }
@ -155,8 +163,9 @@ public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
public static class LEAST<X extends Comparable<X>> extends AggregationFunction<X> { public static class LEAST<X extends Comparable<X>> extends AggregationFunction<X> {
public static final String NAME = "min"; public static final String NAME = "min";
@SuppressWarnings({ "unchecked" })
public LEAST(QueryBuilderImpl queryBuilder, Expression<X> expression) { public LEAST(QueryBuilderImpl queryBuilder, Expression<X> expression) {
super( queryBuilder, expression.getJavaType(), NAME , expression); super( queryBuilder, ( Class<X> ) expression.getJavaType(), NAME , expression);
} }
} }
@ -168,8 +177,9 @@ public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
public static class GREATEST<X extends Comparable<X>> extends AggregationFunction<X> { public static class GREATEST<X extends Comparable<X>> extends AggregationFunction<X> {
public static final String NAME = "max"; public static final String NAME = "max";
@SuppressWarnings({ "unchecked" })
public GREATEST(QueryBuilderImpl queryBuilder, Expression<X> expression) { public GREATEST(QueryBuilderImpl queryBuilder, Expression<X> expression) {
super( queryBuilder, expression.getJavaType(), NAME , expression); super( queryBuilder, ( Class<X> ) expression.getJavaType(), NAME , expression);
} }
} }
} }

View File

@ -24,8 +24,7 @@
package org.hibernate.ejb.criteria.expression.function; package org.hibernate.ejb.criteria.expression.function;
import javax.persistence.criteria.Expression; import javax.persistence.criteria.Expression;
import javax.persistence.criteria.QueryBuilder.Trimspec; import javax.persistence.criteria.CriteriaBuilder.Trimspec;
import org.hibernate.ejb.criteria.ParameterContainer;
import org.hibernate.ejb.criteria.ParameterRegistry; import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.QueryBuilderImpl; import org.hibernate.ejb.criteria.QueryBuilderImpl;
import org.hibernate.ejb.criteria.expression.LiteralExpression; import org.hibernate.ejb.criteria.expression.LiteralExpression;

View File

@ -47,7 +47,7 @@ public abstract class AbstractPredicateImpl extends ExpressionImpl<Boolean> impl
return negated; return negated;
} }
public Predicate negate() { public Predicate not() {
negated = !negated; negated = !negated;
return this; return this;
} }

View File

@ -143,12 +143,12 @@ public class EntityTypeDelegator<X> implements EntityType<X>, Serializable {
return delegate.getDeclaredMap( name, keyType, valueType ); return delegate.getDeclaredMap( name, keyType, valueType );
} }
public Set<PluralAttribute<? super X, ?, ?>> getCollections() { public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
return delegate.getCollections(); return delegate.getPluralAttributes();
} }
public Set<PluralAttribute<X, ?, ?>> getDeclaredCollections() { public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
return delegate.getDeclaredCollections(); return delegate.getDeclaredPluralAttributes();
} }
public Attribute<? super X, ?> getAttribute(String name) { public Attribute<? super X, ?> getAttribute(String name) {

View File

@ -1,8 +1,10 @@
/* /*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as * Hibernate, Relational Persistence for Idiomatic Java
* indicated by the @author tags or express copyright attribution *
* statements applied by the authors. All third-party contributions are * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
* distributed under license by Red Hat Middleware LLC. * third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
* *
* This copyrighted material is made available to anyone wishing to use, modify, * This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU * copy, or redistribute it subject to the terms and conditions of the GNU
@ -203,11 +205,11 @@ public abstract class ManagedTypeImpl<X> implements ManagedType<X>, Serializable
return result; return result;
} }
public Set<PluralAttribute<? super X, ?, ?>> getCollections() { public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public Set<PluralAttribute<X, ?, ?>> getDeclaredCollections() { public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
return new HashSet<PluralAttribute<X,?,?>>(declaredCollections.values()); return new HashSet<PluralAttribute<X,?,?>>(declaredCollections.values());
} }

View File

@ -63,6 +63,10 @@ public class MetamodelImpl implements Metamodel, Serializable {
} }
} }
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
public <X> EntityType<X> entity(Class<X> cls) { public <X> EntityType<X> entity(Class<X> cls) {
final EntityType<?> entityType = entities.get( cls ); final EntityType<?> entityType = entities.get( cls );
if ( entityType == null ) throw new IllegalArgumentException( "Not an entity: " + cls ); if ( entityType == null ) throw new IllegalArgumentException( "Not an entity: " + cls );
@ -70,14 +74,21 @@ public class MetamodelImpl implements Metamodel, Serializable {
return (EntityType<X>) entityType; return (EntityType<X>) entityType;
} }
public <X> ManagedType<X> type(Class<X> cls) { /**
ManagedType<?> type = null; * {@inheritDoc}
type = entities.get( cls ); */
@SuppressWarnings({ "unchecked" })
public <X> ManagedType<X> managedType(Class<X> cls) {
ManagedType<?> type = entities.get( cls );
if ( type == null ) throw new IllegalArgumentException( "Not an managed type: " + cls ); if ( type == null ) throw new IllegalArgumentException( "Not an managed type: " + cls );
//unsafe casting is our map inserts guarantee them //unsafe casting is our map inserts guarantee them
return (ManagedType<X>) type; return (ManagedType<X>) type;
} }
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
public <X> EmbeddableType<X> embeddable(Class<X> cls) { public <X> EmbeddableType<X> embeddable(Class<X> cls) {
final EmbeddableType<?> embeddableType = embeddables.get( cls ); final EmbeddableType<?> embeddableType = embeddables.get( cls );
if ( embeddableType == null ) throw new IllegalArgumentException( "Not an entity: " + cls ); if ( embeddableType == null ) throw new IllegalArgumentException( "Not an entity: " + cls );
@ -85,6 +96,9 @@ public class MetamodelImpl implements Metamodel, Serializable {
return (EmbeddableType<X>) embeddableType; return (EmbeddableType<X>) embeddableType;
} }
/**
* {@inheritDoc}
*/
public Set<ManagedType<?>> getManagedTypes() { public Set<ManagedType<?>> getManagedTypes() {
final Set<ManagedType<?>> managedTypes = new HashSet<ManagedType<?>>( entities.size() + embeddables.size() ); final Set<ManagedType<?>> managedTypes = new HashSet<ManagedType<?>>( entities.size() + embeddables.size() );
managedTypes.addAll( entities.values() ); managedTypes.addAll( entities.values() );
@ -92,10 +106,16 @@ public class MetamodelImpl implements Metamodel, Serializable {
return managedTypes; return managedTypes;
} }
/**
* {@inheritDoc}
*/
public Set<EntityType<?>> getEntities() { public Set<EntityType<?>> getEntities() {
return new HashSet<EntityType<?>>(entities.values()); return new HashSet<EntityType<?>>(entities.values());
} }
/**
* {@inheritDoc}
*/
public Set<EmbeddableType<?>> getEmbeddables() { public Set<EmbeddableType<?>> getEmbeddables() {
return new HashSet<EmbeddableType<?>>(embeddables.values()); return new HashSet<EmbeddableType<?>>(embeddables.values());
} }

View File

@ -427,7 +427,7 @@
<dependency> <dependency>
<groupId>org.hibernate.java-persistence</groupId> <groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId> <artifactId>jpa-api</artifactId>
<version>2.0.Beta-SNAPSHOT</version> <version>2.0-cr-1</version>
</dependency> </dependency>
<!-- Set the version of the hibernate-commons-annotations to be used throughout the the project --> <!-- Set the version of the hibernate-commons-annotations to be used throughout the the project -->
<dependency> <dependency>