Friday, February 27, 2015

org.hibernate.MappingException: Unknown entity

Problem:
This exception will occur mainly because of the following two reasons

1. Making the @Entity with the wrong annotation

import org.hibernate.annotations.Entity; 
@Entity
public class Employee implements Serializable {
...
}
solution for this one is changing the package name.
import javax.persistence.Entity;
2. Missing the @Entity annotation

public class Employee implements Serializable {
...
}

solution for this one is adding the @Entity annotation to the class.

import javax.persistence.Entity;

@Entity
public class Employee implements Serializable {

}


Happy Coding!!!

0 comments: