filter « Query « JPA Q&A

1. How do I turn this HQL into a filter query?

I have this query:

sess.createQuery("from Box b join b.items bi order by").list()
It works fine. However, I have a hibernate's Collection boxes and want to filter is. Naive tries:
 sess.createFilter(boxes, "join this.items bi order ...

2. Hibernate query filter on collection

I want to execute following query:

from Item i where i.categoryItems.catalogId = :catId
That however yields in following exception: illegal attempt to dereference collection So I googled, found this Hibernate forum post

3. Hibernate filtering query collections

I would like to ask if it's possible to do this using hibernate. Let say I have already run a HQL and retrieved a collection. Is it possible to further filter it ...

4. Criteria query filter by object type

I'm using jpa criteria query. Is it possible to filter an entity by the type of some of it's atributes? let me explain: I have an entity (let's call it Child) that extends from ...

5. Hibernate: @wherejointable to filter subtable

I am already using @where clause to filter soft deleted rows for an entity. (with a 'deleted' flag). This works very well. Now, I need to filter a linked table that store ...

6. HIBERNATE - JPA2 - H2 - Querying @ElementCollections HashMap by key

I'm using hibernate-entitymanager 3.6.4.Final and h2 database 1.3.155 I'm using the H2Dialect. I'm having trouble filtering records by elements in an @ElementCollection. Here is my entity

public class Item {
  @GeneratedValue(strategy ...

7. Hibernate Filters for native queries

Does hibernate3 support for filters for native queries if so can you please provide an example.

8. JPA criteria like filters

i will try to explain my problem in english :) Im trying to make a generic filter query. I have a map Map and for each field I want to apply a ...

9. Defining HQL in clause parameter on a collection filter

I'm trying to define a collection filter on a set that will allow items in the list to be filtered by a list of valid audience values (integers). In regular HQL I have this working by passing a List to the query by converting an array of Integer values: qy.setParameterList("aud",Arrays.asList(audiences)); But now I'm trying to define a collection filter on a ...

10. Problem with filtering the select statement.

11. Hibernate Query for filtering a Set

12. Filter not support Object query?

13. Enable filter without the where clause

Hi, I'm using nHibernate 2.1.0 with Oracle 10g R2. I have defined the following filter in an HBM file: Then I use this filter to restrict a many-to-one collection

16. Possible to selected timespan in filter

17. Querying with Filters

I have the following three entities described below. I want to be able to query my transaction entity and apply a filter to my text collection inside item so that the texts are locale specific based on the current user's session. How can I do this? Code: @Entity public class Transaction { @ManyToOne(fetch=FetchType.EAGER) @JoinColumns({@JoinColumn(name="item_id",insertable=false,updatable=false),@JoinColumn(name="pid",insertable=false,updatable=false)}) public ...

19. Hibernate filter query problem

Hey Hibernate Friends, Ive got a Problem with Filtering. Iam using parameters for filtering. But I dont know witch filters I have to use. So I will generate a filter for all attributes. If any attribute is filled hibernate should Filter the query. Do you have any idea how to do this graceful? Thank you so much, kind regards, mathias

20. Help querying a set with session.filter

I am confused on the use of session.filter to query a collection. I have a class, Animal, that has a collection of Tattoos. I want to execute a query that selects animals based on the value of the tattoo (tattoo has several properties, value, location, etc.). Session.filter sounds like what I want, except the first parameter to the method is the ...

23. Use filter for ordering sql-query

24. query cache and filters broken?

I am using the query cache and filters as the mapping and code below shows. Well my problem is that the query cache does not use the filter parameter as part of the key as evident from the toString below. The result is that I get a leakage between different filters. /Konstantin PS Everything works fine when the cache is disabled ...

25. Collection Filter and Order named query

26. Filtering Associations With WHERE clause in

Author Message SonicWave Post subject: Filtering Associations With WHERE clause in Posted: Wed Sep 14, 2005 6:34 am Newbie Joined: Tue Aug 30, 2005 10:01 pm Posts: 2 Good day, The following shows the associations between Orgrel (which store the relationship between OrgUnit) and OrgUnit (Organization Unit). When a OrgUnit is deleted, the status is marked with 'D' ...

27. H3 Filter and order by (asc,desc)

Hi , l am using Hibernate3 Filter , and cause SQLGrammarException. env: 1. mysql 4.1.8-nt 2. hibernate 3.1 rc3 l have a LibraryUser.hbm.xml , Code: ....

28. How to filter a collection of a an entity in one query?

Hi. We're trying to do something similar to the following: Support you have a forum with: topic 1-* posts. Is it possible to query for topic, and return only a few posts? (for example: everything after yesterday) ? In HQL you'd do something like: select t, p from topic as t join t.posts as p where < :date Now, this ...

29. Hibernate filters and Correlated Query

30. Filtering Collection at Select

Newbie Joined: Mon Jan 02, 2006 9:10 am Posts: 10 Hi all! I am trying to write an evaluation program for "consultants", but I am having problems with accessing collections of a fetched object. I posted a similar post earlier but no success yet so I try to post again with some more detail. There are two objects involved: consultants and ...

31. Filtering an HQL Query with Criteria API?

I'm using Hibernate in an application where I have 2 main requirements: 1. I need to make a query in hql, wich I store in metadata (xdoclet) giving it a name 2. I need to use this query by name AND filter it afterwards (let the final user apply additional filters to the original query results) I would like to do ...

33. equivalent query gives different result with enabled filter

Beginner Joined: Fri Nov 21, 2003 4:50 am Posts: 23 Hibernate version:3.2.0.CR2 we are playing around with filters and found a inconsistent behaviour in using a filter in an explicit vs. implicit join. In explicit join a filter is not active, but in an implicit join it is active. Personally I'm unsure when a filter is active in a query, is ...

34. Filter aggregates count but not sum

35. Any way to use native sql filters on non-native sql queries?

Hibernate version: 3.2.0 ga I'm trying to create a Filter on a class via the @FilterDef/@Filter annotations. The Filter uses the "connect by" keyword, i.e. it involves native sql syntax. Everything works fine when I enable the filter and run a native SQL query involving that class. However, it fails when the query is enabled and I run a query using ...

36. Quick Question: Does Query Cache ignore filters?

37. Criteria API] Problem with filter, order !

38. Filter not applying to native SQL query

Hi, I have a problem with dynamic hibernate filter, because it's not applying to native sql query. I'm using Hibernate 3.1. Mapping: Code: ...

39. Query Problem: Criteria, collections, filters.

Criteria criteria = session.createCriteria(Person.class); criteria.createAlias("organisation", "o"); Disjunction disjunction = Restrictions.disjunction(); Criterion firstNameCrit = Restrictions.ilike("firstName", searchTerm, MatchMode.ANYWHERE); Criterion lastNameCrit = Restrictions.ilike("lastName", searchTerm, MatchMode.ANYWHERE); Criterion orgNameCrit = Restrictions.ilike("", searchTerm, MatchMode.ANYWHERE); Criterion orgTelCrit = Restrictions.ilike("o.telephone", searchTerm, MatchMode.ANYWHERE); disjunction.add(firstNameCrit); disjunction.add(lastNameCrit); disjunction.add(orgNameCrit); disjunction.add(orgTelCrit); criteria.add(disjunction); criteria.list();

40. HQL Query with collection as filter

41. Filtering update queries

42. How to filter a query according to its instance type?

Newbie Joined: Wed Aug 06, 2008 4:00 pm Posts: 4 Thanks for your help. I have already seen this kind of stuff but it didn't work since I am not using discriminator value. I am using joined-subclass. Here is my actual mapping: Code:

44.  +