0

I am new to hibernate, so I have no idea about this. Hibernate generates SQL query and fires on the database.

I was able to retrieve the query from the console, but I also wish to modify the query before it is fired.

So if the query is: select this_.name as name189_1_ from employee this_ where this_.name=?

  1. How can I modify this query to also get the employee id?

  2. Also since different databases support a slightly different syntax, how can I modify the syntax of the generated SQL query before it is fired on the database?

Allan
  • 25
  • 2
  • 8
  • 1
    How are you generating the query in Java? You would need to add another filter there for employee id. How did you add the filter for `name`? – clinomaniac Feb 07 '18 at 15:49
  • If you are using hibernate, except for really strange edge cases, you are shooting yourself in the foot by wanting to manually edit the generated sql. – Robert Moskal Feb 07 '18 at 16:08

1 Answers1

0

For questions 1: Add projections to the criteria. Refer Here

For question 2: You can configure the type of SQL by setting the Dialect. Refer Here

mc20
  • 1,145
  • 1
  • 10
  • 26