Questions tagged [detachedcriteria]

189 questions
1
vote
2 answers

Create dynamic hibernate criteria query with subcriteria

I have a Java class which has some field annotated with @SearchCriteria(criteria = "class1.class2.field"). criteria parameter inside annotation means for with class this field should be set as hibernate criteria, it mean that, if field marked for…
Yury
  • 664
  • 6
  • 19
1
vote
0 answers

Get only one column from DetachedCriteria with multiple Projections

I have the following code to get the object which has the "Andamento" with the latest date (I have called date -> data). DetachedCriteria criteriaAndamento =…
Soulss
  • 171
  • 1
  • 12
1
vote
2 answers

Call a Stored Procedure with a DetachedCriteria?

Is it possible to construct a DetachedCriteria in nHibernate which queries a stored procedure? How would I accomplish such a task?
GWLlosa
  • 23,995
  • 17
  • 79
  • 116
1
vote
0 answers

Combining Restrictions and Projections on DetachedCriteria

I have problem with combining Restrictions and Projections on DetachedCriteria. If I use only Restriction or Projections separately the program works. How can I combine those two together? I have following sql: select cTopic.topic…
Massoud Kohan
  • 11
  • 1
  • 2
1
vote
1 answer

Hibernate select groupProperty , rowCount with rowCount > n?

Sorry if it is a dumb question but I've stuck with this problem for a whole afternoon but cannot find a solution because I'm not skilled with complicated SQL : I want to find "Top n message-sending users from a table with msg sent count > threshold"…
smallufo
  • 11,516
  • 20
  • 73
  • 111
1
vote
0 answers

Hibernate selecting data for spesific column with detached criteria

I have a simple service method to get customer from db when the customer name is 'John'.But customer name is not primary key so i cannot use getbyid kind of stuff. My dao class name is customerDao and i have such a method in my service class: public…
abidinberkay
  • 1,857
  • 4
  • 36
  • 68
1
vote
1 answer

Hibernate java Criteria query for instances with multiple collection members like tag

Please help me write a Java Criteria-object query to find all items with collections that have all desired members. Basically, I need to "and" the condition, not "or" it. This is exactly like SO articles and tags: search for articles with tags…
chrisinmtown
  • 3,571
  • 3
  • 34
  • 43
1
vote
0 answers

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long (Hibernate)

I am trying to run a subquery in hibernate like this:- DetachedCriteria cartProductIds = DetachedCriteria.forClass(UserCart.class,"usercart") .add(Restrictions.eq("is_deleted", false)) …
Ayush Srivastava
  • 444
  • 1
  • 4
  • 13
1
vote
0 answers

Hibernate DetachedCriteria null pointer for multiple detached queries (DetachedCriteria into DetachedCriteria)

I'm trying to implement a DetachedCriteria, but running a subquery inside another DetachedCriteria error occurs. I have already searched in several places but I have not found any examples where a detacehdCriteria.add (Subqueries.exists (otherDc))…
1
vote
0 answers

Create hibernate DetachedCriteria with JOIN and COUNT

I have two entities: @Entity @Table(name="team") public class Team { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(unique = true) private String name; } and second: @Entity @Table(name="user") public…
paka
  • 434
  • 1
  • 4
  • 9
1
vote
0 answers

How to build Criteria Hibernate Subquery when subquery uses query field for comparison

I'm trying to build a criteria query using subqueries. I read a lot about detachedcriteria for creating subqueries but can't find anything about selecting another select (instead the subquery on where clause etc). Any time an user interacts to the…
1
vote
1 answer

NHibernate DetachedCriteria Orders removed

my work is using NHibernate 2.0.1.4000 for .NET. We are trying to upgrade to later version (3+) but cannot due to changes in DetachedCriteria. In 2.0, you can use DetachedCriteria.AddOrder(order), and then DetachedCriteria.Orders to get the list…
Tapeo
  • 21
  • 1
  • 2
1
vote
0 answers

Paging in hibernate subqueries

I have quite a complex query that applies different layers of filtering and requires ordering/paging. In pseudo-SQL I want to do the following: SELECT ... FROM a WHERE a.id in (SELECT a.id FROM a WHERE [...] limit 10,10) I use Criteria and…
Thomas Stubbe
  • 1,945
  • 5
  • 26
  • 40
1
vote
1 answer

How to make a join using hibernate

I have a question regarding join between 2 entities using hql. Starting on a userProfile, I have to retrieve the name of the role associated to this userProfile. So I need to make a join in order to get it in the role table. I have the following…
AbstractMan
  • 253
  • 2
  • 13
1
vote
1 answer

hibernate: using criteria to access objects within objects

I am using criteria to get a list of notifications that contains users that are active. The problem is that i get the following error: org.hibernate.QueryException: could not resolve property: user.active of: com.company.Notification Other then…
mkoryak
  • 57,086
  • 61
  • 201
  • 257