Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @NamedQuery(name="Employee.salaryLessThan", query="select e from Employee e where salary < :salary")
- class Employee {
- Integer id;
- String name;
- Double salary;
- }
- ------------------
- EntityManager em;
- TypedQuery<Employee> query = em.createNamedQuery("Employee.salaryLessThan", Employee.class);
- query.setParameter("salary", salary);
- List<Employee> result = query.getResultList();
- em.close();
- return result;
- --------
- class Publisher {
- @Id
- @GeneratedValue(strategy=GenerattionType.IDENTITY)
- Integer id;
- String name;
- String address;
- @OneToMany(cascade=CascadeType.PERSIST)
- List<Book> books;
- }
- class Book {
- @Id
- Integer id;
- String title;
- BigInteger price;
- @ManyToOne(mappedBy="books")
- publisher;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement