What would be the correct SQL? I am not a postgresql guy but may have a hand
to help.
On Tue, Nov 11, 2008 at 10:23 PM, Tyler Burd <[EMAIL PROTECTED]> wrote:
> I'm using the NHibernate trunk, along with PostgreSQL 8.3. I'm having an
> issue when querying via DetachedCriteria with SetMaxResults applied to both
> the DetachedCriteria and a subquery within the criteria.
>
>
>
> Here's an example:
>
> ----
>
> //this is the main criteria
>
> var crit1 = DetachedCriteria.For<Organization>();
>
> crit1.SetMaxResults(1);
>
>
>
> //this is the sub criteria, used in a subquery
>
> var subc = DetachedCriteria.For<Organization>();
>
> subc.SetProjection(Projections.Property("Name"));
>
> subc.AddOrder(Order.Desc("Name"));
>
> subc.SetMaxResults(1);
>
>
>
> //add the sub-criteria as a subquery to the main criteria
>
> crit1.Add(Subqueries.Eq("Some Organization Name", subc));
>
> ----
>
> This generates sql like this:
>
> SELECT this_.OrganizationId as Organiza1_1_0_, this_."name" as name2_1_0_
> FROM Organization this_
>
> WHERE :p0 = (SELECT this_0_."name" as y0_ FROM Organization this_0_ ORDER
> BY this_0_."name" desc limit :p1) limit :p2
>
>
>
> Notice the two limit clauses (one in the subquery and one in the parent
> query). However, when this query is executed I receive the following error:
>
>
>
> Npgsql.NpgsqlException: ERROR: 42601: syntax error at or near ":"
>
>
>
> I can give you much more information, but this is already a long email.
> The problem surfaced when I tried to use Ayende's Rhino.Security with
> Postgres. Specifically, the AddPermissionsToQuery method on the
> AuthorizationService crashes in this manner, and I tracked it down to the
> subquery issue.
>
>
>
> Thanks,
>
>
>
> -tyler
>
> >
>
--
Tuna Toksöz
Typos included to enhance the readers attention!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---