Java Reference
In-Depth Information
Coding queries for your application
As you can see from the earlier code, the producer classes make use of beans named
SeatDao
and
SeatTypeDao
to fill their collections of data. These beans perform some
simple finds on the
Seat
and
SeatType
objects, as shown in the following code:
@Stateless
public class SeatDao extends AbstractDao<Seat> {
public SeatDao() {
super(Seat.class);
}
}
@Stateless
public class SeatTypeDao extends AbstractDao<SeatType> {
public SeatTypeDao() {
super(SeatType.class);
}
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public abstract class AbstractDao<T extends Serializable>
implements Serializable {
private final Class<T> clazz;
@Inject
private EntityManager em;
public AbstractDao(Class<T> clazz) {
this.clazz = clazz;
}
public T find(Object id) {
return em.find(clazz, id);
}