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();
|
||||
|
@ -77,23 +78,26 @@ public final class HqlParser extends HqlBaseParser {
|
|||
|
||||
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
private int traceDepth = 0;
|
||||
|
||||
private int traceDepth = 0;
|
||||
|
||||
public void traceIn(String ruleName) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
|
||||
public void traceOut(String ruleName) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
|
||||
public void reportError(RecognitionException e) {
|
||||
|
|
|
@ -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;
|
||||
|
@ -183,15 +184,17 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
private int traceDepth = 0;
|
||||
private int traceDepth = 0;
|
||||
|
||||
public void traceIn(String ruleName, AST tree) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
|
||||
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
|
||||
log.trace( prefix + traceText );
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
|
||||
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
|
||||
log.trace( prefix + traceText );
|
||||
}
|
||||
|
||||
private String buildTraceNodeName(AST tree) {
|
||||
|
@ -201,11 +204,13 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
|
||||
public void traceOut(String ruleName, AST tree) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
@ -81,15 +80,17 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
|
||||
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
private int traceDepth = 0;
|
||||
private int traceDepth = 0;
|
||||
|
||||
public void traceIn(String ruleName, AST tree) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
|
||||
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
|
||||
log.trace( prefix + traceText );
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
|
||||
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
|
||||
log.trace( prefix + traceText );
|
||||
}
|
||||
|
||||
private String buildTraceNodeName(AST tree) {
|
||||
|
@ -99,11 +100,13 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
}
|
||||
|
||||
public void traceOut(String ruleName, AST tree) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
if (trace) {
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
|
||||
log.trace( prefix + ruleName );
|
||||
}
|
||||
|
||||
public List getCollectedParameters() {
|
||||
|
|
Loading…
Reference in New Issue