亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fromelementtype.java

?? hibernate-3.1.3-all-src.zip 面向對象的訪問數據庫工具
?? JAVA
字號:
// $Id: FromElementType.java 9261 2006-02-10 17:29:26Z steveebersole $
package org.hibernate.hql.ast.tree;

import java.util.Map;

import org.hibernate.MappingException;
import org.hibernate.QueryException;
import org.hibernate.engine.JoinSequence;
import org.hibernate.hql.CollectionProperties;
import org.hibernate.hql.CollectionSubqueryFactory;
import org.hibernate.hql.NameGenerator;
import org.hibernate.hql.antlr.HqlSqlTokenTypes;
import org.hibernate.persister.collection.CollectionPropertyMapping;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.PropertyMapping;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.type.EntityType;
import org.hibernate.type.Type;
import org.hibernate.type.TypeFactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Delegate that handles the type and join sequence information for a FromElement.
 *
 * @author josh Feb 12, 2005 10:17:34 AM
 */
class FromElementType {
	private static final Log log = LogFactory.getLog( FromElementType.class );

	private FromElement fromElement;
	private EntityType entityType;
	private EntityPersister persister;
	private QueryableCollection queryableCollection;
	private CollectionPropertyMapping collectionPropertyMapping;
	private JoinSequence joinSequence;

	private String collectionSuffix;

	public FromElementType(FromElement fromElement, EntityPersister persister, EntityType entityType) {
		this.fromElement = fromElement;
		this.persister = persister;
		this.entityType = entityType;
		if ( persister != null ) {
			fromElement.setText( ( ( Queryable ) persister ).getTableName() + " " + getTableAlias() );
		}
	}

	private String getTableAlias() {
		return fromElement.getTableAlias();
	}

	private String getCollectionTableAlias() {
		return fromElement.getCollectionTableAlias();
	}

	public String getCollectionSuffix() {
		return collectionSuffix;
	}

	public void setCollectionSuffix(String suffix) {
		collectionSuffix = suffix;
	}

	public EntityPersister getEntityPersister() {
		return persister;
	}

	public Type getDataType() {
		if ( persister == null ) {
			if ( queryableCollection == null ) {
				return null;
			}
			return queryableCollection.getType();
		}
		else {
			return entityType;
		}
	}

	public Type getSelectType() {
		if (entityType==null) return null;
		boolean shallow = fromElement.getFromClause().getWalker().isShallowQuery();
		return TypeFactory.manyToOne( entityType.getAssociatedEntityName(), shallow );
	}

	/**
	 * Returns the Hibernate queryable implementation for the HQL class.
	 *
	 * @return the Hibernate queryable implementation for the HQL class.
	 */
	public Queryable getQueryable() {
		return ( persister instanceof Queryable ) ? ( Queryable ) persister : null;
	}

	/**
	 * Render the identifier select, but in a 'scalar' context (i.e. generate the column alias).
	 *
	 * @param i the sequence of the returned type
	 * @return the identifier select with the column alias.
	 */
	String renderScalarIdentifierSelect(int i) {
		checkInitialized();
		String[] cols = getPropertyMapping( EntityPersister.ENTITY_ID ).toColumns( getTableAlias(), EntityPersister.ENTITY_ID );
		StringBuffer buf = new StringBuffer();
		// For property references generate <tablealias>.<columnname> as <projectionalias>
		for ( int j = 0; j < cols.length; j++ ) {
			String column = cols[j];
			if ( j > 0 ) {
				buf.append( ", " );
			}
			buf.append( column ).append( " as " ).append( NameGenerator.scalarName( i, j ) );
		}
		return buf.toString();
	}

	/**
	 * Returns the identifier select SQL fragment.
	 *
	 * @param size The total number of returned types.
	 * @param k    The sequence of the current returned type.
	 * @return the identifier select SQL fragment.
	 */
	String renderIdentifierSelect(int size, int k) {
		checkInitialized();
		// Render the identifier select fragment using the table alias.
		if ( fromElement.getFromClause().isSubQuery() ) {
			// TODO: Replace this with a more elegant solution.
			String[] idColumnNames = ( persister != null ) ?
					( ( Queryable ) persister ).getIdentifierColumnNames() : new String[0];
			StringBuffer buf = new StringBuffer();
			for ( int i = 0; i < idColumnNames.length; i++ ) {
				buf.append( fromElement.getTableAlias() ).append( '.' ).append( idColumnNames[i] );
				if ( i != idColumnNames.length - 1 ) buf.append( ", " );
			}
			return buf.toString();
		}
		else {
			if (persister==null) {
				throw new QueryException( "not an entity" );
			}
			String fragment = ( ( Queryable ) persister ).identifierSelectFragment( getTableAlias(), getSuffix( size, k ) );
			return trimLeadingCommaAndSpaces( fragment );
		}
	}

