You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Leo Isiah Sambayan (JIRA)" <ji...@apache.org> on 2010/04/30 12:48:53 UTC

[jira] Created: (OPENJPA-1644) Null field values after calling EntityManager.remove()

Null field values after calling EntityManager.remove()
------------------------------------------------------

                 Key: OPENJPA-1644
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1644
             Project: OpenJPA
          Issue Type: Bug
            Reporter: Leo Isiah Sambayan


Fields of an entity instance are nulled after calling EntityManager.remove() on an instance.

For example, I have an entity class named User. I persist and then remove an instance of User.

//
// EntityManager em is initialized before the following code
//

em.getTransaction().begin();
User user = new User();
user.setName("name1");
em.persist(user);
em.getTransaction().commit();
System.out.println(user.getName); // will print out name1
em.getTransaction().begin();
em.remove(user);
em.getTransaction().commit();
System.out.println(user.getName); // will print out null (oh no!) 

After I persist and remove the same instance of User, it's fields became null. I believe this shouldn't be the case as Section "3.2.3 Removal" of the 2.0 spec states:

"After an entity has been removed, its state (except for generated state) will be that of the entity at the point at which the remove operation was called."

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


[jira] Updated: (OPENJPA-1644) Null field values after calling EntityManager.remove()

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis updated OPENJPA-1644:
---------------------------------

    Attachment: OPENJPA-1644.patch

This patch fixes the reported behavior, but I'm not sure what all it will break(Although all current unit tests pass).

I need to do some more testing before it is committed.

> Null field values after calling EntityManager.remove()
> ------------------------------------------------------
>
>                 Key: OPENJPA-1644
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1644
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 2.0.0
>            Reporter: Leo Isiah Sambayan
>         Attachments: OPENJPA-1644.patch
>
>
> Fields of an entity instance are nulled after calling EntityManager.remove() on an instance.
> For example, I have an entity class named User. I persist and then remove an instance of User.
> //
> // EntityManager em is initialized before the following code
> //
> em.getTransaction().begin();
> User user = new User();
> user.setName("name1");
> em.persist(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out name1
> em.getTransaction().begin();
> em.remove(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out null (oh no!) 
> After I persist and remove the same instance of User, it's fields became null. I believe this shouldn't be the case as Section "3.2.3 Removal" of the 2.0 spec states:
> "After an entity has been removed, its state (except for generated state) will be that of the entity at the point at which the remove operation was called."

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


[jira] Resolved: (OPENJPA-1644) Null field values after calling EntityManager.remove()

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis resolved OPENJPA-1644.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.0

> Null field values after calling EntityManager.remove()
> ------------------------------------------------------
>
>                 Key: OPENJPA-1644
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1644
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 2.0.0
>            Reporter: Leo Isiah Sambayan
>            Assignee: Rick Curtis
>             Fix For: 2.1.0
>
>         Attachments: OPENJPA-1644.patch
>
>
> Fields of an entity instance are nulled after calling EntityManager.remove() on an instance.
> For example, I have an entity class named User. I persist and then remove an instance of User.
> //
> // EntityManager em is initialized before the following code
> //
> em.getTransaction().begin();
> User user = new User();
> user.setName("name1");
> em.persist(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out name1
> em.getTransaction().begin();
> em.remove(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out null (oh no!) 
> After I persist and remove the same instance of User, it's fields became null. I believe this shouldn't be the case as Section "3.2.3 Removal" of the 2.0 spec states:
> "After an entity has been removed, its state (except for generated state) will be that of the entity at the point at which the remove operation was called."

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


[jira] Assigned: (OPENJPA-1644) Null field values after calling EntityManager.remove()

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis reassigned OPENJPA-1644:
------------------------------------

    Assignee: Rick Curtis

> Null field values after calling EntityManager.remove()
> ------------------------------------------------------
>
>                 Key: OPENJPA-1644
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1644
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 2.0.0
>            Reporter: Leo Isiah Sambayan
>            Assignee: Rick Curtis
>         Attachments: OPENJPA-1644.patch
>
>
> Fields of an entity instance are nulled after calling EntityManager.remove() on an instance.
> For example, I have an entity class named User. I persist and then remove an instance of User.
> //
> // EntityManager em is initialized before the following code
> //
> em.getTransaction().begin();
> User user = new User();
> user.setName("name1");
> em.persist(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out name1
> em.getTransaction().begin();
> em.remove(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out null (oh no!) 
> After I persist and remove the same instance of User, it's fields became null. I believe this shouldn't be the case as Section "3.2.3 Removal" of the 2.0 spec states:
> "After an entity has been removed, its state (except for generated state) will be that of the entity at the point at which the remove operation was called."

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


[jira] Commented: (OPENJPA-1644) Null field values after calling EntityManager.remove()

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12919877#action_12919877 ] 

Rick Curtis commented on OPENJPA-1644:
--------------------------------------

I did some research as to why we were clearing out the fields of an Entity after deleting it and it appears that it is something that has been with us from the JDO days. Per the JDO spec: 

"A persistent-deleted instance transitions to transient at commit. During the transition, its persistent fields are written with their Java default values...."The net of that is that after an instance is deleted, the provider must clear out all fields of that Entity.

The JPA 2.0 spec states something along these lines :  "After an entity has been removed, its state (except for generated state) will be that of the entity at the point at which the remove operation was called." I'll be committing changes shortly to support the JPA spec.



> Null field values after calling EntityManager.remove()
> ------------------------------------------------------
>
>                 Key: OPENJPA-1644
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1644
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 2.0.0
>            Reporter: Leo Isiah Sambayan
>            Assignee: Rick Curtis
>         Attachments: OPENJPA-1644.patch
>
>
> Fields of an entity instance are nulled after calling EntityManager.remove() on an instance.
> For example, I have an entity class named User. I persist and then remove an instance of User.
> //
> // EntityManager em is initialized before the following code
> //
> em.getTransaction().begin();
> User user = new User();
> user.setName("name1");
> em.persist(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out name1
> em.getTransaction().begin();
> em.remove(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out null (oh no!) 
> After I persist and remove the same instance of User, it's fields became null. I believe this shouldn't be the case as Section "3.2.3 Removal" of the 2.0 spec states:
> "After an entity has been removed, its state (except for generated state) will be that of the entity at the point at which the remove operation was called."

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


[jira] Updated: (OPENJPA-1644) Null field values after calling EntityManager.remove()

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis updated OPENJPA-1644:
---------------------------------

    Affects Version/s: 2.0.0
                       1.2.2

> Null field values after calling EntityManager.remove()
> ------------------------------------------------------
>
>                 Key: OPENJPA-1644
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1644
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 2.0.0
>            Reporter: Leo Isiah Sambayan
>
> Fields of an entity instance are nulled after calling EntityManager.remove() on an instance.
> For example, I have an entity class named User. I persist and then remove an instance of User.
> //
> // EntityManager em is initialized before the following code
> //
> em.getTransaction().begin();
> User user = new User();
> user.setName("name1");
> em.persist(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out name1
> em.getTransaction().begin();
> em.remove(user);
> em.getTransaction().commit();
> System.out.println(user.getName); // will print out null (oh no!) 
> After I persist and remove the same instance of User, it's fields became null. I believe this shouldn't be the case as Section "3.2.3 Removal" of the 2.0 spec states:
> "After an entity has been removed, its state (except for generated state) will be that of the entity at the point at which the remove operation was called."

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