I'm currently upgrading a project from Hibernate 5 to Hibernate 6.6.1. I have a lot of legacy code that relies on the org.hibernate.criterion.Example API to perform "Query by Example" dynamically, like this:
Since createCriteria and Example.create are removed in Hibernate 6, I'm looking for the standard way to replicate this behavior using Jakarta Persistence (CriteriaBuilder). My constraints: The entity fields are private. I have many different entities, so I'm looking for a generic/reusable solution rather than manually building CriteriaBuilder predicates for every single field in every class. I'm trying to avoid raw reflection (setAccessible(true)) to stay compliant with Sonar security scans. Is there a built-in Hibernate 6 utility I missed