HHH-1480 - JOIN precendence rules per SQL-99
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17869 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
260e2f2022
commit
6d5de2b0af
|
@ -1578,6 +1578,19 @@ public abstract class Dialect {
|
|||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the separator to use for definining cross joins when translating HQL queries.
|
||||
* <p/>
|
||||
* Typically this will be either [<tt> cross join </tt>] or [<tt>, </tt>]
|
||||
* <p/>
|
||||
* Note that the spaces are important!
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getCrossJoinSeparator() {
|
||||
return " cross join ";
|
||||
}
|
||||
|
||||
|
||||
// Informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -210,6 +210,13 @@ public class Oracle8iDialect extends Dialect {
|
|||
return new OracleJoinFragment();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getCrossJoinSeparator() {
|
||||
return ", ";
|
||||
}
|
||||
|
||||
/**
|
||||
* Map case support to the Oracle DECODE function. Oracle did not
|
||||
* add support for CASE until 9i.
|
||||
|
|
|
@ -40,4 +40,7 @@ public class Sybase11Dialect extends AbstractTransactSQLDialect {
|
|||
return new Sybase11JoinFragment();
|
||||
}
|
||||
|
||||
public String getCrossJoinSeparator() {
|
||||
return ", ";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,6 +139,10 @@ public class TimesTenDialect extends Dialect {
|
|||
return new OracleJoinFragment();
|
||||
}
|
||||
|
||||
public String getCrossJoinSeparator() {
|
||||
return ", ";
|
||||
}
|
||||
|
||||
// new methods in dialect3
|
||||
/*public boolean supportsForUpdateNowait() {
|
||||
return false;
|
||||
|
|
|
@ -58,6 +58,8 @@ import org.slf4j.LoggerFactory;
|
|||
public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
||||
private static final Logger log = LoggerFactory.getLogger( SqlGenerator.class );
|
||||
|
||||
public static boolean REGRESSION_STYLE_CROSS_JOINS = false;
|
||||
|
||||
/**
|
||||
* all append invocations on the buf should go through this Output instance variable.
|
||||
* The value of this variable may be temporarily substitued by sql function processing code
|
||||
|
@ -301,7 +303,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
// right represents a joins originating from left; or
|
||||
// both right and left reprersent joins originating from the same FromElement
|
||||
if ( right.getJoinSequence() != null && right.getJoinSequence().isThetaStyle() ) {
|
||||
out( ", " );
|
||||
writeCrossJoinSeparator();
|
||||
}
|
||||
else {
|
||||
out( " " );
|
||||
|
@ -309,8 +311,17 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
|
|||
}
|
||||
else {
|
||||
// these are just two unrelated table references
|
||||
writeCrossJoinSeparator();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCrossJoinSeparator() {
|
||||
if ( REGRESSION_STYLE_CROSS_JOINS ) {
|
||||
out( ", " );
|
||||
}
|
||||
else {
|
||||
out( sessionFactory.getDialect().getCrossJoinSeparator() );
|
||||
}
|
||||
}
|
||||
|
||||
protected void nestedFromFragment(AST d, AST parent) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.hibernate.hql.ast.ASTQueryTranslatorFactory;
|
|||
import org.hibernate.hql.ast.DetailedSemanticException;
|
||||
import org.hibernate.hql.ast.QuerySyntaxException;
|
||||
import org.hibernate.hql.ast.QueryTranslatorImpl;
|
||||
import org.hibernate.hql.ast.SqlGenerator;
|
||||
import org.hibernate.hql.ast.tree.ConstructorNode;
|
||||
import org.hibernate.hql.ast.tree.DotNode;
|
||||
import org.hibernate.hql.ast.tree.FromReferenceNode;
|
||||
|
@ -73,12 +74,14 @@ public class HQLTest extends QueryTranslatorTestCase {
|
|||
throw new QueryException( "illegal syntax near collection: " + propertyName );
|
||||
}
|
||||
};
|
||||
SqlGenerator.REGRESSION_STYLE_CROSS_JOINS = true;
|
||||
}
|
||||
|
||||
protected void cleanupTest() throws Exception {
|
||||
SelectClause.VERSION2_SQL = false;
|
||||
DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = false;
|
||||
DotNode.ILLEGAL_COLL_DEREF_EXCP_BUILDER = DotNode.DEF_ILLEGAL_COLL_DEREF_EXCP_BUILDER;
|
||||
SqlGenerator.REGRESSION_STYLE_CROSS_JOINS = false;
|
||||
super.cleanupTest();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue