Questions tagged [detachedcriteria]

189 questions
0
votes
1 answer

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…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
0
votes
1 answer

A hibernate criteria query where values equal properties with an entity's collection field

How to get all employees named "John Smith" using the hibernate criteria approach? @Entity public class Name{ private long id; private String title private String first; private String last; private String…
Stephen Isienyi
  • 1,292
  • 3
  • 17
  • 29
0
votes
1 answer

Grails Hibernate Criteria: How do I specify multiple criteria for one association?

Edit 1: To further clarify my problem, I updated my example code so that only one property is relevant. In the grails documentation, the following example is given in the Criteria section under querying associations: We can query [...]…
nst1nctz
  • 333
  • 3
  • 23
0
votes
1 answer

DetachedCriteria convert to list

When I tried to return result it will show return type mismatch. What can I do? @Override @SuppressWarnings("unchecked") public List getAllStudent(){ …
sathish
  • 59
  • 1
  • 6
0
votes
1 answer

How to write multiple sub-query in Hibernate criteria

I am trying to write oracle subquery in Hibernate criteria but unable to do it. Can anyone help me to achieve this. Below is my oracle query. SELECT a.id, b.address FROM tableA a INNER JOIN TABLE b ON a.id = b.id WHERE mainId IN (SELECT…
user1127643
  • 169
  • 4
  • 12
0
votes
0 answers

Hibernate's Criteria API - adding left join alias reduces number of results

I'm having a problem with Hibernate's Criteria API. For unknown reason adding a left-join type alias changes the resultset. I want to recreate the following SQL query in Criteria API: select distinct f.* from form_instance i join…
Jan Siekierski
  • 409
  • 6
  • 14
0
votes
0 answers

using NOT IN clause in criteria query

it may seem like duplicate question but my problem is not solving. i have following tables:- ------------------------------------------------------ student student_fine st_id fine_id st_name …
jaykio77
  • 379
  • 1
  • 7
  • 22
0
votes
0 answers

How to create this criteria/detached criteria based query in Grails

I am trying to complete a criteria query in Grails that sometimes has to refer to an unassociated table, therefore using a detached query. Depending on a passed in parameter, I need to perform a different subquery. I have a Customer domain, which…
David Brown
  • 3,021
  • 3
  • 26
  • 46
0
votes
1 answer

Hibernate detached criteria for multiple Restrictions

I am trying to fetch list of Users whose status still shows as inactive and process them. This User is embedded with UserDetails, UserActivity entities. All entity tables have status column with value as Inactive. Right now I am using detached…
user4325796
  • 85
  • 1
  • 2
  • 8
0
votes
1 answer

Complex SQL Query to NHibernate DetachedCriteria or HQL

I have the following SQL Query returning the results I need: SELECT Person.FirstName,Person.LastName,OrganisationUnit.Name AS UnitName, RS_SkillsArea.Name AS SkillsArea, Activity.Name AS ActivityName, Activity.CLASS, Activity.StartsOn,…
IThasTheAnswer
  • 515
  • 1
  • 5
  • 17
0
votes
1 answer

Querying for Unique/Distinct IDs and state Date

I have been trying to solve this for the past couple of days and couldn't find an answer myself, so I'm hoping that someone can either point me to the answer or help me himself. The problem is, lets say that I have 2 different domains - one called…
maad city
  • 5
  • 3
0
votes
2 answers

Creating query in Hibernate

In hibernate how to create this query "select test_type_nmbr from test_table where test_type_name in (select Test_type_name from test_table where test_type_nmbr in('111','222' ))". Here suppose in the database you have values like the…
0
votes
1 answer

Splitting Subqueries into Seperate Queries is more efficient?

I've a subquery like this. Basically I've used multiple detached criteria to form multiple subqueries. SELECT this_.id AS y0_, this_.a AS y1_, this_.b AS y2_, this_.c AS y3_, this_.d AS y4_, this_.e AS…
The Coder
  • 2,562
  • 5
  • 33
  • 62
0
votes
2 answers

Hibernate sort table based on max year and max month and group by id using criteria

I'm having difficulty representing this query which I write for select max month and max year rows from given 'uid'. I have 6 data in which 3 data has uid '4' and other 3 data has uid '5'. I want to get the max month and max year data from both uid…
Jimmy
  • 1,719
  • 3
  • 21
  • 33
0
votes
1 answer

Load collections eagerly in NHibernate using Criteria API

I have an entity A which HasMany entities B and entities C. All entities A, B and C have some references x,y and z which should be loaded eagerly. I want to read from the database all entities A, and load the collections of B and C eagerly using…