Java Reference
In-Depth Information
Iterate over the List , which is actually just one catalog entry, to retrieve the Catalog
entity instance:
for (Iterator iter = catalogEntry.iterator(); iter.hasNext(); ) {
entityInstance = (Catalog);
The find() method returns the Catalog entity instance retrieved. The session bean
class CatalogSessionEJBBean 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 = "CatalogSessionEJB", mappedName = "EJB3-JSF-
public class CatalogSessionEJBBean implements CatalogSessionEJB {
@PersistenceContext(unitName = "em")
private EntityManager em;
public CatalogSessionEJBBean() {
public Object mergeEntity(Object entity) {
return em.merge(entity);
public void persistEntity(int catalogId, String journal,
String publisher,
String edition, String title,
String author) {
Catalog catalog =
new Catalog(author, edition, new Integer(catalogId),
journal, publisher, title);
Search WWH ::

Custom Search