Hibernate : Adding an enum as a property

Using Hibernate Annotations:

@Entity public class TestEntity {
   private TestEnum testEnum; 

Using XML Based Mapping :   Add  hibernate-annotations.jar in your classpath during deployment but there’s no compile-time dependency:

<property name="testEnum" length="30" column="testEnum" lazy="false">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">test.TestEnum</param>
<param name="type">12</param> <!-- To store enum value as VARCHAR -->
This entry was posted in Hibernate, java and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s