@Override public Class<K> getJavaType() { return attribute.getKeyJavaType(); }
private <K,V> void checkMapKeyType(MapAttribute<? super J, K, V> mapAttribute, String name, Class<K> keyType) { if ( mapAttribute.getKeyJavaType() != keyType ) { throw new IllegalArgumentException( "MapAttribute named " + name + " does not support a key of type " + keyType ); } }
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; }
@Override public <K, V> MapAttribute<X, K, V> getDeclaredMap(String paramName, Class<K> keyClazz, Class<V> valueClazz) { PluralAttribute<X, ?, ?> declaredAttrib = getDeclaredPluralAttribute(paramName); if (onCheckMapAttribute(declaredAttrib, valueClazz)) { if (valueClazz != null && valueClazz.equals(((MapAttribute<X, K, V>) declaredAttrib).getKeyJavaType())) { return (MapAttribute<X, K, V>) declaredAttrib; } } throw new IllegalArgumentException( "attribute of the given name and type is not present in the managed MapAttribute type, for name:" + paramName + " , value type:" + valueClazz + "key tpye:" + keyClazz); }
@Override public <K, V> MapAttribute<? super X, K, V> getMap(String paramName, Class<K> keyClazz, Class<V> valueClazz) { PluralAttribute<X, ?, ?> declaredAttrib = getDeclaredPluralAttribute(paramName); if (onCheckMapAttribute(declaredAttrib, valueClazz)) { if (valueClazz != null && valueClazz.equals(((MapAttribute<X, K, V>) declaredAttrib).getKeyJavaType())) { return (MapAttribute<X, K, V>) declaredAttrib; } } PluralAttribute<? super X, ?, ?> superAttrib = getPluralAttriute(paramName); if (onCheckMapAttribute(superAttrib, valueClazz)) { if (valueClazz != null && valueClazz.equals(((MapAttribute<? super X, K, V>) superAttrib).getKeyJavaType())) { return (MapAttribute<? super X, K, V>) superAttrib; } } throw new IllegalArgumentException( "attribute of the given name and type is not present in the managed MapAttribute type, for name:" + paramName + " , value type:" + valueClazz + "key tpye:" + keyClazz); }
@Override public Class<Y> getBindableJavaType() { return attribute.getKeyJavaType(); } }
/** * {@inheritDoc} */ public Class<K> getJavaType() { return attribute.getKeyJavaType(); }
@Override public Class<Y> getJavaType() { return attribute.getKeyJavaType(); }
@Override public Class<Y> getBindableJavaType() { return attribute.getKeyJavaType(); } }
private <K,V> void checkMapKeyType(MapAttribute<? super X, K, V> mapAttribute, String name, Class<K> keyType) { if ( mapAttribute.getKeyJavaType() != keyType ) { throw new IllegalArgumentException( "MapAttribute named " + name + " does not support a key of type " + keyType ); } }
@Override public Class<K> getBindableJavaType() { return this.mapAttributeJoin.getAttribute().getKeyJavaType(); }
public MapKey(Map<Z,K,?> joinMap){ super(((MapAttribute<Z, K, ?>)joinMap.getAttribute()).getKeyJavaType()); attr = ((MapAttributeImpl<Z, K, ?>)joinMap.getAttribute()); this.map = joinMap; }
public MapKey(Map<Z,K,?> joinMap){ super(((MapAttribute<Z, K, ?>)joinMap.getAttribute()).getKeyJavaType()); attr = ((MapAttributeImpl<Z, K, ?>)joinMap.getAttribute()); this.map = joinMap; }
public MapKey(Map<Z,K,?> joinMap){ super(((MapAttribute<Z, K, ?>)joinMap.getAttribute()).getKeyJavaType()); attr = ((MapAttributeImpl<Z, K, ?>)joinMap.getAttribute()); this.map = joinMap; }
public MapKey(Map<Z,K,?> joinMap){ super(((MapAttribute<Z, K, ?>)joinMap.getAttribute()).getKeyJavaType()); attr = ((MapAttributeImpl<Z, K, ?>)joinMap.getAttribute()); this.map = joinMap; }
public Path<K> key() { if (this.getModel().getKeyType().getPersistenceType().equals(PersistenceType.BASIC)){ return new PathImpl(this, metamodel, ((MapAttribute)this.modelArtifact).getKeyJavaType(), this.currentNode.mapKey(), this.getModel()); } return new JoinImpl(this, (ManagedType)this.getModel().getKeyType(), metamodel, this.getModel().getKeyJavaType(), this.currentNode.mapKey(), this.getModel()); }
public MapKeyAttribute(BlazeCriteriaBuilderImpl 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; this.persistentAttributeType = Type.PersistenceType.ENTITY .equals(jpaType.getPersistenceType()) ? PersistentAttributeType.MANY_TO_ONE : Type.PersistenceType.EMBEDDABLE .equals(jpaType.getPersistenceType()) ? PersistentAttributeType.EMBEDDED : PersistentAttributeType.BASIC; }
public MapKeyAttribute(BlazeCriteriaBuilderImpl 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; this.persistentAttributeType = Type.PersistenceType.ENTITY .equals(jpaType.getPersistenceType()) ? PersistentAttributeType.MANY_TO_ONE : Type.PersistenceType.EMBEDDABLE .equals(jpaType.getPersistenceType()) ? PersistentAttributeType.EMBEDDED : PersistentAttributeType.BASIC; }
public Join<Map<K, V>, K> joinKey(JoinType jt) { if (this.getModel().getKeyType().getPersistenceType().equals(PersistenceType.BASIC)){ throw new IllegalStateException(ExceptionLocalization.buildMessage("attemped_to_join_basic_key")); } return new JoinImpl(this, (ManagedType)this.getModel().getKeyType(), metamodel, this.getModel().getKeyJavaType(), this.currentNode.mapKey(), this.getModel()); }
private JoinNode joinMapKey(MapKeyExpression mapKeyExpression, String alias, ClauseType fromClause, Set<String> currentlyResolvingAliases, boolean fromSubquery, boolean fromSelectAlias, boolean joinRequired, boolean fetch, boolean implicit, boolean defaultJoin) { implicitJoin(mapKeyExpression.getPath(), true, true, null, fromClause, null, currentlyResolvingAliases, fromSubquery, fromSelectAlias, joinRequired, false, fetch, false); JoinNode current = (JoinNode) mapKeyExpression.getPath().getBaseNode(); String joinRelationName = "KEY(" + current.getParentTreeNode().getRelationName() + ")"; MapAttribute<?, ?, ?> mapAttribute = (MapAttribute<?, ?, ?>) current.getParentTreeNode().getAttribute(); Attribute<?, ?> keyAttribute = new MapKeyAttribute<>(mapAttribute); String aliasToUse = alias == null ? current.getParentTreeNode().getRelationName().replaceAll("\\.", "_") + "_key" : alias; Type<?> joinRelationType = metamodel.type(mapAttribute.getKeyJavaType()); current = getOrCreate(current, joinRelationName, joinRelationType, null, aliasToUse, JoinType.LEFT, "Ambiguous implicit join", implicit, true, keyAttribute); return current; }