How do I get Hibernate Filters to work in JPA? -
i have following entity class:
@entity @filterdef (name = "bylastname", parameters = @parameter (name = "lastname", type="string")) @filters ({ @filter (name = "bylastname", condition = "lastname = :lastname") }) public class user { string firstname; string lastname; } in dao this:
public user findbyid (long id) { session s = (session) em.getdelegate ( ); s.enablefilter ("bylastname").setparameter ("lastname", "smith"); user u = em.find (user.class, id); return (u); } now, if i'm understanding correctly, filter should applied, , user try retrieve should come null if lastname not equal "smith". problem filters don't appear applied. user attempt retrieve database, regardless of value of lastname gets returned.
am misunderstanding how filters work? or missing in how have configured? note i'm not using hibernate.cfg.xml; configured me using jpa , annotations.
any appreciated.
thanks.
filters not affect form of ids. exact reason one-to-one , many-to-one associations cannot filtered.
Comments
Post a Comment