Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is not supported by JPA but if you are using hibernate as JPA provider then you can use annotation <code>@FilterDef</code> and <code>@Filter</code>.</p> <blockquote> <p><a href="http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#objectstate-filters" rel="noreferrer">Hibernate Core Reference Documentation</a></p> <p>Hibernate3 has the ability to pre-define filter criteria and attach those filters at both a class level and a collection level. A filter criteria allows you to define a restriction clause similar to the existing "where" attribute available on the class and various collection elements. These filter conditions, however, can be parameterized. The application can then decide at runtime whether certain filters should be enabled and what their parameter values should be. Filters can be used like database views, but they are parameterized inside the application.</p> </blockquote> <p><strong>Exemple</strong> </p> <pre><code>@Entity public class A implements Serializable{ @Id @Column(name = "REF") private int ref; @OneToMany @JoinColumn(name = "A_REF", referencedColumnName = "REF") @Filter(name="test") private Set&lt;B&gt; bs; } @Entity @FilterDef(name="test", defaultCondition="other = 123") public class B implements Serializable{ @Id @Column(name = "A_REF") private int aRef; @Id @Column(name = "OTHER") private int other; } Session session = entityManager.unwrap(Session.class); session.enableFilter("test"); A a = entityManager.find(A.class, new Integer(0)) a.getb().size() //Only contains b that are equals to 123 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload