From: <hib...@li...> - 2006-03-09 18:49:59
|
Author: epbernard Date: 2006-03-09 13:48:31 -0500 (Thu, 09 Mar 2006) New Revision: 9583 Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java trunk/HibernateExt/ejb-api/src/javax/persistence/Query.java trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerFactoryImpl.java Log: EJB-141 Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java =================================================================== --- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java 2006-03-09 17:40:57 UTC (rev 9582) +++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java 2006-03-09 18:48:31 UTC (rev 9583) @@ -12,6 +12,8 @@ /** * @author Gavin King + * @author Emmanuel Bernard + * @deprecated no longer used since getEntityManager is no longer here */ public class CurrentEntityManagerImpl extends AbstractEntityManagerImpl { Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerFactoryImpl.java =================================================================== --- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2006-03-09 17:40:57 UTC (rev 9582) +++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2006-03-09 18:48:31 UTC (rev 9583) @@ -1,6 +1,7 @@ //$Id$ package org.hibernate.ejb; +import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.PersistenceContextType; import javax.persistence.spi.PersistenceUnitTransactionType; @@ -9,6 +10,7 @@ /** * @author Gavin King + * @author Emmanuel Bernard */ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { @@ -19,24 +21,24 @@ public EntityManagerFactoryImpl( SessionFactory sessionFactory, PersistenceUnitTransactionType transactionType, - boolean discardOnClose) { + boolean discardOnClose + ) { this.sessionFactory = sessionFactory; this.transactionType = transactionType; this.discardOnClose = discardOnClose; } public EntityManager createEntityManager() { - return createEntityManager( PersistenceContextType.TRANSACTION ); + return createEntityManager( null ); } - public EntityManager createEntityManager(PersistenceContextType type) { - return new EntityManagerImpl( sessionFactory, type, transactionType, discardOnClose ); + public EntityManager createEntityManager(Map map) { + //TODO support discardOnClose, persistencecontexttype?, interceptor, + return new EntityManagerImpl( + sessionFactory, PersistenceContextType.EXTENDED, transactionType, discardOnClose + ); } - public EntityManager getEntityManager() { - return new CurrentEntityManagerImpl( sessionFactory, transactionType ); - } - public void close() { sessionFactory.close(); } Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java =================================================================== --- trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java 2006-03-09 17:40:57 UTC (rev 9582) +++ trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java 2006-03-09 18:48:31 UTC (rev 9583) @@ -226,15 +226,16 @@ /** * Close an application-managed EntityManager. - * After an EntityManager has been closed, all methods on the - * EntityManager instance will throw the IllegalStateException - * except for isOpen, which will return false. - * This method can only be called when the EntityManager - * is not associated with an active transaction. + * After the close method has been invoked, all methods + * on the EntityManager instance and any Query objects obtained + * from it will throw the IllegalStateException except + * for getTransaction and isOpen (which will return false). + * If this method is called when the EntityManager is + * associated with an active transaction, the persistence + * context remains managed until the transaction completes. * - * @throws IllegalStateException if the EntityManager is - * associated with an active transaction or if the - * EntityManager is container-managed. + * @throws IllegalStateException if the EntityManager + * is container-managed. */ public void close(); @@ -252,7 +253,7 @@ * * @return EntityTransaction instance * @throws IllegalStateException if invoked on a JTA - * EntityManager or an EntityManager that has been closed. + * EntityManager. */ public EntityTransaction getTransaction(); } \ No newline at end of file Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java =================================================================== --- trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java 2006-03-09 17:40:57 UTC (rev 9582) +++ trunk/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java 2006-03-09 18:48:31 UTC (rev 9583) @@ -1,47 +1,34 @@ //$Id$ package javax.persistence; +import java.util.Map; + public interface EntityManagerFactory { + /** - * Create a new EntityManager of of type - * PersistenceContextType.TRANSACTION. - * This method returns a new application-managed EntityManager - * instance (with a new stand-alone persistence context) each - * time it is invoked. + * Create a new EntityManager. + * This method returns a new EntityManager instance each time + * it is invoked. * The isOpen method will return true on the returned instance. */ EntityManager createEntityManager(); /** - * Create a new EntityManager of the specified persistence - * context type. - * This method returns a new application-managed EntityManager - * instance (with a new stand-alone persistence context) each - * time it is invoked. + * Create a new EntityManager with the specified Map of + * properties. + * This method returns a new EntityManager instance each time + * it is invoked. * The isOpen method will return true on the returned instance. */ - EntityManager createEntityManager(PersistenceContextType type); + EntityManager createEntityManager(Map map); /** - * Get an EntityManager instance whose persistence context - * is propagated with the current JTA transaction. - * If there is no persistence context bound to the current - * JTA transaction, a new transaction-scoped persistence - * context is created and associated with the transaction - * and the entity manager instance that is created and - * returned. If no JTA transaction is in progress, an - * EntityManager instance is created for which the persistence - * context will be propagated with subsequent JTA transactions. - * Throws IllegalStateException if called on an - * EntityManagerFactory that does not provide JTA EntityManagers. - */ - EntityManager getEntityManager(); - - /** * Close the factory, releasing any resources that it holds. * After a factory instance is closed, all methods invoked on * it will throw an IllegalStateException, except for isOpen, - * which will return false. + * which will return false. Once an EntityManagerFactory has + * been closed, all its entity managers are considered to be + * in the closed state. */ void close(); Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Query.java =================================================================== --- trunk/HibernateExt/ejb-api/src/javax/persistence/Query.java 2006-03-09 17:40:57 UTC (rev 9582) +++ trunk/HibernateExt/ejb-api/src/javax/persistence/Query.java 2006-03-09 18:48:31 UTC (rev 9583) @@ -12,30 +12,30 @@ public interface Query { /** * Execute the query and return the query results as a List. - * + * * @return a list of the results */ public List getResultList(); /** * Execute a query that returns a single result. - * + * * @return the result - * @throws EntityNotFoundException if there is no result + * @throws EntityNotFoundException if there is no result * @throws NonUniqueResultException if more than one result */ public Object getSingleResult(); /** * Execute an update or delete statement. - * + * * @return the number of entities updated or deleted */ public int executeUpdate(); /** * Set the maximum number of results to retrieve. - * + * * @param maxResult * @return the same query instance * @throws IllegalArgumentException if argument is negative @@ -44,7 +44,7 @@ /** * Set the position of the first result to retrieve. - * + * * @param startPosition position of the first result, numbered from 0 * @return the same query instance * @throws IllegalArgumentException if argument is negative @@ -54,7 +54,7 @@ /** * Set an implementation-specific hint. If the hint name is not recognized, it is silently * ignored. - * + * * @param hintName * @param value * @return the same query instance @@ -64,65 +64,65 @@ /** * Bind an argument to a named parameter. - * - * @param name the parameter name + * + * @param name the parameter name * @param value * @return the same query instance * @throws IllegalArgumentException if parameter name does not* correspond to parameter in query - * string or argument is of incorrect type + * string or argument is of incorrect type */ public Query setParameter(String name, Object value); /** * Bind an instance of java.util.Date to a named parameter. - * + * * @param name * @param value * @param temporalType * @return the same query instance * @throws IllegalArgumentException if parameter name does not correspond to parameter in query - * string + * string */ public Query setParameter(String name, Date value, TemporalType temporalType); /** * Bind an instance of java.util.Calendar to a named parameter. - * + * * @param name * @param value * @param temporalType * @return the same query instance * @throws IllegalArgumentException if parameter name does not correspond to parameter in query - * string + * string */ public Query setParameter(String name, Calendar value, TemporalType temporalType); /** * Bind an argument to a positional parameter. - * + * * @param position * @param value * @return the same query instance * @throws IllegalArgumentException if position does not correspond to positional parameter of - * query or argument is of incorrect type + * query or argument is of incorrect type */ public Query setParameter(int position, Object value); /** * Bind an instance of java.util.Date to a positional parameter. - * + * * @param position * @param value * @param temporalType * @return the same query instance * @throws IllegalArgumentException if position does not correspond to positional parameter of - * query + * query */ public Query setParameter(int position, Date value, TemporalType temporalType); /** * Bind an instance of java.util.Calendar to a positional parameter. - * + * * @param position * @param value * @param temporalType @@ -132,7 +132,9 @@ /** * Set the flush mode type to be used for the query execution. - * + * The flush mode type applies to the query regardless of the + * flush mode type in use for the entity manager. + * * @param flushMode */ public Query setFlushMode(FlushModeType flushMode); |