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

  • #16
    Solved, thank a lot

    Comment


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

      Comment


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

        Comment


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

          import javax.persistence.Entity;

          you have:

          import org.hibernate.annotations.Entity;

          Best regards

          Comment


          • #20
            More details in this blog spot.
            http://udevi-community.blogspot.com/...ingexcept.html

            Comment


            • #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 .

              Comment


              • #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" >
                <list>
                <value>login.hbm.xml</value>
                <value>staff.hbm.xml</value>
                </list>
                </property>

                and my class Staff.java


                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(){
                return this.mobile;
                }

                public void setMobile(String mobile){
                this.mobile = mobile;
                }

                public String getEmail(){
                return this.email;
                }

                public void setEmail(String email){
                this.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() {
                return this.photo;
                }

                public void setPhoto(Blob photo) {
                this.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" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
                <hibernate-mapping>
                <class entity-name="staff" name="erp.domain.Staff" table="efe_staff">
                <id column="STAFF_ID" name="staffId" type="int">
                <generator class="native"/>
                </id>

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

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

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

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

                <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>

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

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

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

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

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

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

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

                <property name="photo" type="blob">
                <column name="PHOTO"/>
                </property>
                </class>
                </hibernate-mapping>


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

                Comment


                • #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.

                  Comment


                  • #24
                    sol

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

                    ranjith

                    Comment


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

                      _______________________
                      Riverside Attorneys

                      Comment

                      Working...
                      X