use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class BookingServiceImpl method get.
@Transactional(Transactional.TxType.SUPPORTS)
@Override
public Booking get(Long id) {
TypedQuery<Booking> query = entityManager.createQuery("SELECT b FROM Booking b WHERE b.id=:id", Booking.class);
query.setParameter("id", id);
Booking booking = null;
try {
booking = query.getSingleResult();
} catch (NoResultException e) {
// nothing to do
}
return booking;
}
use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class GetCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("ID");
table.column("Flight");
table.column("Customer");
Booking booking = bookingService.get(id);
table.addRow().addContent(booking.getId(), booking.getFlight(), booking.getCustomer());
table.print(System.out);
return null;
}
use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class BookingServiceImpl method add.
@Transactional(Transactional.TxType.REQUIRES_NEW)
@Override
public void add(String flight, String customer) {
Booking booking = new Booking();
booking.setCustomer(customer);
booking.setFlight(flight);
entityManager.persist(booking);
}
use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class BookingServiceImpl method get.
@Transactional(Transactional.TxType.SUPPORTS)
@Override
public Booking get(Long id) {
TypedQuery<Booking> query = entityManager.createQuery("SELECT b FROM Booking b WHERE b.id=:id", Booking.class);
query.setParameter("id", id);
Booking booking = null;
try {
booking = query.getSingleResult();
} catch (NoResultException e) {
// nothing to do
}
return booking;
}
use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class BookingServiceImpl method add.
@Transactional(Transactional.TxType.REQUIRES_NEW)
@Override
public void add(String flight, String customer) {
Booking booking = new Booking();
booking.setCustomer(customer);
booking.setFlight(flight);
entityManager.persist(booking);
}
Aggregations