If you want to use inverse=true on lists you need to handle the index on your child.
Here's one way doing it https://www.hibernate.org/193.html If you're using late nh version, access="readonly" suits fine to skip the setter for the index prop. /Roger ________________________________ Från: [email protected] [[email protected]] för Rémi Després-Smyth [[email protected]] Skickat: den 4 januari 2010 21:16 Till: [email protected] Ämne: [nhusers] Mapping collections as <list> A quick question regarding mapping collections as <list>. Here was the mapping file I used in my tests: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1234" default-access="field.camelcase" default-lazy="false"> <class name="Parent" table="parent"> <id name="Id" column="parentId"> <generator class="assigned" /> </id> <property name="Descript" column="descript" /> <list name="Children" table="child" cascade="all" inverse="true"> <key column="parentId"/> <index column="position"/> <one-to-many class="Child"/> </list> </class> <class name="Child" table="child"> <id name="Id" column="childId"> <generator class="assigned" /> </id> <property name="Descript" column="descript" /> <many-to-one name="Parent" class="Parent" column="parentId" not-null="true" /> </class> </hibernate-mapping> In my testing, I found that if I use the mapping file as listed here, I get HibernateException errors (“null index column for collection …”) related to the list mapping, but if I remove inverse=”true” it works fine. I had set inverse=true because in my actual project, the child class has and needs a reference to the parent class. I’ve worked around it, but just wondering: is there any reason I don’t see why I can’t use inverse=”true”? Regards, Remi. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
