org.jboss.seam.persistence
Interface SeamPersistenceProvider


public interface SeamPersistenceProvider

The interface can be implemented to provide extra functionality to a seam managed persistence context.

seam-persistence contains a default implementation and a hibernate based implementation.

Persistence providers are services rather than beans. Injection etc is not availible and the implementations classes must be listed in

META-INF/services/org.jboss.seam.persistence.SeamPersistenceProvider

Author:
Stuart Douglas

Method Summary
 void checkVersion(Object bean, EntityManager entityManager, Object oldVersion, Object version)
           
 Set<Class<?>> getAdditionalEntityManagerInterfaces()
           
 Class<?> getBeanClass(Object bean)
          Returns the class of an entity bean instance
 Object getId(Object bean, EntityManager entityManager)
          Get the value of the entity identifier attribute.
 String getName(Object bean, EntityManager entityManager)
          Get the name of the entity
 FlushModeType getRenderFlushMode()
           Gets the FlushMode the persistence contexts should use during rendering
 Object getVersion(Object bean, EntityManager entityManager)
          Get the value of the entity version attribute.
 boolean isCorrectProvider(EntityManager em)
          Should return true if this is the correct persistence provider for the given entity manager factory
 boolean isDirty(EntityManager entityManager)
          Does the persistence context have unflushed changes? If it does not, persistence context replication can be optimized.
 Object proxyDelegate(Object delegate)
          Wrap the delegate before returning it to the application
 EntityManager proxyEntityManager(EntityManager entityManager)
           
 boolean registerSynchronization(Synchronization sync, EntityManager entityManager)
          Register a Synchronization with the current transaction.
 void setFlushMode(EntityManager entityManager, FlushModeType type)
          sets the flush mode
 void setFlushModeManual(EntityManager entityManager)
          Set the flush mode to manual-only flushing.
 

Method Detail

setFlushMode

void setFlushMode(EntityManager entityManager,
                  FlushModeType type)
sets the flush mode


isCorrectProvider

boolean isCorrectProvider(EntityManager em)
Should return true if this is the correct persistence provider for the given entity manager factory


setFlushModeManual

void setFlushModeManual(EntityManager entityManager)
Set the flush mode to manual-only flushing. Called when an atomic persistence context is required.


getRenderFlushMode

FlushModeType getRenderFlushMode()

Gets the FlushMode the persistence contexts should use during rendering

Ideally, this should be MANUAL since changes should never flush to the database while in render response and the cost of a dirty check can be avoided. However, since the MANUAL mode is not officially part of the JPA specification, the default implementation will perform no operation.


isDirty

boolean isDirty(EntityManager entityManager)
Does the persistence context have unflushed changes? If it does not, persistence context replication can be optimized.

Returns:
true to indicate that there are unflushed changes

getId

Object getId(Object bean,
             EntityManager entityManager)
Get the value of the entity identifier attribute.

Parameters:
bean - a managed entity instance

getName

String getName(Object bean,
               EntityManager entityManager)
               throws IllegalArgumentException
Get the name of the entity

Parameters:
bean -
entityManager -
Throws:
IllegalArgumentException - if the passed object is not an entity

getVersion

Object getVersion(Object bean,
                  EntityManager entityManager)
Get the value of the entity version attribute.

Parameters:
bean - a managed entity instance

checkVersion

void checkVersion(Object bean,
                  EntityManager entityManager,
                  Object oldVersion,
                  Object version)

registerSynchronization

boolean registerSynchronization(Synchronization sync,
                                EntityManager entityManager)
Register a Synchronization with the current transaction.


proxyDelegate

Object proxyDelegate(Object delegate)
Wrap the delegate before returning it to the application


proxyEntityManager

EntityManager proxyEntityManager(EntityManager entityManager)

getAdditionalEntityManagerInterfaces

Set<Class<?>> getAdditionalEntityManagerInterfaces()

getBeanClass

Class<?> getBeanClass(Object bean)
Returns the class of an entity bean instance

Parameters:
bean - The entity bean instance
Returns:
The class of the entity bean


Copyright © 2011 Seam Framework. All Rights Reserved.