HHH-6714 Parentheses dissapear in HQL query where they should stay
This commit is contained in:
parent
3c3482bd59
commit
77107cc35a
|
@ -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
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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...
|
||||||
|
|
|
@ -35,50 +35,48 @@ import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
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 ServiceRegistry serviceRegistry;
|
||||||
|
private final transient JdbcServices jdbcServices;
|
||||||
|
private final transient JtaPlatform jtaPlatform;
|
||||||
|
private final transient TransactionFactory transactionFactory;
|
||||||
|
|
||||||
private final transient StatisticsImplementor statisticsImplementor;
|
public TransactionEnvironmentImpl(SessionFactoryImpl sessionFactory) {
|
||||||
private final transient ServiceRegistry serviceRegistry;
|
this.sessionFactory = sessionFactory;
|
||||||
private final transient JdbcServices jdbcServices;
|
this.statisticsImplementor = sessionFactory.getStatisticsImplementor();
|
||||||
private final transient JtaPlatform jtaPlatform;
|
this.serviceRegistry = sessionFactory.getServiceRegistry();
|
||||||
private final transient TransactionFactory transactionFactory;
|
this.jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||||
|
this.jtaPlatform = serviceRegistry.getService( JtaPlatform.class );
|
||||||
|
this.transactionFactory = serviceRegistry.getService( TransactionFactory.class );
|
||||||
|
}
|
||||||
|
|
||||||
public TransactionEnvironmentImpl(SessionFactoryImpl sessionFactory) {
|
@Override
|
||||||
this.sessionFactory = sessionFactory;
|
public SessionFactoryImplementor getSessionFactory() {
|
||||||
this.statisticsImplementor = sessionFactory.getStatisticsImplementor();
|
return sessionFactory;
|
||||||
this.serviceRegistry = sessionFactory.getServiceRegistry();
|
}
|
||||||
this.jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
|
||||||
this.jtaPlatform = serviceRegistry.getService( JtaPlatform.class );
|
|
||||||
this.transactionFactory = serviceRegistry.getService( TransactionFactory.class );
|
|
||||||
|
|
||||||
}
|
protected ServiceRegistry serviceRegistry() {
|
||||||
|
return serviceRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SessionFactoryImplementor getSessionFactory() {
|
public JdbcServices getJdbcServices() {
|
||||||
return sessionFactory;
|
return jdbcServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServiceRegistry serviceRegistry() {
|
@Override
|
||||||
return serviceRegistry;
|
public JtaPlatform getJtaPlatform() {
|
||||||
}
|
return jtaPlatform;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcServices getJdbcServices() {
|
public TransactionFactory getTransactionFactory() {
|
||||||
return jdbcServices;
|
return transactionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JtaPlatform getJtaPlatform() {
|
public StatisticsImplementor getStatisticsImplementor() {
|
||||||
return jtaPlatform;
|
return statisticsImplementor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TransactionFactory getTransactionFactory() {
|
|
||||||
return transactionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StatisticsImplementor getStatisticsImplementor() {
|
|
||||||
return statisticsImplementor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue