I want to define one to many relation between two entities defined as dynamic models. Sample entities are provided below. one Order can have multiple items in it. Association needed to be defined on "ORDER_ID" column.
please have a look at i am using "entity-name" not "name".
#Order Entity
<class entity-name="Order">
<id name="id"
type="long"
column="ID">
<generator class="sequence"/>
</id>
<property name="ORDER_ID" type="string"
column="ORDER_ID" not-null="true" />
</class>
#OrderItems Entity
<class entity-name="OrderItems">
<id name="id"
type="long"
column="ID">
<generator class="sequence"/>
</id>
<property name="ORDER_ID" type="string"
column="ORDER_ID" not-null="true" />
</class>
Why do you need this to be "dynamic"? If you just create the classes this will be a lot simpler and you will find lots of resources on the web about how to model these mappings with JPA annotations.
Apart from that, the first result on google for "hbm xml one-to-many example" gave a perfect example that shows how to do this: https://mkyong.com/hibernate/hibernate-one-to-many-relationship-example/