LINQ.Any creates too many parentheses for Oracle. NHibernate bug?

73 views
Skip to first unread message

Glenn

unread,
Jan 18, 2011, 4:41:08 AM1/18/11
to nhu...@googlegroups.com
I'm using NHibernate 3.0 LINQ against an Oracle 11g R2 and wanted to use the .Any statement in LINQ
from p in session.Query<Project>()
   where p.Personprojects.Any(pp => pp.Id.PersonId == userId)
   select p
(pp.Id is a composite ID with PersonId and ProjectId)

This creates the following SQL:
select
project0_.PROJECT_ID as PROJECT1_92_,
 (... lots of properties snipped...),
project0_.VALIDTODATE as VALIDTO25_92_ 
from PROJECT project0_ 
where exists (
select
(
personproj1_.PROJECT_ID,
personproj1_.PERSON_ID)
 
from PERSONPROJECT personproj1_ 
where project0_.PROJECT_ID=personproj1_.PROJECT_ID and
personproj1_.PERSON_ID=4042 /* :p0 */)
Oracle complains with "ORA-00907: missing right parenthesis"

I narrowed it down to the parentheses in the second select:
select
 (
  personproj1_.PROJECT_ID,
  personproj1_.PERSON_ID)
If I remove those the query works fine. 

Oracle doesn't like parentheses around column names in it's select. A simple
select (PROJECT_ID, PERSON_ID)
from PERSONPROJECT  
will also fail.

Is this an NHibernate bug or am I doing something stupid? If I wanted to change this behavior in NHibernate and make a patch, do you have any pointers to where in the NHibernate source I should start?


 

Kelly Stuard

unread,
Jan 18, 2011, 5:45:17 PM1/18/11
to nhusers
This seems to have been fixed in trunk as of two days ago:
http://216.121.112.228/browse/NH-2280

I just ran into it with 3.0.0 final and am moving to trunk, tonight.

Glenn F. Henriksen

unread,
Jan 19, 2011, 5:05:25 PM1/19/11
to nhu...@googlegroups.com
Nice! Thanks!

-Glenn

--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to
nhusers+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.

Reply all
Reply to author
Forward
0 new messages