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.  [ 3 posts ] 
Author Message
 Post subject: many-to-one with foreignkey=String.Empty instead of null
PostPosted: Fri Feb 26, 2010 11:17 am 
Newbie

Joined: Fri Apr 25, 2008 8:19 am
Posts: 17
I have two tables. One table has a many-to-one mapping to the other.
I make a Criteria with selecting from table1 and SetFetchMode for the many-to-one mapping to FetchMode.Join.
When the foreignkey field in the database ist null or has a valid value all works fine. The objects are loaded with only one Join-SQL.
But there are many references in the database (MSSQL) with foreignkey=String.Empty instead of NULL. In this case NHibernate fires one big Join-SQL and a select for every reference which is set to String.Empty. I have about 1000 records, this means it fires 1001 select sqls.
Can i configure that String.Empty is equivalent to NULL or something else?
My many-ton-one mapping:
<many-to-one name="Adresse" not-found="ignore" column="adrnr" access="field.pascalcase-underscore"/>

If i clear not-found="ignore" it works but i want to have null when no reference is set and not a proxy-object.


Top
 Profile  
 
 Post subject: Re: many-to-one with foreignkey=String.Empty instead of null
PostPosted: Tue Mar 02, 2010 6:22 am 
Newbie

Joined: Fri Apr 25, 2008 8:19 am
Posts: 17
I don't understand why this is not configurable. Hope that one of the programmers of NHibernate can give me tips how i can change this behaviour. I have no chance to change the behaviour in the database, because there are one another application read and write the tables. And this other application saves non referenced foreign keys as "" (Empty) instead of NULL.


Top
 Profile  
 
 Post subject: Re: many-to-one with foreignkey=String.Empty instead of null
PostPosted: Thu Mar 11, 2010 6:45 am 
Newbie

Joined: Fri Apr 25, 2008 8:19 am
Posts: 17
I need a solution!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.