| Author |
Recursive Mapping of collections
|
Echo.Narcissus Echo
Greenhorn
Joined: Jul 16, 2011
Posts: 2
|
|
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/collections.html... really has me befuddled.
I am trying to create a ToDo List with Vaadin/ Hibernate /Spring /MySQL.
So my <hibernate mapping> looks like this
And my Task.java thus
I am expecting that each Task in the Task table will have an entry ParentId which in relation to TaskId (indexed key of the table) will give the one-to-many parent to child collection mapping.
Obviously it seems that this mapping is not something i understood very well.
Because hibernate complains ..
nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.intellizens.ribbon.tasks.model.Task column: parentId (should be mapped with insert="false" update="false")
Or is it that i am expecting hibernate to read my mind.. and making a obvious mistake.
|
 |
Waswani Naresh
Ranch Hand
Joined: May 01, 2008
Posts: 66
|
|
Hi Echo,
You are probably trying to do some thing like....
One task can have multiple sub-tasks and each task will have its parent task ID.
Try this approach
Task.java
Task.hbm.xml
Do let me know if this serves the purpose.
Regards,
Naresh Waswani
|
Naresh Waswani
|
 |
Echo.Narcissus Echo
Greenhorn
Joined: Jul 16, 2011
Posts: 2
|
|
Thanks for your response.
What about the parentId mapping?
<property name="parentId" type="java.lang.Long">
<column name="parentId" length="45" not-null="true" />
</property>
|
 |
Waswani Naresh
Ranch Hand
Joined: May 01, 2008
Posts: 66
|
|
Look at the key element with in the set. Its mapped to PARENT_ID. So you don't need to define it separately.
Regards,
Naresh Waswani
|
 |
 |
|
|
subject: Recursive Mapping of collections
|
|
|