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,7 +35,6 @@ import antlr.Token;
|
|||
* in order to keep the grammar source file clean.
|
||||
*/
|
||||
class HqlLexer extends HqlBaseLexer {
|
||||
|
||||
private boolean possibleID;
|
||||
|
||||
public HqlLexer(Reader in) {
|
||||
|
|
|
@ -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,12 +137,15 @@ 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;
|
||||
|
@ -145,9 +156,11 @@ public final class HqlParser extends HqlBaseParser {
|
|||
// ... 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,80 +188,111 @@ 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:
|
||||
case OR: {
|
||||
x.setType( AND );
|
||||
x.setText( "{and}" );
|
||||
x.setFirstChild( negateNode( x.getFirstChild() ) );
|
||||
x.getFirstChild().setNextSibling( negateNode( x.getFirstChild().getNextSibling() ) );
|
||||
return x;
|
||||
case AND:
|
||||
}
|
||||
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() );
|
||||
|
@ -256,11 +301,13 @@ public final class HqlParser extends HqlBaseParser {
|
|||
return not;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process equality expressions, clean up the subtree.
|
||||
*
|
||||
* @param x The equality expression.
|
||||
*
|
||||
* @return AST - The clean sub-tree.
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -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,7 +253,7 @@ 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.
|
||||
|
@ -253,7 +261,8 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
queryTranslatorImpl.showHqlAst( hqlParser.getAST() );
|
||||
|
||||
// Create a parameter specification for the collection filter...
|
||||
Type collectionFilterKeyType = sessionFactoryHelper.requireQueryableCollection( collectionFilterRole ).getKeyType();
|
||||
Type collectionFilterKeyType = sessionFactoryHelper.requireQueryableCollection( collectionFilterRole )
|
||||
.getKeyType();
|
||||
ParameterNode collectionFilterKeyParameter = (ParameterNode) astFactory.create( PARAM, "?" );
|
||||
CollectionFilterKeyParameterSpecification collectionFilterKeyParameterSpec = new CollectionFilterKeyParameterSpecification(
|
||||
collectionFilterRole, collectionFilterKeyType, positionalParameterCount++
|
||||
|
@ -338,10 +347,12 @@ 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 );
|
||||
|
@ -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 );
|
||||
|
@ -575,10 +591,14 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
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());
|
||||
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 );
|
||||
|
@ -653,7 +673,8 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
// Add in the EntityGraph attribute nodes.
|
||||
if ( queryTranslatorImpl.getEntityGraphQueryHint() != null ) {
|
||||
qn.getFromClause().getFromElements().addAll(
|
||||
queryTranslatorImpl.getEntityGraphQueryHint().toFromElements( qn.getFromClause(), this ) );
|
||||
queryTranslatorImpl.getEntityGraphQueryHint().toFromElements( qn.getFromClause(), this )
|
||||
);
|
||||
}
|
||||
|
||||
if ( !explicitSelect ) {
|
||||
|
@ -793,8 +814,10 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
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();
|
||||
|
@ -827,7 +850,10 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
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 );
|
||||
|
@ -837,7 +863,8 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
versionValueNode.setNextSibling(
|
||||
getASTFactory().create(
|
||||
HqlSqlTokenTypes.IDENT,
|
||||
sessionFactoryHelper.getFactory().getDialect().getTypeName( sqlTypes[0] ) )
|
||||
sessionFactoryHelper.getFactory().getDialect().getTypeName( sqlTypes[0] )
|
||||
)
|
||||
);
|
||||
processFunction( versionMethodNode, true );
|
||||
versionValueNode = versionMethodNode;
|
||||
|
@ -854,7 +881,9 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
}
|
||||
}
|
||||
else if ( isDatabaseGeneratedTimestamp( versionType ) ) {
|
||||
String functionName = sessionFactoryHelper.getFactory().getDialect().getCurrentTimestampSQLFunctionName();
|
||||
String functionName = sessionFactoryHelper.getFactory()
|
||||
.getDialect()
|
||||
.getCurrentTimestampSQLFunctionName();
|
||||
versionValueNode = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, functionName );
|
||||
}
|
||||
else {
|
||||
|
@ -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 " +
|
||||
|
@ -1017,7 +1048,10 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
|||
|
||||
@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
|
||||
|
@ -1094,7 +1128,10 @@ 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};
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,13 +140,20 @@ 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,
|
||||
|
|
|
@ -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();
|
||||
|
@ -86,6 +88,7 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS
|
|||
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.
|
||||
|
@ -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,31 +217,38 @@ 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" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlias() {
|
||||
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) {
|
||||
|
@ -268,7 +272,12 @@ 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;
|
||||
|
@ -278,7 +287,9 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
|||
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();
|
||||
|
@ -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
|
||||
|
@ -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,7 +573,9 @@ 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();
|
||||
if ( EntityPersister.ENTITY_ID.equals( propertyName ) ) {
|
||||
return owningType.isReferenceToPrimaryKey();
|
||||
}
|
||||
String keyPropertyName = getSessionFactoryHelper().getIdentifierOrUniqueKeyPropertyName( owningType );
|
||||
return keyPropertyName != null && keyPropertyName.equals( propertyName ) && owningType.isReferenceToPrimaryKey();
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue