EJB-447 : Implement JPA 2.0 criteria apis

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17236 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2009-08-05 19:28:58 +00:00
parent bd4c85ce10
commit aceeb48968
2 changed files with 63 additions and 29 deletions

View File

@ -120,28 +120,62 @@ public abstract class AbstractBasicPluralJoin<O,C,E>
} }
@Override @Override
public <Y> Join<E, Y> join(String attributeName, JoinType jt) { public <E,Y> Join<E, Y> join(String attributeName, JoinType jt) {
throw illegalJoin(); throw illegalJoin();
} }
@Override @Override
public <Y> CollectionJoin<E, Y> joinCollection(String attributeName, JoinType jt) { public <E,Y> CollectionJoin<E, Y> joinCollection(String attributeName, JoinType jt) {
throw illegalJoin(); throw illegalJoin();
} }
@Override @Override
public <Y> ListJoin<E, Y> joinList(String attributeName, JoinType jt) { public <E,Y> ListJoin<E, Y> joinList(String attributeName, JoinType jt) {
throw illegalJoin(); throw illegalJoin();
} }
@Override @Override
public <L, W> MapJoin<E, L, W> joinMap(String attributeName, JoinType jt) { public <E, L, W> MapJoin<E, L, W> joinMap(String attributeName, JoinType jt) {
throw illegalJoin(); throw illegalJoin();
} }
@Override @Override
public <Y> SetJoin<E, Y> joinSet(String attributeName, JoinType jt) { public <E,Y> SetJoin<E, Y> joinSet(String attributeName, JoinType jt) {
throw illegalJoin(); throw illegalJoin();
} }
@Override
public <Y> Fetch<E, Y> fetch(SingularAttribute<? super E, Y> singularAttribute) {
throw illegalFetch();
}
private BasicPathUsageException illegalFetch() {
return new BasicPathUsageException( "Basic collection cannot be source of a fetch", getAttribute() );
}
@Override
public <Y> Fetch<E, Y> fetch(SingularAttribute<? super E, Y> attribute, JoinType jt) {
throw illegalFetch();
}
@Override
public <Y> Fetch<E, Y> fetch(PluralAttribute<? super E, ?, Y> pluralAttribute) {
throw illegalFetch();
}
@Override
public <Y> Fetch<E, Y> fetch(PluralAttribute<? super E, ?, Y> pluralAttribute, JoinType jt) {
throw illegalFetch();
}
@Override
public <X, Y> Fetch<X, Y> fetch(String attributeName) {
throw illegalFetch();
}
@Override
public <X, Y> Fetch<X, Y> fetch(String attributeName, JoinType jt) {
throw illegalFetch();
}
} }

View File

@ -307,14 +307,14 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> Join<X, Y> join(String attributeName) { public <X,Y> Join<X, Y> join(String attributeName) {
return join( attributeName, DEFAULT_JOIN_TYPE ); return join( attributeName, DEFAULT_JOIN_TYPE );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> Join<X, Y> join(String attributeName, JoinType jt) { public <X,Y> Join<X, Y> join(String attributeName, JoinType jt) {
if ( jt.equals( JoinType.RIGHT ) ) { if ( jt.equals( JoinType.RIGHT ) ) {
throw new UnsupportedOperationException( "RIGHT JOIN not supported" ); throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
} }
@ -323,34 +323,34 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
if ( attribute.isCollection() ) { if ( attribute.isCollection() ) {
final PluralAttribute pluralAttribute = ( PluralAttribute ) attribute; final PluralAttribute pluralAttribute = ( PluralAttribute ) attribute;
if ( CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) { if ( CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
return join( (CollectionAttribute<X,Y>) attribute, jt ); return (Join<X,Y>) join( (CollectionAttribute) attribute, jt );
} }
else if ( CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) { else if ( CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
return join( (ListAttribute<X,Y>) attribute, jt ); return (Join<X,Y>) join( (ListAttribute) attribute, jt );
} }
else if ( CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) { else if ( CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
return join( (SetAttribute<X,Y>) attribute, jt ); return (Join<X,Y>) join( (SetAttribute) attribute, jt );
} }
else { else {
return join( (MapAttribute<X,?,Y>) attribute, jt ); return (Join<X,Y>) join( (MapAttribute) attribute, jt );
} }
} }
else { else {
return join( (SingularAttribute)attribute, jt ); return (Join<X,Y>) join( (SingularAttribute)attribute, jt );
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> CollectionJoin<X, Y> joinCollection(String attributeName) { public <X,Y> CollectionJoin<X, Y> joinCollection(String attributeName) {
return joinCollection( attributeName, DEFAULT_JOIN_TYPE ); return joinCollection( attributeName, DEFAULT_JOIN_TYPE );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) { public <X,Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName ); final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
if ( ! attribute.isCollection() ) { if ( ! attribute.isCollection() ) {
throw new IllegalArgumentException( "Requested attribute was not a collection" ); throw new IllegalArgumentException( "Requested attribute was not a collection" );
@ -361,20 +361,20 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
throw new IllegalArgumentException( "Requested attribute was not a collection" ); throw new IllegalArgumentException( "Requested attribute was not a collection" );
} }
return join( (CollectionAttribute<X,Y>) attribute, jt ); return (CollectionJoin<X,Y>) join( (CollectionAttribute) attribute, jt );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> SetJoin<X, Y> joinSet(String attributeName) { public <X,Y> SetJoin<X, Y> joinSet(String attributeName) {
return joinSet( attributeName, DEFAULT_JOIN_TYPE ); return joinSet( attributeName, DEFAULT_JOIN_TYPE );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt) { public <X,Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt) {
final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName ); final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
if ( ! attribute.isCollection() ) { if ( ! attribute.isCollection() ) {
throw new IllegalArgumentException( "Requested attribute was not a set" ); throw new IllegalArgumentException( "Requested attribute was not a set" );
@ -385,20 +385,20 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
throw new IllegalArgumentException( "Requested attribute was not a set" ); throw new IllegalArgumentException( "Requested attribute was not a set" );
} }
return join( (SetAttribute<X,Y>) attribute, jt ); return (SetJoin<X,Y>) join( (SetAttribute) attribute, jt );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> ListJoin<X, Y> joinList(String attributeName) { public <X,Y> ListJoin<X, Y> joinList(String attributeName) {
return joinList( attributeName, DEFAULT_JOIN_TYPE ); return joinList( attributeName, DEFAULT_JOIN_TYPE );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt) { public <X,Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt) {
final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName ); final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
if ( ! attribute.isCollection() ) { if ( ! attribute.isCollection() ) {
throw new IllegalArgumentException( "Requested attribute was not a list" ); throw new IllegalArgumentException( "Requested attribute was not a list" );
@ -409,20 +409,20 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
throw new IllegalArgumentException( "Requested attribute was not a list" ); throw new IllegalArgumentException( "Requested attribute was not a list" );
} }
return join( (ListAttribute<X,Y>) attribute, jt ); return (ListJoin<X,Y>) join( (ListAttribute) attribute, jt );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <K, V> MapJoin<X, K, V> joinMap(String attributeName) { public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName) {
return joinMap( attributeName, DEFAULT_JOIN_TYPE ); return joinMap( attributeName, DEFAULT_JOIN_TYPE );
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public <K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) { public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName ); final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
if ( ! attribute.isCollection() ) { if ( ! attribute.isCollection() ) {
throw new IllegalArgumentException( "Requested attribute was not a map" ); throw new IllegalArgumentException( "Requested attribute was not a map" );
@ -433,7 +433,7 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
throw new IllegalArgumentException( "Requested attribute was not a map" ); throw new IllegalArgumentException( "Requested attribute was not a map" );
} }
return join( (MapAttribute<X,K,V>) attribute, jt ); return (MapJoin<X,K,V>) join( (MapAttribute) attribute, jt );
} }
@ -492,17 +492,17 @@ public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X> {
return fetch; return fetch;
} }
public <Y> Fetch<X, Y> fetch(String attributeName) { public <X,Y> Fetch<X, Y> fetch(String attributeName) {
return fetch( attributeName, DEFAULT_JOIN_TYPE ); return fetch( attributeName, DEFAULT_JOIN_TYPE );
} }
public <Y> Fetch<X, Y> fetch(String attributeName, JoinType jt) { public <X,Y> Fetch<X, Y> fetch(String attributeName, JoinType jt) {
Attribute<X,?> attribute = getAttribute( attributeName ); Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
if ( attribute.isCollection() ) { if ( attribute.isCollection() ) {
return fetch( (PluralAttribute<X,?,Y>)attribute, jt ); return (Fetch<X, Y>) fetch( (PluralAttribute) attribute, jt );
} }
else { else {
return fetch( (SingularAttribute<X,Y>) attribute, jt ); return (Fetch<X, Y>) fetch( (SingularAttribute) attribute, jt );
} }
} }