0

Im using Indexed parameters to pass values into native query JPA. How to change logging so I can see the actual values passed into query printed in the console? Currently values are not shown, only ?:

org.hibernate.SQL : select * from car_records where carVinNo = ?

query

   public interface CarRepository extends JpaRepository<Car, String> {
    @Query(nativeQuery = true,
           value = "select * from car_records where carVinNo >= ?1")
   }
   List<Car> retrieveCars(Long startRegTs);

I tried to config yml as suggested in other posts but nothing works so far.

logging:
  level:
    org.hibernate.SQL: DEBUG
    org.hibernate.type: TRACE
Mar
  • 363
  • 1
  • 3
  • 10
  • Logging won't replace the question marks, it will log the values in separate log messages (i.e. lines in typical configurations) – Jens Schauder Feb 09 '21 at 12:12
  • This really seems like a dup of https://stackoverflow.com/questions/1710476/how-to-print-a-query-string-with-parameter-values-when-using-hibernate but I'm leaving it open since you seem to already apply that solution, so the mistake is somewhere else. – Jens Schauder Feb 09 '21 at 12:14
  • Thats what Im looking for. The values should be printed somewhere in the console. – Mar Feb 09 '21 at 12:52
  • if you use the logging framework to write a log message to `org.hibernate.type`, does it get logged out? Can you put a break point where hibernate logs these values and step into the logging framework code to see where and why it does get discarded? – Jens Schauder Feb 09 '21 at 14:48

0 Answers0