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
My DBA wants to have SQL Server default “Set NoCount On”, which does not allow the NHibernate expectations of inserts\updates to work.
Is there a way to have NHiberante call “Set NoCount Off”, or to have it disable the expectation stuff?
I am using NH 1.2.1
Thanks everyone!
-Sean
Awesome, thanks!
Also, I’m assuming by “will do that”, is to call “Set NoCount Off” ?