In hibernate, is it possible to define a mapping for a class to a set of enums?
I've been able to find examples of how to define mappings of Sets and I've been able to find separate examples for how to map Enums, but I cannot figure out how to define a of Enums for a class.
Could anyone please provide me with an example?
This is being built on top of an existing application, so I cannot alter the database schema.
This is the relation I wish to model. Wicket is a normal class and WicketType is a Java Enum.
+----------------+ +------------+ +------------+
| Wicket | | Ref Table | | WicketType |
+----------------+ +------------+ +------------+
| INT | W_ID | | | | W_TypeId |
| .... | | FK | W_ID | FK | WicketType |
| INT | TYPE |----| W_TypeId |----| |
+----------------+ +------------+ +------------+
Thanks again
A simpler way is
<typedef name="WicketTypeType" class="org.hibernate.type.EnumType">
<param name="enumClass">Wicket</param>
<param name="type">12</param>
</typedef>
<class name="Wicket"...
<set name="WicketType" table="Ref Table">
<key column="W_ID" />
<element column="W_TypeID" type="WicketTypeType"/>
</set>
...
</class>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With