facebook

Error in .hbm.xml after creating Hibernate mapping

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #221784 Reply

    rmauer
    Member

    I am using MyEclipse 3.8.3. After creating a Hibernate mapping, the hbm.xml file will show the following error:

    The content of element type “class” must match “(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive array)*,(subclass*|joined-sublass*))”
    ————————————-

    Here is the mapping section from Customers.hbm.xml:

    <hibernate-mapping package=”com.visn15.hibernate”>

    <class name=”Customers” table=”customers”>

    <property name=”customernumber” column=”CustomerNumber” type=”java.lang.Integer” not-null=”true” />
    <property name=”lastname” column=”LastName” type=”java.lang.String” not-null=”true” />
    <property name=”firstname” column=”FirstName” type=”java.lang.String” not-null=”true” />
    <property name=”streetaddress” column=”StreetAddress” type=”java.lang.String” not-null=”true” />
    <property name=”city” column=”City” type=”java.lang.String” not-null=”true” />
    <property name=”state” column=”State” type=”java.lang.String” not-null=”true” />
    <property name=”zip” column=”Zip” type=”java.lang.String” not-null=”true” />
    </class>

    </hibernate-mapping>
    —————————————————-
    Here is the hibernate.cfg.xml:

    <hibernate-configuration>

    <session-factory>
    <!– properties –>
    <property name=”connection.username”>xxxx</property>
    <property name=”connection.url”>jdbc:microsoft:sqlserver://myserver:1433</property>
    <property name=”dialect”>net.sf.hibernate.dialect.SQLServerDialect</property>
    <property name=”connection.password”>xxxxxxx</property>
    <property name=”connection.driver_class”>com.microsoft.jdbc.sqlserver.SQLServerDriver</property>

    <!– mapping files –>
    <mapping resource=”com/visn15/hibernate/Customers.hbm.xml”/>

    </session-factory>

    </hibernate-configuration>
    ———————————————-

    Thanks for your help

    #221794 Reply

    rmauer
    Member

    I noticed the customer table I was using did not have a Primary Key. I set the CustomerNumber as the Primary Key and set the hibernate mapping. The Customers.hbm.xml was created successfully.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Error in .hbm.xml after creating Hibernate mapping

You must be logged in to post in the forum log in