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: Uneccessary updates
PostPosted: Sat Nov 14, 2009 11:28 am 
Newbie

Joined: Sat Nov 14, 2009 11:22 am
Posts: 1
Hi,

I'm using nhibernate via activerecord. I have a simple master and a detail table, Member and MemberDetail... In the MemberDetail table I have a CityId column which is not nullable and is not a foreignKey for City table. If a member does not want to indicate his/her city this field contains "-1" value. When i call my Member's ActiveRecord entity class like Member.FindAll(), i got an exception "Cannot insert the value NULL into column 'CityId', table 'MemberDetail'; column does not allow nulls". I traced the sql queries via Sql Server Profiler and I saw that nhibernate executes two sql update queries for each row it has just selected (one for Member and one for MemberDetail). Then I changed the CityId column to nullable. After this alter Member.FindAll call executed without any exceptions but in the database CityId columns, which have "-1" value, returned NULL because of nhibernate's update queries.

My first question, why are these update queries are executed, are they really necessary? And second, is there any way to prevent from these update queries. I think i have to do something with dynamic update or optimistic locking. I tried some combinations of these attributes but had no success.

Hope my issue is clear,
Thanks in advance.


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.