Java Reference
In-Depth Information
The corresponding database row gets deleted from the Catalog table. Subsequently,
create and run a query to list all the entity instances mapped to the database. The
session bean class, CatalogTestBean , is listed next:
package ejb3;
import java.util.Iterator;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
* Session Bean implementation class CatalogTestBean
@Stateless(mappedName = "EJB3-SessionEJB")
public class CatalogTestBean implements CatalogTestBeanRemote {
@PersistenceContext(unitName = "em")
EntityManager em;
* Default constructor.
public CatalogTestBean() {
// TODO Auto-generated constructor stub
public String test() {
Catalog catalog = new Catalog(new Integer(1), "Oracle Magazine",
"Oracle Publishing", "September-October 2009",
"Put Your Arrays in a Bind","Mark Williams");
Catalog catalog2 = new Catalog(new Integer(2), "Oracle Magazine",
"Oracle Publishing", "September-October 2009",
"Oracle Fusion Middleware 11g: The Foundation for Innovation",
"David Baum");
Catalog catalog3 = new Catalog(new Integer(3), "Oracle Magazine",
"Oracle Publishing", "September-October 2009",
"Integrating Information","David Baum");
String retValue = "<b>Catalog Entries: </b>";
List catalogEntry = em.createQuery("SELECT c from Catalog c
"David Baum").getResultList();
for (Iterator iter = catalogEntry.iterator(); iter.hasNext(); ) {
Search WWH ::

Custom Search