Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Examples/JPA/QueryOptimization

< EclipseLink‎ | Examples‎ | JPA
Revision as of 15:53, 15 October 2007 by Unnamed Poltroon (Talk) (New page: EclipseLink allows users the option to optimize their queries through the use of a query hint. == Via Annotations == <code><pre> @Entity @Table(name="JPA_EMPLOYEE") @NamedQuery( name="f...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

EclipseLink allows users the option to optimize their queries through the use of a query hint.

Via Annotations

@Entity
@Table(name="JPA_EMPLOYEE")
@NamedQuery(
  name="findEmployeeByPK",
  query="SELECT OBJECT(employee) FROM Employee employee WHERE employee.id = :id"),
  hints={
    @QueryHint(
      name=EclipseLinkQueryHints.BATCH, 
      value=EclipseLinkQueryHints.BATCH),
    @QueryHint(
      name=EclipseLinkQueryHints.FETCH, 
      value=EclipseLinkQueryHints.FETCH),
  }
)
public class Employee implements Serializable {
...

}

Via XML

<entity name="Employee" class="org.eclipse.testing.Employee" access="PROPERTY">
  ...
  <named-query name="findAllEmployeesByFirstName">
    <query>SELECT OBJECT(employee) FROM Employee employee WHERE employee.firstName = :firstname</query>
    <hint name="eclipselink.batch" value="eclipselink.batch">
    <hint name="eclipselink.join-fetch" value="eclipselink.join-fetch">
  </named-query>
  ...
</entity>

Back to the top