Java Tutorial/JPA/Cache

Материал из Java эксперт
Перейти к: навигация, поиск

Cache Hint

File: Student.java



import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.QueryHint;
@Entity
@NamedQuery(name="findStudentNoCache",
            query="SELECT e FROM Student e WHERE e.id = ?1",
            hints={@QueryHint(name="toplink.cache-usage", value="DoNotCheckCache")})
public class Student {
    @Id
    private int id;
    private String name;
    private long salary;
    public int getId() {
        return id;
    }
    
    public String getName() {
        return name;
    }
    public long getSalary() {
        return salary;
    }
    
    public String toString() {
        return "Student " + getId() + 
               ": name: " + getName() +
               ", salary: " + getSalary();
    }
}