hibernate配置复合主键报错,请大侠看看格式哪里错了,研究很多天了,急!
运行错误如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
我的hibernate配置文件如下:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.freejava.hibernate.model">
<class
name="UserMailbox"
table="USERMAILBOX"
>
<meta attribute="sync-DAO">false</meta>
<composite-id name="userMailboxPK" class="com.freejava.hibernate.model.UserMailboxPK">
<key-property name="id" column="ID" type="java.lang.Integer" length="10" />
<key-property name="mailAddress" column="MAILADDRESS" type="java.lang.String" length="32" />
</composite-id>
<property
name="senderName"
column="SENDERNAME"
type="string"
not-null="true"
length="10"
/>
<property
name="mailType"
column="MAILTYPE"
type="string"
not-null="true"
length="10"
/>
</class>
</hibernate-mapping>