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: One-To-Many does strange things
PostPosted: Fri Dec 15, 2006 10:32 am 
Newbie

Joined: Thu Sep 07, 2006 11:30 am
Posts: 2
I have 2 classes : Student and Academic.
In Student class i have a private field mAcademicInfo and I actually expose its properties as properties of Student e.g. InstitutionType and Institution

Code:
private Academic mAcademicInfo;

        public virtual Academic.InstitutionTypeEnum InstitutionType {
            get { return mAcademicInfo.InstitutionType; }
        }

        public virtual string Institution {
            get { return mAcademicInfo.Institution; }
        }


The mapping is:
Code:
<many-to-one cascade="none" name="mAcademicInfo" column="SchoolCode"  access="field" />

where SchoolCode is the column in Student table that I keep the primary key of the Academic table.

Ok..this is the weird part:
when i fetch a Student I get the following sql :

NHibernate: select student0_.ID as ID2_ ... where student0_.Identifier=@p0); @p0 = '06057786'

NHibernate: SELECT academic0_.SchoolCode as SchoolCode3_0_ ... WHERE academic0_.SchoolCode=@p0; @p0 = '106'

NHibernate: UPDATE Academic SET InstitutionType = @p0, Institution = @p1 ... WHERE SchoolCode = @p5; @p0 = 'AEI', ... , @p5 = '106'

It issues an UPDATE but I cant imagine why!!!!!

Anyone's got a clue??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 15, 2006 12:52 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
I think that you are doing something more and saving, and the extra update is because you don't have inverse=true on the other side of the assoication


Top
 Profile  
 
 Post subject: Hmmmm
PostPosted: Sat Dec 16, 2006 7:10 pm 
Newbie

Joined: Thu Sep 07, 2006 11:30 am
Posts: 2
Actually I never did say that was a 2-way relationship. I mean that the relationship is not defined in Academic mapping. So the inverse attriute wont work.
I only do a GetBy<Something> in Student class using a session.CreateQuery. I cant imagine how this would produce an extra update .

Anyways... I forgot to mention that I am using 1.2 beta2 version. So can this be a bug?


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.