Hibernate 6 migration help regarding Person.isPatient

Hello,

I am in the process of migrating openmrs-core to hibernate 6.x. One issue I have ran into is related to Person.isPatient. In the person.hbm.xml we have a patient property that is created from a formula

	    <property name="patient" type="boolean" insert="false" update="false" lazy="true">
	    	<formula>case when exists (select * from patient p where p.patient_id = person_id) then 1 else 0 end</formula> 
	    </property>

Then we have this indexed field derived from the patient bool

	@GenericField
	@NotAudited
	@IndexingDependency(derivedFrom = @ObjectPath(@PropertyValue(propertyName = "patient")))
	private boolean isPatient;

This seemed fine in hibernate 5, but in 6.x I get the below error:

Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:

Hibernate ORM mapping: 
    type 'org.openmrs.PatientIdentifier': 
        path '.patient<no value extractors>.isPatient<no value extractors>': 
            failures: 
              - value involves formulas
    type 'org.openmrs.PersonAttribute': 
        path '.person<no value extractors>.isPatient<no value extractors>': 
            failures: 
              - value involves formulas
    type 'org.openmrs.PersonName': 
        path '.person<no value extractors>.isPatient<no value extractors>': 
            failures: 
              - value involves formulas

Here is the full stack trace - https://pastebin.com/qSUHJY4K

Having trouble finding a solution for this so just posting it here if anyone has experience with formulas or any ideas?

2 Likes

After a bit more digging I think it could be related to this bug in hibernate - Jira

I haven’t seen it again after trying to upgrade to hibernate search 7, so may need to upgrade to that

3 Likes

I find no problem upgrading all the way to the latest version of Hibernate, since we are aiming for major upgrades of Java, Spring, etc.

Thanks again @k4pran for keeping the momentum on this very valuable and critical upgrade! :handshake:

3 Likes