-2

Exception in thread "main" org.hibernate.AnnotationException: No identifier specified for entity: Employee at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:266) at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:211) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:731) at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:249) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:417) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:86) at StoreData.main(StoreData.java:14)

Ashwani
  • 11
  • maybe this: https://stackoverflow.com/questions/4381290/hibernate-exception-org-hibernate-annotationexception-no-identifier-specified?rq=1 – Willem Jan 09 '20 at 16:57

2 Answers2

0

It would be nice if you provide your Employee class. What this issue means is your entity class is missing a field, annotated with @Id. Every @Entity needs and @Id, which is the primary key in the database.

Shafiul
  • 1,452
  • 14
  • 21
  • In case we do no create id field in employee table. then we can not access the employee tables records. if have created in firstname,lastname column in employee table. – Ashwani Jan 09 '20 at 17:09
  • You basically need some kind of id(either '@Id', or '@EmbeddedId' or multiple '@Ids' with an IdClass for composite key). For you ruse case, you can create a composite primary key with both firstname and lastname or to simplify, add a primary key 'id' in the table. – Shafiul Jan 10 '20 at 09:36
  • Ok ,Thank now it is working fine. Am insert and retrieve the records. – Ashwani Jan 10 '20 at 17:18
0

@Entity @Table(name = "employee", schema="test") public class Employee {

 @Column(name="FIRST_NAME")
private String `firstName`;  


 @Column(name="LAST_NAME")
private String `lastName`;

 public String `getFirstName()` {  
return `firstName`;  

}
public void setFirstName(String firstName){
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

Ashwani
  • 11