@Table(name = "BIKE")
public class Bike{
@Id
private String name;
private String description;
private int expectedkilometers;
//...some code omitted.
The generated Session Bean looks like:
@Stateless
public class BikeFacade implements BikeFacadeLocal {
@PersistenceContext
private EntityManager em;
public void create(Bike bike) {
em.persist(bike);
}
public void edit(Bike bike) {
em.merge(bike);
}
public void remove(Bike bike) {
em.remove(em.merge(bike));
}
public Bike find(Object id) {
return em.find(com.abien.wizardsample.Bike.class, id);
}
public List<Bike> findAll() {
return em.createQuery("select object(o) from Bike as o").getResultList();
}
}
The coresponding Local interface is clean and simple as well:
@Local
public interface BikeFacadeLocal {
void create(Bike bike);
void edit(Bike bike);
void remove(Bike bike);
Bike find(Object id);
List<Bike> findAll();
}
As mentioned, the code is o.k, but there is still room some for improvement: