Enabling Hibernate Logging

Hi there!

I’m trying to make ends meet on merging Patient and Encounter data, but for some reason am yet to find, I’m getting this exception on calling

patientService.save(patient);

In order to see what really causes the error, I need to turn on Hibernate logging to see whats really going on. But I don’t know how cause I’m calling this core method from my module. Is this possible?

cc: @ssmusoke, @dkayiwa

Are you able to reproduce this in a unit test?

Wat a cool morning it was, the issue was resolved :smile:

These threads are searched by others who get into similar problems. Therefore, it would be kind enough to share what the problem was and how you resolved it.

The issue was that I was trying to save a Patient object with references to rows that hibernate expected to be existing in that particular session when in actual sense they are not

Solution

I just set those foreign keys to null :slight_smile:

Existing in the session or database? Out of curiosity, you mean those fields should never be set?

No that @wyclif the context of the whole thing was that I was trying to merge Patient data using the mergepatientdata module

the above exception was caused at the Validation layer.

Sorry in the database. :slight_smile:

To be honest I still need your help here.

How To get this error

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

cc: @dkayiwa, @ssmusoke

Did you finally get around this?

Yes @dkayiwa

Whenever that happens, it is always good to say so and give a summary of how you did so. I almost wasted time trying to look for how to help you on this, not knowing that you had already solved it.

I’m sorry, could be you just missed out this

That was a different thread. Am looking at some one who comes to this thread to help, without knowing that you resolved this using another thread.

Issue context

Solution