-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: one-to-many mapping to inherited object gives an error
PostPosted: Sat Jul 14, 2007 10:48 am 
Beginner
Beginner

Joined: Thu Oct 20, 2005 9:26 am
Posts: 27
Location: Barcelona
Hi,

I'm using nhibernate 1.0.4 and I get an error when I try to map a collection to a class, which is a subclass of another class.

I get this error: Invalid column name 'userid'.

The mapping looks like this (only the essential properties are shown):
It's the users answers that gives me problems:

<class name="Business.Data.User, Business" table="`User`">
<cache usage="nonstrict-read-write"/>
<id name="Id" type="Int32" unsaved-value="0">
<column name="Id" sql-type="int" not-null="true" unique="true" index="PK_tblUser"/>
<generator class="native" />
</id>
<bag name="Answers" inverse="true" cascade="all" lazy="true">
<key column="userid" />
<one-to-many class="Business.Data.Answer, Business"></one-to-many>
</bag>
</class>

<class name="Business.Data.Post, Business" table="Post">
<cache usage="nonstrict-read-write"/>
<id name="Id" type="Int32" unsaved-value="0">
<column name="Id" sql-type="int" not-null="true" unique="true" index="PK_tblPost"/>
<generator class="native" />
</id>
<many-to-one name="User" class="Business.Data.User, Business">
<column name="UserId" />
</many-to-one>
<joined-subclass name="Business.Data.Answer, Business" table="AnswerPost">
<key column="PostId" />
<property name="PointsReceived" type="Int32" column="PointsReceived" />
<many-to-one name="Question" class="Business.Data.Question, Business">
<column name="QuestionId" />
</many-to-one>
<bag name="Ratings" inverse="true" cascade='all' lazy="true">
<key column="AnswerId" />
<one-to-many class="Business.Data.AnswerRating, Business"></one-to-many>
</bag>
</joined-subclass>
</class>

Since the Post and Answer classes are mapped to two different tables in the database, the query constructed tries to get the userid from the answer-table instead of the mother-post-table.
If I comment that collection out, the rest works without problems.
It seems to be an error in the framework to me, but maybe I'm doing something wrong?
Hope you can help, thanks.

David


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.