package com.sapient.impl;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.sapient.entities.Book;
import com.sapient.spec.BookDAO;
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
public class BookDAOEJB implements BookDAO{
@PersistenceContext
private EntityManager em;
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void saveBook(Book b) {
System.out.println("---- saveBook method(***) called ----");
em.persist(b);
}
@Override
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public Book findBookById(String id) {
Book bookFromDB = em.find(Book.class, id);
System.out.println("---- BookDAO EJB Loading book with id "+id);
return bookFromDB;
}
}
Wednesday, 21 December 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment