Since SessionFactory#getClassMetadata(java.lang.Class)
was deprecated, I am not able to use ClassMetadata. I would like to access to the following methods:
org.hibernate.metadata.ClassMetadata#getNaturalIdentifierProperties
org.hibernate.metadata.ClassMetadata#hasNaturalIdentifier
According to the documentation, I should replace getClassMetada with EntityManagerFactory.getMetamodel(). However, the metamodel does not contain methods to get natural-id. I am using xml mapping for natural-id and I would like to get the property names of the natural-id to create a dynamic query.
<class name="User">
<cache usage="read-write"/>
<id name="id">
<generator class="increment"/>
</id>
<natural-id>
<property name="name"/>
<property name="org"/>
</natural-id>
<property name="password"/>
</class>
- Is there a way to use those methods to get the natural id mapping?
- Is there another way to get a ClassMetadata instance?
- Is it possible to get an instance of
entityMetamodel
to replace the ClassMetadata?