Java Reference
In-Depth Information
{Catalog element = (Catalog);
retValue =retValue + "<br/>" + element.getJournal() +
"<br/>" + element.getPublisher() +
"<br/>" + element.getEdition() + "<br/>" +element.getTitle() + "<br/>"
+ element.getAuthor() +
Similarly, run a query to list all titles. Remove an entity instance using the remove
method of the EntityManager . Subsequently, run a query to list all the remaining
entity instances.
The test method returns a String , which consists of a catalog entry, a list of all the
titles, and all the entity instances after removing an entity instance. The session bean
class is listed next:
package model;
import java.util.Iterator;
import java.util.List;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@Stateless(name = "CatalogTestSessionEJB",
mappedName = "EJB3-SessionEJB")
public class CatalogTestSessionEJBBean implements
CatalogTestSessionEJB {
@PersistenceContext(unitName = "em")
private EntityManager em;
public CatalogTestSessionEJBBean() {
public String test() {
Catalog catalog =
new Catalog("Kimberly Floss", "Nov-Dec 2004", new Integer(1),
"Oracle Magazine", "Oracle Publishing",
"Database Resource Manager");
Catalog catalog2 =
new Catalog("Jonas Jacobi", "Nov-Dec 2004", new Integer(2),
"Oracle Magazine", "Oracle Publishing",
Search WWH ::

Custom Search