The exception you've posted is caused by you explicitly specifying an entity name on <class>
declaration and not specifying it on <many-to-one>
. Entity name is a special attribute used for distinguishing between different mappings based on the same class. You do NOT need it for you mapping.
That said, there are multiple additional issues with your mapping:
<one-to-one>
mapping for parent is wrong. It can't be one-to-one by definition - while this post will only have one parent, another post may have that same parent (especially for comments) which makes parent's end of association one-to-many. You need to map it as<many-to-one>
instead.- List of comments is not really a list unless you have a special column to maintain its index (which you don't judging by empty - and invalid -
<index/>
declaration). Map it as<bag>
instead. - Comment list really should be mapped with inverse=true.
- Not a problem per se but it makes your mapping harder to read - there's no need for nested
<column>
element; you can have it as attribute instead or skip it altogether if column name matches property name. Similarly, no point in having update=false everywhere - if you don't want your posts updated, don't save them :-)
ChssPly76
2009-10-14 05:40:17