	private String getSuffix(int size, int sequence) {
		return generateSuffix( size, sequence );
	}

	private static String generateSuffix(int size, int k) {
		String suffix = size == 1 ? "" : Integer.toString( k ) + '_';
		return suffix;
	}

	private void checkInitialized() {
		fromElement.checkInitialized();
	}

	/**
	 * Returns the property select SQL fragment.
	 * @param size The total number of returned types.
	 * @param k    The sequence of the current returned type.
	 * @return the property select SQL fragment.
	 */
	String renderPropertySelect(int size, int k, boolean allProperties) {
		checkInitialized();
		if ( persister == null ) {
			return "";
		}
		else {
			String fragment =  ( ( Queryable ) persister ).propertySelectFragment(
					getTableAlias(),
					getSuffix( size, k ),
					allProperties
				);
			return trimLeadingCommaAndSpaces( fragment );
		}
	}

	String renderCollectionSelectFragment(int size, int k) {
		if ( queryableCollection == null ) {
			return "";
		}
		else {
			if ( collectionSuffix == null ) {
				collectionSuffix = generateSuffix( size, k );
			}
			String fragment = queryableCollection.selectFragment( getCollectionTableAlias(), collectionSuffix );
			return trimLeadingCommaAndSpaces( fragment );
		}
	}

	public String renderValueCollectionSelectFragment(int size, int k) {
		if ( queryableCollection == null ) {
			return "";
		}
		else {
			if ( collectionSuffix == null ) {
				collectionSuffix = generateSuffix( size, k );
			}
			String fragment =  queryableCollection.selectFragment( getTableAlias(), collectionSuffix );
			return trimLeadingCommaAndSpaces( fragment );
		}
	}

	/**
	 * This accounts for a quirk in Queryable, where it sometimes generates ',  ' in front of the
	 * SQL fragment.  :-P
	 *
	 * @param fragment An SQL fragment.
	 * @return The fragment, without the leading comma and spaces.
	 */
	private static String trimLeadingCommaAndSpaces(String fragment) {
		if ( fragment.length() > 0 && fragment.charAt( 0 ) == ',' ) {
			fragment = fragment.substring( 1 );
		}
		fragment = fragment.trim();
		return fragment.trim();
	}

	public void setJoinSequence(JoinSequence joinSequence) {
		this.joinSequence = joinSequence;
	}

	public JoinSequence getJoinSequence() {
		if ( joinSequence != null ) {
			return joinSequence;
		}

		// Class names in the FROM clause result in a JoinSequence (the old FromParser does this).
		if ( persister instanceof Joinable ) {
			Joinable joinable = ( Joinable ) persister;
			return fromElement.getSessionFactoryHelper().createJoinSequence().setRoot( joinable, getTableAlias() );
		}
		else {
			return null;	// TODO: Should this really return null?  If not, figure out something better to do here.
		}
	}

	public void setQueryableCollection(QueryableCollection queryableCollection) {
		if ( this.queryableCollection != null ) {
			throw new IllegalStateException( "QueryableCollection is already defined for " + this + "!" );
		}
		this.queryableCollection = queryableCollection;
		if ( !queryableCollection.isOneToMany() ) {
			// For many-to-many joins, use the tablename from the queryable collection for the default text.
			fromElement.setText( queryableCollection.getTableName() + " " + getTableAlias() );
		}
	}

	public QueryableCollection getQueryableCollection() {
		return queryableCollection;
	}

	/**
	 * Returns the type of a property, given it's name (the last part) and the full path.
	 *
	 * @param propertyName The last part of the full path to the property.
	 * @return The type.
	 * @0param propertyPath The full property path.
	 */
	public Type getPropertyType(String propertyName, String propertyPath) {
		checkInitialized();
		Type type = null;
		// If this is an entity and the property is the identifier property, then use getIdentifierType().
		//      Note that the propertyName.equals( propertyPath ) checks whether we have a component
		//      key reference, where the component class property name is the same as the
		//      entity id property name; if the two are not equal, this is the case and
		//      we'd need to "fall through" to using the property mapping.
		if ( persister != null && propertyName.equals( propertyPath ) && propertyName.equals( persister.getIdentifierPropertyName() ) ) {
			type = persister.getIdentifierType();
		}
		else {	// Otherwise, use the property mapping.
			PropertyMapping mapping = getPropertyMapping( propertyName );
			type = mapping.toType( propertyPath );
		}
		if ( type == null ) {
			throw new MappingException( "Property " + propertyName + " does not exist in " +
					( ( queryableCollection == null ) ? "class" : "collection" ) + " "
					+ ( ( queryableCollection == null ) ? fromElement.getClassName() : queryableCollection.getRole() ) );
		}
		return type;
	}

