Interview Questions

Hibernate 4 - How to persiste Enums?

Use the following code to use Enums with Entities in Hibernate4

class Person
{


private Gender gender;

       
    @Column(name="gender")
    @Enumerated(EnumType.STRING)
    public Gender getGender() {
                return gender;
        }
   
   
       
        public void setGender(Gender  gender) {
                this.gender = gender;
        }



}

enum Gender{

 MALE,FEMALE;

}

0
No votes yet
Your rating: None