-->
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.  [ 4 posts ] 
Author Message
 Post subject: Guide Mapping Example not working
PostPosted: Thu Aug 09, 2007 10:50 am 
Newbie

Joined: Wed Aug 08, 2007 8:55 am
Posts: 9
Is the Parent/Child Mapping example working (page 65 of pdf guide)?
I create a Child and add it to Parent, shouldn't Nhibernate save the Child on its own?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 12:11 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Did you set the Parent property of the Child? The parent collection of a P-C relationship is not controlling, the *-1 relation on the child is. However, cascading won't work unless you add the Child to the collection, too. So, you realy do need to do both.

Don't know which version of the PDF you have, does it match this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 5:46 pm 
Newbie

Joined: Wed Aug 08, 2007 8:55 am
Posts: 9
I think is that version, at least is the one shipped with the installer.
I made the changes to match those in the link, but I have a question:

when I save a parent (after adding the child) shouldn't the child be saved and parent_id filled with the id of the parent table?

I copied the full example and it doesn't work.

The error is:


[ArgumentException: No mapping exists from DbType UInt64 to a known SqlDbType.]

[ADOException: could not insert: [EuroEstates.Model.Licitacao][SQL: INSERT INTO Licitacao (Valor, LeilaoId) VALUES (?, ?)]]

I believe is the mapping of the Parent class in the child class.


Parent Class:
<set name="Licitacoes" table="Licitacao" inverse="true">
<key column="LeilaoId"/>
<one-to-many class="Licitacao" />
</set>

Child Class:
<many-to-one name="Auction" class="Leilao" column="LeilaoId" not-null="true" />


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 6:01 am 
Newbie

Joined: Wed Aug 08, 2007 8:55 am
Posts: 9
SOLVED

same problem in this post:

http://forum.hibernate.org/viewtopic.php?t=978192


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

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.