-->
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: Many-to-one Additional Select Issue
PostPosted: Thu Nov 30, 2006 5:03 pm 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: NHibernate 1.2 Beta 2

Mapping documents:


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="MyAssembly.Domain.EntityA, MyAssembly.Domain" table="tblEntityA" lazy="true">
<id name="EntityAID" column="EntityAID" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<property name="Name" column="EntityAName"/>
<one-to-one name="EntityB" class="MyAssembly.Domain.EntityB, MyAssembly.Domain" property-ref="EntityA" constrained="true" lazy="proxy" />
</class>
</hibernate-mapping>


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="MyAssembly.Domain.EntityB, MyAssembly.Domain" table="tblEntityB" lazy="true">
<id name="EntityBID" column="EntityBID" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<many-to-one name="EntityA" class="MyAssembly.Domain.EntityA, MyAssembly.Domain" column="EntityAID" lazy="proxy" />
<property name="Message" column="EntityBMessage"/>
</class>
</hibernate-mapping>




Name and version of the database you are using: SQL Server 2000


Hi all,

I've got a really frustrating issue. Basically I have a DB entity mapping of
EntityA (1:M) EntityB but I want it to work as a pseudo 1:1 because that is the actual use, e.g. EntityAID is unique in table EntityB.

My problem is that whenever I do a select for EntityA, even with an eager fetch for EntityB then it always does a seperate select for EntityB. I've tried every combination of lazy load, outerjoin, constrained etc. etc. I can think of but no matter what I do EntityB is always got in a seperate select when I select EntityA, even when I don't access the EntityB property of EntityA.

Is there an answer? This is the only thing now really stopping me using this for a port of our company app and it is so frustrating I can't work it out. This is an existing DB so I can't really change the schema as I did to maintain two seperate apps of the same DB.


Many thanks

Stuart Jones


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 02, 2006 3:33 pm 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
Hi,

Alternatively is there any other way of having the 1:1 relationship with different primary keys. If you use the standard unidirectional one-to-one tag it always assumes the second class has a shared primary key and there doesn't seem to be any way of specifying a foreign key for the join.

Please, if anyone has th answers to these could you post.

Many thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 3:58 pm 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
Hi,

Not wanting to be a pain but does anyone have any idea? This seems like a common problem...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 4:03 pm 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
Hi people,

Every so sorry - just realsed I posted this to the Hibernate forums rather than the NHibernate forum

Please accept my apologies....

Many thanks


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.