Merge branch 'HHH-5843' of git://github.com/Sanne/hibernate-core into Sanne-HHH-5843
This commit is contained in:
commit
3bf6625ab1
|
@ -55,6 +55,7 @@ public final class HqlParser extends HqlBaseParser {
|
|||
* A logger for this class.
|
||||
*/
|
||||
private static final Logger log = LoggerFactory.getLogger( HqlParser.class );
|
||||
private final boolean trace = log.isTraceEnabled();
|
||||
|
||||
private ParseErrorHandler parseErrorHandler;
|
||||
private ASTPrinter printer = getASTPrinter();
|
||||
|
@ -79,22 +80,25 @@ public final class HqlParser extends HqlBaseParser {
|
|||
|
||||
private int traceDepth = 0;
|
||||
|
||||
|
||||
public void traceIn(String ruleName) {
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
}
|
||||
|
||||
public void traceOut(String ruleName) {
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
}
|
||||
|
||||
public void reportError(RecognitionException e) {
|
||||
parseErrorHandler.reportError( e ); // Use the delegate.
|
||||
|
|
|
@ -110,7 +110,7 @@ import antlr.collections.AST;
|
|||
* Implements methods used by the HQL->SQL tree transform grammar (a.k.a. the second phase).
|
||||
* <ul>
|
||||
* <li>Isolates the Hibernate API-specific code from the ANTLR generated code.</li>
|
||||
* <li>Handles the SQL framgents generated by the persisters in order to create the SELECT and FROM clauses,
|
||||
* <li>Handles the SQL fragments generated by the persisters in order to create the SELECT and FROM clauses,
|
||||
* taking into account the joins and projections that are implied by the mappings (persister/queryable).</li>
|
||||
* <li>Uses SqlASTFactory to create customized AST nodes.</li>
|
||||
* </ul>
|
||||
|
@ -119,6 +119,7 @@ import antlr.collections.AST;
|
|||
*/
|
||||
public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, ParameterBinder.NamedParameterSource {
|
||||
private static final Logger log = LoggerFactory.getLogger( HqlSqlWalker.class );
|
||||
private final boolean trace = log.isTraceEnabled();
|
||||
|
||||
private final QueryTranslatorImpl queryTranslatorImpl;
|
||||
private final HqlParser hqlParser;
|
||||
|
@ -186,6 +187,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
private int traceDepth = 0;
|
||||
|
||||
public void traceIn(String ruleName, AST tree) {
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -193,6 +195,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
|
||||
log.trace( prefix + traceText );
|
||||
}
|
||||
}
|
||||
|
||||
private String buildTraceNodeName(AST tree) {
|
||||
return tree == null
|
||||
|
@ -201,12 +204,14 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
|
||||
public void traceOut(String ruleName, AST tree) {
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void prepareFromClauseInputTree(AST fromClauseInput) {
|
||||
|
@ -583,7 +588,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
if ( fromElements.size() == 1 ) {
|
||||
final FromElement fromElement = ( FromElement ) fromElements.get( 0 );
|
||||
try {
|
||||
log.trace( "attempting to resolve property [" + identText + "] as a non-qualified ref" );
|
||||
if (trace) log.trace( "attempting to resolve property [" + identText + "] as a non-qualified ref" );
|
||||
return fromElement.getPropertyMapping( identText ).toType( identText ) != null;
|
||||
}
|
||||
catch( QueryException e ) {
|
||||
|
|
|
@ -33,7 +33,6 @@ import antlr.RecognitionException;
|
|||
import antlr.collections.AST;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.hql.ast.tree.FunctionNode;
|
||||
import org.hibernate.hql.ast.tree.SqlNode;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.util.StringHelper;
|
||||
import org.hibernate.param.ParameterSpecification;
|
||||
|
@ -41,7 +40,6 @@ import org.hibernate.dialect.function.SQLFunction;
|
|||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.hql.antlr.SqlGeneratorBase;
|
||||
import org.hibernate.hql.antlr.SqlTokenTypes;
|
||||
import org.hibernate.hql.ast.tree.MethodNode;
|
||||
import org.hibernate.hql.ast.tree.FromElement;
|
||||
import org.hibernate.hql.ast.tree.Node;
|
||||
import org.hibernate.hql.ast.tree.ParameterNode;
|
||||
|
@ -60,14 +58,15 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
||||
private static final Logger log = LoggerFactory.getLogger( SqlGenerator.class );
|
||||
private final boolean trace = log.isTraceEnabled();
|
||||
|
||||
public static boolean REGRESSION_STYLE_CROSS_JOINS = false;
|
||||
|
||||
/**
|
||||
* all append invocations on the buf should go through this Output instance variable.
|
||||
* The value of this variable may be temporarily substitued by sql function processing code
|
||||
* The value of this variable may be temporarily substituted by sql function processing code
|
||||
* to catch generated arguments.
|
||||
* This is because sql function templates need arguments as seperate string chunks
|
||||
* This is because sql function templates need arguments as separate string chunks
|
||||
* that will be assembled into the target dialect-specific function call.
|
||||
*/
|
||||
private SqlWriter writer = new DefaultWriter();
|
||||
|
@ -84,6 +83,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
private int traceDepth = 0;
|
||||
|
||||
public void traceIn(String ruleName, AST tree) {
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
|
||||
log.trace( prefix + traceText );
|
||||
}
|
||||
}
|
||||
|
||||
private String buildTraceNodeName(AST tree) {
|
||||
return tree == null
|
||||
|
@ -99,12 +100,14 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
}
|
||||
|
||||
public void traceOut(String ruleName, AST tree) {
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
}
|
||||
|
||||
public List getCollectedParameters() {
|
||||
return collectedParameters;
|
||||
|
|
Loading…
Reference in New Issue