當前位置: 首頁>>代碼示例>>Java>>正文


Java SessionFactoryImplementor.getImplementors方法代碼示例

本文整理匯總了Java中org.hibernate.engine.spi.SessionFactoryImplementor.getImplementors方法的典型用法代碼示例。如果您正苦於以下問題:Java SessionFactoryImplementor.getImplementors方法的具體用法?Java SessionFactoryImplementor.getImplementors怎麽用?Java SessionFactoryImplementor.getImplementors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.engine.spi.SessionFactoryImplementor的用法示例。


在下文中一共展示了SessionFactoryImplementor.getImplementors方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: concreteQueries

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
/**
 * Handle Hibernate "implicit" polymorphism, by translating the query string into
 * several "concrete" queries against mapped classes.
 */
public static String[] concreteQueries(String query, SessionFactoryImplementor factory) throws MappingException {

	//scan the query string for class names appearing in the from clause and replace
	//with all persistent implementors of the class/interface, returning multiple
	//query strings (make sure we don't pick up a class in the select clause!)

	//TODO: this is one of the ugliest and most fragile pieces of code in Hibernate....

	String[] tokens = StringHelper.split( StringHelper.WHITESPACE + "(),", query, true );
	if ( tokens.length == 0 ) {
		// just especially for the trivial collection filter
		return new String[] { query };
	}
	ArrayList<String> placeholders = new ArrayList<String>();
	ArrayList<String[]> replacements = new ArrayList<String[]>();
	StringBuilder templateQuery = new StringBuilder( 40 );

	int start = getStartingPositionFor( tokens, templateQuery );
	int count = 0;
	String next;
	String last = tokens[start - 1].toLowerCase();

	for ( int i = start; i < tokens.length; i++ ) {

		String token = tokens[i];

		if ( ParserHelper.isWhitespace( token ) ) {
			templateQuery.append( token );
			continue;
		}

		next = nextNonWhite( tokens, i ).toLowerCase();

		boolean process = isJavaIdentifier( token ) &&
				isPossiblyClassName( last, next );

		last = token.toLowerCase();

		if ( process ) {
			String importedClassName = getImportedClass( token, factory );
			if ( importedClassName != null ) {
				String[] implementors = factory.getImplementors( importedClassName );
				token = "$clazz" + count++ + "$";
				if ( implementors != null ) {
					placeholders.add( token );
					replacements.add( implementors );
				}
			}
		}

		templateQuery.append( token );

	}
	String[] results = StringHelper.multiply(
			templateQuery.toString(),
			placeholders.iterator(),
			replacements.iterator()
	);
	if ( results.length == 0 ) {
		LOG.noPersistentClassesFound( query );
	}
	return results;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:68,代碼來源:QuerySplitter.java


注:本文中的org.hibernate.engine.spi.SessionFactoryImplementor.getImplementors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。