	String[] toColumns(String tableAlias, String path, boolean inSelect) {
		return toColumns( tableAlias, path, inSelect, false );
	}

	String[] toColumns(String tableAlias, String path, boolean inSelect, boolean forceAlias) {
		checkInitialized();
		PropertyMapping propertyMapping = getPropertyMapping( path );
		// If this from element is a collection and the path is a collection property (maxIndex, etc.) then
		// generate a sub-query.
		if ( !inSelect && queryableCollection != null && CollectionProperties.isCollectionProperty( path ) ) {
			Map enabledFilters = fromElement.getWalker().getEnabledFilters();
			String subquery = CollectionSubqueryFactory.createCollectionSubquery(
					joinSequence,
			        enabledFilters,
					propertyMapping.toColumns( tableAlias, path )
			);
			if ( log.isDebugEnabled() ) {
				log.debug( "toColumns(" + tableAlias + "," + path + ") : subquery = " + subquery );
			}
			return new String[]{"(" + subquery + ")"};
		}
		else {
			// decide if we need to use table-alias qualification
			boolean useTableAlias = fromElement.getWalker().getStatementType() == HqlSqlTokenTypes.SELECT
					|| fromElement.getWalker().getCurrentClauseType() == HqlSqlTokenTypes.SELECT
			        || fromElement.getWalker().isSubQuery()
					|| forceAlias;
			if ( useTableAlias ) {
				return propertyMapping.toColumns( tableAlias, path );
			}
			else {
				return propertyMapping.toColumns( path );
			}
		}
	}

	PropertyMapping getPropertyMapping(String propertyName) {
		checkInitialized();
		if ( queryableCollection == null ) {		// Not a collection?
			return ( PropertyMapping ) persister;	// Return the entity property mapping.
		}
		// If the property is a special collection property name, return a CollectionPropertyMapping.
		if ( CollectionProperties.isCollectionProperty( propertyName ) ) {
			if ( collectionPropertyMapping == null ) {
				collectionPropertyMapping = new CollectionPropertyMapping( queryableCollection );
			}
			return collectionPropertyMapping;
		}
		if ( queryableCollection.getElementType().isComponentType() ) {	// Collection of components.
			if ( propertyName.equals( EntityPersister.ENTITY_ID ) ) {
				return ( PropertyMapping ) queryableCollection.getOwnerEntityPersister();
			}
		}
		return queryableCollection;
	}

	public boolean isCollectionOfValuesOrComponents() {
		if ( persister == null ) {
			if ( queryableCollection == null ) {
				return false;
			}
			else {
				return !queryableCollection.getElementType().isEntityType();
			}
		}
		else {
			return false;
		}
	}

