本文整理汇总了Java中org.hibernate.type.Type.isAssociationType方法的典型用法代码示例。如果您正苦于以下问题:Java Type.isAssociationType方法的具体用法?Java Type.isAssociationType怎么用?Java Type.isAssociationType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.type.Type
的用法示例。
在下文中一共展示了Type.isAssociationType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finishingCollectionElements
import org.hibernate.type.Type; //导入方法依赖的package包/类
@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()
);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:AbstractLoadPlanBuildingAssociationVisitationStrategy.java
示例2: startingAttribute
import org.hibernate.type.Type; //导入方法依赖的package包/类
@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 );
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AbstractLoadPlanBuildingAssociationVisitationStrategy.java
示例3: getSubclassPropertyTableNumber
import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
* Warning:
* When there are duplicated property names in the subclasses
* of the class, this method may return the wrong table
* number for the duplicated subclass property (note that
* SingleTableEntityPersister defines an overloaded form
* which takes the entity name.
*/
public int getSubclassPropertyTableNumber(String propertyPath) {
String rootPropertyName = StringHelper.root(propertyPath);
Type type = propertyMapping.toType(rootPropertyName);
if ( type.isAssociationType() ) {
AssociationType assocType = ( AssociationType ) type;
if ( assocType.useLHSPrimaryKey() ) {
// performance op to avoid the array search
return 0;
}
else if ( type.isCollectionType() ) {
// properly handle property-ref-based associations
rootPropertyName = assocType.getLHSPropertyName();
}
}
//Enable for HHH-440, which we don't like:
/*if ( type.isComponentType() && !propertyName.equals(rootPropertyName) ) {
String unrooted = StringHelper.unroot(propertyName);
int idx = ArrayHelper.indexOf( getSubclassColumnClosure(), unrooted );
if ( idx != -1 ) {
return getSubclassColumnTableNumberClosure()[idx];
}
}*/
int index = ArrayHelper.indexOf( getSubclassPropertyNameClosure(), rootPropertyName); //TODO: optimize this better!
return index==-1 ? 0 : getSubclassPropertyTableNumber(index);
}
示例4: decode
import org.hibernate.type.Type; //导入方法依赖的package包/类
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;
}
}
示例5: determineKeySelectExpressions
import org.hibernate.type.Type; //导入方法依赖的package包/类
private void determineKeySelectExpressions(QueryableCollection collectionPersister, List selections) {
AliasGenerator aliasGenerator = new LocalAliasGenerator( 0 );
appendSelectExpressions( collectionPersister.getIndexColumnNames(), selections, aliasGenerator );
Type keyType = collectionPersister.getIndexType();
if ( keyType.isAssociationType() ) {
EntityType entityType = (EntityType) keyType;
Queryable keyEntityPersister = (Queryable) sfi().getEntityPersister(
entityType.getAssociatedEntityName( sfi() )
);
SelectFragment fragment = keyEntityPersister.propertySelectFragmentFragment(
collectionTableAlias(),
null,
false
);
appendSelectExpressions( fragment, selections, aliasGenerator );
}
}
示例6: determineValueSelectExpressions
import org.hibernate.type.Type; //导入方法依赖的package包/类
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 );
}
}
示例7: isPropertyIncluded
import org.hibernate.type.Type; //导入方法依赖的package包/类
@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 );
}
示例8: getJoinedAssociationTypeOrNull
import org.hibernate.type.Type; //导入方法依赖的package包/类
private AssociationType getJoinedAssociationTypeOrNull(Join join) {
if ( !JoinDefinedByMetadata.class.isInstance( join ) ) {
return null;
}
final Type joinedType = ( (JoinDefinedByMetadata) join ).getJoinedPropertyType();
return joinedType.isAssociationType()
? (AssociationType) joinedType
: null;
}
示例9: startingCollectionElements
import org.hibernate.type.Type; //导入方法依赖的package包/类
@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()
);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:AbstractLoadPlanBuildingAssociationVisitationStrategy.java
示例10: resolveAsNakedPropertyRef
import org.hibernate.type.Type; //导入方法依赖的package包/类
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 = StringHelper.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;
}
示例11: visitCollectionIndex
import org.hibernate.type.Type; //导入方法依赖的package包/类
private void visitCollectionIndex(CollectionDefinition collectionDefinition) {
final CollectionIndexDefinition collectionIndexDefinition = collectionDefinition.getIndexDefinition();
if ( collectionIndexDefinition == null ) {
return;
}
strategy.startingCollectionIndex( collectionIndexDefinition );
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();
}
strategy.finishingCollectionIndex( collectionIndexDefinition );
}
示例12: buildStandardProperty
import org.hibernate.type.Type; //导入方法依赖的package包/类
@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()
);
}
示例13: walkCollectionTree
import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
* For a collection role, return a list of associations to be fetched by outerjoin
*/
private void walkCollectionTree(
final QueryableCollection persister,
final String alias,
final PropertyPath path,
final int currentDepth) throws MappingException {
if ( persister.isOneToMany() ) {
walkEntityTree(
(OuterJoinLoadable) persister.getElementPersister(),
alias,
path,
currentDepth
);
}
else {
Type type = persister.getElementType();
if ( type.isAssociationType() ) {
// a many-to-many;
// decrement currentDepth here to allow join across the association table
// without exceeding MAX_FETCH_DEPTH (i.e. the "currentDepth - 1" bit)
AssociationType associationType = (AssociationType) type;
String[] aliasedLhsColumns = persister.getElementColumnNames(alias);
String[] lhsColumns = persister.getElementColumnNames();
// if the current depth is 0, the root thing being loaded is the
// many-to-many collection itself. Here, it is alright to use
// an inner join...
boolean useInnerJoin = currentDepth == 0;
final JoinType joinType = getJoinType(
associationType,
persister.getFetchMode(),
path,
persister.getTableName(),
lhsColumns,
!useInnerJoin,
currentDepth - 1,
null //operations which cascade as far as the collection also cascade to collection elements
);
addAssociationToJoinTreeIfNecessary(
associationType,
aliasedLhsColumns,
alias,
path,
currentDepth - 1,
joinType
);
}
else if ( type.isComponentType() ) {
walkCompositeElementTree(
(CompositeType) type,
persister.getElementColumnNames(),
persister,
alias,
path,
currentDepth
);
}
}
}
示例14: walkEntityTree
import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
* Walk the association tree for an entity, adding associations which should
* be join fetched to the {@link #associations} inst var. This form is the
* entry point into the walking for a given entity, starting the recursive
* calls into {@link #walkEntityTree(org.hibernate.persister.entity.OuterJoinLoadable, String, PropertyPath ,int)}.
*
* @param persister The persister representing the entity to be walked.
* @param alias The (root) alias to use for this entity/persister.
* @param path The property path to the entity being walked
* @param currentDepth The current join depth
* @throws org.hibernate.MappingException ???
*/
private void walkEntityTree(
final OuterJoinLoadable persister,
final String alias,
final PropertyPath path,
final int currentDepth) throws MappingException {
int n = persister.countSubclassProperties();
for ( int i = 0; i < n; i++ ) {
Type type = persister.getSubclassPropertyType(i);
if ( type.isAssociationType() ) {
walkEntityAssociationTree(
( AssociationType ) type,
persister,
i,
alias,
path,
persister.isSubclassPropertyNullable(i),
currentDepth
);
}
else if ( type.isComponentType() ) {
walkComponentTree(
( CompositeType ) type,
i,
0,
persister,
alias,
path.append( persister.getSubclassPropertyName(i) ),
currentDepth
);
}
}
// if the entity has a composite identifier, see if we need to handle
// its sub-properties separately
final Type idType = persister.getIdentifierType();
if ( idType.isComponentType() ) {
final CompositeType cidType = (CompositeType) idType;
if ( cidType.isEmbedded() ) {
// we have an embedded composite identifier. Most likely we need to process the composite
// properties separately, although there is an edge case where the identifier is really
// a simple identifier (single value) wrapped in a JPA @IdClass or even in the case of a
// a simple identifier (single value) wrapped in a Hibernate composite type.
//
// We really do not have a built-in method to determine that. However, generally the
// persister would report that there is single, physical identifier property which is
// explicitly at odds with the notion of "embedded composite". So we use that for now
if ( persister.getEntityMetamodel().getIdentifierProperty().isEmbedded() ) {
walkComponentTree(
cidType,
-1,
0,
persister,
alias,
path,
currentDepth
);
}
}
}
}
示例15: getPathInfo
import org.hibernate.type.Type; //导入方法依赖的package包/类
private CriteriaInfoProvider getPathInfo(String path) {
StringTokenizer tokens = new StringTokenizer( path, "." );
String componentPath = "";
// start with the 'rootProvider'
CriteriaInfoProvider provider = nameCriteriaInfoMap.get( rootEntityName );
while ( tokens.hasMoreTokens() ) {
componentPath += tokens.nextToken();
final Type type = provider.getType( componentPath );
if ( type.isAssociationType() ) {
// CollectionTypes are always also AssociationTypes - but there's not always an associated entity...
final AssociationType atype = (AssociationType) type;
final CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null;
final Type elementType = (ctype != null) ? ctype.getElementType( sessionFactory ) : null;
// is the association a collection of components or value-types? (i.e a colloction of valued types?)
if ( ctype != null && elementType.isComponentType() ) {
provider = new ComponentCollectionCriteriaInfoProvider( helper.getCollectionPersister(ctype.getRole()) );
}
else if ( ctype != null && !elementType.isEntityType() ) {
provider = new ScalarCollectionCriteriaInfoProvider( helper, ctype.getRole() );
}
else {
provider = new EntityCriteriaInfoProvider(
(Queryable) sessionFactory.getEntityPersister( atype.getAssociatedEntityName( sessionFactory ) )
);
}
componentPath = "";
}
else if ( type.isComponentType() ) {
if (!tokens.hasMoreTokens()) {
throw new QueryException(
"Criteria objects cannot be created directly on components. Create a criteria on " +
"owning entity and use a dotted property to access component property: " + path
);
}
else {
componentPath += '.';
}
}
else {
throw new QueryException( "not an association: " + componentPath );
}
}
return provider;
}