Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate shows question marks in SQL query [duplicate]

Tags:

java

hibernate

How do I see the actual value in query instead of questions marks? Now, I am seeing

Hibernate: inser into TABEL (ID, FORMAT, SIZE) values (?,?,?)

I want to see the real values being used instead of the question marks.

I set this in my hibernate config file and turned on the debug flag.

<property name="show_sql"> true </property>

Thank you in advance.

like image 669
codereviewanskquestions Avatar asked Apr 02 '13 23:04

codereviewanskquestions


People also ask

How do you escape a question mark in SQL query?

To keep such question marks in a SQL statement from being interpreted as positional parameters, use two question marks ( ?? ) as escape sequence. You can also use this escape sequence in a Statement , but that is not required. Specifically only in a Statement a single ( ? ) can be used as an operator.

Can we write SQL query in hibernate?

You can use native SQL to express database queries if you want to utilize database-specific features such as query hints or the CONNECT keyword in Oracle. Hibernate 3. x allows you to specify handwritten SQL, including stored procedures, for all create, update, delete, and load operations.

What does hibernate show_sql true mean?

show_sql to true tells hibernate to Write all SQL statements to console. This is an alternative to setting the log category org.


1 Answers

Hibernate uses prepared statements so you can't see the full SQL. You can set the log level for org.hibernate.type to trace to see the values bound to the parameters.

Reference

  • Hibernate 3.5 Core Documentation
    • 3.5. Logging
  • Hibernate 4.1 Core Documentation
    • 4.1. Logging

(As mentioned in/see also this answer).

like image 61
Hauke Ingmar Schmidt Avatar answered Oct 25 '22 18:10

Hauke Ingmar Schmidt