Announcement Announcement Module
No announcement yet.
Hibernate MappingException: Unknown entity Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Solved, thank a lot


    • #17
      Thanks, I used this method and solved the problem.


      • #18
        Thanks, I used the method written by denizstij and solved the problem.


        • #19
          If you using annotations check import section.
          Probably instead

          import javax.persistence.Entity;

          you have:

          import org.hibernate.annotations.Entity;

          Best regards


          • #20
            More details in this blog spot.


            • #21
              Thank, it's works...
              Just for sharing, if u guys develop by using netbeans, u only need to add class entity name in the persistence.xml .


              • #22
                Hi all I have a class and its mapping in hbm file and I have specified it in the config file as a resource, but still gets mapping exception unknown entity : org.hibernate.MappingException: Unknown entity:

                mapping file specified:

                <property name="mappingResources" >

                and my class

                public class Staff {

                private int staffId;
                private String staffName;
                private String shortName;
                private String designation;
                private String parentSpouse;
                private Address address;
                private String gender;
                private Date dateOfBirth;
                private String mobile;
                private String email;
                private String religion;
                private String cast;
                private String catagory;
                private int leaveBalance;
                private Blob photo;

                public Staff(){

                public int getStaffId(){
                return this.staffId;

                public void setStaffId(int staffId){
                this.staffId = staffId;

                public String getStaffName(){
                return this.staffName;

                public void setStaffName(String staffName){
                this.staffName = staffName;

                public String getShortName(){
                return this.shortName;

                public void setShortName(String shortName){
                this.shortName = shortName;

                public String getDesignation(){
                return this.designation;

                public void setDesignation(String designation){
                this.designation = designation;

                public String getParentSpouse(){
                return this.parentSpouse;

                public void setParentSpouse(String parentSpouse){
                this.parentSpouse = parentSpouse;

                public Address getAddress(){
                return this.address;

                public void setAddress(Address address){
                this.address = address;

                public String getGender(){
                return this.gender;

                public void setGender(String gender){
                this.gender = gender;

                public Date getDateOfBirth(){
                return this.dateOfBirth;

                public void setDateOfBirth(Date dateOfBirth){
                this.dateOfBirth = dateOfBirth;

                public String getMobile(){

                public void setMobile(String mobile){
       = mobile;

                public String getEmail(){

                public void setEmail(String email){
       = email;

                public String getReligion(){
                return this.religion;

                public void setReligion(String religion){
                this.religion = religion;

                public String getCast(){
                return this.cast;

                public void setCast(String cast){
                this.cast = cast;

                public String getCatagory(){
                return this.catagory;

                public void setCatagory(String catagory){
                this.catagory = catagory;

                public int getLeaveBalance(){
                return this.leaveBalance;

                public void setLeaveBalance(int leaveBalance){
                this.leaveBalance = leaveBalance;

                public Blob getPhoto() {

                public void setPhoto(Blob photo) {
       = photo;

                and staff.hbm.xml file

                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "">
                <class entity-name="staff" name="erp.domain.Staff" table="efe_staff">
                <id column="STAFF_ID" name="staffId" type="int">
                <generator class="native"/>

                <property name="staffName">
                <column name="STAFF_NAME"/>

                <property name="shortName">
                <column name="SHORT_NAME"/>

                <property name="designation">
                <column name="DESIGNATION"/>

                <property name="parentSpouse">
                <column name="PARENT_SPOUSE"/>

                <many-to-one name="address" class="erp.domain.Address"
                column="ADDRESS_ID" unique="true"
                cascade="all" not-null="true"/>

                <property name="gender">
                <column name="GENDER"/>

                <property name="dateOfBirth">
                <column name="DATE_OF_BIRTH"/>

                <property name="mobile">
                <column name="MOBILE_NUMBER"/>

                <property name="email">
                <column name="EMAIL"/>

                <property name="religion">
                <column name="RELGION"/>

                <property name="cast">
                <column name="CAST"/>

                <property name="catagory">
                <column name="CATAGORY"/>

                <property name="leaveBalance">
                <column name="LEAVE_BALANCE"/>

                <property name="photo" type="blob">
                <column name="PHOTO"/>

                Please help me any help would be appreciated, thanks in advance


                • #23
                  Problem solved

                  I removed the tag entity-name="staff" from hbm file and left name="erp.domain.Staff".
                  Problem is that when we give entity-name we should use that name where ever we refer this class.


                  • #24

                    this error will occur if we are not mentining(placing) our new hbm file names in session factory config file...



                    • #26
                      Thank, all great information be found in this post!

                      Riverside Attorneys