May
23
2015

org.hibernate.AnnotationException: No identifier specified for entity

Hi in this post we will see one more exception that occur because some time we forgaet to mention which field in our entity class will be primary key column. To remove this exception we need to tell hibernate which propery of entity class will be out primary key column. Let see simple example how this exception occur then we will resolve it

Student.java

hibernate.cfg.xml

AnnotationExceptionClass.java

When we will run above program then hibernate will throw Exception in thread “main” org.hibernate.AnnotationException: No identifier specified for entity.

To remove this exception we need to tell hibernate which propery of entity class will be out primary key column.

Student.java

This is all in this hibernate tutorial . This was pretty simple and small post. Hope it has help you.

 

About the Author: devender kumar

java/j2EE developer

Comments are closed.