	public boolean isEntity() {
		return persister != null;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩另类一区| 91在线视频免费91| 日韩一区二区电影| 日韩在线一二三区| 欧美撒尿777hd撒尿| 亚洲一区日韩精品中文字幕| 欧美影院午夜播放| 一区二区三区美女视频| 欧美亚洲国产怡红院影院| 一区二区久久久| 9191国产精品| 久久成人久久鬼色| 欧美激情在线观看视频免费| 成人综合婷婷国产精品久久蜜臀| 国产精品久久看| 在线免费观看日本欧美| 日产欧产美韩系列久久99| 精品嫩草影院久久| 成人午夜又粗又硬又大| 亚洲欧美偷拍三级| 欧美日韩国产片| 狠狠色丁香婷婷综合久久片| 国产视频一区二区三区在线观看| 成人成人成人在线视频| 亚洲制服欧美中文字幕中文字幕| 欧美一区二区三区在| 国产成人在线看| 一区二区三区 在线观看视频| 91精品国产综合久久精品app| 精品亚洲aⅴ乱码一区二区三区| 中文字幕欧美激情一区| 欧美色综合网站| 国产真实乱偷精品视频免| 亚洲人成影院在线观看| 在线不卡免费欧美| 国产精品一二三区在线| 亚洲一二三区在线观看| 久久奇米777| 欧美日韩在线一区二区| 国产精品自在在线| 亚洲第一主播视频| 日本一区二区成人在线| 555www色欧美视频| bt7086福利一区国产| 免费一区二区视频| 亚洲人xxxx| 久久久久久久国产精品影院| 欧美日韩激情一区二区| 国产91对白在线观看九色| 日韩和欧美的一区| 18成人在线观看| 欧美mv和日韩mv的网站| 欧美日韩一区小说| 成人精品电影在线观看| 日本一不卡视频| 蜜桃久久av一区| 亚洲视频免费在线| 久久久亚洲综合| 欧美欧美午夜aⅴ在线观看| www.欧美色图| 国产成人av电影免费在线观看| 日日摸夜夜添夜夜添亚洲女人| 自拍偷拍国产精品| 久久综合九色综合久久久精品综合| 欧美三级电影在线看| jlzzjlzz亚洲日本少妇| 国产一区二区三区四区五区美女| 午夜精品久久久久久久99水蜜桃| 一区免费观看视频| 国产午夜精品一区二区三区嫩草 | 日韩电影一二三区| ...av二区三区久久精品| 国产亚洲污的网站| 日韩一区二区在线播放| 欧美精选一区二区| 欧美日韩在线一区二区| 欧美视频自拍偷拍| 在线免费观看成人短视频| av在线不卡网| av激情亚洲男人天堂| 成人免费毛片高清视频| 懂色中文一区二区在线播放| 国产一区二区三区| 国产精品一线二线三线| 国产米奇在线777精品观看| 精品一区二区三区av| 美女mm1313爽爽久久久蜜臀| 奇米一区二区三区av| 日韩在线一区二区三区| 美国欧美日韩国产在线播放| 秋霞av亚洲一区二区三| 麻豆成人免费电影| 九九视频精品免费| 国产一区二区伦理片| 国产一区视频导航| 国产成人在线视频播放| 成人午夜伦理影院| 97精品久久久午夜一区二区三区| 91麻豆自制传媒国产之光| 91久久精品国产91性色tv| 欧美自拍偷拍午夜视频| 欧美久久一二区| 日韩精品影音先锋| 国产日韩精品一区二区三区| 中文字幕在线不卡| 亚洲伊人伊色伊影伊综合网| 日日欢夜夜爽一区| 精品一区二区三区在线视频| 福利视频网站一区二区三区| 99久久99精品久久久久久| 久久亚区不卡日本| 亚洲人妖av一区二区| 亚洲成人手机在线| 精品伊人久久久久7777人| 国产福利一区二区| 色丁香久综合在线久综合在线观看| 欧美探花视频资源| 精品免费国产二区三区| 国产精品毛片a∨一区二区三区| 亚洲欧美乱综合| 免费看欧美女人艹b| 成人免费视频app| 欧美日韩一区 二区 三区 久久精品| 欧美成人高清电影在线| 日本一区二区久久| 日韩av一二三| gogogo免费视频观看亚洲一| 欧美区在线观看| 欧美国产精品一区二区| 天天综合天天综合色| 粉嫩高潮美女一区二区三区| 欧美日本在线看| 欧美激情一区二区三区四区| 五月激情六月综合| 成人理论电影网| 欧美一区二区视频在线观看2020 | 久久久噜噜噜久噜久久综合| 亚洲免费大片在线观看| 国产美女一区二区三区| 欧美性猛交一区二区三区精品| 久久一区二区三区国产精品| 亚洲一本大道在线| 成人毛片在线观看| 欧美成人三级在线| 亚洲一区二区三区四区的| 国v精品久久久网| 日韩一区二区在线播放| 一区二区三区日本| aaa亚洲精品一二三区| 精品国产免费视频| 午夜伊人狠狠久久| 91在线精品一区二区| 久久精品人人爽人人爽| 五月天国产精品| 色欧美日韩亚洲| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 麻豆成人免费电影| 欧美伊人久久大香线蕉综合69 | 精品sm捆绑视频| 日韩av电影免费观看高清完整版| 在线视频综合导航| 亚洲免费观看高清完整| 北岛玲一区二区三区四区 | 久久久久88色偷偷免费| 麻豆精品一区二区三区| 欧美精品tushy高清| 一区二区三区精品视频在线| 99热精品国产| 国产精品免费视频观看| 精品一区二区在线播放| 日韩欧美亚洲国产另类 | 日韩欧美aaaaaa| 日韩电影免费在线| 91精品久久久久久蜜臀| 视频精品一区二区| 91精品国产高清一区二区三区| 天天av天天翘天天综合网色鬼国产| 91视频免费看| 亚洲视频你懂的| 欧洲中文字幕精品| 亚洲午夜一区二区| 欧美日本在线一区| 日韩黄色片在线观看| 91精品视频网| 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美一区二区日韩| 国内外成人在线视频| 久久久久国色av免费看影院| 国产不卡在线一区| 中文字幕一区二区三区四区| 一本色道久久综合亚洲aⅴ蜜桃| 一区二区三区在线影院| 欧美日韩综合在线| 美女mm1313爽爽久久久蜜臀| 久久―日本道色综合久久| 成人黄色大片在线观看| 亚洲精选免费视频| 56国语精品自产拍在线观看| 韩国在线一区二区| 1000部国产精品成人观看|