Turning on Hibernate logging

Extending discussion from Enabling Hibernate Logging

Thats really the case?

Like for instance you are merging Patients from serverA to B which a new server with Patients. However, data comes with primary keys and foreign keys set yet we use key Generator class of hibernate. Ok I tried as possible to set all these IDs like patientId to null to tell hibernate that this is a new Object. However, there some culprit id values that I could be missing to set to null which make Hibernate think that we are updating it ending up with StaleStateException

Recommended solution

Check the Hibernate logs to see which row Hibernate is trying to updated or retrieve but I don’t know how to turn the Hibernate logging

see: https://stackoverflow.com/a/2743663

CC: @dkayiwa, @wyclif, @ssmusoke

Unfortunately this is too deep into Hibernate & OpenMRS core for me :cold_sweat:

Let me hustle the whole night. Could be I could want to inspect using Reflection and see all the properties of the Patient Object at runtime.

cc: @dkayiwa

But wait, before I try the manual workaround, is this possible in Openmrs dev

@dkayiwa, @darius, @wyclif

You could save a soul some how :flushed:

@samuel34 are you trying to log them in a unit test or when running the application?

When running the application :blush:

You probably need a unit test to better debug the issue.

Append org.hibernate.SQL:debug,org.hibernate.type:trace to the log.level global property, keep in mind it gets very verbose, might be tricky to locate the actual area in the logs you need to look at, this is why a unit test would be nice to have.

1 Like

I’ve updated the value, it should be org.hibernate.SQL:debug,org.hibernate.type:trace

1 Like

How @wyclif ? using the ‘+’ something like


@wyclif your an angel, in my locale, we say “onzaadde” :smile:

Thanks you have saved a soul, I got the culprit @ssmusoke

Hopefully you figure it out, the default value is org.openmrs.api:info and you needed to add org.hibernate.SQL:debug,org.hibernate.type:trace to the value to become org.openmrs.api:info,org.hibernate.SQL:debug,org.hibernate.type:trace

@wyclif, thanks this really saved my time and the bug is resolved