Hi everyone,

I'm sure that this must have been hashed out here before, but I can't seem to find any real solutions. I hope someone can point me to a good resource. I've got a pretty simple setup, thus far. I'm using Spring to autowire my DAO with the entity manager factory, and I have a TestCase that sets up the local datastore for testing. I have one test that works fine, then another that fails and throws that infamous "Object Manager has been closed" exception. My DAO are based on a GenericDao implementation from the Crank project. It works great with regular JPA. So, I figured I'd give it a try with GAE. The error doesn't seem to me to be related to that, though.

I've seen a lot of postings where people recommend the OpenEntityManagerFactoryInView filter. That's great for a production environment where you have a web container, but doesn't really help for unit testing purposes.

 My persistent object is this:

   @Entity
   public class Person {

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Key key;

        private String email;

        public Person() {}

        [getters and setters here]
   }

Here is a test that works:

        @Test
        public void testReadThePerson() {
            Person person = new Person("y...@yada.com");
            dao.store(person);

            Person person2 = dao.read(person.getKey());
            assertNotNull("Person not found", person2);
        }

Here is the test that fails:

        @Test
        public void testFindThePerson() {
            Person person = new Person("y...@yada.com");
            dao.store(person);

            List<Person> list = dao.find("email", "y...@yada.com");
            assertEquals("Did not find the person.", 1, list.size());
        }

It blows up trying to get the list.size() value.  What gives?
Thanks,
Dave

--
You received this message because you are subscribed to the Google Groups "Google 
App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to