filter « Collection « JPA Q&A





1. Hibernate many-to-many collection filtering    stackoverflow.com

I have the following POJO with a Set inside:

class Word {
    private Long id;
    private String word;
    private int type = WordListFactory.TYPE_DEFAULT;

 ...

2. Hibernate using filter on Collection    stackoverflow.com

I am having the following class

public class Document  implements Serializable{
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "DOCUMENT_ID")
    private Integer id;

 ...

3. @Filter with Collections    forum.hibernate.org

Hi! I'm having a problem with filters when I must use a collection to filter the query, the first time everything works fine, but the second time, if I change the number of parameters that I pass in parameterList method, sql launchs this error : "Missing IN or OUT parameter at index:: 5". I've seen in the output query that the ...

4. Filter lazy fetched collection    forum.hibernate.org

Hi all, I've got a one-to-many-association with lazy fetching. It's working as expected, e.g. when I call course.getPeople() the statement is sent to the database. How can I fetch only specific (in this case) people? How can I filter the collection I fetch? I.e. I don't want to select * from people where course_id = xy but select * from people ...

6. Filtering collections    forum.hibernate.org

I'm using Spring for my application framework. I've read several posts about an org.hibernate.QueryException: The collection was unreferenced error. To simplify the calls I created a controller method bellow, which calls Dao layer directly: Code: @RequestMapping(method=RequestMethod.GET ) @Transactional public @ResponseBody Map getAll( ...

7. Collection filtering strategy    forum.hibernate.org

Hibernate 2.1b6, JDK 1.4.2_02 I have this situation: - Parent has one-to-many Children - Children objects/records are only viewable at a certain authorization level My mapping for this association in Parent.hbm.xml is as follows: Code: ...

8. Collection filtering?    forum.hibernate.org

Hi, When I used a persisted collection in a statement like this: Collection orderedCollection = s.filter( collection, "order by this.amount" ); Is Hibernate parsing the "order by" and doing the ordering on the client side or is this string instead passed on to the DB server? I guess it is a little confusing since it seems like the collection (or at ...

9. collection filters and Many-to-Many    forum.hibernate.org

Hi, Here's my problem. I have an existing table structure: (simplified) TABLE SCIENTISTS: SC_ID TABLE REPORTS: RP_ID TABLE SC_RP: RP_ID SC_ID ROLE In hibernate, I set up getReports() in Scientists, which works fine, except now I want to retrieve reports only if the role for the scientists equals("PI"). From previous posts, I can see how session.filter could help me with a ...





10. Filtering a collection    forum.hibernate.org

Trying to filter a collection. I do get the initial collection of campusLocs below but I hang on the line that creats a new collection of uniqLocs. I dont get any exceptions or anything, jsut hang. Any help will be appreciated. BTW, the application architecture is struts/weblogic8/oracle9i. session = SessionHelper.getSession(); logger.info("getCampusLocations: B4 findCollection " ); campusLocs = gateway.findCollection("HrRecruitSchedule"); logger.info("getCampusLocations: all locs ...

11. filtering always throws QueryException: The collection was u    forum.hibernate.org

I query, get a List of results, then (try to) filter those results. This always produces: [java] net.sf.hibernate.QueryException: The collection was unreferenced [java] at net.sf.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:3408) [java] at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3471) [java] at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3366) [java] at com.publishworks.merchandise.ItemMeta.filterForAttributeName(ItemMeta.java:24) [java] at com.publishworks.hibernate.test.Test1.ReebokTest(Test1.java:99) [java] at com.publishworks.hibernate.test.Test1.main(Test1.java:189) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:324) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:233) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:170) [java] at ...

12. filter collection based on business method    forum.hibernate.org

