hibernate-filters

Hibernate filter does not apply for join entity

南笙酒味 提交于 2021-01-27 19:35:07
问题 I am trying to understand hibernate filters, i thought that the filter is applied even if the query is not started from the filtered entity and can be applied if i just join to it. My entities: @Table(name = "SPM_SECTION", schema = "TEST") @GenericGenerator(name = "MODSEC_ID.GEN", strategy = "uuid2") public class ModuleSection implements Serializable { private AcademicClass academicClass; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "CLASS_ID") public AcademicClass getAcademicClass()

How to filter an entity in hibernate with hibernate filters

风格不统一 提交于 2020-01-24 23:03:15
问题 I need to filter an entity in a list of objects, for example: public class Student { private int id; private List<Course> courses; } public class Course { private int id; private String name; private float note; private Classroom classroom; } public class Classroom { private int id; private String classroom; } How to obtain a student object with a list of courses with only notes greater than 70, and located in classroom 23 (for example)? Is there a way to use the name of the entity instead of

Filter condition using attributes defined in base class

喜你入骨 提交于 2019-12-25 09:39:08
问题 I have 3 classes Base , Child and Other defined as follows: @Entity @Filter(name = "myFilter", condition = "propBase = 'special'") @Inheritance(strategy = InheritanceType.JOINED) public abstract class Base { private String propBase; //Getters, Setters } @Entity public class Child extends Base { private String propChild; //Getters, Setters } @Entity public class Other { @Filter(name = "myFilter", condition = "propBase = 'special'") private Set<Child> myList; //Getters, Setters } Assume the

Soft delete an entity in Grails with Hibernate Filters Plugin

南笙酒味 提交于 2019-12-13 15:01:08
问题 I was looking for a way to avoid deleting my users from DB, but instead to mark them as deleted and don't bring them back in queries. I found this plugin http://grails.org/plugin/hibernate-filter, which was a great tool for the task. But when I tried to implement my solution, I passed trought same problems whose solutions wheren't (or I was not able to find) on internet. So, next, I describe the way that I solve the problem of soft delete. 回答1: In this example I will make my class User to

Using @Filter with @ManyToOne relation

ぃ、小莉子 提交于 2019-12-12 04:59:08
问题 I'm using Hibernate 3.6.7-Final and Spring 3.0.5. I have entity like this @Entity public class Foo { @ManyToOne private Bar bar; } @Entity public class Bar { @Column String group; } How can I use @Filter in Foo where I want to get all Foo 's that have Bar with group = :group ? This is supposed to be a security constraint. Tryied just setting @Filter(name = "groupFilter", condition = "group = :group") at the attribute bar from Foo but it didn't work. Does hibernate have support for this or

How to add a where clause to a Hibernate @OneToMany explicit join table entity?

此生再无相见时 提交于 2019-12-11 15:29:04
问题 Given two entities: Card PurchaseProductGroup , which has a ppg_status column (field named as status on the entity) that can be 'A' (active) or 'D' (deleted) These conceptually have a many-to-many relationship but an explicitly defined join table entity named PurchaseProductGroupCard is used (so an external ID can be assigned for each mapping). So both Card and PurchaseProductGroup have a @OneToMany relationship to PurchaseProductGroupCard , e.g. in Card there is the following: @OneToMany

Spring , Transactions , Hibernate Filters

风格不统一 提交于 2019-12-10 21:42:36
问题 I am using declarative transactions in Spring. I have a service layer which is annotated with "Transactional". This service layer calls the DAO. I need to enable a hibernate filter in all the dao methods. I don't want to have to explicitly call teh session.enablefilter each time. So is there a way using spring transaction aop etc such that a intercepter can be called when the hibernate session is created? My Service layer: @Service("customerViewService") @Transactional public class

Hibernate filter Entity where oneToMany relation contains an object

我只是一个虾纸丫 提交于 2019-12-10 20:47:27
问题 I want to use the hibernate filter but I don't know if what I want to do is possible I have 2 entities : Message and MessageUser. A Message has a list of MessageUser. I want to create a filter so I can do something like : final Session filteredSession = sessionFactory.openSession(); final Filter filter = filteredSession.enableFilter("userRecipient"); filter.setParameter("userRecipient", myUser); filter.validate(); final List<Message> userMessages = filteredSession.createQuery("from Message")

Hibernate enableFilter not working when loading entity by id

坚强是说给别人听的谎言 提交于 2019-12-02 00:39:04
问题 I have 3 classes: Event PublicEvent extends Event PersonalEvent extends Event my hibernate mapping file is somethings like bellow. i wanna add one filter for PersonalEvent and before loading this object, i was enabled that's filter. but this is not working. my hibernate version is 4.3.11.Final . Event.hbm.xml <hibernate-mapping> <class name="org.calendar.Event"> ... <filter name="personalEventAuthorize" condition="person_ID = :personId" /> </class> <joined-subclass name="org.calendar

Hibernate enableFilter not working when loading entity by id

心不动则不痛 提交于 2019-12-01 21:32:38
I have 3 classes: Event PublicEvent extends Event PersonalEvent extends Event my hibernate mapping file is somethings like bellow. i wanna add one filter for PersonalEvent and before loading this object, i was enabled that's filter. but this is not working. my hibernate version is 4.3.11.Final . Event.hbm.xml <hibernate-mapping> <class name="org.calendar.Event"> ... <filter name="personalEventAuthorize" condition="person_ID = :personId" /> </class> <joined-subclass name="org.calendar.PersonalEvent" extends="org.calendar.Event"> <key column="id" property-ref="id" /> ... <many-to-one name=