javax.persistence.metamodel.MapAttribute Java Examples

The following examples show how to use javax.persistence.metamodel.MapAttribute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPathImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked" })
public <Y> Path<Y> get(String attributeName) {
	if ( ! canBeDereferenced() ) {
		throw illegalDereference();
	}

	final Attribute attribute = locateAttribute( attributeName );

	if ( attribute.isCollection() ) {
		final PluralAttribute<X,Y,?> pluralAttribute = (PluralAttribute<X,Y,?>) attribute;
		if ( PluralAttribute.CollectionType.MAP.equals( pluralAttribute.getCollectionType() ) ) {
			return (PluralAttributePath<Y>) this.<Object,Object,Map<Object, Object>>get( (MapAttribute) pluralAttribute );
		}
		else {
			return (PluralAttributePath<Y>) this.get( (PluralAttribute) pluralAttribute );
		}
	}
	else {
		return get( (SingularAttribute<X,Y>) attribute );
	}
}
 
Example #2
Source File: MapKeyHelpers.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public MapKeyAttribute(CriteriaBuilderImpl criteriaBuilder, MapAttribute<?, K, ?> attribute) {
	this.attribute = attribute;
	this.jpaType = attribute.getKeyType();
	this.jpaBinableJavaType = attribute.getKeyJavaType();
	this.jpaBindableType = Type.PersistenceType
			.ENTITY.equals( jpaType.getPersistenceType() )
			? BindableType.ENTITY_TYPE
			: BindableType.SINGULAR_ATTRIBUTE;

	String guessedRoleName = determineRole( attribute );
	SessionFactoryImplementor sfi = criteriaBuilder.getEntityManagerFactory().getSessionFactory();
	mapPersister = sfi.getCollectionPersister( guessedRoleName );
	if ( mapPersister == null ) {
		throw new IllegalStateException( "Could not locate collection persister [" + guessedRoleName + "]" );
	}
	mapKeyType = mapPersister.getIndexType();
	if ( mapKeyType == null ) {
		throw new IllegalStateException( "Could not determine map-key type [" + guessedRoleName + "]" );
	}

	this.persistentAttributeType = mapKeyType.isEntityType()
			? PersistentAttributeType.MANY_TO_ONE
			: mapKeyType.isComponentType()
					? PersistentAttributeType.EMBEDDED
					: PersistentAttributeType.BASIC;
}
 
Example #3
Source File: AbstractFromImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private <K, V> MapJoinImplementor<X, K, V> constructJoin(MapAttribute<? super X, K, V> map, JoinType jt) {
	if ( jt.equals( JoinType.RIGHT ) ) {
		throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
	}

	// TODO : runtime check that the attribute in fact belongs to this From's model/bindable

	final Class<V> attributeType = map.getBindableJavaType();
	return new MapAttributeJoin<X, K, V>( criteriaBuilder(), attributeType, this, map, jt );
}
 
Example #4
Source File: MapAttributeJoin.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public TreatedMapAttributeJoin(MapAttributeJoin<O, K, ? super T> original, Class<T> treatAsType) {
	super(
			original.criteriaBuilder(),
			treatAsType,
			original.getPathSource(),
			(MapAttribute<? super O, K, T>) original.getAttribute(),
			original.getJoinType()
	);
	this.original = original;
	this.treatAsType = treatAsType;
}
 
Example #5
Source File: MapAttributeJoin.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public MapAttributeJoin(
		CriteriaBuilderImpl criteriaBuilder,
		Class<V> javaType,
		PathSource<O> pathSource,
		MapAttribute<? super O, K, V> joinAttribute,
		JoinType joinType) {
	super( criteriaBuilder, javaType, pathSource, joinAttribute, joinType );
}
 
Example #6
Source File: AbstractPathImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked" })
public <K, V, M extends Map<K, V>> Expression<M> get(MapAttribute<X, K, V> attribute) {
	if ( ! canBeDereferenced() ) {
		throw illegalDereference();
	}

	PluralAttributePath path = (PluralAttributePath) resolveCachedAttributePath( attribute.getName() );
	if ( path == null ) {
		path = new PluralAttributePath( criteriaBuilder(), this, attribute );
		registerAttributePath( attribute.getName(), path );
	}
	return path;
}
 
Example #7
Source File: MapKeyHelpers.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public MapKeySource(
		CriteriaBuilderImpl criteriaBuilder,
		Class<Map<K, V>> javaType,
		MapJoinImplementor<?,K,V> mapJoin,
		MapAttribute<?,K,V> attribute) {
	super( criteriaBuilder, javaType, null );
	this.mapJoin = mapJoin;
	this.mapAttribute = attribute;
}
 
Example #8
Source File: AbstractFromImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
	final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( !attribute.isCollection() ) {
		throw new IllegalArgumentException( "Requested attribute was not a map" );
	}

	final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
	if ( !PluralAttribute.CollectionType.MAP.equals( pluralAttribute.getCollectionType() ) ) {
		throw new IllegalArgumentException( "Requested attribute was not a map" );
	}

	return (MapJoin<X, K, V>) join( (MapAttribute) attribute, jt );
}
 
Example #9
Source File: AbstractFromImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> Join<X, Y> join(String attributeName, JoinType jt) {
	if ( !canBeJoinSource() ) {
		throw illegalJoin();
	}

	if ( jt.equals( JoinType.RIGHT ) ) {
		throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
	}

	final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( attribute.isCollection() ) {
		final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
		if ( PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
			return (Join<X, Y>) join( (CollectionAttribute) attribute, jt );
		}
		else if ( PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
			return (Join<X, Y>) join( (ListAttribute) attribute, jt );
		}
		else if ( PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
			return (Join<X, Y>) join( (SetAttribute) attribute, jt );
		}
		else {
			return (Join<X, Y>) join( (MapAttribute) attribute, jt );
		}
	}
	else {
		return (Join<X, Y>) join( (SingularAttribute) attribute, jt );
	}
}
 
Example #10
Source File: MapEntryExpression.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public MapEntryExpression(
		CriteriaBuilderImpl criteriaBuilder,
		Class<Map.Entry<K, V>> javaType,
		PathImplementor origin,
		MapAttribute<?, K, V> attribute) {
	super( criteriaBuilder, javaType);
	this.origin = origin;
	this.attribute = attribute;
}
 
Example #11
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType, Class<V> valueType) {
	final PluralAttribute<X,?,?> attribute = declaredPluralAttributes.get( name );
	checkMapValueType( attribute, name, valueType );
	final MapAttribute<X, K, V> mapAttribute = ( MapAttribute<X, K, V> ) attribute;
	checkMapKeyType( mapAttribute, name, keyType );
	return mapAttribute;
}
 
Example #12
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked" })
public <K, V> MapAttribute<? super X, K, V> getMap(String name, Class<K> keyType, Class<V> valueType) {
	PluralAttribute<? super X, ?, ?> attribute = getPluralAttribute( name );
	if ( attribute == null && getSupertype() != null ) {
		attribute = getSupertype().getPluralAttribute( name );
	}
	checkMapValueType( attribute, name, valueType );
	final MapAttribute<? super X, K, V> mapAttribute = ( MapAttribute<? super X, K, V> ) attribute;
	checkMapKeyType( mapAttribute, name, keyType );
	return mapAttribute;
}
 
Example #13
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public MapAttribute<X, ?, ?> getDeclaredMap(String name) {
	final PluralAttribute<X,?,?> attribute = declaredPluralAttributes.get( name );
	basicMapCheck( attribute, name );
	return ( MapAttribute<X,?,?> ) attribute;
}
 
Example #14
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked" })
public MapAttribute<? super X, ?, ?> getMap(String name) {
	PluralAttribute<? super X, ?, ?> attribute = getPluralAttribute( name );
	if ( attribute == null && getSupertype() != null ) {
		attribute = getSupertype().getPluralAttribute( name );
	}
	basicMapCheck( attribute, name );
	return (MapAttribute<? super X, ?, ?>) attribute;
}
 
Example #15
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0,
    final Class<K> arg1, final Class<V> arg2) {
  return null;
}
 
Example #16
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
  return null;
}
 
Example #17
Source File: JPAEmbeddableMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
  return null;
}
 
Example #18
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
  return null;
}
 
Example #19
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0,
    final Class<K> arg1, final Class<V> arg2) {
  return null;
}
 
Example #20
Source File: JPAEmbeddableMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
  return null;
}
 
Example #21
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
  return null;
}
 
Example #22
Source File: JPAEmbeddableMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
  return null;
}
 
Example #23
Source File: JPAEmbeddableMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
  return null;
}
 
Example #24
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0,
    final Class<K> arg1, final Class<V> arg2) {
  return null;
}
 
Example #25
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
  return null;
}
 
Example #26
Source File: JPAManagedTypeMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
  return null;
}
 
Example #27
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0,
    final Class<K> arg1, final Class<V> arg2) {
  return null;
}
 
Example #28
Source File: JPAEmbeddableTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
  return null;
}
 
Example #29
Source File: JPAEmbeddableTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0,
    final Class<K> arg1, final Class<V> arg2) {
  return null;
}
 
Example #30
Source File: JPAEmbeddableTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
  return null;
}