April 16, 2018

org.hibernate.AnnotationException: No identifier specified for entity

When I was working with hibernate project. I got this exception. Actually, the issue was because of missing @Id from one of my entity class. @Id is used on the primary key field in the entity class. The field is a primary key in your database table.

If you do not have any primary key in your database table then you can use rowId as the primary key for your entity class.

@Id
@Column(name = "ROWID", insertable = false, updatable = false)
private String rowId;

Disclaimer

We shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its response or damage to your system. We do not guarantee that the integrity or security of this communication has been maintained or that this communication is free of viruses, interceptions or interferences. Anyone communicating with us by email accepts the risks involved and their consequences. We accept no liability for any damage caused by any virus transmitted by this site.