Slow query execution migrating from Hibernate 5.1.2 to 7.0.0

We have migrated from Java 17->21 & have migrated the hibernate version from v5 to v7.
We are still using hibernate.cfg.xml for the mappings.
db connection properties are picked from the Tomcat context file. we are not using any persistence xml file.
However we are seeing the slowness in the application after the migration.
I see the database queries translation/execution is taking more time. Even the opening/closing of a db connection is little slower.
For ex: retreiving user profile previous version takes ~600milliseconds. now its taking 1500 milliseconds with the same piece of code.
I cannot attach the logs here for both the version. how to proceed on this.

Initial query translation might take little longer, but as soon as everything is cached, then ORM 7 should be faster.

I would start by identifying the queries that are executed. Are ORM 5 and 7 producing the same amount of queries? Are the queries more or less the same? How are you building these queries? JPA Criteria or HQL?

When you ruled out the actual SQL, you can attach JFR or async-profiler to produce a flamegraph for the time you’re running your tests and share that with us.

We can only help you if you share a reproducer with us or flamegraphs, as we have no other way to understand what is going on.

I am trying with just 1 query retrieving the user profile, it is using HQL for the retrieval, even though i retrigger it multiple times the translation speed is same.
The query that is generated in both cases is same.Please note i am not using any cache
The difference between the query execution & the extracted values in v5 (basicextractor) is 30 milliseconds. but in v7(JdbcExtractingLogging) its taking around 160milliseconds.

I have tried async-profiler but it needs either mac/linux to function but i am using the windows machine.
Anyother way to generate the flamegraphs

Like I wrote, you can generate flamegraphs also with JFR and IntelliJ also supports using the async profiler on Windows. How do you measure the time difference? By comparing timestamps that are sent through logging? If so, that’s probably not a good idea to measure performance as ORM 7 might be logging completely different things at different times.
If you want to measure performance difference, try to run e.g. a throughput test and see how many successful responses you get with both ORM 5 and 6.
Also, Java code needs some time to warm up, so it would be best if you do a warmup run e.g. 30 seconds.

I am comparing the Logging timestamps from start of the query invocation till the db results are retrieved. I have triggered the same request multiple times even then its the same issue there is no improvement in the performance. I am struggling with gettingflamegraphs with jfr, there is no direct method involved.
If i can send the logs of the query in both the cases,can you be able to help me in identifying the root cause..

It’s hard to say for sure, but logs would definitely help. If you need more targeted help, consider opening a Red Hat support ticket.