Questions tagged [detachedcriteria]

189 questions
4
votes
1 answer

Hibernate Criteria: Add restrictions to Criteria and DetachedCriteria

Currently our queries add a variety of Restrictions to ensure the results are considered active or live. These Restrictions are used in several places/queries so a method was setup similar to public Criteria addStandardCriteria(Criteria criteria,…
Gilean
  • 14,708
  • 10
  • 45
  • 52
4
votes
3 answers

hibernate - How to set max result in DetachedCriteria?

I am using DetachedCriteria and I just want the first result of the query so I want to do something like LIMIT 1 in DetachedCriteria. When I searched google I found setMaxResult but its Criteria. How am I gonna do it in DetachedCriteria?
NinjaBoy
  • 3,715
  • 18
  • 54
  • 69
3
votes
2 answers

Detached criteria on composite PK fields?

I have a table with 3 columns as primary key. Code and mapping is as follows: class for the composite key public class CIDResultCurrentState implements Serializable { private static final long serialVersionUID = -4346801004559840730L; …
Less
  • 3,047
  • 3
  • 35
  • 46
3
votes
2 answers

Hibernate criteria: why no Subqueries.isNull(DetachedCriteria)?

I want to translate a script like this into criteria: SELECT ... FROM A WHERE A.some_date > (select bdate from B where ...) OR (select bdate from B where ...) IS NULL So, an A should be returned if either A.Some_date > B.bdate or if B.bdate is…
Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101
3
votes
1 answer

How do I get hql string from DetachedCriteria

I'd like to get hql request from DetachedCriteria. Is there any right way of doing it(I mean toString is not right)?
user590444
  • 4,252
  • 8
  • 36
  • 43
3
votes
1 answer

Hibernate LEFT OUTER JOIN with DetachedCriteria

I am trying to transform the following SQL into Hibernate DetachedCriteria: SELECT students0_.courseId AS courseId2_1_, students0_.studentId AS studentId1_, student1_.id AS id3_0_, student1_.href AS href3_0_, student1_.created AS…
Kianosh
  • 179
  • 1
  • 3
  • 14
3
votes
2 answers

Can't get "count" and "groupBy" with Grails DetachedCriteria

I have a domain class that I use for querying . TourIndex{ Long tourId String country String location int availability // ... more fields } We use a series if "dynamic" criteria builders for searching based on a series of…
3
votes
0 answers

Mixing Grails query DSL with manual DetachedCriteria building (for exists subqueries)

Since the current version of Grails/GORM (as of Grails 2.3) doesn't support EXISTS subqueries, I was wondering if it is possible to express my query criteria with the GORM DSL (which is nice and compact) and then manually get the DetachedCriteria…
sola
  • 1,498
  • 14
  • 23
3
votes
3 answers

NHibernate: Convert an ICriteria to a DetachedCriteria

Anyone know how to convert an ICriteria into a DetachedCriteria. I need to use an existing ICriteria as part of a subquery using: .Add(Subqueries.PropertyIn("Name", myDetachedCriteriaSubquery)) Is there any way to convert an ICriteria to a…
reach4thelasers
  • 26,181
  • 22
  • 92
  • 123
3
votes
6 answers

What is the best way to limit results using a DetachedCriteria of Hibernate in Java?

I'm using Hibernate 3.5.6-Final in Java. Since I don't have access to the Hibernate Session, I'm using a DetachedCriteria. So, I would like to know what is the best way to limit the results for a DetachedCriteria (in my case I would like to get only…
Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
2
votes
0 answers

Hibernate Subqueries

I have a situation where I need to convert a query like :- select hostname, avg(cpu_utilization_percentage) from cpu_utilization where timestamp In (select distinct(timestamp) from report.cpu_utilization order by timestamp desc limit 6) group by…
2
votes
0 answers

query to fetch data from a table with restriction on list field mapped as many to many relationship

Kindly help me with hibernate template or detached criteria query, to fetch data from a table Clause. It has a set of Department table (Many to Many relationship). Now, i need list of only those clauses which are associated with any of the…
Mishika
  • 61
  • 5
2
votes
1 answer

Using DetachedCriteria to return generic list of non-AR type

I'm fiddling with my repository class and attempted to execute a query with a detached criteria. However, it doesn't seem to like me setting the result transformer to a non AR-type. public class IncidentRepository { public static…
Mike
  • 4,257
  • 3
  • 33
  • 47
2
votes
0 answers

NHibernate/Hibernate - Forced to apply sorting twice on pagination

I'm having an issue currently where I have to apply sorting twice in a query. Since I want paginated results, I'm using a DetachedCriteria approach and using it as a Subquery for the main Criteria. Issue is, that if I apply the sorting only on the…
2
votes
1 answer

Using an interface for a subquery in NHibernate

I normally query interfaces using DetachedCriteria in NHibernate: DetachedCriteria crit = DetachedCriteria.For(); And this works fine. I now want to create a subquery for a child object thus: DetachedCriteria subcrit =…
Stu
  • 2,426
  • 2
  • 26
  • 42
1
2
3
12 13