CreateCriteria and MONTH
Hello! Is it possible to use MONTH in a CreateCriteria-statement? Does NHibernate support YEAR and/or MONTH? I have a sql-statement like select obs2.Lopnr from Obs obs2 where MONTH(obs2.Datum)=11) Best Regards from Mats ...
Hello! Is it possible to use MONTH in a CreateCriteria-statement? Does NHibernate support YEAR and/or MONTH? I have a sql-statement like select obs2.Lopnr from Obs obs2 where MONTH(obs2.Datum)=11) Best Regards from Mats ...
Hi, I have an "Estate" entity, and this entity has a collection "EstateFeatures"(type:EstateFeature) and EstateFeature has a property "MyFeatureValue". Note: These are the limited properties for the question. All Entities has an Id and all necesarry etc Estate IList<EstateFeature> EstateFeatures; EstateFeature FeatureValue MyFeat...
Hi, I have posted a question few days ago about Querying on collections with the Criteria API and after all the answers i see that the thing that i am trying is not possible with the Criteria, there is a bug for the situation in nhibernate and also in hibernate I was using DetachedCriteria to get all criterias together and the list is ...
When i use SetFirstResult and SetMaxResult and if the query has joins the result have duplicate results instead of unique. Then i use all type of Distinct helpers for criteria api. But it doesnt filter the whole result set it just filters the paged result. How can i overcome this issue ? Thanks ...
I have the following domain object: public class Data { public virtual int ID { get; set; } public virtual DateTime TimeStamp { get; set; } public virtual int Value { get; set; } public virtual Channel Channel { get; set; } } I'm using Repositories from Rhino.Commons. I need to select sum of values for few cha...
Hi, is there an easy way to get the (to-be-generated) sql from a Hibernate Criteria? Ideally I would have something like: Criteria criteria = session.createCriteria(Operator.class); ... build up the criteria ... ... and then do something like ... String sql = criteria.toSql() (But this of course does not exist) The idea would then...
I'm looking for a pattern for this general case: "I need to get a subset of data based on directly related criteria and indirectly related data." ...
I have a DetachedCriteria which I am using to search a table based on a name field. I want to make the search case-insensitive, and am wondering if there is a way to do this without using HQL. Something like: private void searchByFullName(DetachedCriteria criteria, String searchCriteria) { criteria.add(Restrictions.like("fullName", "%"...
For this question, we want to avoid having to write a special query since the query would have to be different across multiple databases. Using only hibernate criteria, we want to be able to escape special characters. This situation is the reason for needing the ability to escape special characters: Assume that we have table 'foo' in ...
How would you express the following Criteria query in HQL? var idArray = new int[] { 1, 2, 3, 4, 5 }; Session.CreateCriteria(typeof(Foo)) .Add(Expression.In("Id", idArray) .List<Foo>(); I am aware of that there is an "in" keyword in HQL, but as I understand it that keyword is for use with subqueries rather than something like...
With HQL I can use dynamic instantiation like this: select new ItemRow(item.Id, item.Description, bid.Amount) from Item item join item.Bids bid where bid.Amount > 100 Now I need to create my queries dynamically with the Criteria API. How can I obtain the same results that I would have obtained with HQL, but using the Criteria API? Th...
I'd like to use Hibernate's criteria api to formulate a particular query that joins two entities. Let's say I have two entities, Pet and Owner with a owner having many pets, but crucially that association is not mapped in the Java annotations or xml. With hql, I could select owners that have a pet called 'fido' by specifying the join in...
Given the mapped hibernate class: @Entity public class MyTestClass { /* id and stuff */ private Integer aValue; private Integer bValue; } you can do the following with HQL: Query query = getCurrentSession().createQuery("select aValue * bValue from MyTestClass"); List<Double> resultList = query.list; and get the calculated...
There is two classes 1 class A[properties:-aid,aname] 2 class B[properties:-bid,A,bname] DropDownList ddlist; ICriteria criteria = ActiveRecordMediator<B>.GetSessionFactoryHolder() .CreateSession(typeof(B)).CreateCriteria(typeof(B)) .setFetchMode(“A”,FetchMode.JOIN); ddlistToLet.DataSource ...
Is there any other site for studying critieria queries like http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querycriteria.html ...
SELECT O.*, P.* FROM ORDERS O, PRODUCT P WHERE O.ORDER_ID=P.ORDER_ID; What would be the Criteria representation of the above query? ...
I need to use year() and month() functions in Criteria API to be able to express a business filter constrain. Expressions like cri.Add(Expression.Ge("year(Duration.DateFrom)", Year.Value)); cri.Add(Expression.Le("year(Duration.DateTo)", Year.Value)); obviously do not work - is there any solution how to achieve this? I know it's enti...
Why would this nhibernate criteria query produce the sql query below? return Session.CreateCriteria(typeof(FundingCategory), "fc") .CreateCriteria("FundingPrograms", "fp") .CreateCriteria("Projects", "p", JoinType.LeftOuterJoin) .Add(Restrictions.Disjunction() .Add(Restrictions.Eq("fp.Recipient.Id", recipientId)) ....
Hi, I'm having trouble writing a query for the following domain classes: class Person { static hasMany = [memberships: Membership] } class Membership { static belongsTo = [person: Person, group: Group] Date joinDate = new Date(); Group group; Person person; } class Group { static hasMany = [memberships: Member...
I'm feeling dumb. public class Uber { public Foo Foo { get; set; } public Bar Bar { get; set; } } public class Foo { public string Name { get; set; } } ... var ubercharged = session.CreateCriteria(typeof(Uber)) .Add(Expression.Eq("Foo.Name", "somename")) .UniqueResult<Uber>(); return ubercharged; This throws a "could not r...