Annotation introduction in Hibernate by R4R Team

Annotation introduction: Some Basic pints regarding the Annotation introduction are as given below:

1. Annotation is the replacement of XML.

2. Annotation is introduced with java along with JDK 1.5.

3. Annotation are used to provide the META data to classes, variables, methods of java.

4. Annotation is given by the SUN as replacement of the hibernate mapping ( XML ) files.

5. When we work in the hibernate then we don't need to require the any mapping files but hibernate XML configuration files must.

6. Hibernate borrowed annotation from java persistence API but hibernate if self doesn't contain its own annotations.

7. We need to know every annotation is internally an interface but the key words starts with '@' symbol.

Simple code of example is given below:

public @interface r4r
{
    // code.....
}

8. We need to always remember that when we work with annotation then we must use the java version 1.5 or heigher and hibernate version must be 3.3.

9. In the level of J2SE SUN provided very limited set of annotaions like @override and @Deprecated...

10. But SUN has provided the annotations related to J2SE level under java.lang.annotaions.* package.

11. Most of the annotations related to J2EE level those are given by SUN and their implementations are given by vendors.

12. In the Hibernate SUN has provided the support of annotation under the javax.persistence package and hibernate has provided implementations for the annotations given in that packages.

13. As we use the basic annotation type in the hibernate that is given below:

@Entity
@Table
@Id
@Column

14. @Entity, @Table are class level annotations and @Id, @Column are the field level annotaions, so never be confused.

15. In the Hibernate if we use the POJO class then hibernate mapping files is not required, it means we can annotations are reducing the use of xml files in the Hibernate.

When we work with the hibernate then we alwyas remember some points those are given below:

1. We must ensure that java version must be 1.5 or higher.

2. we must use hibernate version 3.3 or higher.

3. Attatched the requried jar file in the application when we want to use the annotaion.

Following jar files are given below:

1. antlr-2.7.6.jar
2. commons-collections-3.1.jar
3. dom4j-1.6.1.jar
4. hibernate-commons-annotations-3.2.0.Final.jar
5. hibernate-core-3.6.7.Final.jar
6. hibernate-jpa-2.0-api-1.0.1.Final.jar
7. javassist.jar
8. jms-1.1.jar
9. jsr250-api-1.0.jar
10.jta-1.1.jar
11.log4j-1.2.16.jar
12.ojdbc14.jar
13.slf4j-api-1.6.1.jar
14.slf4j-log4j12-1.6.1.jar

Total 14 jar files we need to set in the class path to work with these annotations with hibernate framework,

And click here to download the jar file:

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!