Questions tagged [nhibernate-criteria]

The NHibernate Criteria API allows performing dynamic, object oriented queries in NHibernate.

Using the criteria API is one way to perform queries in NHibernate. Its strength is on writing dynamic queries at runtime. It lacks some features compared to HQL, for instance creation of cross products and joining objects on arbitrary properties.

Related:

  • QueryOver is a successor of Criteria, which provides more type safety at compile time, but is still base on Criteria.
  • Linq To NHibernate once based on Criteria, but had been rewritten to use HQL in later versions.

References:

286 questions
2
votes
1 answer

Usage of NHibernate Interceptor(s) on Projections

I have this situation: I'm using Nhibernate to map an Entity 'User' that is mapped on a large table in Sql, for perfomance reasons I've created a lightweight entity 'LightweightUser' that has only a small set of properties and is NOT mapped in a hbm…
2
votes
2 answers

NHibernate Criteria and Projections

I have my entities like below: (1) Course (with details) (2) Student (with details) (3) StudentEnrolment (that has a one to many mapping of Student to Course) Now I am trying to create a projection class (called CourseSummary) which has few fields…
Dharmesh
  • 560
  • 1
  • 6
  • 16
2
votes
1 answer

NHibernate QueryOver with component list

I have classes as follows: public class File { public Guid Id { get; set; } } public class Customer { public Guid Id { get; set; } public List Files { get; set; } } And Customer.Files is setup as a bag of components (not…
Adam Greene
  • 717
  • 1
  • 6
  • 17
2
votes
1 answer

How to Populate the Child Collections / Associations of an Entity from a Stored Procedure using NHibernate

I want to know if there is a way to populate recursive entities ( child collections / associations ) from a stored procedure in NHibernate. Suppose I have the next class: public class Category { public int category_id { set; protected get; } …
2
votes
0 answers

nHibernate erroring when using order by, conditional projection and SetFirstResult() together

When using an order by, conditional projection and SetFirstResult() together in a query I get this error: Invalid index 4 for this SqlParameterCollection with Count=4 In my experience, this error usually happens when you have one field mapped to…
Dan
  • 29,100
  • 43
  • 148
  • 207
2
votes
1 answer

nhibernate, sql server Datetime compare failing

In nhibernate i am using following to compare date Restrictions.Eq(Projections.Property("SubmittedDate"), request.Data.SubmittedDateTime.Value) in local environment its working. but in other environment its not returning result. SubmittedDateTime?…
Techmaster
  • 1,032
  • 2
  • 12
  • 26
2
votes
1 answer

Do select and update as a single query using java hibernate criteria API

I have written an application which read 1 record at a time from a table in Oracle Db, do some processing on it and then save it again to same table. I am also maintaining a status column in the table to keep track of my current record progress.For…
Rahul
  • 61
  • 1
  • 7
2
votes
1 answer

Filter the results using n-hibernate via matching with another Db table

I have already written Hbn & code to fetch the users from db. with following info userid, name,email,phone now we have new requirement in which new table has been created with following fields Table 1 userid -- foreign key to above user…
Techmaster
  • 1,032
  • 2
  • 12
  • 26
1
vote
1 answer

Nhibernate criteria expression.in with string of csv

Hello Is it possible in nhibernate to createCriteria expression.in with string of csv, for example public static List ToList(string csvOnly) { ISession session = NhSessionMenager.Instance.GetSession(); List l =…
Endiss
  • 699
  • 2
  • 10
  • 23
1
vote
1 answer

NHibernate: Combining result transformers?

I'm working with the criteria API, querying against a mapping file that I cannot really change. There is a root entity with many child entities joined to it and certain queries have required us to add…
joniba
  • 3,339
  • 4
  • 35
  • 49
1
vote
2 answers

Nhibernate Criterias inner join subquery

Im trying to replicate the following sql in Nhibernate ICriteria SELECT DISTINCT AP.ID FROM ActivityParts AP INNER JOIN ActivityBookings AB ON AB.ActivityPartID = AP.ID INNER JOIN OrderPartBookings OPB ON OPB.ActivityBookingID = AB.ID …
1
vote
1 answer

Is it possible to make an Nhibernate query generate columnName<>'value' rather than not(columnName='value')?)

Is it possible to make an Nhibernate query generate Sql that has columnName<>'value' rather than not(columnName='value')? I am told that using not() can have Sql performance issues over <>. Typically I am writing my queries like…
Simon Keep
  • 9,886
  • 9
  • 63
  • 78
1
vote
3 answers

Union with NHibernate and Criteria?

Union with NHibernate and Criteria: Is it possible in Criteria or QueryOver? If not, is there any other way to achieve a union of two result within the same query?
Mattias
  • 684
  • 3
  • 7
  • 16
1
vote
1 answer

Return properties from subclass left joins when querying superclass in NHibernate

I have an ICriteria that returns properties from a superclass Animal. Now I want to include in the results several properties from a subclass, Bird. For other subclasses, these properties should return null. I am using table-per-subclass…
Annabelle
  • 10,596
  • 5
  • 27
  • 26
1
vote
1 answer

NHibernate Criteria left antijoin/ subquery confusion

I'll preface this with the fact that NHibernate is well out of my comfort zone, so this may be much simpler than I'm making it out to be. I have a users table and an events table mapped to user and event objects. My event objects reference a…
Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254