- This topic has 1 reply, 1 voice, and was last updated 19 years, 11 months ago by rmauer.
-
AuthorPosts
-
rmauerMemberI 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
rmauerMemberI 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.
-
AuthorPosts