Saturday, April 3, 2010

Java Annotations


Java Annotations - Though java annotations were introduced in jdk5 version, it started gaining momentum when the leading frameworks started reaping the benefits of annotations.

Though people are familiar with annotations from long back, but never bothered much due to lack of idea on the hidden fruit "annotations"

We (core java developers) see @SuppressWarnings, @deprecated annotations in most of the IDEs but never bothered about these. But the actual usage is unfolded by the popular frameworks like SPRING, HIBERNATE and many more.

It is very simple to specify a POJO as an entity in Hibernate. Instead of specifying in an xml, you can go ahead and specify @Entity on top of the class declaration. In the same way, @Table is used to specify the table name to which this entity or POJO is referred in the database.

Though a big turn around, it is very simple to use if you are adapted to this change.

You can sense the revolution of annotations in the java world by the following case:

In today's world, most of the applications started using annotations as an alternative of xml files. For example we need not create hbm files for each and every entity we create, instead we can go ahead with annotations.

Its evident that developers are more comfortable with annotations.

No comments:

Post a Comment