Java Reference
In-Depth Information
Coding queries for your application
As you can see from the earlier code, the producer classes make use of a bean
named DataManager to fill up their collection of data. This bean performs some
simple finds on the Seat and SeatType objects, as shown by the following code:
@javax.enterprise.context.ApplicationScoped
public class DataManager {
@Inject
private EntityManager em;
public Seat findSeatById(Long id) {
return em.find(Seat.class, id);
}
public List<SeatType> findAllSeatTypes() {
return em.createQuery("from SeatType
seat").getResultList();
}
public List<Seat> findAllSeats() {
return em.createQuery("from Seat
seat").getResultList();
}
public void deleteAllData() {
em.createQuery("delete from
Seat").executeUpdate();
em.createQuery("delete from
SeatType").executeUpdate();
}
}
Search WWH ::




Custom Search