本文整理汇总了Java中org.hibernate.type.AssociationType类的典型用法代码示例。如果您正苦于以下问题:Java AssociationType类的具体用法?Java AssociationType怎么用?Java AssociationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssociationType类属于org.hibernate.type包,在下文中一共展示了AssociationType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAssociationToJoinTreeIfNecessary
import org.hibernate.type.AssociationType; //导入依赖的package包/类
/**
* Add on association (one-to-one, many-to-one, or a collection) to a list
* of associations to be fetched by outerjoin (if necessary)
*/
private void addAssociationToJoinTreeIfNecessary(
final AssociationType type,
final String[] aliasedLhsColumns,
final String alias,
final PropertyPath path,
int currentDepth,
final JoinType joinType) throws MappingException {
if ( joinType != JoinType.NONE ) {
addAssociationToJoinTree(
type,
aliasedLhsColumns,
alias,
path,
currentDepth,
joinType
);
}
}
示例2: getJoinType
import org.hibernate.type.AssociationType; //导入依赖的package包/类
/**
* Determine the appropriate type of join (if any) to use to fetch the
* given association.
*
* @param persister The owner of the association.
* @param path The path to the association
* @param propertyNumber The property number representing the association.
* @param associationType The association type.
* @param metadataFetchMode The metadata-defined fetch mode.
* @param metadataCascadeStyle The metadata-defined cascade style.
* @param lhsTable The owner table
* @param lhsColumns The owner join columns
* @param nullable Is the association nullable.
* @param currentDepth Current join depth
* @return type of join to use ({@link org.hibernate.sql.JoinType#INNER_JOIN},
* {@link org.hibernate.sql.JoinType#LEFT_OUTER_JOIN}, or -1 to indicate no joining.
* @throws MappingException ??
*/
protected JoinType getJoinType(
OuterJoinLoadable persister,
final PropertyPath path,
int propertyNumber,
AssociationType associationType,
FetchMode metadataFetchMode,
CascadeStyle metadataCascadeStyle,
String lhsTable,
String[] lhsColumns,
final boolean nullable,
final int currentDepth) throws MappingException {
return getJoinType(
associationType,
metadataFetchMode,
path,
lhsTable,
lhsColumns,
nullable,
currentDepth,
metadataCascadeStyle
);
}
示例3: isJoinedFetchEnabledInMapping
import org.hibernate.type.AssociationType; //导入依赖的package包/类
/**
* Does the mapping, and Hibernate default semantics, specify that
* this association should be fetched by outer joining
*/
protected boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type)
throws MappingException {
if ( !type.isEntityType() && !type.isCollectionType() ) {
return false;
}
else {
if (config==FetchMode.JOIN) return true;
if (config==FetchMode.SELECT) return false;
if ( type.isEntityType() ) {
//TODO: look at the owning property and check that it
// isn't lazy (by instrumentation)
EntityType entityType =(EntityType) type;
EntityPersister persister = getFactory().getEntityPersister( entityType.getAssociatedEntityName() );
return !persister.hasProxy();
}
else {
return false;
}
}
}
示例4: isJoinable
import org.hibernate.type.AssociationType; //导入依赖的package包/类
/**
* Should we join this association?
*/
protected boolean isJoinable(
final JoinType joinType,
final Set visitedAssociationKeys,
final String lhsTable,
final String[] lhsColumnNames,
final AssociationType type,
final int depth) {
if ( joinType == JoinType.NONE ) {
return false;
}
if ( joinType == JoinType.INNER_JOIN ) {
return true;
}
Integer maxFetchDepth = getFactory().getSettings().getMaximumFetchDepth();
final boolean tooDeep = maxFetchDepth!=null && depth >= maxFetchDepth;
return !tooDeep && !isDuplicateAssociation(lhsTable, lhsColumnNames, type);
}
示例5: getJoinType
import org.hibernate.type.AssociationType; //导入依赖的package包/类
@Override
protected JoinType getJoinType(
AssociationType associationType,
FetchMode config,
PropertyPath path,
String lhsTable,
String[] lhsColumns,
boolean nullable,
int currentDepth,
CascadeStyle cascadeStyle) throws MappingException {
return getJoinType(
null,
path,
-1,
associationType,
config,
cascadeStyle,
lhsTable,
lhsColumns,
nullable,
currentDepth
);
}
示例6: createRoot
import org.hibernate.type.AssociationType; //导入依赖的package包/类
public static OuterJoinableAssociation createRoot(
AssociationType joinableType,
String alias,
SessionFactoryImplementor factory) {
return new OuterJoinableAssociation(
new PropertyPath(),
joinableType,
null,
null,
alias,
JoinType.LEFT_OUTER_JOIN,
null,
false,
factory,
Collections.EMPTY_MAP
);
}
示例7: OuterJoinableAssociation
import org.hibernate.type.AssociationType; //导入依赖的package包/类
public OuterJoinableAssociation(
PropertyPath propertyPath,
AssociationType joinableType,
String lhsAlias,
String[] lhsColumns,
String rhsAlias,
JoinType joinType,
String withClause,
boolean hasRestriction,
SessionFactoryImplementor factory,
Map enabledFilters) throws MappingException {
this.propertyPath = propertyPath;
this.joinableType = joinableType;
this.lhsAlias = lhsAlias;
this.lhsColumns = lhsColumns;
this.rhsAlias = rhsAlias;
this.joinType = joinType;
this.joinable = joinableType.getAssociatedJoinable(factory);
this.rhsColumns = JoinHelper.getRHSColumnNames(joinableType, factory);
this.on = joinableType.getOnCondition(rhsAlias, factory, enabledFilters)
+ ( withClause == null || withClause.trim().length() == 0 ? "" : " and ( " + withClause + " )" );
this.hasRestriction = hasRestriction;
this.enabledFilters = enabledFilters; // needed later for many-to-many/filter application
}
示例8: resolveAdditionalJoinCondition
import org.hibernate.type.AssociationType; //导入依赖的package包/类
private String resolveAdditionalJoinCondition(String rhsTableAlias, String withClause, Joinable joinable, AssociationType associationType) {
// turns out that the call to AssociationType#getOnCondition in the initial code really just translates to
// calls to the Joinable.filterFragment() method where the Joinable is either the entity or
// collection persister
final String filter = associationType!=null?
associationType.getOnCondition( rhsTableAlias, factory, buildingParameters.getQueryInfluencers().getEnabledFilters() ):
joinable.filterFragment(
rhsTableAlias,
buildingParameters.getQueryInfluencers().getEnabledFilters()
);
if ( StringHelper.isEmpty( withClause ) && StringHelper.isEmpty( filter ) ) {
return "";
}
else if ( StringHelper.isNotEmpty( withClause ) && StringHelper.isNotEmpty( filter ) ) {
return filter + " and " + withClause;
}
else {
// only one is non-empty...
return StringHelper.isNotEmpty( filter ) ? filter : withClause;
}
}
示例9: getSubclassPropertyTableNumber
import org.hibernate.type.AssociationType; //导入依赖的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);
}
示例10: selectFragment
import org.hibernate.type.AssociationType; //导入依赖的package包/类
public String selectFragment(
Joinable rhs,
String rhsAlias,
String lhsAlias,
String entitySuffix,
String collectionSuffix,
boolean includeCollectionColumns) {
// we need to determine the best way to know that two joinables
// represent a single many-to-many...
if ( rhs != null && isManyToMany() && !rhs.isCollection() ) {
AssociationType elementType = ( ( AssociationType ) getElementType() );
if ( rhs.equals( elementType.getAssociatedJoinable( getFactory() ) ) ) {
return manyToManySelectFragment( rhs, rhsAlias, lhsAlias, collectionSuffix );
}
}
return includeCollectionColumns ? selectFragment( lhsAlias, collectionSuffix ) : "";
}
示例11: determineFetchTiming
import org.hibernate.type.AssociationType; //导入依赖的package包/类
public static FetchTiming determineFetchTiming(
FetchStyle style,
AssociationType type,
SessionFactoryImplementor sessionFactory) {
switch ( style ) {
case JOIN: {
return FetchTiming.IMMEDIATE;
}
case BATCH:
case SUBSELECT: {
return FetchTiming.DELAYED;
}
default: {
// SELECT case, can be either
return isSubsequentSelectDelayed( type, sessionFactory )
? FetchTiming.DELAYED
: FetchTiming.IMMEDIATE;
}
}
}
示例12: decode
import org.hibernate.type.AssociationType; //导入依赖的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;
}
}
示例13: getAliasedLHSColumnNames
import org.hibernate.type.AssociationType; //导入依赖的package包/类
/**
* Get the qualified (prefixed by alias) names of the columns of the owning entity which are to be used in the join
*
* @param associationType The association type for the association that represents the join
* @param columnQualifier The left-hand side table alias
* @param propertyIndex The index of the property that represents the association/join
* @param begin The index for any nested (composites) attributes
* @param lhsPersister The persister for the left-hand side of the association/join
* @param mapping The mapping (typically the SessionFactory).
*
* @return The qualified column names.
*/
public static String[] getAliasedLHSColumnNames(
AssociationType associationType,
String columnQualifier,
int propertyIndex,
int begin,
OuterJoinLoadable lhsPersister,
Mapping mapping) {
if ( associationType.useLHSPrimaryKey() ) {
return StringHelper.qualify( columnQualifier, lhsPersister.getIdentifierColumnNames() );
}
else {
final String propertyName = associationType.getLHSPropertyName();
if ( propertyName == null ) {
return ArrayHelper.slice(
toColumns( lhsPersister, columnQualifier, propertyIndex ),
begin,
associationType.getColumnSpan( mapping )
);
}
else {
//bad cast
return ( (PropertyMapping) lhsPersister ).toColumns( columnQualifier, propertyName );
}
}
}
示例14: addAssociationToJoinTreeIfNecessary
import org.hibernate.type.AssociationType; //导入依赖的package包/类
/**
* Add on association (one-to-one, many-to-one, or a collection) to a list
* of associations to be fetched by outerjoin (if necessary)
*/
private void addAssociationToJoinTreeIfNecessary(
final AssociationType type,
final String[] aliasedLhsColumns,
final String alias,
final String path,
int currentDepth,
final int joinType)
throws MappingException {
if (joinType>=0) {
addAssociationToJoinTree(
type,
aliasedLhsColumns,
alias,
path,
currentDepth,
joinType
);
}
}
示例15: getJoinType
import org.hibernate.type.AssociationType; //导入依赖的package包/类
/**
* Get the join type (inner, outer, etc) or -1 if the
* association should not be joined. Override on
* subclasses.
*/
protected int getJoinType(
AssociationType type,
FetchMode config,
String path,
String lhsTable,
String[] lhsColumns,
boolean nullable,
int currentDepth,
CascadeStyle cascadeStyle)
throws MappingException {
if ( !isJoinedFetchEnabled(type, config, cascadeStyle) ) return -1;
if ( isTooDeep(currentDepth) || ( type.isCollectionType() && isTooManyCollections() ) ) return -1;
final boolean dupe = isDuplicateAssociation(lhsTable, lhsColumns, type);
if (dupe) return -1;
return getJoinType(nullable, currentDepth);
}