I am having trouble understanding an error I am getting while trying to set up a one-to-many association in Hibernate 3.1.
My database consists of three tables:
Code:
tblGroups:
id_g (PK)
tblItems:
id_i (PK)
tblGroupings:
id (PK)
id_g (FK)
id_i (FK)
This is intended to represent a structure between objects such as: Group--(0..1)--------------------(0..*)--Item
I have used the hibernate_reference.pdf as supplied in the download as guidance, and I thought the scenario as covered ing section 7.5.1 one to many / many to one matched my problem. As a result I have set up my hibernate mapping as follows:
<hibernate-mapping
package="
spike.grouping">
. <class
name="
Group"
table="
tblGroups"
. . ....
. . ....
. . <set
name="
items"
table="
tblGroupings">
. . . <key
column="
id_g" />
. . . <many-to-many
column="
id_i"
unique="
true"
class="
Item"/>
. . </set>
. </class>
. <class
name="
Item"
table="
tblItems"
dynamic-update="
true"
optimistic-lock="
version">
. . ....
. . <join
table="
tblGroupings"
inverse="
true"
optional="
true">
. . . <key
column="
id_i"/>
. . . <many-to-one
name="
Group"
column="
id_g"
not-null="
true"/>
. . </join>
. </class>
</hibernate-mapping>
However, when I run my unit tests I get the following error which I do not understand, (I've cut the bulk of it out, just listing line details, I can give the fill stack trace if needed:
Quote:
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:424)
.........
Caused by: 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)*)".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
...........
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:421)
... 40 more
Obvisouly it's informing me that I've done somthing wrong in my mapping, but I do not undersand which bit, if any it is telling me is wrong.
Any help would be very much appreciated.