criteria

Hibernate Criteria: Projecting Count with group by clause

I want to execute the following SQL select count(*) as myCount from user group by name; I came up with the following criteria for the same DetachedCriteria.ForClass(typeof(UserDTO)) .setProjections(Projections.ProjectionList() .Add(Projections.rowCount(),"myCount") .Add(Projections....

nhibernate +criteria. How to return result without one referenced entity

I have criteria: ICriteria criteria = Session.CreateCriteria<Entity>() .SetFetchMode("Entity1", FetchMode.Eager) .SetFetchMode("Entity2", FetchMode.Select) .SetMaxResults(max) .SetFirstResult(min) .Add(Restrictions.Eq("Available", true)) .Cre...

NHibernate criteria fetchmode

I have a type Type1 with a property Type2s consisting of a List<Type2>. I have configured the NHibernate mapping for the property as follows: [Map(0, Table = "Type2s", Schema = "MySchema", Cascade = CascadeStyle.All, Lazy = true, Inverse = true)] [Key(1, Column = "Type1Id")] [OneToMany(2, Class = "Type2, MyNamespace")] What is the dif...

Selecting certain fields using Propel select criteria

Hello, I am unable to find something like this in documentation provided for Propel Criteria in Symfony 1.4 The criteria, by default, is: $this->Merchantss = MerchantsPeer::doSelect(new Criteria()); However, this selects all the fields in the table for 'Merchants'. I would only like to select a couple, lets say: id, name, category. ...

Using DateTimeOffset as WHERE criteria in a SQL Server 2008 query

Hi Everyone, I was wondering if anyone could help me understand why these two criteria do not return the same result sets. To me, it seems weird that SQL Server 2008 R2 wouldn't know to use the offset while constraining the data. Is there a better way to do this? As far as I can tell, Criteria Two is the only way to get the correct data...

Anonymous count with nhibernate criteria?

Is it possible to create a anoynmous count with nhibernate? The below query throws the exception "No column *". I could of course add a column name, but I'd prefer not to, because if I do, I'll have to lookup column names for 95 tables... NHibernate.Criterion.DetachedCriteria dcIsUniqueDomainname = NHibernate.Criterion.DetachedCriteria...

IIf function inside Access query

I have a query and I would like to use an IIf function as part of the criteria. Here is the full SQL: SELECT Hits.HitID, Hits.ListingID, Hits.HitCount, Hits.HitDate, Hits.HitTypeID, Hits.IsDeleted FROM Hits WHERE (((Hits.HitDate)>=[Forms]![frmReports]![txtStartDate]) AND ((Hits.IsDeleted)="N")); Here is the piece of code that causing...

Can anyone tell why this Hibernate query is invalid?

I have criteria query that, when executed, results the following exception thrown: java.lang.IllegalArgumentException: org.hibernate.QueryException: illegal syntax near collection: id [select generatedAlias0.permissions from temp.package.commons.user.Role as generatedAlias0 where generatedAlias0.id=2L] at org.hibernate.ejb.AbstractEntit...

Can anyone tell why this JPA criteria query generates an invalid SQL statement when executed (Hibernate) and how to fix it?

Hi! I'm having a hard time constructing a criteria query to get the "permissions" attribute from the Role entity with id = 2. The permission attribute is of Set type, so I'm creating a join and selecting from it, but the query fails with invalid grammar exception reporting "Unknown column '2L' in 'where clause'" The criteria query that...

Can't create grails Criteria query containing a belongsTo relation

Hi all, I've been trying to create a criteria builder containing a belongsTo relation and have yet to succeed. Consider the following model: class Msg { ... static belongsTo = [user: User] ... } class User { ... Organisation organisation ... } I'm trying to make the following query: Msg.createCriteria()....