With the help of the annotation method we can do mapping with the pojo class to database table. It is a new way to define mapping without using xml file. we can use annotation in the replacement of xml mapping metadata.
Hibernate Annotations provide the metadata for the Object and Relational Table mapping. All the metadata into the pojo class in java along with the code which help us to understand the table structure.
If we create application portable to other EJB 3 compliant ORM applications, so we have to use annotations to represent the mapping information but still if you want greater flexibility then you should go with XML-based mappings.
Step to Follow for the Hibernate Mapping with Annotation:
Before creating a application with hibernate annotation then We have to follow some basic step which are given below:
Step 1.we have to confirm that we are using JDK 5.O if we do not then we have to upgrade the version of the JDK 5.O to take advantage of the native support for annotations.
Step 2. We need to install Hibernate 3.x annotation distribution package and copy hibernate-annotations.jar, lib/hibernate-comons-annotations.jar and lib/ejb3-persistence.jar.