-->
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: Incorrect SQL for OrderBy on M:N association
PostPosted: Mon Jan 16, 2006 12:23 pm 
Newbie

Joined: Tue Oct 11, 2005 10:40 am
Posts: 4
Hi, i'm currently using NH 1.0 with NET 1.1

I've an M:N association that works fine, it saves and retrieves elements properly. I've added an 'OrderBy' attribute on collections's mapping that seems to generate incorrect SQL statements.

Here's the collection's mapping:
Code:
[Bag(0, Table = "PUTAssLivelliFasi", Lazy = true, Inverse = true, Cascade = CascadeStyle.SaveUpdate, OrderBy = "Codice asc")]
[Key(1, Column = "LivelloKD")]
[ManyToMany(2, ClassType = typeof(Fase), Column = "FaseKD")]


And here's the generated SQL:
Code:
... FROM PUTAssLivelliFasi fasi0_ inner join PUTFasi fase1_ on fasi0_.FaseKD=fase1_.FaseKD WHERE fasi0_.LivelloKD=@p0 ORDER BY fasi0_.Codice asc', N'@p0 int', @p0 = 2519


This statements return (correctly) the error: "Cannot find column 'Codice'". Indeed 'Codice' belongs to PUTFasi and not to PUTAssLivelliFasi.

I'm missing something in the mapping?

Thanks
Massimo


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.