HHH-6714 Parentheses dissapear in HQL query where they should stay

This commit is contained in:
Strong Liu 2011-11-04 03:24:12 +08:00
parent 3c3482bd59
commit 77107cc35a
7 changed files with 64 additions and 45 deletions

View File

@ -361,7 +361,7 @@ arithmeticExpr
: additiveExpr : additiveExpr
| multiplicativeExpr | multiplicativeExpr
// | #(CONCAT { out("("); } expr ( { out("||"); } expr )+ { out(")"); } ) // | #(CONCAT { out("("); } expr ( { out("||"); } expr )+ { out(")"); } )
| #(UNARY_MINUS { out("-"); } expr) | #(UNARY_MINUS { out("-"); } nestedExprAfterMinusDiv)
| caseExpr | caseExpr
; ;

View File

@ -123,7 +123,7 @@ public final class Hibernate {
public static LobCreator getLobCreator(SessionImplementor session) { public static LobCreator getLobCreator(SessionImplementor session) {
return session.getFactory() return session.getFactory()
.getJdbcServices() .getJdbcServices()
.getLobCreator( ( LobCreationContext ) session ); .getLobCreator( session );
} }
/** /**

View File

@ -34,7 +34,7 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
/** /**
* Helper to extract type innformation from {@link DatabaseMetaData JDBC metadata} * Helper to extract type information from {@link DatabaseMetaData JDBC metadata}
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -111,6 +111,9 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
@Override @Override
protected void out(String s) { protected void out(String s) {
if(s.contains( "countaaa" )){
System.out.println("------------");
}
writer.clause( s ); writer.clause( s );
} }

View File

@ -159,9 +159,7 @@ import org.hibernate.type.Type;
* *
* @author Gavin King * @author Gavin King
*/ */
public final class SessionImpl public final class SessionImpl extends AbstractSessionImpl implements EventSource {
extends AbstractSessionImpl
implements EventSource, org.hibernate.Session, TransactionContext, LobCreationContext {
// todo : need to find a clean way to handle the "event source" role // todo : need to find a clean way to handle the "event source" role
// a separate class responsible for generating/dispatching events just duplicates most of the Session methods... // a separate class responsible for generating/dispatching events just duplicates most of the Session methods...

View File

@ -36,7 +36,6 @@ import org.hibernate.stat.spi.StatisticsImplementor;
*/ */
public class TransactionEnvironmentImpl implements TransactionEnvironment { public class TransactionEnvironmentImpl implements TransactionEnvironment {
private final SessionFactoryImpl sessionFactory; private final SessionFactoryImpl sessionFactory;
private final transient StatisticsImplementor statisticsImplementor; private final transient StatisticsImplementor statisticsImplementor;
private final transient ServiceRegistry serviceRegistry; private final transient ServiceRegistry serviceRegistry;
private final transient JdbcServices jdbcServices; private final transient JdbcServices jdbcServices;
@ -50,7 +49,6 @@ public class TransactionEnvironmentImpl implements TransactionEnvironment {
this.jdbcServices = serviceRegistry.getService( JdbcServices.class ); this.jdbcServices = serviceRegistry.getService( JdbcServices.class );
this.jtaPlatform = serviceRegistry.getService( JtaPlatform.class ); this.jtaPlatform = serviceRegistry.getService( JtaPlatform.class );
this.transactionFactory = serviceRegistry.getService( TransactionFactory.class ); this.transactionFactory = serviceRegistry.getService( TransactionFactory.class );
} }
@Override @Override

View File

@ -634,6 +634,26 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
return count; return count;
} }
@Test
@TestForIssue( jiraKey = "HHH-6714" )
public void testUnaryMinus(){
Session s = openSession();
s.beginTransaction();
Human stliu = new Human();
stliu.setIntValue( 26 );
s.persist( stliu );
s.getTransaction().commit();
s.clear();
s.beginTransaction();
List list =s.createQuery( "from Human h where -(h.intValue - 100)=74" ).list();
assertEquals( 1, list.size() );
s.getTransaction().commit();
s.close();
}
@Test @Test
public void testEntityAndOneToOneReturnedByQuery() { public void testEntityAndOneToOneReturnedByQuery() {
Session s = openSession(); Session s = openSession();