本文整理汇总了Java中javax.persistence.metamodel.MapAttribute类的典型用法代码示例。如果您正苦于以下问题:Java MapAttribute类的具体用法?Java MapAttribute怎么用?Java MapAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapAttribute类属于javax.persistence.metamodel包,在下文中一共展示了MapAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: join
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Nonnull
public static <T, U> Join<T, U> join(
@Nonnull final From<?, T> from, @Nonnull final PluralAttribute<? super T, ?, U> attribute) {
Objects.requireNonNull(from, "from is null");
Objects.requireNonNull(attribute, "attribute is null");
if (attribute instanceof CollectionAttribute) {
return from.join((CollectionAttribute<T, U>) attribute);
}
if (attribute instanceof SetAttribute) {
return from.join((SetAttribute<T, U>) attribute);
}
if (attribute instanceof ListAttribute) {
return from.join((ListAttribute<T, U>) attribute);
}
if (attribute instanceof MapAttribute) {
return from.join((MapAttribute<T, ?, U>) attribute);
}
// Should never end up here.
throw new IllegalArgumentException();
}
示例2: getSelectedType
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
private Class<?> getSelectedType(Path entityPath, Set<TypeDefinition> typeDefinitions) {
if (entityPath.isKeyPath()) {
TypeDefinition typeDefinition = typeForAlias(entityPath.getRootAlias())
.withMetamodel(metamodel)
.filter(typeDefinitions);
MapAttribute<?, ?, ?> mapAttribute = (MapAttribute<?, ?, ?>)attributeForPath(typeDefinition.getJoinPath())
.withMetamodel(metamodel)
.filter(typeDefinitions);
Class<?> keyType = mapAttribute.getKeyJavaType();
if (!entityPath.hasSubpath()) {
return keyType;
}
return attributeForPath(new Path(entityPath.getSubpath()))
.withMetamodel(metamodel)
.withRootType(keyType)
.filter()
.getJavaType();
} else if (entityPath.hasSubpath()) {
SingularAttribute<?, ?> attribute = (SingularAttribute<?, ?>)attributeForPath(entityPath)
.withMetamodel(metamodel)
.filter(typeDefinitions);
return attribute.getType().getJavaType();
} else {
return typeForAlias(entityPath.getRootAlias()).withMetamodel(metamodel).filter(typeDefinitions).getType();
}
}
示例3: get
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked" })
public <K, V, M extends Map<K, V>> JpaExpression<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;
throw new NotYetImplementedException( );
}
示例4: copyJoins
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
/**
* @return last possibly used alias
*/
private int copyJoins(From<?, ?> from, From<?, ?> to, int counter) {
for (Join<?, ?> join : sort(comparator, from.getJoins())) {
Attribute<?, ?> attr = join.getAttribute();
// Hibern fails with String-bases api; Join.join(String, JoinType)
@SuppressWarnings({ "rawtypes", "unchecked" })
Join<Object, Object> j = attr instanceof SingularAttribute ? to.join((SingularAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof CollectionAttribute ? to.join((CollectionAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof SetAttribute ? to.join((SetAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof ListAttribute ? to.join((ListAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof MapAttribute ? to.join((MapAttribute) join.getAttribute(), join.getJoinType()) :
to.join((CollectionAttribute) join.getAttribute(), join.getJoinType());
copyAlias(join, j, ++counter);
counter = copyJoins(join, j, ++counter);
}
copyFetches(from, to);
return counter;
}
示例5: visitJoin
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
private boolean visitJoin(Node node,
Set<TypeDefinition> typeDefinitions,
boolean innerJoin,
boolean fetchJoin) {
Path fetchPath = new Path(node.jjtGetChild(0).toString());
Class<?> keyType = null;
Attribute<?, ?> attribute = TypeDefinition.Filter.attributeForPath(fetchPath)
.withMetamodel(metamodel)
.filter(typeDefinitions);
Class<?> type;
if (attribute instanceof MapAttribute) {
MapAttribute<?, ?, ?> mapAttribute = (MapAttribute<?, ?, ?>)attribute;
keyType = mapAttribute.getKeyJavaType();
type = mapAttribute.getBindableJavaType();
} else {
type = TypeDefinition.Filter.managedTypeForPath(fetchPath)
.withMetamodel(metamodel)
.filter(typeDefinitions)
.getJavaType();
}
if (keyType != null) {
typeDefinitions.add(new TypeDefinition(keyType, fetchPath, innerJoin, fetchJoin));
}
if (node.jjtGetNumChildren() == 1) {
typeDefinitions.add(new TypeDefinition(type, fetchPath, innerJoin, fetchJoin));
} else {
Alias alias = getAlias(node);
typeDefinitions.add(new TypeDefinition(alias, type, fetchPath, innerJoin, fetchJoin));
}
return false;
}
示例6: join
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
public <K, V> JpaMapJoin<X, K, V> join(MapAttribute<? super X, K, V> map, JoinType jt) {
// if ( !canBeJoinSource() ) {
// throw illegalJoin();
// }
//
// final MapJoin<X, K, V> join = constructJoin( map, jt );
// joinScope.addJoin( join );
// return join;
throw new NotYetImplementedException( );
}
示例7: joinMap
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, K, V> JpaMapJoin<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 (JpaMapJoin<X, K, V>) join( (MapAttribute) attribute, jt );
}
示例8: get
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
public static Expression<?> get(Path<?> path, Attribute<?,?> attr) {
@SuppressWarnings({ "rawtypes", "unchecked" })
Expression<?> ret = attr instanceof SingularAttribute ? path.get((SingularAttribute) attr) :
attr instanceof CollectionAttribute ? path.get((CollectionAttribute) attr) :
attr instanceof SetAttribute ? path.get((SetAttribute) attr) :
attr instanceof ListAttribute ? path.get((ListAttribute) attr) :
attr instanceof MapAttribute ? path.get((PluralAttribute) attr) :
path.get((CollectionAttribute) attr);
return ret;
}
示例9: copyFetches
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
private static void copyFetches(FetchParent<?, ?> from, FetchParent<?, ?> to) {
for (Fetch<?, ?> fetch : sort(fetchComparator, from.getFetches())) {
Attribute<?, ?> attr = fetch.getAttribute();
@SuppressWarnings({ "rawtypes", "unchecked" })
Fetch<?, ?> f = attr instanceof SingularAttribute ? to.fetch((SingularAttribute) fetch.getAttribute(), fetch.getJoinType()) :
attr instanceof CollectionAttribute ? to.fetch((CollectionAttribute) fetch.getAttribute(), fetch.getJoinType()) :
attr instanceof SetAttribute ? to.fetch((SetAttribute) fetch.getAttribute(), fetch.getJoinType()) :
attr instanceof ListAttribute ? to.fetch((ListAttribute) fetch.getAttribute(), fetch.getJoinType()) :
attr instanceof MapAttribute ? to.fetch((MapAttribute) fetch.getAttribute(), fetch.getJoinType()) :
to.fetch((CollectionAttribute) fetch.getAttribute(), fetch.getJoinType());
copyFetches(fetch, f);
}
}
示例10: join
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
public <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map) {
// TODO Auto-generated method stub
return null;
}
示例11: get
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
public <K, V, M extends Map<K, V>> Expression<M> get(
MapAttribute<X, K, V> map) {
// TODO Auto-generated method stub
return null;
}
示例12: initialize
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Before
public void initialize() throws ParseException, NoSuchMethodException {
Metamodel metamodel = mock(Metamodel.class);
SecurePersistenceUnitUtil persistenceUnitUtil = mock(SecurePersistenceUnitUtil.class);
accessManager = mock(DefaultAccessManager.class);
SecurityContext securityContext = mock(SecurityContext.class);
EntityType entityType = mock(EntityType.class);
SingularAttribute idAttribute = mock(SingularAttribute.class);
SingularAttribute nameAttribute = mock(SingularAttribute.class);
SingularAttribute parentAttribute = mock(SingularAttribute.class);
PluralAttribute childrenAttribute = mock(PluralAttribute.class);
MapAttribute relatedAttribute = mock(MapAttribute.class);
Type integerType = mock(Type.class);
when(metamodel.getEntities()).thenReturn(Collections.<EntityType<?>>singleton(entityType));
when(metamodel.managedType(MethodAccessTestBean.class)).thenReturn(entityType);
when(metamodel.entity(MethodAccessTestBean.class)).thenReturn(entityType);
when(accessManager.getContext()).thenReturn(securityContext);
when(securityContext.getAliases()).thenReturn(Collections.singleton(CURRENT_PRINCIPAL));
when(securityContext.getAliasValue(CURRENT_PRINCIPAL)).thenReturn(NAME);
when(entityType.getName()).thenReturn(MethodAccessTestBean.class.getSimpleName());
when(entityType.getJavaType()).thenReturn((Class)MethodAccessTestBean.class);
when(entityType.getAttributes()).thenReturn(new HashSet(Arrays.asList(
idAttribute, nameAttribute, parentAttribute, childrenAttribute, relatedAttribute)));
when(entityType.getAttribute("id")).thenReturn(idAttribute);
when(entityType.getAttribute("name")).thenReturn(nameAttribute);
when(entityType.getAttribute("parent")).thenReturn(parentAttribute);
when(entityType.getAttribute("children")).thenReturn(childrenAttribute);
when(entityType.getAttribute("related")).thenReturn(relatedAttribute);
when(idAttribute.getName()).thenReturn("id");
when(idAttribute.isCollection()).thenReturn(false);
when(idAttribute.getType()).thenReturn(integerType);
when(idAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
when(idAttribute.getJavaType()).thenReturn(Integer.TYPE);
when(idAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getId"));
when(nameAttribute.getName()).thenReturn("name");
when(nameAttribute.isCollection()).thenReturn(false);
when(nameAttribute.getType()).thenReturn(integerType);
when(nameAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
when(nameAttribute.getJavaType()).thenReturn(String.class);
when(nameAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getName"));
when(parentAttribute.getName()).thenReturn("parent");
when(parentAttribute.isCollection()).thenReturn(false);
when(parentAttribute.getType()).thenReturn(entityType);
when(parentAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.MANY_TO_ONE);
when(parentAttribute.getJavaType()).thenReturn(MethodAccessTestBean.class);
when(parentAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getParent"));
when(childrenAttribute.getName()).thenReturn("children");
when(childrenAttribute.isCollection()).thenReturn(true);
when(childrenAttribute.getElementType()).thenReturn(entityType);
when(childrenAttribute.getJavaMember())
.thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getChildren"));
when(relatedAttribute.getName()).thenReturn("related");
when(relatedAttribute.isCollection()).thenReturn(true);
when(relatedAttribute.getKeyJavaType()).thenReturn(MethodAccessTestBean.class);
when(relatedAttribute.getBindableJavaType()).thenReturn(MethodAccessTestBean.class);
when(relatedAttribute.getElementType()).thenReturn(entityType);
when(relatedAttribute.getJavaMember())
.thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getRelated"));
entityFilter = new EntityFilter(metamodel, persistenceUnitUtil, initializeAccessRules(metamodel));
DefaultAccessManager.Instance.register(accessManager);
}
示例13: join
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
<K, V> JpaMapJoin<X, K, V> join(MapAttribute<? super X, K, V> map);
示例14: get
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
<K, V, M extends Map<K, V>> JpaExpression<M> get(MapAttribute<X, K, V> map);
示例15: getDeclaredMap
import javax.persistence.metamodel.MapAttribute; //导入依赖的package包/类
@Override
public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
return null;
}