本文整理了Java中org.hibernate.type.Type.isAssociationType()
方法的一些代码示例,展示了Type.isAssociationType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.isAssociationType()
方法的具体详情如下:
包路径:org.hibernate.type.Type
类名称:Type
方法名:isAssociationType
[英]Return true if the implementation is castable to AssociationType. This does not necessarily imply that the type actually represents an association. Essentially a polymorphic version of (type instanceof AssociationType.class)
[中]如果实现可强制转换为AssociationType,则返回true。这并不一定意味着类型实际上代表一个关联。本质上是(类型instanceof AssociationType.class)的多态版本
代码示例来源:origin: hibernate/hibernate-orm
public boolean isScalar() throws SemanticException {
// Default implementation:
// If this node has a data type, and that data type is not an association, then this is scalar.
Type type = getDataType();
return type != null && !type.isAssociationType(); // Moved here from SelectClause [jsd]
}
代码示例来源:origin: hibernate/hibernate-orm
private AssociationType getJoinedAssociationTypeOrNull(Join join) {
if ( !JoinDefinedByMetadata.class.isInstance( join ) ) {
return null;
}
final Type joinedType = ( (JoinDefinedByMetadata) join ).getJoinedPropertyType();
return joinedType.isAssociationType()
? (AssociationType) joinedType
: null;
}
代码示例来源:origin: hibernate/hibernate-orm
@SuppressWarnings("SimplifiableIfStatement")
private boolean isPropertyIncluded(Object value, String name, Type type) {
if ( excludedProperties.contains( name ) ) {
// was explicitly excluded
return false;
}
if ( type.isAssociationType() ) {
// associations are implicitly excluded
return false;
}
return selector.include( value, name, type );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Returns whether the collection is a map-type and that the map element is defined as a Clob/NClob type.
*
* @return {@code true} if the element is a Clob/NClob type, otherwise {@code false}.
*/
private boolean isLobMapElementType() {
if ( propertyValue instanceof org.hibernate.mapping.Map ) {
final Type type = propertyValue.getElement().getType();
// we're only interested in basic types
if ( !type.isComponentType() && !type.isAssociationType() ) {
return ( type instanceof MaterializedClobType ) || ( type instanceof MaterializedNClobType );
}
}
return false;
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Returns whether the revision type column of the map-key is part of the collection table's primary key.
*
* NOTE: It is safe to call this method, even for non-map collection types as this method will always return
* {@code false} for non-map collection types.
*
* @return {@code true} if the revision type should be part of the primary key, otherwise {@code false}.
*/
private boolean isKeyRevisionTypeInId() {
if ( propertyValue instanceof org.hibernate.mapping.Map ) {
final Type type = propertyValue.getKey().getType();
if ( !type.isComponentType() && !type.isAssociationType() ) {
return ( type instanceof MaterializedClobType ) || ( type instanceof MaterializedNClobType );
}
}
return false;
}
代码示例来源:origin: hibernate/hibernate-orm
private static NonIdentifierAttributeNature decode(Type type) {
if ( type.isAssociationType() ) {
AssociationType associationType = (AssociationType) type;
if ( type.isComponentType() ) {
// an any type is both an association and a composite...
return NonIdentifierAttributeNature.ANY;
}
return type.isCollectionType()
? NonIdentifierAttributeNature.COLLECTION
: NonIdentifierAttributeNature.ENTITY;
}
else {
if ( type.isComponentType() ) {
return NonIdentifierAttributeNature.COMPOSITE;
}
return NonIdentifierAttributeNature.BASIC;
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Object getIdentifier(Object entity, EntityMode entityMode, SharedSessionContractImplementor session) {
final Object id = mappedIdentifierType.instantiate( entityMode );
final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode );
final Type[] subTypes = virtualIdComponent.getSubtypes();
final Type[] copierSubTypes = mappedIdentifierType.getSubtypes();
final int length = subTypes.length;
for ( int i = 0; i < length; i++ ) {
if ( propertyValues[i] == null ) {
throw new HibernateException( "No part of a composite identifier may be null" );
}
//JPA 2 @MapsId + @IdClass points to the pk of the entity
if ( subTypes[i].isAssociationType() && !copierSubTypes[i].isAssociationType() ) {
propertyValues[i] = determineEntityId(
propertyValues[i],
(AssociationType) subTypes[i],
session,
sessionFactory
);
}
}
mappedIdentifierType.setPropertyValues( id, propertyValues, entityMode );
return id;
}
代码示例来源:origin: hibernate/hibernate-orm
private int getSubclassPropertyTableNumber(String propertyName, String entityName) {
// When there are duplicated property names in the subclasses
// then propertyMapping.toType( propertyName ) may return an
// incorrect Type. To ensure correct results, lookup the property type
// using the concrete EntityPersister with the specified entityName
// (since the concrete EntityPersister cannot have duplicated property names).
final EntityPersister concreteEntityPersister;
if ( getEntityName().equals( entityName ) ) {
concreteEntityPersister = this;
}
else {
concreteEntityPersister = getFactory().getMetamodel().entityPersister( entityName );
}
Type type = concreteEntityPersister.getPropertyType( propertyName );
if ( type.isAssociationType() && ( (AssociationType) type ).useLHSPrimaryKey() ) {
return 0;
}
final Integer tabnum = propertyTableNumbersByNameAndSubclass.get( entityName + '.' + propertyName );
return tabnum == null ? 0 : tabnum;
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Check if eager of the association is overriden by anything.
*
* @param session session
* @param entityName entity name
* @param associationName association name
*
* @return null if there is no overriding, true if it is overridden to eager and false if it is overridden to lazy
*/
private static Boolean getOverridingEager(
SharedSessionContractImplementor session,
String entityName,
String associationName,
Type type) {
if ( type.isAssociationType() || type.isCollectionType() ) {
Boolean overridingEager = isEagerFetchProfile( session, entityName + "." + associationName );
if ( LOG.isDebugEnabled() ) {
if ( overridingEager != null ) {
LOG.debugf(
"Overriding eager fetching using active fetch profile. EntityName: %s, associationName: %s, eager fetching: %s",
entityName,
associationName,
overridingEager
);
}
}
return overridingEager;
}
return null;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public void finishingCollectionElements(CollectionElementDefinition elementDefinition) {
final Type elementType = elementDefinition.getType();
if ( elementType.isAnyType() ) {
// nothing to do because the element graph was not pushed in #startingCollectionElement..
}
else if ( elementType.isComponentType() || elementType.isAssociationType()) {
// pop it from the stack
final ExpandingFetchSource popped = popFromStack();
// validation
if ( ! CollectionFetchableElement.class.isInstance( popped ) ) {
throw new WalkingException( "Mismatched FetchSource from stack on pop" );
}
}
log.tracef(
"%s Finished collection element graph : %s",
StringHelper.repeat( "<<", fetchSourceStack.size() ),
elementDefinition.getCollectionDefinition().getCollectionPersister().getRole()
);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public boolean startingAttribute(AttributeDefinition attributeDefinition) {
log.tracef(
"%s Starting attribute %s",
StringHelper.repeat( ">>", fetchSourceStack.size() ),
attributeDefinition
);
final Type attributeType = attributeDefinition.getType();
final boolean isComponentType = attributeType.isComponentType();
final boolean isAssociationType = attributeType.isAssociationType();
final boolean isBasicType = ! ( isComponentType || isAssociationType );
currentPropertyPath = currentPropertyPath.append( attributeDefinition.getName() );
if ( isBasicType ) {
return true;
}
else if ( isAssociationType ) {
// also handles any type attributes...
return handleAssociationAttribute( (AssociationAttributeDefinition) attributeDefinition );
}
else {
return handleCompositeAttribute( attributeDefinition );
}
}
代码示例来源:origin: hibernate/hibernate-orm
componentPath += tokens.nextToken();
final Type type = provider.getType( componentPath );
if ( type.isAssociationType() ) {
代码示例来源:origin: hibernate/hibernate-orm
@Override
public void startingCollectionElements(CollectionElementDefinition elementDefinition) {
final Type elementType = elementDefinition.getType();
log.tracef(
"%s Starting collection element graph : %s",
StringHelper.repeat( ">>", fetchSourceStack.size() ),
elementDefinition.getCollectionDefinition().getCollectionPersister().getRole()
);
final CollectionReference collectionReference = currentCollection();
final CollectionFetchableElement elementGraph = collectionReference.getElementGraph();
if ( elementType.isAssociationType() || elementType.isComponentType() ) {
if ( elementGraph == null ) {
throw new IllegalStateException(
"CollectionReference did not return an expected element graph : " +
elementDefinition.getCollectionDefinition().getCollectionPersister().getRole()
);
}
if ( !elementType.isAnyType() ) {
pushToStack( (ExpandingFetchSource) elementGraph );
}
}
else {
if ( elementGraph != null ) {
throw new IllegalStateException(
"CollectionReference returned an unexpected element graph : " +
elementDefinition.getCollectionDefinition().getCollectionPersister().getRole()
);
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
String rootPropertyName = StringHelper.root( propertyPath );
Type type = propertyMapping.toType( rootPropertyName );
if ( type.isAssociationType() ) {
AssociationType assocType = (AssociationType) type;
if ( assocType.useLHSPrimaryKey() ) {
代码示例来源:origin: hibernate/hibernate-orm
private void determineValueSelectExpressions(QueryableCollection collectionPersister, List selections) {
AliasGenerator aliasGenerator = new LocalAliasGenerator( 1 );
appendSelectExpressions( collectionPersister.getElementColumnNames(), selections, aliasGenerator );
Type valueType = collectionPersister.getElementType();
if ( valueType.isAssociationType() ) {
EntityType valueEntityType = (EntityType) valueType;
Queryable valueEntityPersister = (Queryable) sfi().getEntityPersister(
valueEntityType.getAssociatedEntityName( sfi() )
);
SelectFragment fragment = valueEntityPersister.propertySelectFragmentFragment(
elementTableAlias(),
null,
false
);
appendSelectExpressions( fragment, selections, aliasGenerator );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private DereferenceType resolveAsNakedPropertyRef() {
FromElement fromElement = locateSingleFromElement();
if (fromElement == null) {
return DereferenceType.UNKNOWN;
}
Queryable persister = fromElement.getQueryable();
if (persister == null) {
return DereferenceType.UNKNOWN;
}
Type propertyType = getNakedPropertyType(fromElement);
if (propertyType == null) {
// assume this ident's text does *not* refer to a property on the given persister
return DereferenceType.UNKNOWN;
}
if ((propertyType.isComponentType() || propertyType.isAssociationType() )) {
return DereferenceType.COMPONENT_REF;
}
setFromElement(fromElement);
String property = getText();
String[] columns = getWalker().isSelectStatement()
? persister.toColumns(fromElement.getTableAlias(), property)
: persister.toColumns(property);
String text = String.join(", ", columns);
setText(columns.length == 1 ? text : "(" + text + ")");
setType(SqlTokenTypes.SQL_TOKEN);
// these pieces are needed for usage in select clause
super.setDataType(propertyType);
nakedPropertyRef = true;
return DereferenceType.PROPERTY_REF;
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* @deprecated See mainly {@link #buildEntityBasedAttribute}
*/
@Deprecated
public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) {
final Type type = property.getValue().getType();
// we need to dirty check collections, since they can cause an owner
// version number increment
// we need to dirty check many-to-ones with not-found="ignore" in order
// to update the cache (not the database), since in this case a null
// entity reference can lose information
boolean alwaysDirtyCheck = type.isAssociationType() &&
( (AssociationType) type ).isAlwaysDirtyChecked();
return new StandardProperty(
property.getName(),
type,
lazyAvailable && property.isLazy(),
property.isInsertable(),
property.isUpdateable(),
property.getValueGenerationStrategy(),
property.isOptional(),
alwaysDirtyCheck || property.isUpdateable(),
property.isOptimisticLocked(),
property.getCascadeStyle(),
property.getValue().getFetchMode()
);
}
代码示例来源:origin: hibernate/hibernate-orm
private void visitCollectionIndex(CollectionDefinition collectionDefinition) {
final CollectionIndexDefinition collectionIndexDefinition = collectionDefinition.getIndexDefinition();
if ( collectionIndexDefinition == null ) {
return;
}
strategy.startingCollectionIndex( collectionIndexDefinition );
try {
log.debug( "Visiting index for collection : " + currentPropertyPath.getFullPath() );
currentPropertyPath = currentPropertyPath.append( "<index>" );
try {
final Type collectionIndexType = collectionIndexDefinition.getType();
if ( collectionIndexType.isAnyType() ) {
visitAnyDefinition( collectionIndexDefinition.toAnyMappingDefinition() );
}
else if ( collectionIndexType.isComponentType() ) {
visitCompositeDefinition( collectionIndexDefinition.toCompositeDefinition() );
}
else if ( collectionIndexType.isAssociationType() ) {
visitEntityDefinition( collectionIndexDefinition.toEntityDefinition() );
}
}
finally {
currentPropertyPath = currentPropertyPath.getParent();
}
}
finally {
strategy.finishingCollectionIndex( collectionIndexDefinition );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private CollectionFetchableElement buildElementGraph() {
final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
final Type type = persister.getElementType();
if ( type.isAssociationType() ) {
if ( type.isEntityType() ) {
final EntityPersister elementPersister = persister.getFactory().getEntityPersister(
代码示例来源:origin: hibernate/hibernate-orm
if ( persister.hasIndex() ) {
final Type type = persister.getIndexType();
if ( type.isAssociationType() ) {
if ( type.isEntityType() ) {
final EntityPersister indexPersister = persister.getFactory().getEntityPersister(
内容来源于网络,如有侵权,请联系作者删除!