Filter « Map « JPA Q&A





1. Can I specify a hibernate relationship with a filter?    stackoverflow.com

I have a foo that has a relationship to many bar's. When I delete bar's in my system I want to keep them in the database for some crazy business reason so ...

2. Hibernate: does filter on parent entity implicitly filters child entity?    stackoverflow.com

Suppose there are two entities EntityA and EntityB. Two tables are defined for both entities. EntityB is child entity of EntityA. Now in java pojos using hibernate annotation, i have defined two classes ...

3. Hibernate Filter Programmatically    stackoverflow.com

How to programmatically achieve the same result (as the following annotation would achieve)? Or injecting the value 'SMITH' in a spring configuration file?

@Filter(name="smithFilter", condition="LAST_NAME = 'SMITH'")
public String getLastName()
{
   ...

4. HiberNate Filter with annotaions in one to many mapping    stackoverflow.com

I have a class Person which can have 4 type of addresses and there could be multiple number of adresses corresponding to a single type of address.

public class Person{
 Set<Address> ...

5. Hibernate - filter child collection    coderanch.com

I'm back with yet another!! I have a Criteria query where I call a parent/child relationship which his mapped as a parent class w/ a Set collection of child records. To get them all I can call this, and it works fine: public List getAll() { //get session from hibernate Session s = HibernateUtil.getCurrentSession(); //create selection criteria Criteria c = s.createCriteria(AnnouncementCategory.class); ...

6. Help with querying children of children to filter parent obj    forum.hibernate.org

Hi, I'm trying to execute a particular query either in HQL or using the Criteria API. I have four tables, a User table (srm_user_t), a Groups table (srm_group_t), a table that maps users to groups (srm_group_member_t) and a permissions table that maps the permissions that a group has (srm_group_permissions_t). Here is my mapping: Code: ...

7. ManyToMany, SoftDelete Filter    forum.hibernate.org

Querying data from ManyToMany mapping using conditions does not seem to work. The scenario: 1. every table has a boolean "deleted" column enabling soft deletes. 2. Persons and Groups are mapped via ManyToMany --> Resulting in a mapping table also having this deleted column. The code extract from the Person class: Code: @ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER) ...

8. Filters in mapping for one-to-one associations    forum.hibernate.org

9. Filter on a manytoone association    forum.hibernate.org

Hi, I'm trying to filter Offers based on the property Region from a manytoone association with City. I understand I have to place the filter on Offer and that I can use arbitrary sql in the condition but I don't understand how I would phrase the sql. Initially I thought placing the filter on City would do the trick, but there ...





10. Filtering Join to an Inheritance-Mapped Entity    forum.hibernate.org

select dogbasket0_.id as id2_0_, dogs1_.id as id0_1_, dogs1_1_.alive as alive0_1_, dogs1_.barkDecibels as barkDeci1_1_1_, dogs1_.basket_id as basket3_1_1_, dogs1_.basket_id as basket3_2_0__, dogs1_.id as id0__ from DogBasket dogbasket0_ left outer join Dog dogs1_ on dogbasket0_.id=dogs1_.basket_id ...

11. Filter vs Where clause on Class Mapping Definition    forum.hibernate.org

Your condition will be hard-coded. It's like a permanent filter. I use it when I want to get only active records (based on some flag - so, making a record inactive should not delete it, but will make it inaccessible from the application). I wonder though if I can still retrieve inactive records via a query or filter if I do ...

12. Filter inheritance problem    forum.hibernate.org

Hello togehter, I've a problem with inheritance and filter in hibernate. I've two classes element1 and element2 they have both there own table in the database. The search over all these elements in element3 is OK . Now I try to filter only the active elements in element3 as a list. The active field is in element1. Then I get this ...

13. Filtering of Map    forum.hibernate.org

Greetings! Is it possible to filter a property of the type Map? I have the following case (classical): There are two classes Company and Person. These classes are associated using Temporal Property pattern (also known as Historical Mapping). Effectively, class Person has a property of type Map where the key is a Date when the employment has started and the value ...

14. Filtering by child (many-to-many) relationship    forum.hibernate.org

I try that again and get the same result: SEVERE: Error filtering enterprises:cirrus.hibernate.QueryException: IN expected [from Enterprise as e where e.deleted!=:isDeleted and :mySegment in elements(e.segments)] And I try another adjust: Query query = sessioncreateQuery("from Enterprise in class adama.supplier.Enterprise where Enterprise.deleted!=:isDeleted and :mySegment in elements(Enterprise .segments)"); query.setParameter("isDeleted", Boolean.TRUE); query.setParameter("mySegment", new Long(segment)); objects = query.list(); and get the follow Exception: SEVERE: Error filtering ...

15. Is Filtering at sublevels using hibernate mappings possible?    forum.hibernate.org

I have a use case where there are categories subCategories articles Customer wants to filter via user attributes at each of these levels and if no data exists at the sub level then don't show the parent. i.e If there are no articles for a subCategory then don't show subCategory and if that evaluates that now there are no subCategories for ...

16. CreateCriteria Filtering on Child Property    forum.hibernate.org





17. SQLGrammarException when filtering collection in mapping    forum.hibernate.org

Hallo, I use a delete-flag instead of a delete-operation. But I a SQLGrammarException will be thrown when I try to filter the collection with a where in my mapping-file. I use Hibernate 3.0. Mapping-File: Code:

18. Mapping error while using simple filter    forum.hibernate.org

Hi all, How do I use a filter in the mapping mapping file??? I took the syntax directly off the Hibernate ref guide and I believe I'm using the correct DTD... But still I get an exception... If I remove the filter usage, all is ok... Hibernate version: 3.1 Mapping documents: Code:

19. Filtering objects if child has a null property    forum.hibernate.org

20. Simple Filtering of Child Objects    forum.hibernate.org

My basic situation is that I have an object named Committee, and the Committee has members that belong to it (the data structure is a little more complex, but this covers the principle). There is a method Committee.getMembers() which returns members. At a certain point I want Hibernate to bring back a list of Committee objects with a list of members, ...

21. session.get does not apply filters defined in mapping file    forum.hibernate.org

Hello, I have a database with logical deletes and use hibernate's filters so I get only entities not marked as deleted. But now I found out that session.get() does not apply the filters. My code is the following: Code: SessionFactory factory = HibernateUtil.getSessionFactory(databaseName); Session session = factory.openSession(); session.enableFilter(FILTER_NOT_DELETED); UserVO user1 = (UserVO) session.createQuery("FROM UserVO WHERE id='userId'").uniqueResult(); UserVO user2 = (UserVO) session.get(UserVO.class, ...

22. Filtering results in Annotation Mappings    forum.hibernate.org

Hi I was wondering if someone could give me some pointers in the right direction... What I need to do is filter the results to only those that are active. If for example the property in a mapped entity looked like this @OneToMany @JoinTable(...) @Filter("WHERE active = true") //obviously I just made this part up, but I need this kind of ...

23. Filter child collection on query?    forum.hibernate.org

I have a bidirectional mapping that looks like this; Parent: Child: I need to run a query like this; select parent from t_parent where parent.id in (x,y) and child.childType != '' So I have used; List results = session.createCriteria(Parent.class) .add(Restrictions.in("id", ids)) .createCriteria("child","kids") .add(Restrictions.ne("kids.childType","")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list() and a similar ...

25. filtering mapped collection    forum.hibernate.org

Hi all, Is there any way to filter entity's mapped collection? I have AnObject having a collection of AChildObject. I'd like to make a query (preferably criteria-based, but HQL is acceptable) returning list of AnObject with prefetched AChildObject collections, but not all of children - a subset of them. So I can use AnObject.getChildren() without issuing additional queries to the DB ...

26. Is there anyway to make @Filters inherited?    forum.hibernate.org

28. Inheritance of Filter annotations    forum.hibernate.org

I have a base entity in which I like to define a filter in. I'd like to use this filter for all sub-classes but when I try to enable it I get the following exception. org.hibernate.HibernateException: No such filter configured [myFilter] My question is if what I'm trying to accomplish is possible. I'm using Hibernate 3.2.6.ga and Hibernate-annotations 3.3.1.ga. Thanks, Johan ...