public boolean isBasicCollection() { return Type.PersistenceType.BASIC.equals( getAttribute().getElementType().getPersistenceType() ); }
private <Y> JoinImplementor<X, Y> constructJoin(SingularAttribute<? super X, Y> attribute, JoinType jt) { if ( Type.PersistenceType.BASIC.equals( attribute.getType().getPersistenceType() ) ) { throw new BasicPathUsageException( "Cannot join to attribute of basic type", attribute ); } // TODO : runtime check that the attribute in fact belongs to this From's model/bindable if ( jt.equals( JoinType.RIGHT ) ) { throw new UnsupportedOperationException( "RIGHT JOIN not supported" ); } final Class<Y> attributeType = attribute.getBindableJavaType(); return new SingularAttributeJoin<X, Y>( criteriaBuilder(), attributeType, this, attribute, jt ); }
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; }
/** * Assert on embeddable. * * @param embeddableAttrib * the embeddable attrib * @param clazz * the clazz */ @SuppressWarnings({ "rawtypes", "unchecked" }) private void assertOnEmbeddable(SingularAttribute embeddableAttrib, Class clazz) { Assert.assertNotNull(embeddableAttrib); Assert.assertEquals(PersistentAttributeType.EMBEDDED, embeddableAttrib.getPersistentAttributeType()); Assert.assertEquals(PersistenceType.EMBEDDABLE, embeddableAttrib.getType().getPersistenceType()); Assert.assertEquals(clazz, embeddableAttrib.getType().getJavaType()); }
/** * Assert on embeddable. * * @param embeddableAttrib * the embeddable attrib * @param clazz * the clazz */ @SuppressWarnings({ "rawtypes", "unchecked" }) private void assertOnEmbeddable(SingularAttribute embeddableAttrib, Class clazz) { Assert.assertNotNull(embeddableAttrib); Assert.assertEquals(PersistentAttributeType.EMBEDDED, embeddableAttrib.getPersistentAttributeType()); Assert.assertEquals(PersistenceType.EMBEDDABLE, embeddableAttrib.getType().getPersistenceType()); Assert.assertEquals(clazz, embeddableAttrib.getType().getJavaType()); } }
void assertJoinable(Type<?> type) { if (type.getPersistenceType() == PersistenceType.BASIC) { throw new IllegalArgumentException(this + " is a basic path and can not be navigated to "); } }
void assertJoinable(Type<?> type) { if (type.getPersistenceType() == PersistenceType.BASIC) { throw new IllegalArgumentException(this + " is a basic path and can not be navigated to "); } }
void assertJoinable(Type<?> type) { if (type.getPersistenceType() == PersistenceType.BASIC) { throw new IllegalArgumentException(this + " is a basic path and can not be navigated to "); } }
public MapKeyAttribute(MapAttribute<?, Y, ?> attribute) { this.attribute = attribute; Type<Y> jpaType = attribute.getKeyType(); 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; }
@SuppressWarnings("unchecked") private void discoverEnumTypes(Set<Class<?>> seenTypesForEnumResolving, Map<String, Class<Enum<?>>> enumTypes, Type<?> type) { if (type.getPersistenceType() == Type.PersistenceType.BASIC) { Class<?> elementType = type.getJavaType(); if (elementType.isEnum()) { enumTypes.put(elementType.getName(), (Class<Enum<?>>) elementType); } } else { discoverEnumTypes(seenTypesForEnumResolving, enumTypes, (ManagedType<?>) type); } }
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; }
@Override void determineStructuredType() { if (getRowType().getPersistenceType() == PersistenceType.EMBEDDABLE) type = schema.getStructuredType((PluralAttribute<?, ?, ?>) jpaAttribute); else type = null; }
public <Y> Path<Y> get(String attrName) { Type<?> type = this.getType(); if (type.getPersistenceType() == PersistenceType.BASIC) { throw new IllegalArgumentException(this + " is BASIC and we cannot navigate to " + attrName); } AttributeImpl<? super X, Y> next = (AttributeImpl<? super X, Y>) ((ManagedType<? super X>)type).getAttribute(attrName); return new PathImpl<X,Y>(this, next, next.getJavaType()); }
@Override public boolean isCompositeNode(Attribute<?, ?> attr) { if (attr.isCollection()) { PluralAttribute<?, ?, ?> pluralAttribute = (PluralAttribute<?, ?, ?>) attr; if (pluralAttribute.getElementType().getPersistenceType() == Type.PersistenceType.BASIC) { return false; } return true; } return attr.getPersistentAttributeType() == Attribute.PersistentAttributeType.MANY_TO_ONE || attr.getPersistentAttributeType() == Attribute.PersistentAttributeType.ONE_TO_ONE; }
private <Y> AbstractJoin<X, Y> constructJoin(SingularAttribute<? super X, Y> attribute, String alias, JoinType jt) { if (Type.PersistenceType.BASIC.equals(attribute.getType().getPersistenceType())) { throw new IllegalArgumentException("Cannot join to attribute of basic type: " + attribute.getJavaType().getName()); } checkJoin(attribute, jt); final Class<Y> attributeType = attribute.getBindableJavaType(); SingularAttributeJoin<X, Y> join = new SingularAttributeJoin<X, Y>(criteriaBuilder, attributeType, this, attribute, jt); join.setAlias(alias); return join; }
@Override public boolean isCompositeNode(Attribute<?, ?> attr) { if (attr.isCollection()) { PluralAttribute<?, ?, ?> pluralAttribute = (PluralAttribute<?, ?, ?>) attr; if (pluralAttribute.getElementType().getPersistenceType() == Type.PersistenceType.BASIC) { return false; } return true; } return attr.getPersistentAttributeType() == Attribute.PersistentAttributeType.MANY_TO_ONE || attr.getPersistentAttributeType() == Attribute.PersistentAttributeType.ONE_TO_ONE; }
private <Y> AbstractJoin<X, Y> constructJoin(SingularAttribute<? super X, Y> attribute, String alias, JoinType jt) { if (Type.PersistenceType.BASIC.equals(attribute.getType().getPersistenceType())) { throw new IllegalArgumentException("Cannot join to attribute of basic type: " + attribute.getJavaType().getName()); } checkJoin(attribute, jt); final Class<Y> attributeType = attribute.getBindableJavaType(); SingularAttributeJoin<X, Y> join = new SingularAttributeJoin<X, Y>(criteriaBuilder, attributeType, this, attribute, jt); join.setAlias(alias); return join; }
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()); }
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()); }