public class Parent { private List children; public List getChildren() { List res = new LinkedLIst(); for(Iterator it=children.iterator(); it.hasNext(); ) { Child child = (Child) it.next(); if( businessMethod(child) ) ...

13. collection filter limit    forum.hibernate.org

14. Filter whth collections    forum.hibernate.org

Hello all... My class diagram... Author name compositions Composition publisher authors How can I list Authors to associate him to a composition??? I explain: I would like to list the authors that yet aren't authors of a composition. So, how can I write a query that list all authors, except the authors of the a composition. Something like this query in ...

15. Init. a Collection with a sub set of data using a filter?    forum.hibernate.org

I currently have the requirement to lazy load a collection based on some date criteria. i.e. I may have a collection of details that are amount sensitive and I want to be able to load up a sub set of that collection (ones that are above a certain amount). I can use a filter such in the manner of Code: session.filter(persistentCollection, ...

16. Collection (man-to-many) filtering    forum.hibernate.org

I have the following mapping and I would like to find out if there's a better way to filter the results of a collection. I want InventoryItem to contain only the "promo" items where promotions.offer_ends is a date in the future. The current solution using "when=" works but I'm not sure how portable it is. Is there a more Hibernatish way? ...





17. Collection filtering in Hibernate 2.1.x    forum.hibernate.org

The new Hibernate3 defines the tag in the mappings file for enabling subsets of data to be returned, which is great. I want to know if it's possible to filter the results of a one-to-many association in Hibernate 2.1.x, without having to create a separate query just for filtering the associated collection (I make a query for an object, but ...

18. What's the best way to filter collections?    forum.hibernate.org

Hibernate version: 2.1 Let's say I have an order with 100 line items and I want to display a single item in the order. I can use something like the following to get the subset of my line items, lineItems = session.filter(order.getLineItems, "where this.itemNo=20") However, the client code only retrieves line items via order.getLineItems() and is not aware of session. The ...

19. ConcurrentModificationException when filtering collection    forum.hibernate.org

Beginner Joined: Tue Sep 09, 2003 5:20 pm Posts: 43 I am getting this error when trying to filter a collection (getAssessments) for an object (PoClassMeasurement) I've just retrieved. Am I doing the filter incorrectly? or what. I hope I've provide the information below correctly. I appreciate the template as to what to provide. At first, it seemed a little irritating. ...

20. Filtering Collections    forum.hibernate.org

Hibernate version: 3.0.3 Hello, I have read about the new filter-def in Hibernate 3.0, but I think it is not versatile enough for my application. Is there another way to filter the associated collections of an object? The associated Objects to my "main"-object are being versioned, so their amount can grow without limit. I'd like to just retrieve the ones with ...

21. hibernate3 collection filter    forum.hibernate.org

I have a class Employees that has a collection of class Address, and also a collection of class Groups. When I query for Employees, since I can outer join fetch only one collection, I fetch the collection of Address. Once I get the list of Employees, I want to lazy initialize the collection Groups - but for this collection, I want ...

22. How to filter a collection of collection    forum.hibernate.org

Lets say that I have A ---->* B -----> * C This is working fine : List X=session.createFilter( a.getBs(),"order by this.fieldinB").list(); But what about I want to order on a field in C This is not working: List X=session.createFilter( ((B) a.getBs()).getCs(),"order by this.fieldinC").list(); How can I sort my entries on a field in C ?

23. getReturnTypes() fails on collection filter    forum.hibernate.org

Hi I'm using a simple collection filter: query = session.createFilter(docs, "where this.id < 20"). The filter works fine, but as soon as I call query.getReturnTypes(), I get an exception (see bellow). I have to call it because I'm writing a query execution framework and I need reflection. It happened on 3.0.5 and 3.1 CVS. Is this a bug or am I ...

24. filter and collection was unreferenced    forum.hibernate.org

25. filtering collections on object graph    forum.hibernate.org

Assume the following object graph (an example): person.contacts.address.city.name person is the owning class. contacts is a collection (one-to-many), city and address are many-to-one relationships. name is a string attribute on city. Now I would like the following: Get all persons which contacts are in a specific city. It should return person objects where ONLY contacts are included where the city name ...

26. filtering collections    forum.hibernate.org

Hi, I have 2 tables named Forms and FormPages. Forms have one to many relationship to FormPages table. The Forms entity can have multiple FormPages entities in it. I need to retrieve all Forms; and the FormPages collection should be filtered w.r.t a field named 'isloaded' in the FormPages table. I have written the following code: Criteria crt=HibernateUtil.getCurrentSession().createCriteria(Forms.class); crt.createCriteria("formpageses"); .add((Expression.eq("isloaded","Y"))); crt.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP); ...

27. Many-to-many collections retrieval & filtering logic    forum.hibernate.org

First of all if you have declared many to many relationship in both direction you can simply do: item = session.load( Item.class, id ); Set categories = item.getCategories(); that is all. If for some reason there is not item.categories and only category.items than you may use this query: select c.id from Category c join c.items i where i = :chosenItem Please ...

29. Filter Collection    forum.hibernate.org

30. When not to use filters on collections    forum.hibernate.org

Hi, consider this mapping: Code: class Thing { ... @OneToMany(mappedBy = "thing", cascade = CascadeType.ALL) @org.hibernate.annotations.Cascade( value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN ) @Filters({ @Filter(name = "littleThings", condition = "(littles = 0)"), @Filter(name = "specificThings", condition = "(specific in (:id))") }) private Set bigThings= new HashSet(); ... } ...