HHH-8741 - More checkstyle cleanups
This commit is contained in:
parent
3a2c9f83e6
commit
66d3902ec2
|
@ -31,10 +31,9 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
import org.hibernate.hql.spi.FilterTranslator;
|
||||
import org.hibernate.hql.spi.QueryTranslator;
|
||||
import org.hibernate.hql.spi.QueryTranslatorFactory;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Generates translators which uses the Antlr-based parser to perform
|
||||
* the translation.
|
||||
|
@ -42,17 +41,13 @@ import org.jboss.logging.Logger;
|
|||
* @author Gavin King
|
||||
*/
|
||||
public class ASTQueryTranslatorFactory implements QueryTranslatorFactory {
|
||||
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,
|
||||
ASTQueryTranslatorFactory.class.getName());
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( ASTQueryTranslatorFactory.class );
|
||||
|
||||
public ASTQueryTranslatorFactory() {
|
||||
LOG.usingAstQueryTranslatorFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.hibernate.hql.spi.QueryTranslatorFactory#createQueryTranslator
|
||||
*/
|
||||
@Override
|
||||
public QueryTranslator createQueryTranslator(
|
||||
String queryIdentifier,
|
||||
String queryString,
|
||||
|
@ -62,9 +57,7 @@ public class ASTQueryTranslatorFactory implements QueryTranslatorFactory {
|
|||
return new QueryTranslatorImpl( queryIdentifier, queryString, filters, factory, entityGraphQueryHint );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryTranslatorFactory#createFilterTranslator
|
||||
*/
|
||||
@Override
|
||||
public FilterTranslator createFilterTranslator(
|
||||
String queryIdentifier,
|
||||
String queryString,
|
||||
|
|
|
@ -35,11 +35,10 @@ import antlr.Token;
|
|||
* in order to keep the grammar source file clean.
|
||||
*/
|
||||
class HqlLexer extends HqlBaseLexer {
|
||||
|
||||
private boolean possibleID;
|
||||
|
||||
public HqlLexer(Reader in) {
|
||||
super(in);
|
||||
super( in );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +53,7 @@ class HqlLexer extends HqlBaseLexer {
|
|||
|
||||
@Override
|
||||
protected Token makeToken(int i) {
|
||||
HqlToken token = ( HqlToken ) super.makeToken( i );
|
||||
HqlToken token = (HqlToken) super.makeToken( i );
|
||||
token.setPossibleID( possibleID );
|
||||
possibleID = false;
|
||||
return token;
|
||||
|
@ -63,12 +62,12 @@ class HqlLexer extends HqlBaseLexer {
|
|||
@Override
|
||||
public void panic() {
|
||||
//overriden to avoid System.exit
|
||||
panic("CharScanner: panic");
|
||||
panic( "CharScanner: panic" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void panic(String s) {
|
||||
//overriden to avoid System.exit
|
||||
throw new QueryException(s);
|
||||
throw new QueryException( s );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,16 +91,24 @@ public final class HqlParser extends HqlBaseParser {
|
|||
|
||||
@Override
|
||||
public void traceIn(String ruleName) {
|
||||
if ( !LOG.isTraceEnabled() ) return;
|
||||
if ( inputState.guessing > 0 ) return;
|
||||
if ( !LOG.isTraceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', ( traceDepth++ * 2 ) ) + "-> ";
|
||||
LOG.trace( prefix + ruleName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void traceOut(String ruleName) {
|
||||
if ( !LOG.isTraceEnabled() ) return;
|
||||
if ( inputState.guessing > 0 ) return;
|
||||
if ( !LOG.isTraceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', ( --traceDepth * 2 ) ) + " ";
|
||||
LOG.trace( prefix + ruleName );
|
||||
}
|
||||
|
@ -129,25 +137,30 @@ public final class HqlParser extends HqlBaseParser {
|
|||
*
|
||||
* @param token The token.
|
||||
* @param ex The recognition exception.
|
||||
*
|
||||
* @return AST - The new AST.
|
||||
*
|
||||
* @throws antlr.RecognitionException if the substitution was not possible.
|
||||
* @throws antlr.TokenStreamException if the substitution was not possible.
|
||||
*/
|
||||
@Override
|
||||
public AST handleIdentifierError(Token token, RecognitionException ex) throws RecognitionException, TokenStreamException {
|
||||
public AST handleIdentifierError(Token token, RecognitionException ex)
|
||||
throws RecognitionException, TokenStreamException {
|
||||
// If the token can tell us if it could be an identifier...
|
||||
if ( token instanceof HqlToken ) {
|
||||
HqlToken hqlToken = ( HqlToken ) token;
|
||||
HqlToken hqlToken = (HqlToken) token;
|
||||
// ... and the token could be an identifer and the error is
|
||||
// a mismatched token error ...
|
||||
if ( hqlToken.isPossibleID() && ( ex instanceof MismatchedTokenException ) ) {
|
||||
MismatchedTokenException mte = ( MismatchedTokenException ) ex;
|
||||
MismatchedTokenException mte = (MismatchedTokenException) ex;
|
||||
// ... and the expected token type was an identifier, then:
|
||||
if ( mte.expecting == HqlTokenTypes.IDENT ) {
|
||||
// Use the token as an identifier.
|
||||
reportWarning( "Keyword '"
|
||||
reportWarning(
|
||||
"Keyword '"
|
||||
+ token.getText()
|
||||
+ "' is being interpreted as an identifier due to: " + mte.getMessage() );
|
||||
+ "' is being interpreted as an identifier due to: " + mte.getMessage()
|
||||
);
|
||||
// Add the token to the AST.
|
||||
ASTPair currentAST = new ASTPair();
|
||||
token.setType( HqlTokenTypes.WEIRD_IDENT );
|
||||
|
@ -167,6 +180,7 @@ public final class HqlParser extends HqlBaseParser {
|
|||
* </pre>
|
||||
*
|
||||
* @param x The sub tree to transform, the parent is assumed to be NOT.
|
||||
*
|
||||
* @return AST - The equivalent sub-tree.
|
||||
*/
|
||||
@Override
|
||||
|
@ -174,93 +188,126 @@ public final class HqlParser extends HqlBaseParser {
|
|||
//TODO: switch statements are always evil! We already had bugs because
|
||||
// of forgotten token types. Use polymorphism for this!
|
||||
switch ( x.getType() ) {
|
||||
case OR:
|
||||
x.setType(AND);
|
||||
x.setText("{and}");
|
||||
x.setFirstChild(negateNode( x.getFirstChild() ));
|
||||
x.getFirstChild().setNextSibling(negateNode( x.getFirstChild().getNextSibling() ));
|
||||
case OR: {
|
||||
x.setType( AND );
|
||||
x.setText( "{and}" );
|
||||
x.setFirstChild( negateNode( x.getFirstChild() ) );
|
||||
x.getFirstChild().setNextSibling( negateNode( x.getFirstChild().getNextSibling() ) );
|
||||
return x;
|
||||
case AND:
|
||||
x.setType(OR);
|
||||
x.setText("{or}");
|
||||
x.setFirstChild(negateNode( x.getFirstChild() ));
|
||||
x.getFirstChild().setNextSibling(negateNode( x.getFirstChild().getNextSibling() ));
|
||||
}
|
||||
case AND: {
|
||||
x.setType( OR );
|
||||
x.setText( "{or}" );
|
||||
x.setFirstChild( negateNode( x.getFirstChild() ) );
|
||||
x.getFirstChild().setNextSibling( negateNode( x.getFirstChild().getNextSibling() ) );
|
||||
return x;
|
||||
case EQ:
|
||||
}
|
||||
case EQ: {
|
||||
// (NOT (EQ a b) ) => (NE a b)
|
||||
x.setType( NE );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (EQ a b) ) => (NE a b)
|
||||
case NE:
|
||||
return x;
|
||||
}
|
||||
case NE: {
|
||||
// (NOT (NE a b) ) => (EQ a b)
|
||||
x.setType( EQ );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (NE a b) ) => (EQ a b)
|
||||
case GT:
|
||||
return x;
|
||||
}
|
||||
case GT: {
|
||||
// (NOT (GT a b) ) => (LE a b)
|
||||
x.setType( LE );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (GT a b) ) => (LE a b)
|
||||
case LT:
|
||||
return x;
|
||||
}
|
||||
case LT: {
|
||||
// (NOT (LT a b) ) => (GE a b)
|
||||
x.setType( GE );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (LT a b) ) => (GE a b)
|
||||
case GE:
|
||||
return x;
|
||||
}
|
||||
case GE: {
|
||||
// (NOT (GE a b) ) => (LT a b)
|
||||
x.setType( LT );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (GE a b) ) => (LT a b)
|
||||
case LE:
|
||||
return x;
|
||||
}
|
||||
case LE: {
|
||||
// (NOT (LE a b) ) => (GT a b)
|
||||
x.setType( GT );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (LE a b) ) => (GT a b)
|
||||
case LIKE:
|
||||
return x;
|
||||
}
|
||||
case LIKE: {
|
||||
// (NOT (LIKE a b) ) => (NOT_LIKE a b)
|
||||
x.setType( NOT_LIKE );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (LIKE a b) ) => (NOT_LIKE a b)
|
||||
case NOT_LIKE:
|
||||
return x;
|
||||
}
|
||||
case NOT_LIKE: {
|
||||
// (NOT (NOT_LIKE a b) ) => (LIKE a b)
|
||||
x.setType( LIKE );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (NOT_LIKE a b) ) => (LIKE a b)
|
||||
case IN:
|
||||
return x;
|
||||
}
|
||||
case IN: {
|
||||
x.setType( NOT_IN );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x;
|
||||
case NOT_IN:
|
||||
}
|
||||
case NOT_IN: {
|
||||
x.setType( IN );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x;
|
||||
case IS_NULL:
|
||||
}
|
||||
case IS_NULL: {
|
||||
// (NOT (IS_NULL a b) ) => (IS_NOT_NULL a b)
|
||||
x.setType( IS_NOT_NULL );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (IS_NULL a b) ) => (IS_NOT_NULL a b)
|
||||
case IS_NOT_NULL:
|
||||
return x;
|
||||
}
|
||||
case IS_NOT_NULL: {
|
||||
// (NOT (IS_NOT_NULL a b) ) => (IS_NULL a b)
|
||||
x.setType( IS_NULL );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (IS_NOT_NULL a b) ) => (IS_NULL a b)
|
||||
case BETWEEN:
|
||||
return x;
|
||||
}
|
||||
case BETWEEN: {
|
||||
// (NOT (BETWEEN a b) ) => (NOT_BETWEEN a b)
|
||||
x.setType( NOT_BETWEEN );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (BETWEEN a b) ) => (NOT_BETWEEN a b)
|
||||
case NOT_BETWEEN:
|
||||
return x;
|
||||
}
|
||||
case NOT_BETWEEN: {
|
||||
// (NOT (NOT_BETWEEN a b) ) => (BETWEEN a b)
|
||||
x.setType( BETWEEN );
|
||||
x.setText( "{not}" + x.getText() );
|
||||
return x; // (NOT (NOT_BETWEEN a b) ) => (BETWEEN a b)
|
||||
return x;
|
||||
}
|
||||
/* This can never happen because this rule will always eliminate the child NOT.
|
||||
case NOT:
|
||||
return x.getFirstChild(); // (NOT (NOT x) ) => (x)
|
||||
case NOT: {
|
||||
// (NOT (NOT x) ) => (x)
|
||||
return x.getFirstChild();
|
||||
}
|
||||
*/
|
||||
default:
|
||||
AST not = super.negateNode( x ); // Just add a 'not' parent.
|
||||
default: {
|
||||
// Just add a 'not' parent.
|
||||
AST not = super.negateNode( x );
|
||||
if ( not != x ) {
|
||||
// relink the next sibling to the new 'not' parent
|
||||
not.setNextSibling(x.getNextSibling());
|
||||
x.setNextSibling(null);
|
||||
not.setNextSibling( x.getNextSibling() );
|
||||
x.setNextSibling( null );
|
||||
}
|
||||
return not;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process equality expressions, clean up the subtree.
|
||||
*
|
||||
* @param x The equality expression.
|
||||
*
|
||||
* @return AST - The clean sub-tree.
|
||||
*/
|
||||
@Override
|
||||
|
@ -397,7 +444,7 @@ public final class HqlParser extends HqlBaseParser {
|
|||
elementsNode.addChild( p );
|
||||
}
|
||||
|
||||
private Map<String,Set<String>> treatMap;
|
||||
private Map<String, Set<String>> treatMap;
|
||||
|
||||
@Override
|
||||
protected void registerTreat(AST pathToTreat, AST treatAs) {
|
||||
|
@ -434,6 +481,6 @@ public final class HqlParser extends HqlBaseParser {
|
|||
|
||||
static public void panic() {
|
||||
//overriden to avoid System.exit
|
||||
throw new QueryException("Parser: panic");
|
||||
throw new QueryException( "Parser: panic" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
/**
|
||||
* Maps each top-level result variable to its SelectExpression;
|
||||
* (excludes result variables defined in subqueries)
|
||||
**/
|
||||
*/
|
||||
private Map<String, SelectExpression> selectExpressionsByResultVariable = new HashMap<String, SelectExpression>();
|
||||
|
||||
private Set<Serializable> querySpaces = new HashSet<Serializable>();
|
||||
|
@ -185,8 +185,12 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
public void traceIn(String ruleName, AST tree) {
|
||||
if ( !LOG.isTraceEnabled() ) return;
|
||||
if ( inputState.guessing > 0 ) return;
|
||||
if ( !LOG.isTraceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', ( traceDepth++ * 2 ) ) + "-> ";
|
||||
String traceText = ruleName + " (" + buildTraceNodeName( tree ) + ")";
|
||||
LOG.trace( prefix + traceText );
|
||||
|
@ -200,8 +204,12 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
public void traceOut(String ruleName, AST tree) {
|
||||
if ( !LOG.isTraceEnabled() ) return;
|
||||
if ( inputState.guessing > 0 ) return;
|
||||
if ( !LOG.isTraceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', ( --traceDepth * 2 ) ) + " ";
|
||||
LOG.trace( prefix + ruleName );
|
||||
}
|
||||
|
@ -245,16 +253,17 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
String collectionElementEntityName = persister.getElementPersister().getEntityName();
|
||||
ASTFactory inputAstFactory = hqlParser.getASTFactory();
|
||||
AST fromElement = ASTUtil.create( inputAstFactory, HqlTokenTypes.FILTER_ENTITY, collectionElementEntityName );
|
||||
AST fromElement = inputAstFactory.create( HqlTokenTypes.FILTER_ENTITY, collectionElementEntityName );
|
||||
ASTUtil.createSibling( inputAstFactory, HqlTokenTypes.ALIAS, "this", fromElement );
|
||||
fromClauseInput.addChild( fromElement );
|
||||
// Show the modified AST.
|
||||
LOG.debug("prepareFromClauseInputTree() : Filter - Added 'this' as a from element...");
|
||||
LOG.debug( "prepareFromClauseInputTree() : Filter - Added 'this' as a from element..." );
|
||||
queryTranslatorImpl.showHqlAst( hqlParser.getAST() );
|
||||
|
||||
// Create a parameter specification for the collection filter...
|
||||
Type collectionFilterKeyType = sessionFactoryHelper.requireQueryableCollection( collectionFilterRole ).getKeyType();
|
||||
ParameterNode collectionFilterKeyParameter = ( ParameterNode ) astFactory.create( PARAM, "?" );
|
||||
Type collectionFilterKeyType = sessionFactoryHelper.requireQueryableCollection( collectionFilterRole )
|
||||
.getKeyType();
|
||||
ParameterNode collectionFilterKeyParameter = (ParameterNode) astFactory.create( PARAM, "?" );
|
||||
CollectionFilterKeyParameterSpecification collectionFilterKeyParameterSpec = new CollectionFilterKeyParameterSpecification(
|
||||
collectionFilterRole, collectionFilterKeyType, positionalParameterCount++
|
||||
);
|
||||
|
@ -320,7 +329,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
@Override
|
||||
protected AST createFromElement(String path, AST alias, AST propertyFetch) throws SemanticException {
|
||||
FromElement fromElement = currentFromClause.addFromElement( path, alias );
|
||||
fromElement.setAllPropertyFetch(propertyFetch!=null);
|
||||
fromElement.setAllPropertyFetch( propertyFetch != null );
|
||||
return fromElement;
|
||||
}
|
||||
|
||||
|
@ -338,15 +347,17 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
JoinSequence join = sessionFactoryHelper.createJoinSequence();
|
||||
join.setRoot( persister, fkTableAlias );
|
||||
if ( !persister.isOneToMany() ) {
|
||||
join.addJoin( ( AssociationType ) persister.getElementType(),
|
||||
join.addJoin(
|
||||
(AssociationType) persister.getElementType(),
|
||||
fromElement.getTableAlias(),
|
||||
JoinType.INNER_JOIN,
|
||||
persister.getElementColumnNames( fkTableAlias ) );
|
||||
persister.getElementColumnNames( fkTableAlias )
|
||||
);
|
||||
}
|
||||
join.addCondition( fkTableAlias, keyColumnNames, " = ?" );
|
||||
fromElement.setJoinSequence( join );
|
||||
fromElement.setFilter( true );
|
||||
LOG.debug("createFromFilterElement() : processed filter FROM element.");
|
||||
LOG.debug( "createFromFilterElement() : processed filter FROM element." );
|
||||
return fromElement;
|
||||
}
|
||||
|
||||
|
@ -366,7 +377,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
if ( path.getType() != SqlTokenTypes.DOT ) {
|
||||
throw new SemanticException( "Path expected for join!" );
|
||||
}
|
||||
DotNode dot = ( DotNode ) path;
|
||||
DotNode dot = (DotNode) path;
|
||||
JoinType hibernateJoinType = JoinProcessor.toHibernateJoinType( joinType );
|
||||
dot.setJoinType( hibernateJoinType ); // Tell the dot node about the join type.
|
||||
dot.setFetch( fetch );
|
||||
|
@ -404,7 +415,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug("createFromJoinElement() : " + getASTPrinter().showAsString(fromElement, "-- join tree --") );
|
||||
LOG.debug( "createFromJoinElement() : " + getASTPrinter().showAsString( fromElement, "-- join tree --" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,7 +424,12 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
withClause( hqlWithNode );
|
||||
AST hqlSqlWithNode = returnAST;
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "handleWithFragment() : " + getASTPrinter().showAsString(hqlSqlWithNode, "-- with clause --") );
|
||||
LOG.debug(
|
||||
"handleWithFragment() : " + getASTPrinter().showAsString(
|
||||
hqlSqlWithNode,
|
||||
"-- with clause --"
|
||||
)
|
||||
);
|
||||
}
|
||||
WithClauseVisitor visitor = new WithClauseVisitor( fromElement, queryTranslatorImpl );
|
||||
NodeTraverser traverser = new NodeTraverser( visitor );
|
||||
|
@ -439,13 +455,13 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
fromElement.setWithClauseFragment( withClauseJoinAlias, "(" + sql.getSQL() + ")" );
|
||||
}
|
||||
catch( SemanticException e ) {
|
||||
catch (SemanticException e) {
|
||||
throw e;
|
||||
}
|
||||
catch( InvalidWithClauseException e ) {
|
||||
catch (InvalidWithClauseException e) {
|
||||
throw e;
|
||||
}
|
||||
catch ( Exception e) {
|
||||
catch (Exception e) {
|
||||
throw new SemanticException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
@ -474,7 +490,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
// the join alias to which it applies and then pass that information
|
||||
// back to the FromElement so it can pass it along to the JoinSequence
|
||||
if ( node instanceof DotNode ) {
|
||||
DotNode dotNode = ( DotNode ) node;
|
||||
DotNode dotNode = (DotNode) node;
|
||||
FromElement fromElement = dotNode.getFromElement();
|
||||
if ( referencedFromElement != null ) {
|
||||
if ( fromElement != referencedFromElement ) {
|
||||
|
@ -497,10 +513,10 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
}
|
||||
else if ( node instanceof ParameterNode ) {
|
||||
applyParameterSpecification( ( ( ParameterNode ) node ).getHqlParameterSpecification() );
|
||||
applyParameterSpecification( ( (ParameterNode) node ).getHqlParameterSpecification() );
|
||||
}
|
||||
else if ( node instanceof ParameterContainer ) {
|
||||
applyParameterSpecifications( ( ParameterContainer ) node );
|
||||
applyParameterSpecifications( (ParameterContainer) node );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -538,7 +554,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
*/
|
||||
@Override
|
||||
protected void pushFromClause(AST fromNode, AST inputFromNode) {
|
||||
FromClause newFromClause = ( FromClause ) fromNode;
|
||||
FromClause newFromClause = (FromClause) fromNode;
|
||||
newFromClause.setParentFromClause( currentFromClause );
|
||||
currentFromClause = newFromClause;
|
||||
}
|
||||
|
@ -554,7 +570,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
protected void lookupAlias(AST aliasRef)
|
||||
throws SemanticException {
|
||||
FromElement alias = currentFromClause.getFromElement( aliasRef.getText() );
|
||||
FromReferenceNode aliasRefNode = ( FromReferenceNode ) aliasRef;
|
||||
FromReferenceNode aliasRefNode = (FromReferenceNode) aliasRef;
|
||||
aliasRefNode.setFromElement( alias );
|
||||
}
|
||||
|
||||
|
@ -569,17 +585,21 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
protected AST lookupProperty(AST dot, boolean root, boolean inSelect) throws SemanticException {
|
||||
DotNode dotNode = ( DotNode ) dot;
|
||||
DotNode dotNode = (DotNode) dot;
|
||||
FromReferenceNode lhs = dotNode.getLhs();
|
||||
AST rhs = lhs.getNextSibling();
|
||||
switch ( rhs.getType() ) {
|
||||
case SqlTokenTypes.ELEMENTS:
|
||||
case SqlTokenTypes.INDICES:
|
||||
if (LOG.isDebugEnabled()) LOG.debugf("lookupProperty() %s => %s(%s)",
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf(
|
||||
"lookupProperty() %s => %s(%s)",
|
||||
dotNode.getPath(),
|
||||
rhs.getText(),
|
||||
lhs.getPath());
|
||||
CollectionFunction f = ( CollectionFunction ) rhs;
|
||||
lhs.getPath()
|
||||
);
|
||||
}
|
||||
CollectionFunction f = (CollectionFunction) rhs;
|
||||
// Re-arrange the tree so that the collection function is the root and the lhs is the path.
|
||||
f.setFirstChild( lhs );
|
||||
lhs.setNextSibling( null );
|
||||
|
@ -603,12 +623,12 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
List fromElements = currentFromClause.getExplicitFromElements();
|
||||
if ( fromElements.size() == 1 ) {
|
||||
final FromElement fromElement = ( FromElement ) fromElements.get( 0 );
|
||||
final FromElement fromElement = (FromElement) fromElements.get( 0 );
|
||||
try {
|
||||
LOG.tracev( "Attempting to resolve property [{0}] as a non-qualified ref", identText );
|
||||
return fromElement.getPropertyMapping( identText ).toType( identText ) != null;
|
||||
}
|
||||
catch( QueryException e ) {
|
||||
catch (QueryException e) {
|
||||
// Should mean that no such property was found
|
||||
}
|
||||
}
|
||||
|
@ -618,7 +638,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
protected AST lookupNonQualifiedProperty(AST property) throws SemanticException {
|
||||
final FromElement fromElement = ( FromElement ) currentFromClause.getExplicitFromElements().get( 0 );
|
||||
final FromElement fromElement = (FromElement) currentFromClause.getExplicitFromElements().get( 0 );
|
||||
AST syntheticDotNode = generateSyntheticDotNodeForNonQualifiedPropertyRef( property, fromElement );
|
||||
return lookupProperty( syntheticDotNode, false, getCurrentClauseType() == HqlSqlTokenTypes.SELECT );
|
||||
}
|
||||
|
@ -626,9 +646,9 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
private AST generateSyntheticDotNodeForNonQualifiedPropertyRef(AST property, FromElement fromElement) {
|
||||
AST dot = getASTFactory().create( DOT, "{non-qualified-property-ref}" );
|
||||
// TODO : better way?!?
|
||||
( ( DotNode ) dot ).setPropertyPath( ( ( FromReferenceNode ) property ).getPath() );
|
||||
( (DotNode) dot ).setPropertyPath( ( (FromReferenceNode) property ).getPath() );
|
||||
|
||||
IdentNode syntheticAlias = ( IdentNode ) getASTFactory().create( IDENT, "{synthetic-alias}" );
|
||||
IdentNode syntheticAlias = (IdentNode) getASTFactory().create( IDENT, "{synthetic-alias}" );
|
||||
syntheticAlias.setFromElement( fromElement );
|
||||
syntheticAlias.setResolved();
|
||||
|
||||
|
@ -645,15 +665,16 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
|
||||
try {
|
||||
QueryNode qn = ( QueryNode ) query;
|
||||
QueryNode qn = (QueryNode) query;
|
||||
|
||||
// Was there an explicit select expression?
|
||||
boolean explicitSelect = select != null && select.getNumberOfChildren() > 0;
|
||||
|
||||
// Add in the EntityGraph attribute nodes.
|
||||
if (queryTranslatorImpl.getEntityGraphQueryHint() != null) {
|
||||
if ( queryTranslatorImpl.getEntityGraphQueryHint() != null ) {
|
||||
qn.getFromClause().getFromElements().addAll(
|
||||
queryTranslatorImpl.getEntityGraphQueryHint().toFromElements( qn.getFromClause(), this ) );
|
||||
queryTranslatorImpl.getEntityGraphQueryHint().toFromElements( qn.getFromClause(), this )
|
||||
);
|
||||
}
|
||||
|
||||
if ( !explicitSelect ) {
|
||||
|
@ -678,7 +699,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
// Attach any mapping-defined "ORDER BY" fragments
|
||||
Iterator itr = qn.getFromClause().getProjectionList().iterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final FromElement fromElement = ( FromElement ) itr.next();
|
||||
final FromElement fromElement = (FromElement) itr.next();
|
||||
// if ( fromElement.isFetch() && fromElement.isCollectionJoin() ) {
|
||||
if ( fromElement.isFetch() && fromElement.getQueryableCollection() != null ) {
|
||||
// Does the collection referenced by this FromElement
|
||||
|
@ -706,7 +727,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
protected void postProcessDML(RestrictableStatement statement) throws SemanticException {
|
||||
statement.getFromClause().resolve();
|
||||
|
||||
FromElement fromElement = ( FromElement ) statement.getFromClause().getFromElements().get( 0 );
|
||||
FromElement fromElement = (FromElement) statement.getFromClause().getFromElements().get( 0 );
|
||||
Queryable persister = fromElement.getQueryable();
|
||||
// Make #@%$^#^&# sure no alias is applied to the table name
|
||||
fromElement.setText( persister.getTableName() );
|
||||
|
@ -721,7 +742,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
// fromElement.getTableAlias()
|
||||
// );
|
||||
// }
|
||||
if ( persister.getDiscriminatorType() != null || ! queryTranslatorImpl.getEnabledFilters().isEmpty() ) {
|
||||
if ( persister.getDiscriminatorType() != null || !queryTranslatorImpl.getEnabledFilters().isEmpty() ) {
|
||||
new SyntheticAndFactory( this ).addDiscriminatorWhereFragment(
|
||||
statement,
|
||||
persister,
|
||||
|
@ -734,19 +755,19 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
protected void postProcessUpdate(AST update) throws SemanticException {
|
||||
UpdateStatement updateStatement = ( UpdateStatement ) update;
|
||||
UpdateStatement updateStatement = (UpdateStatement) update;
|
||||
|
||||
postProcessDML( updateStatement );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessDelete(AST delete) throws SemanticException {
|
||||
postProcessDML( ( DeleteStatement ) delete );
|
||||
postProcessDML( (DeleteStatement) delete );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessInsert(AST insert) throws SemanticException, QueryException {
|
||||
InsertStatement insertStatement = ( InsertStatement ) insert;
|
||||
InsertStatement insertStatement = (InsertStatement) insert;
|
||||
insertStatement.validate();
|
||||
|
||||
SelectClause selectClause = insertStatement.getSelectClause();
|
||||
|
@ -764,7 +785,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
final BulkInsertionCapableIdentifierGenerator capableGenerator =
|
||||
BulkInsertionCapableIdentifierGenerator.class.cast( generator );
|
||||
if ( ! capableGenerator.supportsBulkInsertionIdentifierGeneration() ) {
|
||||
if ( !capableGenerator.supportsBulkInsertionIdentifierGeneration() ) {
|
||||
throw new QueryException(
|
||||
"Identifier generator reported it does not support implicit id handling as part of bulk insertions"
|
||||
);
|
||||
|
@ -790,11 +811,13 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
if ( sessionFactoryHelper.getFactory().getDialect().supportsParametersInInsertSelect() ) {
|
||||
AST child = selectClause.getFirstChild();
|
||||
int i = 0;
|
||||
while(child != null) {
|
||||
if(child instanceof ParameterNode) {
|
||||
while ( child != null ) {
|
||||
if ( child instanceof ParameterNode ) {
|
||||
// infer the parameter type from the type listed in the INSERT INTO clause
|
||||
((ParameterNode)child).setExpectedType(insertStatement.getIntoClause()
|
||||
.getInsertionTypes()[selectClause.getParameterPositions().get(i)]);
|
||||
( (ParameterNode) child ).setExpectedType(
|
||||
insertStatement.getIntoClause()
|
||||
.getInsertionTypes()[selectClause.getParameterPositions().get( i )]
|
||||
);
|
||||
i++;
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
|
@ -822,22 +845,26 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
versionValueNode = getASTFactory().create( HqlSqlTokenTypes.PARAM, "?" );
|
||||
ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification( versionType );
|
||||
( ( ParameterNode ) versionValueNode ).setHqlParameterSpecification( paramSpec );
|
||||
( (ParameterNode) versionValueNode ).setHqlParameterSpecification( paramSpec );
|
||||
parameters.add( 0, paramSpec );
|
||||
|
||||
if ( sessionFactoryHelper.getFactory().getDialect().requiresCastingOfParametersInSelectClause() ) {
|
||||
// we need to wrtap the param in a cast()
|
||||
MethodNode versionMethodNode = ( MethodNode ) getASTFactory().create( HqlSqlTokenTypes.METHOD_CALL, "(" );
|
||||
MethodNode versionMethodNode = (MethodNode) getASTFactory().create(
|
||||
HqlSqlTokenTypes.METHOD_CALL,
|
||||
"("
|
||||
);
|
||||
AST methodIdentNode = getASTFactory().create( HqlSqlTokenTypes.IDENT, "cast" );
|
||||
versionMethodNode.addChild( methodIdentNode );
|
||||
versionMethodNode.initializeMethodNode(methodIdentNode, true );
|
||||
versionMethodNode.initializeMethodNode( methodIdentNode, true );
|
||||
AST castExprListNode = getASTFactory().create( HqlSqlTokenTypes.EXPR_LIST, "exprList" );
|
||||
methodIdentNode.setNextSibling( castExprListNode );
|
||||
castExprListNode.addChild( versionValueNode );
|
||||
versionValueNode.setNextSibling(
|
||||
getASTFactory().create(
|
||||
HqlSqlTokenTypes.IDENT,
|
||||
sessionFactoryHelper.getFactory().getDialect().getTypeName( sqlTypes[0] ) )
|
||||
sessionFactoryHelper.getFactory().getDialect().getTypeName( sqlTypes[0] )
|
||||
)
|
||||
);
|
||||
processFunction( versionMethodNode, true );
|
||||
versionValueNode = versionMethodNode;
|
||||
|
@ -849,12 +876,14 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
Object seedValue = versionType.seed( null );
|
||||
versionValueNode = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, seedValue.toString() );
|
||||
}
|
||||
catch( Throwable t ) {
|
||||
catch (Throwable t) {
|
||||
throw new QueryException( "could not determine seed value for version on bulk insert [" + versionType + "]" );
|
||||
}
|
||||
}
|
||||
else if ( isDatabaseGeneratedTimestamp( versionType ) ) {
|
||||
String functionName = sessionFactoryHelper.getFactory().getDialect().getCurrentTimestampSQLFunctionName();
|
||||
String functionName = sessionFactoryHelper.getFactory()
|
||||
.getDialect()
|
||||
.getCurrentTimestampSQLFunctionName();
|
||||
versionValueNode = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, functionName );
|
||||
}
|
||||
else {
|
||||
|
@ -890,7 +919,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
|
||||
private void useSelectClause(AST select) throws SemanticException {
|
||||
selectClause = ( SelectClause ) select;
|
||||
selectClause = (SelectClause) select;
|
||||
selectClause.initializeExplicitSelectClause( currentFromClause );
|
||||
}
|
||||
|
||||
|
@ -899,7 +928,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
AST sibling = qn.getFromClause();
|
||||
qn.setFirstChild( select );
|
||||
select.setNextSibling( sibling );
|
||||
selectClause = ( SelectClause ) select;
|
||||
selectClause = (SelectClause) select;
|
||||
selectClause.initializeDerivedSelectClause( currentFromClause );
|
||||
LOG.debug( "Derived SELECT clause created." );
|
||||
}
|
||||
|
@ -908,7 +937,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
protected void resolve(AST node) throws SemanticException {
|
||||
if ( node != null ) {
|
||||
// This is called when it's time to fully resolve a path expression.
|
||||
ResolvableNode r = ( ResolvableNode ) node;
|
||||
ResolvableNode r = (ResolvableNode) node;
|
||||
if ( isInFunctionCall() ) {
|
||||
r.resolveInFunctionCall( false, true );
|
||||
}
|
||||
|
@ -924,13 +953,13 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
int type = node.getType();
|
||||
switch ( type ) {
|
||||
case DOT: {
|
||||
DotNode dot = ( DotNode ) node;
|
||||
DotNode dot = (DotNode) node;
|
||||
dot.resolveSelectExpression();
|
||||
break;
|
||||
}
|
||||
case ALIAS_REF: {
|
||||
// Notify the FROM element that it is being referenced by the select.
|
||||
FromReferenceNode aliasRefNode = ( FromReferenceNode ) node;
|
||||
FromReferenceNode aliasRefNode = (FromReferenceNode) node;
|
||||
//aliasRefNode.resolve( false, false, aliasRefNode.getText() ); //TODO: is it kosher to do it here?
|
||||
aliasRefNode.resolve( false, false ); //TODO: is it kosher to do it here?
|
||||
FromElement fromElement = aliasRefNode.getFromElement();
|
||||
|
@ -951,7 +980,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
FromClause from = getCurrentFromClause();
|
||||
List fromElements = from.getFromElements();
|
||||
for ( Iterator iterator = fromElements.iterator(); iterator.hasNext(); ) {
|
||||
FromElement fromElement = ( FromElement ) iterator.next();
|
||||
FromElement fromElement = (FromElement) iterator.next();
|
||||
fromElement.setIncludeSubclasses( false );
|
||||
}
|
||||
}
|
||||
|
@ -959,7 +988,9 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
@Override
|
||||
protected AST generatePositionalParameter(AST inputNode) throws SemanticException {
|
||||
if ( namedParameters.size() > 0 ) {
|
||||
throw new SemanticException( "cannot define positional parameter after any named parameters have been defined" );
|
||||
throw new SemanticException(
|
||||
"cannot define positional parameter after any named parameters have been defined"
|
||||
);
|
||||
}
|
||||
LOG.warnf(
|
||||
"[DEPRECATION] Encountered positional parameter near line %s, column %s. Positional parameter " +
|
||||
|
@ -967,7 +998,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
inputNode.getLine(),
|
||||
inputNode.getColumn()
|
||||
);
|
||||
ParameterNode parameter = ( ParameterNode ) astFactory.create( PARAM, "?" );
|
||||
ParameterNode parameter = (ParameterNode) astFactory.create( PARAM, "?" );
|
||||
PositionalParameterSpecification paramSpec = new PositionalParameterSpecification(
|
||||
inputNode.getLine(),
|
||||
inputNode.getColumn(),
|
||||
|
@ -985,7 +1016,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
// create the node initially with the param name so that it shows
|
||||
// appropriately in the "original text" attribute
|
||||
ParameterNode parameter = ( ParameterNode ) astFactory.create( NAMED_PARAM, name );
|
||||
ParameterNode parameter = (ParameterNode) astFactory.create( NAMED_PARAM, name );
|
||||
parameter.setText( "?" );
|
||||
|
||||
NamedParameterSpecification paramSpec = new NamedParameterSpecification(
|
||||
|
@ -1011,13 +1042,16 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
namedParameters.put( name, list );
|
||||
}
|
||||
else {
|
||||
( ( ArrayList ) o ).add( loc );
|
||||
( (ArrayList) o ).add( loc );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processConstant(AST constant) throws SemanticException {
|
||||
literalProcessor.processConstant( constant, true ); // Use the delegate, resolve identifiers as FROM element aliases.
|
||||
literalProcessor.processConstant(
|
||||
constant,
|
||||
true
|
||||
); // Use the delegate, resolve identifiers as FROM element aliases.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1032,35 +1066,35 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
protected void processIndex(AST indexOp) throws SemanticException {
|
||||
IndexNode indexNode = ( IndexNode ) indexOp;
|
||||
IndexNode indexNode = (IndexNode) indexOp;
|
||||
indexNode.resolve( true, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processFunction(AST functionCall, boolean inSelect) throws SemanticException {
|
||||
MethodNode methodNode = ( MethodNode ) functionCall;
|
||||
MethodNode methodNode = (MethodNode) functionCall;
|
||||
methodNode.resolve( inSelect );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processAggregation(AST node, boolean inSelect) throws SemanticException {
|
||||
AggregateNode aggregateNode = ( AggregateNode ) node;
|
||||
AggregateNode aggregateNode = (AggregateNode) node;
|
||||
aggregateNode.resolve();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processConstructor(AST constructor) throws SemanticException {
|
||||
ConstructorNode constructorNode = ( ConstructorNode ) constructor;
|
||||
ConstructorNode constructorNode = (ConstructorNode) constructor;
|
||||
constructorNode.prepare();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAlias(AST selectExpr, AST ident) {
|
||||
((SelectExpression) selectExpr).setAlias(ident.getText());
|
||||
( (SelectExpression) selectExpr ).setAlias( ident.getText() );
|
||||
// only put the alias (i.e., result variable) in selectExpressionsByResultVariable
|
||||
// if is not defined in a subquery.
|
||||
if ( ! isSubQuery() ) {
|
||||
selectExpressionsByResultVariable.put( ident.getText(), ( SelectExpression ) selectExpr );
|
||||
if ( !isSubQuery() ) {
|
||||
selectExpressionsByResultVariable.put( ident.getText(), (SelectExpression) selectExpr );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1068,7 +1102,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
protected boolean isOrderExpressionResultVariableRef(AST orderExpressionNode) throws SemanticException {
|
||||
// ORDER BY is not supported in a subquery
|
||||
// TODO: should an exception be thrown if an ORDER BY is in a subquery?
|
||||
if ( ! isSubQuery() &&
|
||||
if ( !isSubQuery() &&
|
||||
orderExpressionNode.getType() == IDENT &&
|
||||
selectExpressionsByResultVariable.containsKey( orderExpressionNode.getText() ) ) {
|
||||
return true;
|
||||
|
@ -1083,7 +1117,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
"References to result variables in subqueries are not supported."
|
||||
);
|
||||
}
|
||||
( ( ResultVariableRefNode ) resultVariableRef ).setSelectExpression(
|
||||
( (ResultVariableRefNode) resultVariableRef ).setSelectExpression(
|
||||
selectExpressionsByResultVariable.get( resultVariableRef.getText() )
|
||||
);
|
||||
}
|
||||
|
@ -1094,10 +1128,13 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
public int[] getNamedParameterLocations(String name) throws QueryException {
|
||||
Object o = namedParameters.get( name );
|
||||
if ( o == null ) {
|
||||
throw new QueryException( QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name, queryTranslatorImpl.getQueryString() );
|
||||
throw new QueryException(
|
||||
QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name,
|
||||
queryTranslatorImpl.getQueryString()
|
||||
);
|
||||
}
|
||||
if ( o instanceof Integer ) {
|
||||
return new int[]{ (Integer) o };
|
||||
return new int[] {(Integer) o};
|
||||
}
|
||||
else {
|
||||
return ArrayHelper.toIntArray( (ArrayList) o );
|
||||
|
@ -1180,9 +1217,9 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
protected AST createIntoClause(String path, AST propertySpec) throws SemanticException {
|
||||
Queryable persister = ( Queryable ) getSessionFactoryHelper().requireClassPersister( path );
|
||||
Queryable persister = (Queryable) getSessionFactoryHelper().requireClassPersister( path );
|
||||
|
||||
IntoClause intoClause = ( IntoClause ) getASTFactory().create( INTO, persister.getEntityName() );
|
||||
IntoClause intoClause = (IntoClause) getASTFactory().create( INTO, persister.getEntityName() );
|
||||
intoClause.setFirstChild( propertySpec );
|
||||
intoClause.initialize( persister );
|
||||
|
||||
|
@ -1193,7 +1230,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
protected void prepareVersioned(AST updateNode, AST versioned) throws SemanticException {
|
||||
UpdateStatement updateStatement = ( UpdateStatement ) updateNode;
|
||||
UpdateStatement updateStatement = (UpdateStatement) updateNode;
|
||||
FromClause fromClause = updateStatement.getFromClause();
|
||||
if ( versioned != null ) {
|
||||
// Make sure that the persister is versioned
|
||||
|
@ -1216,7 +1253,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
if ( isTimestampBasedVersion( versionType ) ) {
|
||||
versionIncrementNode = getASTFactory().create( HqlSqlTokenTypes.PARAM, "?" );
|
||||
ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification( versionType );
|
||||
( ( ParameterNode ) versionIncrementNode ).setHqlParameterSpecification( paramSpec );
|
||||
( (ParameterNode) versionIncrementNode ).setHqlParameterSpecification( paramSpec );
|
||||
parameters.add( 0, paramSpec );
|
||||
}
|
||||
else {
|
||||
|
@ -1245,7 +1282,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
|
||||
private AST generateVersionPropertyNode(Queryable persister) throws SemanticException {
|
||||
String versionPropertyName = persister.getPropertyNames()[ persister.getVersionProperty() ];
|
||||
String versionPropertyName = persister.getPropertyNames()[persister.getVersionProperty()];
|
||||
AST versionPropertyRef = getASTFactory().create( HqlSqlTokenTypes.IDENT, versionPropertyName );
|
||||
AST versionPropertyNode = lookupNonQualifiedProperty( versionPropertyRef );
|
||||
resolve( versionPropertyNode );
|
||||
|
@ -1254,12 +1291,12 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@Override
|
||||
protected void prepareLogicOperator(AST operator) throws SemanticException {
|
||||
( ( OperatorNode ) operator ).initialize();
|
||||
( (OperatorNode) operator ).initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareArithmeticOperator(AST operator) throws SemanticException {
|
||||
( ( OperatorNode ) operator ).initialize();
|
||||
( (OperatorNode) operator ).initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1267,14 +1304,14 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
try {
|
||||
FromReferenceNode fromReferenceNode = (FromReferenceNode) node;
|
||||
QueryableCollection collectionPersister = fromReferenceNode.getFromElement().getQueryableCollection();
|
||||
if ( ! Map.class.isAssignableFrom( collectionPersister.getCollectionType().getReturnedClass() ) ) {
|
||||
if ( !Map.class.isAssignableFrom( collectionPersister.getCollectionType().getReturnedClass() ) ) {
|
||||
throw new SemanticException( "node did not reference a map" );
|
||||
}
|
||||
}
|
||||
catch ( SemanticException se ) {
|
||||
catch (SemanticException se) {
|
||||
throw se;
|
||||
}
|
||||
catch ( Throwable t ) {
|
||||
catch (Throwable t) {
|
||||
throw new SemanticException( "node did not reference a map" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -606,7 +606,9 @@ public class QueryTranslatorImpl implements FilterTranslator {
|
|||
public void visit(AST node) {
|
||||
if ( dotRoot != null ) {
|
||||
// we are already processing a dot-structure
|
||||
if (ASTUtil.isSubtreeChild(dotRoot, node)) return;
|
||||
if ( ASTUtil.isSubtreeChild(dotRoot, node) ) {
|
||||
return;
|
||||
}
|
||||
// we are now at a new tree level
|
||||
dotRoot = null;
|
||||
}
|
||||
|
|
|
@ -84,8 +84,12 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
|
||||
@Override
|
||||
public void traceIn(String ruleName, AST tree) {
|
||||
if ( !LOG.isTraceEnabled() ) return;
|
||||
if ( inputState.guessing > 0 ) return;
|
||||
if ( !LOG.isTraceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringHelper.repeat( '-', ( traceDepth++ * 2 ) ) + "-> ";
|
||||
String traceText = ruleName + " (" + buildTraceNodeName( tree ) + ")";
|
||||
LOG.trace( prefix + traceText );
|
||||
|
@ -99,8 +103,12 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
|
||||
@Override
|
||||
public void traceOut(String ruleName, AST tree) {
|
||||
if ( !LOG.isTraceEnabled() ) return;
|
||||
if ( inputState.guessing > 0 ) return;
|
||||
if ( !LOG.isTraceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
if ( inputState.guessing > 0 ) {
|
||||
return;
|
||||
}
|
||||
String prefix = "<-" + StringHelper.repeat( '-', ( --traceDepth * 2 ) ) + " ";
|
||||
LOG.trace( prefix + ruleName );
|
||||
}
|
||||
|
@ -117,18 +125,18 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
@Override
|
||||
protected void out(AST n) {
|
||||
if ( n instanceof Node ) {
|
||||
out( ( ( Node ) n ).getRenderText( sessionFactory ) );
|
||||
out( ( (Node) n ).getRenderText( sessionFactory ) );
|
||||
}
|
||||
else {
|
||||
super.out( n );
|
||||
}
|
||||
|
||||
if ( n instanceof ParameterNode ) {
|
||||
collectedParameters.add( ( ( ParameterNode ) n ).getHqlParameterSpecification() );
|
||||
collectedParameters.add( ( (ParameterNode) n ).getHqlParameterSpecification() );
|
||||
}
|
||||
else if ( n instanceof ParameterContainer ) {
|
||||
if ( ( ( ParameterContainer ) n ).hasEmbeddedParameters() ) {
|
||||
ParameterSpecification[] specifications = ( ( ParameterContainer ) n ).getEmbeddedParameters();
|
||||
if ( ( (ParameterContainer) n ).hasEmbeddedParameters() ) {
|
||||
ParameterSpecification[] specifications = ( (ParameterContainer) n ).getEmbeddedParameters();
|
||||
if ( specifications != null ) {
|
||||
collectedParameters.addAll( Arrays.asList( specifications ) );
|
||||
}
|
||||
|
@ -143,12 +151,12 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
|
||||
@Override
|
||||
public void reportError(RecognitionException e) {
|
||||
parseErrorHandler.reportError( e ); // Use the delegate.
|
||||
parseErrorHandler.reportError( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportError(String s) {
|
||||
parseErrorHandler.reportError( s ); // Use the delegate.
|
||||
parseErrorHandler.reportError( s );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,7 +199,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
protected void beginFunctionTemplate(AST node, AST nameNode) {
|
||||
// NOTE for AGGREGATE both nodes are the same; for METHOD the first is the METHOD, the second is the
|
||||
// METHOD_NAME
|
||||
FunctionNode functionNode = ( FunctionNode ) node;
|
||||
FunctionNode functionNode = (FunctionNode) node;
|
||||
SQLFunction sqlFunction = functionNode.getSQLFunction();
|
||||
if ( sqlFunction == null ) {
|
||||
// if SQLFunction is null we just write the function out as it appears in the hql statement
|
||||
|
@ -206,7 +214,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
|
||||
@Override
|
||||
protected void endFunctionTemplate(AST node) {
|
||||
FunctionNode functionNode = ( FunctionNode ) node;
|
||||
FunctionNode functionNode = (FunctionNode) node;
|
||||
SQLFunction sqlFunction = functionNode.getSQLFunction();
|
||||
if ( sqlFunction == null ) {
|
||||
super.endFunctionTemplate( node );
|
||||
|
@ -214,7 +222,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
else {
|
||||
final Type functionType = functionNode.getFirstArgumentType();
|
||||
// this function has a registered SQLFunction -> redirect output and catch the arguments
|
||||
FunctionArguments functionArguments = ( FunctionArguments ) writer;
|
||||
FunctionArguments functionArguments = (FunctionArguments) writer;
|
||||
writer = outputStack.removeFirst();
|
||||
out( sqlFunction.render( functionType, functionArguments.getArgs(), sessionFactory ) );
|
||||
}
|
||||
|
@ -244,7 +252,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
*/
|
||||
class FunctionArguments implements SqlWriter {
|
||||
private int argInd;
|
||||
private final List<String> args = new ArrayList<String>(3);
|
||||
private final List<String> args = new ArrayList<String>( 3 );
|
||||
|
||||
@Override
|
||||
public void clause(String clause) {
|
||||
|
@ -293,8 +301,8 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
return;
|
||||
}
|
||||
|
||||
FromElement left = ( FromElement ) a;
|
||||
FromElement right = ( FromElement ) next;
|
||||
FromElement left = (FromElement) a;
|
||||
FromElement right = (FromElement) next;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// HACK ALERT !!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
@ -306,7 +314,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
// Essentially, look-ahead to the next FromElement that actually
|
||||
// writes something to the SQL
|
||||
while ( right != null && !hasText( right ) ) {
|
||||
right = ( FromElement ) right.getNextSibling();
|
||||
right = (FromElement) right.getNextSibling();
|
||||
}
|
||||
if ( right == null ) {
|
||||
return;
|
||||
|
@ -350,8 +358,8 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
if ( d != null && hasText( d ) ) {
|
||||
if ( parent != null && hasText( parent ) ) {
|
||||
// again, both should be FromElements
|
||||
FromElement left = ( FromElement ) parent;
|
||||
FromElement right = ( FromElement ) d;
|
||||
FromElement left = (FromElement) parent;
|
||||
FromElement right = (FromElement) d;
|
||||
if ( right.getRealOrigin() == left ) {
|
||||
// right represents a joins originating from left...
|
||||
if ( right.getJoinSequence() != null && right.getJoinSequence().isThetaStyle() ) {
|
||||
|
@ -373,7 +381,10 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
|
||||
@Override
|
||||
protected String renderOrderByElement(String expression, String order, String nulls) {
|
||||
final NullPrecedence nullPrecedence = NullPrecedence.parse( nulls, sessionFactory.getSettings().getDefaultNullPrecedence() );
|
||||
final NullPrecedence nullPrecedence = NullPrecedence.parse( nulls,
|
||||
sessionFactory.getSettings()
|
||||
.getDefaultNullPrecedence()
|
||||
);
|
||||
return sessionFactory.getDialect().renderOrderByElement( expression, null, order, nullPrecedence );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,7 @@ public class MultiTableDeleteExecutor implements StatementExecutor {
|
|||
private final MultiTableBulkIdStrategy.DeleteHandler deleteHandler;
|
||||
|
||||
public MultiTableDeleteExecutor(HqlSqlWalker walker) {
|
||||
MultiTableBulkIdStrategy strategy = walker.getSessionFactoryHelper()
|
||||
.getFactory()
|
||||
.getSettings()
|
||||
final MultiTableBulkIdStrategy strategy = walker.getSessionFactoryHelper().getFactory().getSettings()
|
||||
.getMultiTableBulkIdStrategy();
|
||||
this.deleteHandler = strategy.buildDeleteHandler( walker.getSessionFactoryHelper().getFactory(), walker );
|
||||
}
|
||||
|
|
|
@ -40,10 +40,6 @@ import antlr.collections.AST;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractNullnessCheckNode extends UnaryLogicOperatorNode {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
// TODO : this really needs to be delayed unitl after we definitively know the operand node type;
|
||||
|
|
|
@ -37,7 +37,6 @@ import antlr.collections.AST;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractRestrictableStatement extends AbstractStatement implements RestrictableStatement {
|
||||
|
||||
private FromClause fromClause;
|
||||
private AST whereClause;
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ import antlr.collections.AST;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AssignmentSpecification {
|
||||
|
||||
private final Set tableNames;
|
||||
private final ParameterSpecification[] hqlParameters;
|
||||
private final AST eq;
|
||||
|
|
|
@ -37,9 +37,10 @@ import antlr.SemanticException;
|
|||
*/
|
||||
public class BinaryArithmeticOperatorNode extends AbstractSelectExpression implements BinaryOperatorNode, DisplayableNode {
|
||||
|
||||
@Override
|
||||
public void initialize() throws SemanticException {
|
||||
Node lhs = getLeftHandOperand();
|
||||
Node rhs = getRightHandOperand();
|
||||
final Node lhs = getLeftHandOperand();
|
||||
final Node rhs = getRightHandOperand();
|
||||
if ( lhs == null ) {
|
||||
throw new SemanticException( "left-hand operand of a binary operator was null" );
|
||||
}
|
||||
|
@ -47,8 +48,8 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
throw new SemanticException( "right-hand operand of a binary operator was null" );
|
||||
}
|
||||
|
||||
Type lhType = ( lhs instanceof SqlNode ) ? ( ( SqlNode ) lhs ).getDataType() : null;
|
||||
Type rhType = ( rhs instanceof SqlNode ) ? ( ( SqlNode ) rhs ).getDataType() : null;
|
||||
final Type lhType = ( lhs instanceof SqlNode ) ? ( ( SqlNode ) lhs ).getDataType() : null;
|
||||
final Type rhType = ( rhs instanceof SqlNode ) ? ( ( SqlNode ) rhs ).getDataType() : null;
|
||||
|
||||
if ( ExpectedTypeAwareNode.class.isAssignableFrom( lhs.getClass() ) && rhType != null ) {
|
||||
Type expectedType = null;
|
||||
|
@ -92,6 +93,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
* the types of the operands. Sometimes we don't know both types,
|
||||
* if, for example, one is a parameter.
|
||||
*/
|
||||
@Override
|
||||
public Type getDataType() {
|
||||
if ( super.getDataType() == null ) {
|
||||
super.setDataType( resolveDataType() );
|
||||
|
@ -152,11 +154,9 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
}
|
||||
|
||||
private boolean isDateTimeType(Type type) {
|
||||
if ( type == null ) {
|
||||
return false;
|
||||
}
|
||||
return java.util.Date.class.isAssignableFrom( type.getReturnedClass() ) ||
|
||||
java.util.Calendar.class.isAssignableFrom( type.getReturnedClass() );
|
||||
return type != null
|
||||
&& ( java.util.Date.class.isAssignableFrom( type.getReturnedClass() )
|
||||
|| java.util.Calendar.class.isAssignableFrom( type.getReturnedClass() ) );
|
||||
}
|
||||
|
||||
private Type resolveDateTimeArithmeticResultType(Type lhType, Type rhType) {
|
||||
|
@ -197,6 +197,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScalarColumnText(int i) throws SemanticException {
|
||||
ColumnHelper.generateSingleScalarColumn( this, i );
|
||||
}
|
||||
|
@ -206,6 +207,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
*
|
||||
* @return The left-hand operand
|
||||
*/
|
||||
@Override
|
||||
public Node getLeftHandOperand() {
|
||||
return ( Node ) getFirstChild();
|
||||
}
|
||||
|
@ -215,10 +217,12 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
*
|
||||
* @return The right-hand operand
|
||||
*/
|
||||
@Override
|
||||
public Node getRightHandOperand() {
|
||||
return ( Node ) getFirstChild().getNextSibling();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return "{dataType=" + getDataType() + "}";
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public class BinaryLogicOperatorNode extends HqlSqlWalkerNode implements BinaryO
|
|||
* Performs the operator node initialization by seeking out any parameter
|
||||
* nodes and setting their expected type, if possible.
|
||||
*/
|
||||
@Override
|
||||
public void initialize() throws SemanticException {
|
||||
Node lhs = getLeftHandOperand();
|
||||
if ( lhs == null ) {
|
||||
|
@ -139,18 +140,25 @@ public class BinaryLogicOperatorNode extends HqlSqlWalkerNode implements BinaryO
|
|||
? null
|
||||
: ( ( ParameterNode ) getRightHandOperand() ).getHqlParameterSpecification();
|
||||
|
||||
translate( valueElements, comparisonType, comparisonText,
|
||||
lhsElementTexts, rhsElementTexts,
|
||||
translate(
|
||||
valueElements,
|
||||
comparisonType,
|
||||
comparisonText,
|
||||
lhsElementTexts,
|
||||
rhsElementTexts,
|
||||
lhsEmbeddedCompositeParameterSpecification,
|
||||
rhsEmbeddedCompositeParameterSpecification, this );
|
||||
rhsEmbeddedCompositeParameterSpecification,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
protected void translate( int valueElements, int comparisonType,
|
||||
protected void translate(
|
||||
int valueElements, int comparisonType,
|
||||
String comparisonText, String[] lhsElementTexts,
|
||||
String[] rhsElementTexts,
|
||||
ParameterSpecification lhsEmbeddedCompositeParameterSpecification,
|
||||
ParameterSpecification rhsEmbeddedCompositeParameterSpecification,
|
||||
AST container ) {
|
||||
AST container) {
|
||||
for ( int i = valueElements - 1; i > 0; i-- ) {
|
||||
if ( i == 1 ) {
|
||||
AST op1 = getASTFactory().create( comparisonType, comparisonText );
|
||||
|
@ -168,7 +176,7 @@ public class BinaryLogicOperatorNode extends HqlSqlWalkerNode implements BinaryO
|
|||
|
||||
// "pass along" our initial embedded parameter node(s) to the first generated
|
||||
// sql fragment so that it can be handled later for parameter binding...
|
||||
SqlFragment fragment = ( SqlFragment ) lhs1;
|
||||
SqlFragment fragment = (SqlFragment) lhs1;
|
||||
if ( lhsEmbeddedCompositeParameterSpecification != null ) {
|
||||
fragment.addEmbeddedParameter( lhsEmbeddedCompositeParameterSpecification );
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ public class ComponentJoin extends FromElement {
|
|||
return componentType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Type getDataType() {
|
||||
return getComponentType();
|
||||
|
@ -119,25 +118,16 @@ public class ComponentJoin extends FromElement {
|
|||
return getComponentType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public QueryableCollection getQueryableCollection() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PropertyMapping getPropertyMapping(String propertyName) {
|
||||
return propertyMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Type getPropertyType(String propertyName, String propertyPath) {
|
||||
int index = getComponentType().getPropertyIndex( propertyName );
|
||||
|
@ -165,10 +155,12 @@ public class ComponentJoin extends FromElement {
|
|||
}
|
||||
|
||||
private final class ComponentPropertyMapping implements PropertyMapping {
|
||||
@Override
|
||||
public Type getType() {
|
||||
return getComponentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type toType(String propertyName) throws QueryException {
|
||||
return getBasePropertyMapping().toType( getPropertyPath( propertyName ) );
|
||||
}
|
||||
|
@ -177,10 +169,12 @@ public class ComponentJoin extends FromElement {
|
|||
return getComponentPath() + '.' + propertyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toColumns(String alias, String propertyName) throws QueryException {
|
||||
return getBasePropertyMapping().toColumns( alias, getPropertyPath( propertyName ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException {
|
||||
return getBasePropertyMapping().toColumns( getPropertyPath( propertyName ) );
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
private boolean isMap;
|
||||
private boolean isList;
|
||||
|
||||
@Override
|
||||
public ResultTransformer getResultTransformer() {
|
||||
if ( constructor != null ) {
|
||||
return new AliasToBeanConstructorResultTransformer( constructor );
|
||||
|
@ -69,6 +70,7 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
|
||||
private String[] aggregatedAliases;
|
||||
|
||||
@Override
|
||||
public String[] getAggregatedAliases() {
|
||||
if ( aggregatedAliases == null ) {
|
||||
aggregatedAliases = buildAggregatedAliases();
|
||||
|
@ -78,14 +80,15 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
|
||||
private String[] buildAggregatedAliases() {
|
||||
SelectExpression[] selectExpressions = collectSelectExpressions();
|
||||
String[] aliases = new String[selectExpressions.length] ;
|
||||
for ( int i=0; i<selectExpressions.length; i++ ) {
|
||||
String[] aliases = new String[selectExpressions.length];
|
||||
for ( int i = 0; i < selectExpressions.length; i++ ) {
|
||||
String alias = selectExpressions[i].getAlias();
|
||||
aliases[i] = alias==null ? Integer.toString(i) : alias;
|
||||
aliases[i] = alias == null ? Integer.toString( i ) : alias;
|
||||
}
|
||||
return aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScalarColumn(int i) throws SemanticException {
|
||||
SelectExpression[] selectExpressions = collectSelectExpressions();
|
||||
// Invoke setScalarColumnText on each constructor argument.
|
||||
|
@ -95,10 +98,12 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScalarColumnIndex() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScalarColumnText(int i) throws SemanticException {
|
||||
SelectExpression[] selectExpressions = collectSelectExpressions();
|
||||
// Invoke setScalarColumnText on each constructor argument.
|
||||
|
@ -140,7 +145,7 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
|
||||
public void prepare() throws SemanticException {
|
||||
constructorArgumentTypes = resolveConstructorArgumentTypes();
|
||||
String path = ( ( PathNode ) getFirstChild() ).getPath();
|
||||
String path = ( (PathNode) getFirstChild() ).getPath();
|
||||
if ( "map".equals( path.toLowerCase() ) ) {
|
||||
isMap = true;
|
||||
resultType = Map.class;
|
||||
|
@ -159,7 +164,7 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
SelectExpression[] argumentExpressions = collectSelectExpressions();
|
||||
if ( argumentExpressions == null ) {
|
||||
// return an empty Type array
|
||||
return new Type[]{};
|
||||
return new Type[] {};
|
||||
}
|
||||
|
||||
Type[] types = new Type[argumentExpressions.length];
|
||||
|
@ -179,10 +184,10 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
Class holderClass = ReflectHelper.classForName( className );
|
||||
return ReflectHelper.getConstructor( holderClass, constructorArgumentTypes );
|
||||
}
|
||||
catch ( ClassNotFoundException e ) {
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new DetailedSemanticException( "Unable to locate class [" + className + "]", e );
|
||||
}
|
||||
catch ( PropertyNotFoundException e ) {
|
||||
catch (PropertyNotFoundException e) {
|
||||
// this is the exception returned by ReflectHelper.getConstructor() if it cannot
|
||||
// locate an appropriate constructor
|
||||
throw new DetailedSemanticException( formatMissingContructorExceptionMessage( className ), e );
|
||||
|
@ -198,8 +203,10 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
: constructorArgumentTypes[j].getReturnedClass().getName();
|
||||
}
|
||||
String formattedList = params.length == 0 ? "no arguments constructor" : StringHelper.join( ", ", params );
|
||||
return String.format( "Unable to locate appropriate constructor on class [%s]. Expected arguments are: %s",
|
||||
className, formattedList );
|
||||
return String.format(
|
||||
"Unable to locate appropriate constructor on class [%s]. Expected arguments are: %s",
|
||||
className, formattedList
|
||||
);
|
||||
}
|
||||
|
||||
public Constructor getConstructor() {
|
||||
|
@ -210,32 +217,39 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
return Arrays.asList( constructorArgumentTypes );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getAggregatedSelectionTypeList() {
|
||||
return getConstructorArgumentTypeList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FromElement getFromElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstructor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReturnableEntity() throws SemanticException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScalar() {
|
||||
// Constructors are always considered scalar results.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlias(String alias) {
|
||||
throw new UnsupportedOperationException("constructor may not be aliased");
|
||||
throw new UnsupportedOperationException( "constructor may not be aliased" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlias() {
|
||||
throw new UnsupportedOperationException("constructor may not be aliased");
|
||||
throw new UnsupportedOperationException( "constructor may not be aliased" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,35 +20,28 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.internal.ast.tree;
|
||||
|
||||
import org.hibernate.hql.internal.antlr.HqlSqlTokenTypes;
|
||||
import org.hibernate.hql.internal.antlr.SqlTokenTypes;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Defines a top-level AST node representing an HQL delete statement.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class DeleteStatement extends AbstractRestrictableStatement {
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( DeleteStatement.class );
|
||||
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, DeleteStatement.class.getName());
|
||||
|
||||
/**
|
||||
* @see org.hibernate.hql.internal.ast.tree.Statement#getStatementType()
|
||||
*/
|
||||
@Override
|
||||
public int getStatementType() {
|
||||
return HqlSqlTokenTypes.DELETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.hibernate.hql.internal.ast.tree.Statement#needsExecutor()
|
||||
*/
|
||||
@Override
|
||||
public boolean needsExecutor() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,7 +20,6 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.internal.ast.tree;
|
||||
|
||||
|
@ -61,9 +60,13 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
public static boolean useThetaStyleImplicitJoins;
|
||||
public static boolean REGRESSION_STYLE_JOIN_SUPPRESSION;
|
||||
|
||||
public static interface IllegalCollectionDereferenceExceptionBuilder {
|
||||
public QueryException buildIllegalCollectionDereferenceException(String collectionPropertyName, FromReferenceNode lhs);
|
||||
public QueryException buildIllegalCollectionDereferenceException(
|
||||
String collectionPropertyName,
|
||||
FromReferenceNode lhs);
|
||||
}
|
||||
|
||||
public static final IllegalCollectionDereferenceExceptionBuilder DEF_ILLEGAL_COLL_DEREF_EXCP_BUILDER = new IllegalCollectionDereferenceExceptionBuilder() {
|
||||
public QueryException buildIllegalCollectionDereferenceException(String propertyName, FromReferenceNode lhs) {
|
||||
String lhsPath = ASTUtil.getPathText( lhs );
|
||||
|
@ -122,6 +125,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
* Sets the join type for this '.' node structure.
|
||||
*
|
||||
* @param joinType The type of join to use.
|
||||
*
|
||||
* @see JoinFragment
|
||||
*/
|
||||
public void setJoinType(JoinType joinType) {
|
||||
|
@ -164,8 +168,8 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
*/
|
||||
@Override
|
||||
public void resolveFirstChild() throws SemanticException {
|
||||
FromReferenceNode lhs = ( FromReferenceNode ) getFirstChild();
|
||||
SqlNode property = ( SqlNode ) lhs.getNextSibling();
|
||||
FromReferenceNode lhs = (FromReferenceNode) getFirstChild();
|
||||
SqlNode property = (SqlNode) lhs.getNextSibling();
|
||||
|
||||
// Set the attributes of the property reference expression.
|
||||
String propName = property.getText();
|
||||
|
@ -188,12 +192,12 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
return;
|
||||
}
|
||||
Type propertyType = prepareLhs(); // Prepare the left hand side and get the data type.
|
||||
if ( propertyType!=null && propertyType.isCollectionType() ) {
|
||||
resolveIndex(null);
|
||||
if ( propertyType != null && propertyType.isCollectionType() ) {
|
||||
resolveIndex( null );
|
||||
}
|
||||
else {
|
||||
resolveFirstChild();
|
||||
super.resolve(generateJoin, implicitJoin);
|
||||
super.resolve( generateJoin, implicitJoin );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +207,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
return;
|
||||
}
|
||||
Type propertyType = prepareLhs(); // Prepare the left hand side and get the data type.
|
||||
dereferenceCollection( ( CollectionType ) propertyType, true, true, null, parent );
|
||||
dereferenceCollection( (CollectionType) propertyType, true, true, null, parent );
|
||||
}
|
||||
|
||||
public void resolve(boolean generateJoin, boolean implicitJoin, String classAlias, AST parent)
|
||||
|
@ -234,17 +238,17 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
else if ( propertyType.isEntityType() ) {
|
||||
// The property is another class..
|
||||
checkLhsIsNotCollection();
|
||||
dereferenceEntity( ( EntityType ) propertyType, implicitJoin, classAlias, generateJoin, parent );
|
||||
dereferenceEntity( (EntityType) propertyType, implicitJoin, classAlias, generateJoin, parent );
|
||||
initText();
|
||||
}
|
||||
else if ( propertyType.isCollectionType() ) {
|
||||
// The property is a collection...
|
||||
checkLhsIsNotCollection();
|
||||
dereferenceCollection( ( CollectionType ) propertyType, implicitJoin, false, classAlias, parent );
|
||||
dereferenceCollection( (CollectionType) propertyType, implicitJoin, false, classAlias, parent );
|
||||
}
|
||||
else {
|
||||
// Otherwise, this is a primitive type.
|
||||
if ( ! CollectionProperties.isAnyCollectionProperty( propertyName ) ) {
|
||||
if ( !CollectionProperties.isAnyCollectionProperty( propertyName ) ) {
|
||||
checkLhsIsNotCollection();
|
||||
}
|
||||
dereferenceType = DereferenceType.PRIMITIVE;
|
||||
|
@ -268,17 +272,24 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
return getDataType();
|
||||
}
|
||||
|
||||
private void dereferenceCollection(CollectionType collectionType, boolean implicitJoin, boolean indexed, String classAlias, AST parent)
|
||||
private void dereferenceCollection(
|
||||
CollectionType collectionType,
|
||||
boolean implicitJoin,
|
||||
boolean indexed,
|
||||
String classAlias,
|
||||
AST parent)
|
||||
throws SemanticException {
|
||||
|
||||
dereferenceType = DereferenceType.COLLECTION;
|
||||
String role = collectionType.getRole();
|
||||
|
||||
//foo.bars.size (also handles deprecated stuff like foo.bars.maxelement for backwardness)
|
||||
boolean isSizeProperty = getNextSibling()!=null &&
|
||||
boolean isSizeProperty = getNextSibling() != null &&
|
||||
CollectionProperties.isAnyCollectionProperty( getNextSibling().getText() );
|
||||
|
||||
if ( isSizeProperty ) indexed = true; //yuck!
|
||||
if ( isSizeProperty ) {
|
||||
indexed = true; //yuck!
|
||||
}
|
||||
|
||||
QueryableCollection queryableCollection = getSessionFactoryHelper().requireQueryableCollection( role );
|
||||
String propName = getPath();
|
||||
|
@ -305,7 +316,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
useAlias = true;
|
||||
}
|
||||
}
|
||||
if ( ! useAlias ) {
|
||||
if ( !useAlias ) {
|
||||
final String lhsTableName = lhsFromElement.getQueryable().getTableName();
|
||||
columns = getFromElement().toColumns( lhsTableName, propertyPath, false, true );
|
||||
}
|
||||
|
@ -330,8 +341,8 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
setFromElement( elem ); // This 'dot' expression now refers to the resulting from element.
|
||||
|
||||
if ( isSizeProperty ) {
|
||||
elem.setText("");
|
||||
elem.setUseWhereFragment(false);
|
||||
elem.setText( "" );
|
||||
elem.setUseWhereFragment( false );
|
||||
}
|
||||
|
||||
if ( !implicitJoin ) {
|
||||
|
@ -343,7 +354,12 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
getWalker().addQuerySpaces( queryableCollection.getCollectionSpaces() ); // Always add the collection's query spaces.
|
||||
}
|
||||
|
||||
private void dereferenceEntity(EntityType entityType, boolean implicitJoin, String classAlias, boolean generateJoin, AST parent) throws SemanticException {
|
||||
private void dereferenceEntity(
|
||||
EntityType entityType,
|
||||
boolean implicitJoin,
|
||||
String classAlias,
|
||||
boolean generateJoin,
|
||||
AST parent) throws SemanticException {
|
||||
checkForCorrelatedSubquery( "dereferenceEntity" );
|
||||
// three general cases we check here as to whether to render a physical SQL join:
|
||||
// 1) is our parent a DotNode as well? If so, our property reference is
|
||||
|
@ -373,11 +389,11 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
// our parent is another dot node, meaning we are being further dereferenced.
|
||||
// thus we need to generate a join unless the parent refers to the associated
|
||||
// entity's PK (because 'our' table would know the FK).
|
||||
parentAsDotNode = ( DotNode ) parent;
|
||||
parentAsDotNode = (DotNode) parent;
|
||||
property = parentAsDotNode.propertyName;
|
||||
joinIsNeeded = generateJoin && !isReferenceToPrimaryKey( parentAsDotNode.propertyName, entityType );
|
||||
}
|
||||
else if ( ! getWalker().isSelectStatement() ) {
|
||||
else if ( !getWalker().isSelectStatement() ) {
|
||||
// in non-select queries, the only time we should need to join is if we are in a subquery from clause
|
||||
joinIsNeeded = getWalker().getCurrentStatementType() == SqlTokenTypes.SELECT && getWalker().isInFrom();
|
||||
}
|
||||
|
@ -411,7 +427,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
propertyName,
|
||||
getFromElement().getClassName(),
|
||||
classAlias == null ? "<no alias>" : classAlias,
|
||||
ASTUtil.getDebugString(parent)
|
||||
ASTUtil.getDebugString( parent )
|
||||
);
|
||||
}
|
||||
// Create a new FROM node for the referenced class.
|
||||
|
@ -461,7 +477,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
// always (?) ok to reuse.
|
||||
boolean useFoundFromElement = found && ( elem.isImplied() || areSame( classAlias, elem.getClassAlias() ) );
|
||||
|
||||
if ( ! useFoundFromElement ) {
|
||||
if ( !useFoundFromElement ) {
|
||||
// If this is an implied join in a from element, then use the impled join type which is part of the
|
||||
// tree parser's state (set by the gramamar actions).
|
||||
JoinSequence joinSequence = getSessionFactoryHelper()
|
||||
|
@ -516,7 +532,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
private void setImpliedJoin(FromElement elem) {
|
||||
this.impliedJoin = elem;
|
||||
if ( getFirstChild().getType() == SqlTokenTypes.DOT ) {
|
||||
DotNode dotLhs = ( DotNode ) getFirstChild();
|
||||
DotNode dotLhs = (DotNode) getFirstChild();
|
||||
if ( dotLhs.getImpliedJoin() != null ) {
|
||||
this.impliedJoin = dotLhs.getImpliedJoin();
|
||||
}
|
||||
|
@ -541,6 +557,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
*
|
||||
* @param propertyName The name of the property to check.
|
||||
* @param owningType The type represeting the entity "owning" the property
|
||||
*
|
||||
* @return True if propertyName references the entity's (owningType->associatedEntity)
|
||||
* primary key; false otherwise.
|
||||
*/
|
||||
|
@ -556,9 +573,11 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
// 1) the property-name matches the explicitly identifier property name
|
||||
// 2) the property-name matches the implicit 'id' property name
|
||||
// the referenced node text is the special 'id'
|
||||
if (EntityPersister.ENTITY_ID.equals(propertyName)) return owningType.isReferenceToPrimaryKey();
|
||||
String keyPropertyName = getSessionFactoryHelper().getIdentifierOrUniqueKeyPropertyName(owningType);
|
||||
return keyPropertyName != null && keyPropertyName.equals(propertyName) && owningType.isReferenceToPrimaryKey();
|
||||
if ( EntityPersister.ENTITY_ID.equals( propertyName ) ) {
|
||||
return owningType.isReferenceToPrimaryKey();
|
||||
}
|
||||
String keyPropertyName = getSessionFactoryHelper().getIdentifierOrUniqueKeyPropertyName( owningType );
|
||||
return keyPropertyName != null && keyPropertyName.equals( propertyName ) && owningType.isReferenceToPrimaryKey();
|
||||
}
|
||||
|
||||
private void checkForCorrelatedSubquery(String methodName) {
|
||||
|
@ -577,6 +596,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
throw ILLEGAL_COLL_DEREF_EXCP_BUILDER.buildIllegalCollectionDereferenceException( propertyName, getLhs() );
|
||||
}
|
||||
}
|
||||
|
||||
private void dereferenceComponent(AST parent) {
|
||||
dereferenceType = DereferenceType.COMPONENT;
|
||||
setPropertyNameAndPath( parent );
|
||||
|
@ -586,9 +606,11 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
// special shortcut for id properties, skip the join!
|
||||
// this must only occur at the _end_ of a path expression
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "dereferenceShortcut() : property %s in %s does not require a join.",
|
||||
LOG.debugf(
|
||||
"dereferenceShortcut() : property %s in %s does not require a join.",
|
||||
propertyName,
|
||||
getFromElement().getClassName() );
|
||||
getFromElement().getClassName()
|
||||
);
|
||||
}
|
||||
|
||||
initText();
|
||||
|
@ -603,7 +625,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
|
||||
private void setPropertyNameAndPath(AST parent) {
|
||||
if ( isDotNode( parent ) ) {
|
||||
DotNode dotNode = ( DotNode ) parent;
|
||||
DotNode dotNode = (DotNode) parent;
|
||||
AST lhs = dotNode.getFirstChild();
|
||||
AST rhs = lhs.getNextSibling();
|
||||
propertyName = rhs.getText();
|
||||
|
@ -620,7 +642,9 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
public Type getDataType() {
|
||||
if ( super.getDataType() == null ) {
|
||||
FromElement fromElement = getLhs().getFromElement();
|
||||
if ( fromElement == null ) return null;
|
||||
if ( fromElement == null ) {
|
||||
return null;
|
||||
}
|
||||
// If the lhs is a collection, use CollectionPropertyMapping
|
||||
Type propertyType = fromElement.getPropertyType( propertyName, propertyPath );
|
||||
LOG.debugf( "getDataType() : %s -> %s", propertyPath, propertyType );
|
||||
|
@ -638,7 +662,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
}
|
||||
|
||||
public FromReferenceNode getLhs() {
|
||||
FromReferenceNode lhs = ( ( FromReferenceNode ) getFirstChild() );
|
||||
FromReferenceNode lhs = ( (FromReferenceNode) getFirstChild() );
|
||||
if ( lhs == null ) {
|
||||
throw new IllegalStateException( "DOT node with no left-hand-side!" );
|
||||
}
|
||||
|
@ -658,7 +682,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
path = getText();
|
||||
}
|
||||
else {
|
||||
SqlNode rhs = ( SqlNode ) lhs.getNextSibling();
|
||||
SqlNode rhs = (SqlNode) lhs.getNextSibling();
|
||||
path = lhs.getPath() + "." + rhs.getOriginalText();
|
||||
}
|
||||
}
|
||||
|
@ -681,10 +705,10 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
*/
|
||||
public void resolveSelectExpression() throws SemanticException {
|
||||
if ( getWalker().isShallowQuery() || getWalker().getCurrentFromClause().isSubQuery() ) {
|
||||
resolve(false, true);
|
||||
resolve( false, true );
|
||||
}
|
||||
else {
|
||||
resolve(true, false);
|
||||
resolve( true, false );
|
||||
Type type = getDataType();
|
||||
if ( type.isEntityType() ) {
|
||||
FromElement fromElement = getFromElement();
|
||||
|
@ -703,7 +727,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
FromReferenceNode lhs = getLhs();
|
||||
while ( lhs != null ) {
|
||||
checkSubclassOrSuperclassPropertyReference( lhs, lhs.getNextSibling().getText() );
|
||||
lhs = ( FromReferenceNode ) lhs.getFirstChild();
|
||||
lhs = (FromReferenceNode) lhs.getFirstChild();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue