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/PessimisticLocking

< EclipseLink‎ | Examples‎ | JPA
Revision as of 15:21, 15 October 2007 by Unnamed Poltroon (Talk) (Via Annotations)

EclipseLink allows users the option of using pessimistic locking on their queries. This is done 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.PESSIMISTIC_LOCK, 
      value=EclipseLinkQueryHints.PESSIMISTIC_LOCK)
  }
)
public class Employee implements Serializable {
...

}

Via XML

Copyright © Eclipse Foundation, Inc. All Rights Reserved.