criteria

JPA 2 in Jboss and criteria api

Is there a working JPA 2 implementation for JBoss server? Or maybe there is some additional extension that provides JPA 2's criteria api equivalent? ...

please help me rewrite a simple sql into a NHibernate Criteria

I need to give to a Criteria a list of string receive another one, the sql that makes this is: select loginName from SimpleUsers where loginName in ('admin', 'oscar', 'stig') but I need it in NHinbernate criteria, can anyone please help me with this ? ...

hibernate criteria restriction on a property for all elements of a set

Hi all, I have an entity with a set say like Libray--->books Now I want to retrieve the libraries where ALL the books have a genre So I have something like this c.createCriteria("library", "library").createCriteria("books", "book"); c.add(Restrictions.isNotNull("book.genre")); If I execute the query I get the libraries where at least ...

Adding criteria to filter by a self referencing parent?

Stumped on this one. I have a many to many self referencing relationship(FluentNH) mapped for a given class: public class Folder { public IList<Folder> ParentFolders{get;set;} } I'm looking to create a query that pulls root folders(ie folders that have ParentFolders.Count() == 0). The self reference is done via lookup table, so Pa...

Hibernate Criteria Query - How to search through many-to-many with attributes?

I'm trying to create a Criteria query to select objects that are related via an association table. Insurer * - 1 Insurer_Section 1 - * Section InsurerSection has an association attribute: active:bool. How do I get all Insurers whose active attribute in the InsurerSection class is set to true? PS: I can't go like this: Insurer.FindA...

Hibernate sort by properties of inner bean ?

In my domain model I have following Classes.A 'UserProfile' has one 'SecurityPrincipal' class SecurityPrincipal{ private String loginId; private String password; private Date registeredData; private int status; } class UserProfile { private String name; private String company; private SecurityPrincipa principal } I want to ge...

how would I convert this join using Criteria query?

my create query (HQL) looks like: Session.CreateQuery( "select a from Article as a join a.Categories c where c.ID = :ID") .SetInt32("ID", categoryId) ...

How do I set the Fetchmode on all assocations of a nHibernate ICriteria in one go?

I have an object that has many assocations to other objects. All of these are fetched lazily by nHibernate, which is good in almost all cases. In a particular scenario, in this case an export of a lot of records, I want to set the Fetchmode to eager on all associations. Is there a way to do this, without having to manually specify each...

NHibernate: Criteria Issue with parameter type

I have a varchar field in a table, mapped to string property on a class. Pretty simple stuff, however when I create a criteria to retieve enities based on this field, NHibernare is generating invalid sql. The where clause looks like "Where accountnum = 120001", which won't work with a varchar obviously. Any ideas? ...

Need Good Nhibernate Criteria tutorial

I can't for the life of me find a good NH ICriteria walkthrough. Can anyone assist in pointing one out? ...

Hibernate Criteria / Query on object properties

I have a class AppUser; class AppUser { private String firstName; private String lastName; //-- getters and setters } I also have another class Student; class Student { private AppUser appUser; private Date dateOfBirth; //-- getters and setters } How would i search for Student John Doe, firstName John, lastName Do...

delete using criteria query

can you delete using criteria query? I want to do: DELETE bookmars WHERE userID = @userID How can I do this with criteria? ...

nHibernate Criteria ---- Use of Expression.sql

I need to do a query which checks a column in a table of type integer. how can i use expression.sql(nHIbernate Criteria API) to get all the rows matches the given number. Thank you, Rey. ...

NHibernate - Exclude a property from a projection list (select clause)?

I have classes that look like this public class Agreement { public virtual string ArrgKey { get; set; } public virtual string SubjectCode { get; set; } // mapped as a HasMany to AgreementStateCountyRelation public virtual IList<AgreementStateCountyRelation> StateCounties { get; set; } } public class AgreementStateCount...

boolean in criteria query

My criteria looks like: Session.CreateCriteria(typeof(User)) .Add(Expression.Eq("IsActive", 1); Do I put 1 or True for the IsActive boolean check? (non seem to work?) what are my options? ...

Hibernate Criteria: Eagerly load ManyToMany collection

My problem seems pretty straightforward to me, but I just can't seem to find an answer that works. I have a Hibernate Entity which has a ManyToMany association with another Entity, which is fetched lazily by default. I want to create a Criteria which will return the Entity with the ManyToMany association loaded eagerly. Here is the Enti...

Limit associated entities loaded through a Hibernate Criteria

Is it possible to limit the number of associated entities fetched through a Hibernate Criteria? Consider the following two entities: @Entity public class History { @OneToMany private List<Entry> entries ... } @Entity public class Entry { @ManyToOne private History history; private DateTime date; ... } I need to us...

Grails query with associations - find all in a table where id is not in another table

I need to be able to find all items in a table where the id of each item is not in a relational mapping table. In other words, I have one table where each row has an id. If that id is in a map table, it should not show up in my list. I was thinking of querying my map table for all id's in it, then turning around and querying my main t...

Add a Group by to a Hibernate Criteria-Query without Projection

I have a Criteria-Query, which joins a second table B, to select entities from table A. The problem is, that this query returns some entities from table A multiple times. But I need the results to be distinct. Using Criteria.DISTINCT_ROOT_ENTITY is useless, becaus this filters out the multiple occurences after the SQL-Query was execute...

Badge achievement system like SO: Data being used + Criteria(instant awarding & cron jobs)

I've been looking at an open source clone of SO, http://github.com/cnprog/CNPROG I don't know Python/Django but I can still read whats going on, The developers, seem to only be awarding badges with cron jobs, The awards are given out by the methods, being the "Rules" of the Criteria that must be met to achieve the award. in this file...