-->
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: CreateAlias at second level and inner join
PostPosted: Wed May 17, 2006 10:02 am 
Beginner
Beginner

Joined: Wed May 03, 2006 5:10 am
Posts: 32
Location: Monopoli - Italy
Hello,
I have the following situation in my hbm.xml file and I need to check the Profile.Name attribute in my query using the following code:

ICriteria c = s.OpenSession().CreateCriteria(typeof(ObjectModel.Auth.ProfileActionProperty));
c.CreateAlias("Action", "act");
c.CreateAlias("act.Profile","actpro");
c.Add(NHibernate.Expression.Expression.Eq("act.Profile.Name","my profile name"));

Problem 1: as you can see in the generated-sql section the istruction c.CreateAlias("act.Profile","actpro") is ignored because no joins are created. Consequently I have an exception for "....alias not found..."

Problem 2: it always creates an inner join (I need left outer join in my query); i tried to change this default setting using SetFetchMode("act", FetchMode.Join) without success.

Someone can help me?

Thanks
Antonella

Hibernate version: 1.0.2

Mapping documents:
<class name="ObjectModel.Auth.Profile, ObjectModel" table="Auth_Profile">
<id name="Id" type="Int32" column="Id" access="field.pascalcase-m-underscore">
<generator class="hilo">
<param name="table">NH_Key_Auth</param>
<param name="column">Auth_Profile</param>
<param name="max_lo">0</param>
</generator>
</id>
<version name="RowVersion" column="RowVersion" type="Int32" unsaved-value="negative" />
<property name="Description" column="Description" type="String" />
<property name="Name" column="Name" type="String" />
</class>

<class name="ObjectModel.Auth.ProfileAction, ObjectModel" table="Auth_ProfileAction">
<composite-id>
<key-many-to-one name="Action" class="ObjectModel.Auth.Action, ObjectModel" column="IdAction" />
<key-many-to-one name="Profile" class="ObjectModel.Auth.Profile, ObjectModel" column="IdProfile" />
</composite-id>
<version name="RowVersion" column="RowVersion" type="Int32" unsaved-value="negative" />
<bag name="profileactionproperties" inverse ="false" cascade="all">
<key>
<column name="IdAction" />
<column name="IdProfile" />
</key>
<one-to-many class="ObjectModel.Auth.ProfileActionProperty, ObjectModel" />
</bag>
</class>

<class name="ObjectModel.Auth.ProfileActionProperty, ObjectModel" table="Auth_ProfileActionProperty">
<id name="Id" type="Int32" column="Id" access="field.pascalcase-m-underscore">
<generator class="hilo">
<param name="table">NH_Key_Auth</param>
<param name="column">Auth_ProfileActionProperty</param>
<param name="max_lo">0</param>
</generator>
</id>
<version name="RowVersion" column="RowVersion" type="Int32" unsaved-value="negative" />
<many-to-one name="Action" class="ObjectModel.Auth.ProfileAction, ObjectModel" cascade="none">
<column name="IdAction" />
<column name="IdProfile" />
</many-to-one>
</class>

Name and version of the database you are using: SQLServer 2000

The generated SQL (show_sql=true):
SELECT
{...}
FROM dbo.Auth_ProfileActionProperty this
{...}
inner join dbo.Auth_ProfileAction act ON this.IdAction=act.IdAction AND this.IdProfile=act.IdProfile
WHERE actpro.Name = @p0
@p0 = 'my profile name'


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 3:56 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It looks like a bug to me, can you please report it to JIRA?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 4:12 am 
Beginner
Beginner

Joined: Wed May 03, 2006 5:10 am
Posts: 32
Location: Monopoli - Italy
Done

http://jira.nhibernate.org/browse/NH-608

Antonella


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.