Questions tagged [detachedcriteria]

189 questions
1
vote
1 answer

Hibernate Criteria - Max value from a given list

I'm using Hibernate Criteria, I want to select the maximun value for each group of values, this maximun value must be contained in a given list. Example: select t.field1, max(t.field2) as total from table t where t.field2 in :givenList group by…
gcotis
  • 107
  • 2
  • 15
1
vote
2 answers

Is it possible to unit test methods that rely on NHibernate Detached Criteria?

I have tried to use Moq to unit test a method on a repository that uses the DetachedCriteria class. But I come up against a problem whereby I cannot actually mock the internal Criteria object that is built inside. Is there any way to mock detached…
Aim Kai
  • 2,934
  • 1
  • 22
  • 34
1
vote
1 answer

Nhibernate join on a table twice

Consider the following Class structure... public class ListViewControl { public int SystemId {get; set;} public List Actions {get; set;} public List ListViewActions {get; set;} } public class…
Zuber
  • 577
  • 1
  • 11
  • 29
1
vote
1 answer

Need help optimizing a NHibernate criteria query that uses Restrictions.In(..)

I'm trying to figure out if there's a way I can do the following strictly using Criteria and DetachedCriteria via a subquery or some other way that is more optimal. NameGuidDto is nothing more than a lightweight object that has string and Guid…
Chris F
  • 2,886
  • 2
  • 28
  • 33
1
vote
0 answers

how to retrieve duplicate data using self join in detached criteria.. i wanna join Pool_id and Product_id colum

In this Detached Criteria i want to get duplicate Value from two Colum One Pool_id and Product_id .... Object[] id1={1,2}; DetachedCriteria poolcriteria = DetachedCriteria.forClass(PoolProduct.class, "PoolProduct"); …
1
vote
0 answers

Hibernate criteria sum where property is equal

I store in database data as | RAPORT_DAY | FIELD_VALUE | USER_ID. All works good if I specify user_id, I'm getting one record for one day. But if I dont specify user_id I'm getting a lot of records for same day. Is it possible to sum field_value for…
kxyz
  • 802
  • 1
  • 9
  • 32
1
vote
0 answers

Enum mapping and criteria

I have two entities: "Parent" & "Child" Child is mapped in Parent like this: Code:
Randomize
  • 8,651
  • 18
  • 78
  • 133
1
vote
1 answer

Hibernate Criteria: How to retrieve table data with foreign key relationship

I have two pojo classes wihch are named Document and DocumentUser. DocumentUser has an property documentId which linked to Document's id by foreign key. So i want to create criteria query which retrieve Documents with its DocumentUser which is…
angaraeski
  • 468
  • 1
  • 6
  • 12
1
vote
0 answers

how to use a Grails DetachedCriteria as its own criteria

I want to get all rows that match some arbitrary criteria, then I want to also include any rows whose id is the parentId for any of those rows. def criteria = MovieWorkbook.whereAny { and { ilike("name", name) or { …
Scott Ingram
  • 85
  • 1
  • 11
1
vote
1 answer

Extra entities in search result when Hibernate Criteria used

I have class Event with field linkedRooms: public class Event { Set linkedRooms; ... } Class LinkedRoom has field sourceKey: public class LinkedRoom { Long sourceKey; ... } I need to search all events that have all…
user1092126
1
vote
2 answers

How do i create a Hibernate Criteria to order by some properties of collection

Say, i have an entity that has a history of operations as a collection. I want to sort entities by the date of the latest operation (it's the first element of history). i'd like to do something like…
miceuz
  • 3,327
  • 5
  • 29
  • 33
1
vote
1 answer

Criteria query with restriction across a joined subclass problem

I have the following graph: OrderLine OrderLineExtension OrderLineExtensionA OrderLineExtensionB OrderLineExtensionC OrderLine contains a Set of OrderLineExtension. OrderLineExtension is defined as :…
Kango_V
  • 1,720
  • 2
  • 15
  • 11
1
vote
1 answer

performing nested select using grails and gorm

I have the following SQL query, I was wondering if I could rewrite this in GORM style with grails, possibly using criteria, where, or other programming style querying that HQL. SELECT count(USERID) as Result FROM Answer WHERE USERID IN (SELECT…
AlexCon
  • 1,127
  • 1
  • 13
  • 31
1
vote
0 answers

Grails DetachedCriteria not working for Disjunction like or

I am trying to create a DetachedCriteria query using an or. It workds fine with createCriteria but here the or is being replaced by an and. Any ideas why? Is that a bug. The fact that a and b are defined as closure is a simplified version of what I…
Pascal DeMilly
  • 681
  • 1
  • 6
  • 16
1
vote
1 answer

Grails Detached Criteria Query and "group by" and "having" clause

In a Grails 2.1 application, I'm having trouble getting a criteria query to behave like some handwritten sql I've got. So-here's some background info: The table is in a reporting db and has the following ddl: completed_case table…