本文整理汇总了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;
}