use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class BookingServiceImpl method remove.
@Transactional(Transactional.TxType.REQUIRES_NEW)
@Override
public void remove(Long id) {
Booking booking = get(id);
entityManager.remove(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 remove.
@Transactional(Transactional.TxType.REQUIRES_NEW)
@Override
public void remove(Long id) {
Booking booking = get(id);
entityManager.remove(booking);
}
use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class BookingServiceImpl method add.
@Override
public void add(String flight, String customer) {
Booking booking = new Booking();
booking.setCustomer(customer);
booking.setFlight(flight);
jpaTemplate.tx(TransactionType.RequiresNew, entityManager -> {
entityManager.persist(booking);
entityManager.flush();
});
}
use of org.apache.karaf.examples.jpa.Booking in project karaf by apache.
the class ListCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("ID");
table.column("Flight");
table.column("Customer");
for (Booking booking : bookingService.list()) {
table.addRow().addContent(booking.getId(), booking.getFlight(), booking.getCustomer());
}
table.print(System.out);
return null;
}
Aggregations