criteria

Does NHibernate Criteria API support projections on collection properties?

I need to replicate the following working HQL query using criteria API. session.CreateQuery( "select c " + "from Parent p " + "inner join p.Children c " + "where p.Id = 9 " + "and c.Id = 33") .SetMaxResults(3) .List(); The query selects all the children that satisfy a certain criteria that belong to parents...

How to use ICriteria with Enum properties in NHibernate

Hi I want to write a FindByExample(object o) method. So I tried this: public IList<T> FindByExample(T o) { return Session.CreateCriteria(typeof(T)).Add(Example.Create(o)).List<T>(); } (It's in a generic class) It should work fine, but if T has a property of an enum type, it throws this exception: "Type mismatch in NHibernate.Cri...

NHibernate projection help

Hello there, Im having a problem creating a projection for my nhibernate detachedcriteria object. I have a class Spa which is linked to table Address. Address has a field called City which is a string. public class Spa : IAggregateRoot { [BelongsTo("AddressID", Cascade = CascadeEnum.All)] public Address Address { ge...

NHibernate - CreateCriteria vs CreateAlias

Hi, Assuming the following scenario: class Project{ public Job Job; } class Job{ public Name; } Assuming I want to use the Criteria API to search for all projects whose Job has the name "sumthing". I could use the CreateAlias to create an alias for Job and use it to access Name, or I could create a new Criteria for the proper...

paged data using a CTE, how would nHibernate handle this?

Hi, I use CTE to handle paging of data currently, can criteria queries handle CTE? ...

Getting unique result in Hibernate

how can we get distinct result by using criteria in hibernate. ...

Remote Hibernate Criteria

I have multiple services which call on my database service, which uses Hibernate, and I would like the remote services to be able to create a query and then pass that to be processes. Ideally I would like to pass a Criteria Object but it looks like it needs a Session which they won't have access to. Is there a process similar to the Crit...

NHibernate: Criteria expression to retrieve all entities with null count child collection

In nhibernate, I have two classes that are associated with a many-to-one mapping: <class name="Employee" table="Employee"> .. <bag name="orgUnits"> <key column="id" /> <one-to-many name="OrgUnit" class="OrgUnit"> </bag> .. </class> I would like to use a criteria expression to get only Employees where the the collection...

NHibernate query for matching all tags

Here are my relevant classes: public class Item { public virtual int Id { get; protected set; } public virtual IList<Tag> Tags { get; set; } } public class Tags { public virtual int Id { get; protected set; } public virtual string Name { get; set; } public virtual IList<Item> Items { get; set; } } These are mapped...

How to return an entity with chosen columns using Criteria

I'm really new with Hibernate. I want a List<User> using hibernate criteria, but only with fields User id and name filled up. Is that possible? Something like the query shown below: SELECT user.id, user.name FROM user Regards. ...

Selecting a joined entity with an ICriteria in NHibernate

Hi, In HQL I can do something like this: select roleHeldByOwner.TargetPerson from Person roleOwner join roleOwner.RolesOnPeople roleHeldByOwner where roleOwner.Id = :roleOwnerId How can I achieve the same thing in a Criteria query? Specifically the selecting of something that isn't the first entity in the From clause. Thanks, Matt ...

NHibernate passing parameter in criteria

I have an Ms Access view(query) as following select * from employee Where EmployeeId=SomeID Here SomeId is not a field name If I run this query from MsAccess It prompts me for entering value for SomeId as follows |---------------------------------------| | Enter Parameter Value X | |-----------------------------------...

NHibernate: Query filtering on a list of values using criteria

I'm trying to filter by a list of values using the criteria API. I suspect that this is not possible, I'm just asking here to be sure. class Entity { int id { get; set; } IList<Guid> Guids { get; set; } } The mapping: <class name="Entity"> <id ...></id> <bag name="Guids" table="Entity_Guids"> <key column="Entity_FK"/> ...

hibernate restrictions and/or order

Hi, small questions about Restrictions.or and Restrictions.and If I do something like this: ... criterion = criterionA; criterion = Restrictions.and(criterion, criterionB); criterion = Restrictions.or(criterion, criterionC); criterion = Restrictions.and(criterion, criterionD); Will this be treated as: (A and B) or (C and D) (follow...

Alias of joined table in SQLProjection

Hi I have this query: criteria = session.CreateCriteria(typeof (Building)) .CreateAlias("Estate", "estate") .SetProjection(Projections.ProjectionList() .Add(Property.ForName("Name"), "BuildingName") .Add(Property.ForName("estate.Name"), "EstateName") .Add(Proj...

How to query for map element in hibernate?

I have a hibernate mapping which looks like this: <hibernate-mapping> <class name="MutableEvent" table="events" mutable="true" dynamic-insert="true" dynamic-update="true"> <id name="id"> <generator class="assigned" /> </id> <property name="sourceTimestamp" /> <property name="entry...

Nhibernate.Search, Lucene, and the Criteria API: types mismatch

Update I've been looking around the NHibernate.Search.Tests project to find out how the Criteria API is used (i find it immensely useful to look around the test code to have working examples) and i noticed that the way to use the Fulltext search is radically different. Here are two tests, one with the criteria API, one with the classic ...

How to query a subproperty with NHibernate's criteria api?

Hi! I would like to make a query which needs to compare an property's property with some value. For example: ... WHERE Identity.Location.Room = "room #1" How can I achieve this with criteria api? Best RegardsOliver Hanappi ...

one-to-many with criteria question

enter code hereI want to apply restrictions on the list of items, so only items from a given dates will be retrieved. Here are my mappings: <class name="MyClass" table="MyTable" mutable="false" > <cache usage="read-only"/> <id name="myId" column="myId" type="integer"/> <property name="myProp" type="...

Mathematical operation between coulmn values in hibernate criteria

Hi, I tried to query a table using hibernate. In criteria how to apply mathematical operations in two column values? ...