You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "B.J. Reed (JIRA)" <ji...@apache.org> on 2009/05/15 20:21:45 UTC

[jira] Updated: (OPENJPA-247) new-delete-new-find doesn't work

     [ https://issues.apache.org/jira/browse/OPENJPA-247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

B.J. Reed updated OPENJPA-247:
------------------------------

    Patch Info: [Patch Available]

> new-delete-new-find doesn't work
> --------------------------------
>
>                 Key: OPENJPA-247
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-247
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Assignee: Michael Dick
>         Attachments: OPENJPA-247.patch
>
>
> I have a piece of code that effectively does the same thing the following test does:
>     private void newDeleteNew() throws Exception {
>         beginTx();
>         // Create new
>         Person dain = new Person();
>         dain.setName("dain");
>         assertFalse(entityManager.contains(dain));
>         entityManager.persist(dain);
>         entityManager.flush();
>         assertTrue(entityManager.contains(dain));
>         // Find and verify
>         dain = entityManager.find(Person.class, "dain");
>         assertNotNull(dain);
>         assertEquals("dain", dain.getName());
>         // Delete
>         entityManager.remove(dain);
>         entityManager.flush();
>         assertFalse(entityManager.contains(dain));
>         // Recreate
>         dain = new Person();
>         dain.setName("dain");
>         assertFalse(entityManager.contains(dain));
>         entityManager.persist(dain);
>         entityManager.flush();
>         assertTrue(entityManager.contains(dain));
>         // Find and verify
>         dain = entityManager.find(Person.class, "dain");
>         assertNotNull(dain); // <<<<<<< FAILS
>         assertEquals("dain", dain.getName());
>         commitTx();
>     }
> The test fails at the marked point, because the entityManager seems to think the "dain" entity is still deleted.  I assume this type of code would work.  Is this a bug or is my assumption wrong?
> BTW, I'm using 0.9.8-incubating-SNAPSHOT
> And here is my entity class:
> @Entity
> public class Person {
>     private String name;
>     @Id
>     public String getName() {
>         return name;
>     }
>     public void setName(String name) {
>         this.name = name;
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.