2

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.

AndySavage
  • 1,729
  • 1
  • 20
  • 34
bayes
  • 21
  • 1
  • 2

1 Answers1

3

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

Community
  • 1
  • 1
David Fleeman
  • 2,588
  • 14
  • 17