How can I see the query on my H2 database ?

1
0
-1

Hello,

Using the studio (so a H2 database), I want to see the different query Hibernates run when I do a "myBdmObject.findByPersistenceId()"

Is that possible to switch the H2 driver in a "log" mode, then access al the different queries?

Thank you

1 answer

1
+1
-1
This one is the BEST answer!

Hello Pierre-Yves,

Yes, this is possible.

  1. Run the H2 console from the studio via « Development / Business Data Model / Browse data »
  2. In the console, run this

SET TRACE_LEVEL_SYSTEM_OUT 3;

SET TRACE_LEVEL_FILE 3;

Execute your REST API

  1. Execute your REST API
    Then in the H2 folder (located under /workspace//h2database) a new file is created: business_data.db.trace.db
  2. Open the file

It will contain all the request

/*SQL l:275*/select directionl0_MyBDMObject_persistenceId as MyBDMObject1_1_0_, directionl0_.DIRECTION as DIRECTIO2_64_0_, directionl0_.LibelleAutres_ORDER as directio3_0_ from MyBDMObject directionl0_ where directionl0_.MyBDMObject_persistenceId=? {1: 17283};

Best,

Notifications