Mike Whitis
Mike Whitis

Reputation: 128

Missing SELECT statement using QueryDSL with Spring QueryDslJdbcTemplate causing bad SQL Grammar error

I'm using Spring Data JDBC Extensions 1.0.0 and QueryDSL 2.9.0 to do a simple query from my database.

My query is created like:

        QFaq qFaq = QFaq.faq;
    SQLQuery sqlQuery = jdbcTemplate.newSqlQuery().from(qFaq);
    return jdbcTemplate.query(sqlQuery, new FaqRowMapper());

The problem is that the SQL code that's generated is just

from FAQ FAQ

It's missing a SELECT * at the beginning.

Using an Oracle DB if that matters.

Any ideas?

Thanks

Upvotes: 1

Views: 789

Answers (1)

Timo Westkämper
Timo Westkämper

Reputation: 22200

You don't provide any items for the select part. I assume that you use this method

query(com.mysema.query.sql.SQLQuery sqlQuery, RowMapper<T> rowMapper, com.mysema.query.types.Expression<?>... projection) 

After the query and rowMapper you need to provide the expressions for the select part, e.g. qFaq.id, qFaq.name etc.

Upvotes: 1

Related Questions