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: still regarding one-to-many: how to generate unidirectional?
PostPosted: Thu Sep 20, 2007 7:10 am 
Beginner
Beginner

Joined: Wed Aug 29, 2007 8:23 am
Posts: 31
Hello again.

while trying to solve the issue i've mentioned here:

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

I've also found this post, which looked promising:

http://sdesmedt.wordpress.com/2006/09/0 ... mment-2195

i want to do something similar to the first example. According to the author you can create a unidirection association between the 2 entities with the following hbm files:


<class name="UniDirectional.Customer, NHibernateOneToMany"
table="customer">
<!-- The usual things like an id tag -->
<bag name="OrderList" cascade="all">
<key column="CustomerId"/>
<one-to-many
class="UniDirectional.UOrder, NHibernateOneToMany"/>
</bag>
</class>

<class name="UniDirectional.UOrder,
NHibernateOneToMany"
table="`order`">
<!-- usual mapping members -->
</class>


what happens is that when nhibernate tries to generate the sql it won't generate the name of the foreign key, ie, it'll generate something like:

insert into order (number) @values(?)

and then it crashes since the idcustomer column isn't correctly filled.

I've managed to solve this by addind a bidirectional realtionship. However, that sucks and is not what i want. is there any way to generate a unidirectional relationship in the current release of nhibernate?

thanks


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.