Reputation: 31
Is there any way to convert querydsl query to native query including query parameters? Currently i have something like
QDrm qdrm = QDrm.drm;
String table = "drm";
Path<Object> userPath = new PathImpl<Object>(Object.class, table);
StringPath usernamePath = Expressions.stringPath(userPath, "accessory_id");
query.from(qdrm).where(qdrm.accessory_id.eq(100l));
query.where(qdrm.time.lt("2104-04-14"));
System.out.println(query.getSQL(usernamePath).getSQL());
This results in following output :
select drm.accessory_id
from drm
where drm.accessory_id = ? and drm.time < ?
My goal is to produce
select drm.accessory_id
from drm
where drm.accessory_id = 100 and drm.time < "2104-04-14"
The query will be executed manually or by some other means outside of QueryDSL.
Thanks for you help.
Upvotes: 3
Views: 7044
Reputation: 2648
Use the setUseLiterals() method on the Configuration or on the SQLQuery object. This has been answered here:
How to get fully materialized query from querydsl
Upvotes: 4