org.jboss.seam.framework
Class EntityHome<E>

java.lang.Object
  extended by org.jboss.seam.framework.Controller
      extended by org.jboss.seam.framework.PersistenceController<T>
          extended by org.jboss.seam.framework.MutableController<T>
              extended by org.jboss.seam.framework.Home<javax.persistence.EntityManager,E>
                  extended by org.jboss.seam.framework.EntityHome<E>
All Implemented Interfaces:
Serializable, Mutable

public class EntityHome<E>
extends Home<javax.persistence.EntityManager,E>

Base class for Home objects of JPA entities.

Author:
Gavin King
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.seam.framework.Home
instance, newInstance
 
Constructor Summary
EntityHome()
           
 
Method Summary
 void create()
          Run on EntityHome instantiation.
 E find()
          Implementation of find() for JPA
 javax.persistence.EntityManager getEntityManager()
          The Seam Managed Persistence Context used by this Home component
protected  String getEntityName()
          Implementation of getEntityName() for JPA
protected  String getPersistenceContextName()
          The name the Seam component managing the Persistence Context.
 boolean isManaged()
          Returns true if the entity instance is managed
protected  void joinTransaction()
          Implementation of joinTransaction() for JPA.
protected  E loadInstance()
          Utility method to load entity instance from the EntityManager.
 String persist()
          Persist unmanaged entity instance to the underlying database.
 String remove()
          Remove managed entity instance from the Persistence Context and the underlying database.
 void setEntityManager(javax.persistence.EntityManager entityManager)
          The Seam Managed Persistence Context used by this Home component.
 String update()
          Flush any changes made to the managed entity instance to the underlying database.
 
Methods inherited from class org.jboss.seam.framework.Home
assignId, clearInstance, createdMessage, createInstance, deletedMessage, getCreatedMessage, getCreatedMessageKey, getDeletedMessage, getDeletedMessageKey, getEntityClass, getId, getInstance, getMessageKeyPrefix, getNewInstance, getSimpleEntityName, getUpdatedMessage, getUpdatedMessageKey, handleNotFound, initDefaultMessages, initInstance, isIdDefined, raiseAfterTransactionSuccessEvent, setCreatedMessage, setDeletedMessage, setEntityClass, setId, setInstance, setNewInstance, setUpdatedMessage, updatedMessage
 
Methods inherited from class org.jboss.seam.framework.MutableController
clearDirty, setDirty, setDirty
 
Methods inherited from class org.jboss.seam.framework.PersistenceController
getPersistenceContext, setPersistenceContext
 
Methods inherited from class org.jboss.seam.framework.Controller
addCookie, addFacesMessage, addFacesMessageFromResourceBundle, createValueExpression, createValueExpression, debug, debug, error, error, evaluateValueExpression, evaluateValueExpression, failValidation, fatal, fatal, getApplicationContext, getBusinessProcessContext, getComponentInstance, getComponentInstance, getConversation, getConversationContext, getCookie, getEventContext, getEvents, getFacesContext, getFacesMessages, getIdentity, getLog, getMessages, getMethodContext, getPageContext, getRedirect, getSessionContext, getStatusMessages, getValidator, getValidator, info, info, interpolate, invalidateSession, isTransactionMarkedRollback, raiseAsynchronousEvent, raiseEvent, raiseTransactionSuccessEvent, render, sendHttpError, sendHttpError, trace, trace, validationFailed, validationSucceeded, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityHome

public EntityHome()
Method Detail

create

public void create()
Run on EntityHome instantiation.
Validates that an EntityManager is available.

Overrides:
create in class Home<javax.persistence.EntityManager,E>
See Also:
Home.create()

isManaged

@Transactional
public boolean isManaged()
Returns true if the entity instance is managed


update

@Transactional
public String update()
Flush any changes made to the managed entity instance to the underlying database.
If the update is successful, a log message is printed, a FacesMessage is added and a transaction success event raised.

Returns:
"updated" if the update is successful
See Also:
Home.updatedMessage(), Home.raiseAfterTransactionSuccessEvent()

persist

@Transactional
public String persist()
Persist unmanaged entity instance to the underlying database. If the persist is successful, a log message is printed, a FacesMessage is added and a transaction success event raised.

Returns:
"persisted" if the persist is successful
See Also:
Home.createdMessage(), Home.raiseAfterTransactionSuccessEvent()

remove

@Transactional
public String remove()
Remove managed entity instance from the Persistence Context and the underlying database. If the remove is successful, a log message is printed, a FacesMessage is added and a transaction success event raised.

Returns:
"removed" if the remove is successful
See Also:
Home.deletedMessage(), Home.raiseAfterTransactionSuccessEvent()

find

@Transactional
public E find()
Implementation of find() for JPA

Overrides:
find in class Home<javax.persistence.EntityManager,E>
See Also:
Home.find()

loadInstance

protected E loadInstance()
Utility method to load entity instance from the EntityManager. Called by find().
Can be overridden to support eager fetching of associations.

Returns:
The entity identified by getEntityClass(), getId()

joinTransaction

protected void joinTransaction()
Implementation of joinTransaction() for JPA.

Overrides:
joinTransaction in class Home<javax.persistence.EntityManager,E>

getEntityManager

public javax.persistence.EntityManager getEntityManager()
The Seam Managed Persistence Context used by this Home component


setEntityManager

public void setEntityManager(javax.persistence.EntityManager entityManager)
The Seam Managed Persistence Context used by this Home component.


getPersistenceContextName

protected String getPersistenceContextName()
The name the Seam component managing the Persistence Context.
Override this or getEntityManager() if your persistence context is not named entityManager.

Specified by:
getPersistenceContextName in class PersistenceController<javax.persistence.EntityManager>

getEntityName

protected String getEntityName()
Implementation of getEntityName() for JPA

Specified by:
getEntityName in class Home<javax.persistence.EntityManager,E>
See Also:
Home.getEntityName()


Copyright © 2011 Seam Framework. All Rights Reserved.