0

I am trying to generate Native Query like this so that I can run them separately.

Expected Query:

select test.TEST_KEY
from TEST_TABLE test
where test.TEST_CODE = 'TEST_01' and test.TEST_ACCOUNT_NUMBER = '001' and test.POSTED_UTC_DATE between timestamp '2020-06-19 23:59:59' and timestamp '2020-06-19 23:59:59'

Query I am getting

select testTable.testKey
from testTable
where testTable.testCode = 'TEST_01' and testTable.testAccountNumber = '0000124001' and testTable.postedUtcDate between timestamp '2020-06-19 23:59:59' and timestamp '2020-06-19 23:59:59'

Code

public String getTestResults(DataDto dataDto) {
        SQLTemplates templates= OracleTemplates.builder().printSchema().build();
        Configuration configuration=new Configuration(templates);
        configuration.setUseLiterals(true);
        PathBuilder<?> entityPath = new PathBuilder<>(getEntityClass(), getEntityName());
        SQLQuery<Object> sqlQuery= (SQLQuery<Object>) new SQLQuery(configuration)
                .select(entityPath.getString(getColumnMap().get("TEST_KEY")))
                .from(entityPath)
                .where(buildCondition(dataDto).build());
        sqlQuery.setUseLiterals(true);
        String query=sqlQuery.getSQL().getSQL();
        return query;
    }

I referred to this post and query DSL document however no help so far.

How to get fully materialized query from querydsl

http://www.querydsl.com/static/querydsl/3.3.1/reference/html/ch02s03.html

1 Answers1

0

There was a bug in constant rendering in old versions of QueryDSL. Please upgrade to a more recent version.

See also: https://github.com/querydsl/querydsl/issues/2017