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 name = BinderHelper.isDefault( ann.name() ) ? inferredData.getPropertyName() + "_ORDER" : ann.name();
//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(
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
);
}

View File

@ -269,15 +269,15 @@ public abstract class AbstractQueryImpl<X> implements TypedQuery<X> {
private Map parameterBindings;
protected void registerParameterBinding(Parameter parameter, Object value) {
if ( value != null && parameter.getJavaType() != null ) {
if ( value != null && parameter.getParameterType() != null ) {
if ( Collection.class.isInstance( value ) ) {
final Collection collection = (Collection) value;
// validate the elements...
for ( Object element : collection ) {
if ( ! parameter.getJavaType().isInstance( element ) ) {
if ( ! parameter.getParameterType().isInstance( element ) ) {
throw new IllegalArgumentException(
"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() ) {
final Object[] array = (Object[]) value;
for ( Object element : array ) {
if ( ! parameter.getJavaType().isInstance( element ) ) {
if ( ! parameter.getParameterType().isInstance( element ) ) {
throw new IllegalArgumentException(
"Parameter value [" + element + "] was not matching type [" +
parameter.getJavaType().getName() + "]"
parameter.getParameterType().getName() + "]"
);
}
}
}
else {
if ( ! parameter.getJavaType().isInstance( value ) ) {
if ( ! parameter.getParameterType().isInstance( value ) ) {
throw new IllegalArgumentException(
"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.PersistenceUnitUtil;
import javax.persistence.metamodel.Metamodel;
import javax.persistence.criteria.QueryBuilder;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.persistence.spi.LoadState;
@ -93,7 +93,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
);
}
public QueryBuilder getQueryBuilder() {
public CriteriaBuilder getCriteriaBuilder() {
return criteriaQueryBuilder;
}

View File

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

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.CollectionAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.CollectionJoinImplementor;
@ -66,7 +67,23 @@ public class BasicCollectionJoinImpl<O,E>
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

@ -25,6 +25,7 @@ package org.hibernate.ejb.criteria;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.ListAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.ListJoinImplementor;
import org.hibernate.ejb.criteria.expression.ListIndexExpression;
@ -72,7 +73,23 @@ public class BasicListJoinImpl<O,E>
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.JoinType;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.Type.PersistenceType;
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>
implements JoinImplementors.MapJoinImplementor<O,K,V> {
public BasicMapJoinImpl(
QueryBuilderImpl queryBuilder,
Class<V> javaType,
@ -56,19 +58,6 @@ public class BasicMapJoinImpl<O,K,V>
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
public MapAttribute<? super O, K, V> 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() );
}
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;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.SetAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.SetJoinImplementor;
@ -46,6 +47,16 @@ public class BasicSetJoinImpl<O,E>
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
public SetJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
BasicSetJoinImpl<O,E> correlation = new BasicSetJoinImpl<O,E>(
@ -56,16 +67,23 @@ public class BasicSetJoinImpl<O,E>
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation;
}
@Override
public SetAttribute<? super O, E> getAttribute() {
return (SetAttribute<? super O, E>) super.getAttribute();
private From<O, E> correlationParent;
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
}
@Override
public SetAttribute<? super O, E> getModel() {
return getAttribute();
}
/**
* {@inheritDoc}
*/
public From<O, E> getCorrelationParent() {
return correlationParent;
}
}

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.CollectionAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.CollectionJoinImplementor;
@ -46,19 +47,6 @@ public class CollectionJoinImpl<O,E>
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
public CollectionAttribute<? super O, E> getAttribute() {
return (CollectionAttribute<? super O, E>) super.getAttribute();
@ -69,4 +57,34 @@ public class CollectionJoinImpl<O,E>
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.SetJoin;
import javax.persistence.criteria.Subquery;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.EntityType;
import org.hibernate.ejb.criteria.FromImpl.JoinScope;
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) {
throw new UnsupportedOperationException( "Cannot define fetch from a subquery correlation" );
}
public boolean isCorrelated() {
return true;
}
public From getCorrelationParent() {
return null;
}
};
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 void addJoin(Join<X, ?> join);
public void addFetch(Fetch<X,?> fetch);
public boolean isCorrelated();
public From<?, X> getCorrelationParent();
}
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 );
}
public boolean isCorrelated() {
return false;
}
public From<?, X> getCorrelationParent() {
return null;
}
};
/**
* Special constructor for {@link RootImpl}.
*
* @param queryBuilder
* @param entityType
* @param queryBuilder The query build
* @param entityType The entity defining this root
*/
protected FromImpl(QueryBuilderImpl queryBuilder, EntityType<X> 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,
lhs,
joinProperty,
(ManagedType<X>)queryBuilder.getEntityManagerFactory().getMetamodel().type( javaType )
(ManagedType<X>)queryBuilder.getEntityManagerFactory().getMetamodel().managedType( javaType )
);
this.managedType = (ManagedType<X>) getModel();
this.joinType = joinType;
@ -95,8 +95,24 @@ public class JoinImpl<Z, X> extends FromImpl<Z, X> implements JoinImplementors.J
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
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.MapJoin;
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.

View File

@ -25,6 +25,7 @@ package org.hibernate.ejb.criteria;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.ListAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.ListJoinImplementor;
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 );
}
@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
public ListAttribute<? super O, E> 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();
}
/**
* {@inheritDoc}
*/
public Expression<Integer> index() {
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.JoinType;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.Type.PersistenceType;
import org.hibernate.ejb.criteria.JoinImplementors.MapJoinImplementor;
@ -52,19 +53,6 @@ public class MapJoinImpl<O,K,V>
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
public MapAttribute<? super O, K, V> 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() );
}
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.MapJoin;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.Bindable.BindableType;
import javax.persistence.metamodel.ManagedType;
@ -75,6 +76,13 @@ public class MapKeyHelpers {
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.math.BigDecimal;
import java.math.BigInteger;
import javax.persistence.criteria.QueryBuilder;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Selection;
import javax.persistence.criteria.CompoundSelection;
@ -87,7 +87,7 @@ import static org.hibernate.ejb.criteria.predicate.ComparisonPredicate.Compariso
*
* @author Steve Ebersole
*/
public class QueryBuilderImpl implements QueryBuilder, Serializable {
public class QueryBuilderImpl implements CriteriaBuilder, Serializable {
private final EntityManagerFactoryImpl entityManagerFactory;
public QueryBuilderImpl(EntityManagerFactoryImpl entityManagerFactory) {
@ -260,7 +260,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc}
*/
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}
*/
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
// return new ExplicitTruthValueCheck( this, x, TruthValue.FALSE );
}
@ -334,7 +334,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc}
*/
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) {
//noinspection SuspiciousNameCombination
return new ComparisonPredicate( this, ComparisonOperator.NOT_EQUAL, x, y ).negate();
return new ComparisonPredicate( this, ComparisonOperator.NOT_EQUAL, x, y ).not();
}
/**
* {@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
return new ComparisonPredicate( this, ComparisonOperator.GREATER_THAN, x, y );
}
@ -380,7 +380,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate lessThan(
public <Y extends Comparable<? super Y>> Predicate lessThan(
Expression<? extends Y> x,
Expression<? extends Y> y) {
//noinspection SuspiciousNameCombination
@ -390,7 +390,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(
public <Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(
Expression<? extends Y> x,
Expression<? extends Y> y) {
//noinspection SuspiciousNameCombination
@ -400,7 +400,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(
public <Y extends Comparable<? super Y>> Predicate lessThanOrEqualTo(
Expression<? extends Y> x,
Expression<? extends Y> y) {
//noinspection SuspiciousNameCombination
@ -410,7 +410,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate greaterThan(
public <Y extends Comparable<? super Y>> Predicate greaterThan(
Expression<? extends Y> x,
Y y) {
//noinspection SuspiciousNameCombination
@ -420,7 +420,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate lessThan(
public <Y extends Comparable<? super Y>> Predicate lessThan(
Expression<? extends Y> x,
Y y) {
//noinspection SuspiciousNameCombination
@ -430,7 +430,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(
public <Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(
Expression<? extends Y> x,
Y y) {
//noinspection SuspiciousNameCombination
@ -440,7 +440,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(
public<Y extends Comparable<? super Y>> Predicate lessThanOrEqualTo(
Expression<? extends Y> x,
Y y) {
//noinspection SuspiciousNameCombination
@ -514,7 +514,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate between(
public <Y extends Comparable<? super Y>> Predicate between(
Expression<? extends Y> expression,
Y lowerBound,
Y upperBound) {
@ -524,7 +524,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <Y extends Comparable<Y>> Predicate between(
public <Y extends Comparable<? super Y>> Predicate between(
Expression<? extends Y> expression,
Expression<? extends Y> lowerBound,
Expression<? extends Y> upperBound) {
@ -575,27 +575,27 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
}
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) {
return like( matchExpression, pattern, escapeCharacter ).negate();
return like( matchExpression, pattern, escapeCharacter ).not();
}
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) {
return like( matchExpression, pattern ).negate();
return like( matchExpression, pattern ).not();
}
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) {
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 );
}
/**
* {@inheritDoc}
*/
public <T> Expression<T> nullLiteral(Class<T> resultClass) {
return new LiteralExpression<T>( this, resultClass, null );
}
// aggregate functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -639,6 +646,20 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
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}
*/
@ -656,15 +677,17 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
public <X extends Comparable<X>> Expression<X> greatest(Expression<X> x) {
return new AggregationFunction.GREATEST<X>( this, x );
@SuppressWarnings({ "unchecked" })
public <X extends Comparable<? super X>> Expression<X> greatest(Expression<X> x) {
return new AggregationFunction.GREATEST( this, x );
}
/**
* {@inheritDoc}
*/
public <X extends Comparable<X>> Expression<X> least(Expression<X> x) {
return new AggregationFunction.LEAST<X>( this, x );
@SuppressWarnings({ "unchecked" })
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 returnType The return type.
*
* @param <T> The type of the function return.
*
* @return The function expression
*/
public <T> Expression<T> function(String name, Class<T> returnType) {
@ -816,6 +837,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 );
@ -831,6 +853,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 );
@ -846,12 +869,13 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, (Expression)expression2 );
return new BinaryArithmeticOperation<N>(
this,
(Class<N>) expression1.getJavaType(),
type,
BinaryArithmeticOperation.Operation.SUBTRACT,
expression1,
expression2
@ -861,6 +885,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -876,6 +901,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -891,6 +917,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -906,6 +933,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -921,6 +949,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
type = (Class<N>)BinaryArithmeticOperation.determineReturnType( type, n );
@ -936,6 +965,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
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 );
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) {
return new SubqueryComparisonModifierExpression<Y>(
this,
subquery.getJavaType(),
(Class)subquery.getJavaType(),
subquery,
SubqueryComparisonModifierExpression.Modifier.ALL
);
@ -1106,7 +1136,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
public <Y> Expression<Y> some(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>(
this,
subquery.getJavaType(),
(Class)subquery.getJavaType(),
subquery,
SubqueryComparisonModifierExpression.Modifier.SOME
);
@ -1118,7 +1148,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
public <Y> Expression<Y> any(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>(
this,
subquery.getJavaType(),
(Class)subquery.getJavaType(),
subquery,
SubqueryComparisonModifierExpression.Modifier.ANY
);
@ -1185,7 +1215,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc}
*/
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) {
@ -1196,7 +1226,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc}
*/
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) {
@ -1241,7 +1271,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
return size( ( (LiteralExpression<C>) exp ).getLiteral() );
}
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?
throw new IllegalArgumentException("unknown collection expression type [" + exp.getClass().getName() + "]" );
@ -1265,6 +1295,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
public <C extends Collection<?>> Predicate isEmpty(Expression<C> collectionExpression) {
if ( CollectionExpression.class.isInstance(collectionExpression) ) {
return new IsEmptyPredicate(
@ -1282,7 +1313,7 @@ public class QueryBuilderImpl implements QueryBuilder, Serializable {
* {@inheritDoc}
*/
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}
*/
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}
*/
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;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.EntityType;
@ -33,6 +34,8 @@ import javax.persistence.metamodel.EntityType;
* @author Steve Ebersole
*/
public class RootImpl<X> extends FromImpl<X,X> implements Root<X> {
private RootImpl<X> correlationParent;
public RootImpl(
QueryBuilderImpl queryBuilder,
EntityType<X> model) {
@ -49,9 +52,18 @@ public class RootImpl<X> extends FromImpl<X,X> implements Root<X> {
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) {
RootImpl<X> correlation = new RootImpl<X>( queryBuilder(), getModel() );
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation;
}
}

View File

@ -24,6 +24,7 @@
package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.SetAttribute;
import org.hibernate.ejb.criteria.JoinImplementors.SetJoinImplementor;
@ -46,6 +47,16 @@ public class SetJoinImpl<O,E>
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
public SetJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
SetJoinImpl<O,E> correlation = new SetJoinImpl<O,E>(
@ -56,16 +67,23 @@ public class SetJoinImpl<O,E>
getJoinType()
);
correlation.defineJoinScope( subquery.getJoinScope() );
correlation.correlationParent = this;
return correlation;
}
@Override
public SetAttribute<? super O, E> getAttribute() {
return (SetAttribute<? super O, E>) super.getAttribute();
private From<O, E> correlationParent;
/**
* {@inheritDoc}
*/
public boolean isCorrelated() {
return getCorrelationParent() != null;
}
@Override
public SetAttribute<? super O, E> getModel() {
return getAttribute();
/**
* {@inheritDoc}
*/
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.List;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.QueryBuilder.Coalesce;
import org.hibernate.ejb.criteria.ParameterContainer;
import javax.persistence.criteria.CriteriaBuilder.Coalesce;
import org.hibernate.ejb.criteria.ParameterRegistry;
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 ) );
}
@SuppressWarnings({ "unchecked" })
public Coalesce<T> value(Expression<? extends T> value) {
expressions.add( value );
if ( javaType == null ) {

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ import org.hibernate.ejb.criteria.QueryBuilderImpl;
* @author Steve Ebersole
*/
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 Modifier modifier;

View File

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

View File

@ -36,7 +36,7 @@ public class AbsFunction<N extends Number>
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 );
}
}

View File

@ -41,6 +41,7 @@ public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
* @param functionName The name of the function.
* @param argument The literal argument
*/
@SuppressWarnings({ "unchecked" })
public AggregationFunction(
QueryBuilderImpl queryBuilder,
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 final String NAME = "sum";
@SuppressWarnings({ "unchecked" })
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 final String NAME = "min";
@SuppressWarnings({ "unchecked" })
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 final String NAME = "max";
@SuppressWarnings({ "unchecked" })
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 final String NAME = "min";
@SuppressWarnings({ "unchecked" })
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 final String NAME = "max";
@SuppressWarnings({ "unchecked" })
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;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.QueryBuilder.Trimspec;
import org.hibernate.ejb.criteria.ParameterContainer;
import javax.persistence.criteria.CriteriaBuilder.Trimspec;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.QueryBuilderImpl;
import org.hibernate.ejb.criteria.expression.LiteralExpression;

View File

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

View File

@ -143,12 +143,12 @@ public class EntityTypeDelegator<X> implements EntityType<X>, Serializable {
return delegate.getDeclaredMap( name, keyType, valueType );
}
public Set<PluralAttribute<? super X, ?, ?>> getCollections() {
return delegate.getCollections();
public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
return delegate.getPluralAttributes();
}
public Set<PluralAttribute<X, ?, ?>> getDeclaredCollections() {
return delegate.getDeclaredCollections();
public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
return delegate.getDeclaredPluralAttributes();
}
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
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
* 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,
* 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;
}
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.
}
public Set<PluralAttribute<X, ?, ?>> getDeclaredCollections() {
public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
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) {
final EntityType<?> entityType = entities.get( 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;
}
public <X> ManagedType<X> type(Class<X> cls) {
ManagedType<?> type = null;
type = entities.get( cls );
/**
* {@inheritDoc}
*/
@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 );
//unsafe casting is our map inserts guarantee them
return (ManagedType<X>) type;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
public <X> EmbeddableType<X> embeddable(Class<X> cls) {
final EmbeddableType<?> embeddableType = embeddables.get( 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;
}
/**
* {@inheritDoc}
*/
public Set<ManagedType<?>> getManagedTypes() {
final Set<ManagedType<?>> managedTypes = new HashSet<ManagedType<?>>( entities.size() + embeddables.size() );
managedTypes.addAll( entities.values() );
@ -92,10 +106,16 @@ public class MetamodelImpl implements Metamodel, Serializable {
return managedTypes;
}
/**
* {@inheritDoc}
*/
public Set<EntityType<?>> getEntities() {
return new HashSet<EntityType<?>>(entities.values());
}
/**
* {@inheritDoc}
*/
public Set<EmbeddableType<?>> getEmbeddables() {
return new HashSet<EmbeddableType<?>>(embeddables.values());
}

View File

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