Issue Details (XML | Word | Printable)

Key: OPENJPA-116
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Kevin Sutter
Reporter: Michael Dick
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenJPA

EntityManager.getDelegate should throw an IllegalStateException

Created: 29/Jan/07 10:28 PM   Updated: 17/Apr/07 06:38 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 0.9.7

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works openjpa-116-patch.txt 2007-01-30 03:54 PM Michael Dick 1.0 kB

Resolution Date: 30/Jan/07 07:45 PM


 Description  « Hide
EntityManager.getDelegate() should throw an IllegalStateException if the EntityManager has been closed.

I noticed then when debugging other problems. According to the javadoc http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#getDelegate() we need to throw an exception if the EM has been closed.

In case I missed anything here's what I did to reproduce the problem.


        EntityManagerFactory _emf = Persistence.createEntityManagerFactory("test");

        EntityManager em = _emf.createEntityManager();

        em.close();

        try {
            Object o = em.getDelegate();
            fail();
        }
        catch(IllegalStateException ise) {
            System.out.println("Caught expected exception");
        }



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #501445 Tue Jan 30 16:19:59 UTC 2007 kwsutter Changes for JIRA OPENJPA-116 issue.

Added a test to ensure that the EntityManager was still open before executing the getDelegate() code.
Files Changed
MODIFY /incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java

Repository Revision Date User Message
ASF #501955 Wed Jan 31 19:27:11 UTC 2007 kwsutter Simple test for OPENJPA-116. Just modified the simple TestPersistence testcase with a new variation for testing the exception on getDelegate() when the EM is closed.
Files Changed
MODIFY /incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestPersistence.java