criteria

How to reliably retrieve tables and columns information stored in Torque Criteria object

Hi there, Is there a way to retrieve tables, including alias tables, and columns, including alias columns, from an Apache Torque Criteria object reliably? I understand that there is methods like: getSelectedColumns, getAsColumns(), getJoins(), etc., but for examples, getJoins() will just return a list of joined tables strings in free t...

Is there a way to include math in the where clause of a NHibernate ICRiteria Query?

I am stumped trying to do a query like this SQL query with the NHibernate criteria interface: SELECT * FROM TimeTrack t JOIN Customer c on c.ID = t.CustomerID WHERE t.StartTime + t.EndTime < c.MaxTime I know I can do it with HQL, but I also need to conditionally change the query which is perfect for criteria. I suppose I could put a...

Restrict the class of an association in a Hibernate Criteria query

I have an object, 'Response' that has a property called 'submitter'. Submitters can be one of several different classes including Student, Teacher, etc... I would like to be able to execute a criteria query where I select only responses submitted by teachers - so this means putting a class restriction on an associated entity. Any ideas...

Hibernate restrictions (And / Or)

Hi, small questions about Restrictions. i have query like this : Where A in(1,6) and (B not like 'Value%' or B not like 'ValueII%') the problem is the field B not contains a fixed value, can be one or more. Please, (N)Hibernate experts - help me with this, I cant find a working solution. Any help is greatly appreciated! ...

[hibernate] criteria.list() return rendundant records if fetchtype is EAGER

Hi all, look this code: // In A.java class @OneToMany(mappedBy="a", fetch=FetchType.EAGER) @Cascade(CascadeType.SAVE_UPDATE) private List<B> bList; // In B.java class @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="id_a") @Cascade(CascadeType.SAVE_UPDATE) private A a; And this is my record in DB tables. // Table A | ID |...

Is there any difference in performance between these two instructions?

i have the following criteria specification and wanted to know if there is any difference in the performance or the memory usage of them. 1st way: criteria.add(Restrictions.eq("case.estadoOperativo", Caso.EstadoOperativo.COMPLETADO)) .add(Restrictions.eq("case.estadoAdministrativo", Caso.EstadoAdministrativo.TARIFICADO)); 2nd ...

how do you get "real" sql distinct with hibernate criteria queries?

I have a Hibernate criteria query that is incorrectly pulling out max results. In many cases, when I specify 20 max results, the query actually only returns 1 or 5 results, because the restrictions return many duplicates. Criteria c = session.createCriteria(DomainObject.class); c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); c.cr...

Hibernate criteria distinct with join - fetch the relation

Hello, I've searched on the internet but I didn't understand very much the problem: I'm trying to build a distinct query using criteria and a distinct clause using a projection, trying to resole the lazy attribute of the projection in the distinct. So the query will be like this Code: createCriteria(Parent.class) .setProject(Pro...

Criteria query whith FROM clause which contains only one query and does not contain any tables

Hi all. I have the following query and I don't know how can I write it using criteria. SELECT questions_cnt, COUNT(*) users_cnt FROM ( SELECT COUNT(DISTINCT question) questions_cnt FROM UserAnswer GROUP BY user ) t GROUP BY questions_cnt I have started to write criteria query. It looks like the following final DetachedC...

Nested Select Count Query with Criteria

Hi all, say that we have 2 entity EntityA and EntityB , with the related tables, TableA and TableB. i have to implement this query: select a.Id , (select count(b.Id) from TableB b where b.FKa = a.Id and b.AnotherField > 0) as TheCount from TableA a i'm very close to that since i wrote this code: var subCrit = DetachedCriteria.For<...

What are good criteria for grading programming assignments?

I'm going to be teaching a scripting and tool development class to a group of 3D animators. In amongst teaching them coding fundamentals, I plan to have them pick a repetitive task they must perform frequently and have them iteratively develop a tool to automate or simplify this task as an assignment. What I'd like to know are some cri...

How to return joined objects as result of criteria?

Hi, I'm wondering how I can represent the following in the criteria API return DataContext.Session.CreateQuery(" select ss.PracticeArea from Subsection as ss where ss.Location = :Location ") .SetEntity("Location", location) .List<PracticeArea>(); The where clause is straight forward enough the bit I'm ...

Retrieving Polymorphic Hibernate Objects Using a Criteria Query

In my model I have an abstract "User" class, and multiple subclasses such as Applicant, HiringManager, and Interviewer. They are in a single table, and I have a single DAO to manage them all. User: @Entity @Table(name="User") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name="role", discriminatorTy...

Hibernate one-to-many search with Criteria

Hi all, I've got a Hibernate entity, called Event, which has a one-to-many metadata entity, EventData. Given the following Event: EventId: 1 EventHash: broccoli With the following EventDatas: EventDataId: 1 EventId:1 Field: tag Content: tagme EventDataId: 2 EventId: 1 Field: tag Content: anotherTag How do I create a Criteria que...

Testing Criteria for iPad App

Every one, Currently we are planning to test the new Ipad App and looking for the ideas. What will be the Test strategy for Ipad? Types of testing’s we do on Ipad? Industry Bench mark - • % Memory Usage on target device . % memory leaks • CPU usage on target device • Performance on 3G network . Any tool for measuring these metric...

join using setfetchmode

I have 2 entities that do not have an association in there mapping files, but one enitie's primary key is a foreign key for the other entity. Can I get an example of a critera that results in the join of the two tables? Is it possible to use the getfetchmode functionality of the criteria to accomplish this? Can a restriction be added...

NHibernate self referencing query

How do you write this in NHibernate? criteria .CreateAlias( "CreatorObject.LastCreated", "me" ) .Add( Restrictions.Eq( this, "me" ) ); Edit: something like this without using sql Where there are two tables TypeA and TypeB where typeB creates typeA objects and keeps a reference to the last object created. criteria .Add( Restr...

NHibernate HQL vs CriteriaAPI vs QueryOver. Performance.

Hi, What are the performance differences between the hql and criteriaApi and QueryOver? Are there any situations where one is faster or slower than the other? Edit: I extended the question with QueryOver. ============================================= Well, I am not sure which response to mark as answer so I will mark posts with most ...

Hibernate - setProjection after Criteria after Criteria

why is this not possible? Criteria crit1 = sess.createCriteria(Criteria1Class.class); Criteria crit2 = crit1.createCriteria("criteria2Class"); crit2.setProjection(Projections.groupProperty("criteria2Property")); List<String> l2 = crit2.list(); If I use this construction I get the error: could not resolve property: criteria2Property...

How do I take the "top n" using NHibernate Criteria API?

How do I take the "top n" using NHibernate Criteria API? Ideally I'd like to use detached criteria. ...