Hi,

I would like to find an object and then call EntityManager.remove for
removing it from the persistency context.
When i call find and specify the desired object's id i receive an object but
its id (the field i annotated with @Id) has a null value and therefore when
calling remove afterwards the JDBC query created behind the scenes looks for
a null value instead of the id i originally specified.

When debugging openjpa i found somewhere that there's some configuration for
copying identity fields or something....

Help!

Thanks,
Idan

My code:

                _em.getTransaction().begin();
                SimplePerson p = (SimplePerson) _em.find(SimplePerson.class, 
100);
                _em.remove(p);
                _em.getTransaction().commit();

My class looks like this:
@Entity
@Table(name = "SimplePerson")
public class SimplePerson {

        @Id
        private Integer id;
        @Basic
        private String name;
        @Basic
        private String address;
        @Basic
        private String email;
                
        public SimplePerson(Integer id) {
                this(id, "SimplePerson #" + id, "SimplePerson # " + id + " 
Address",
"SimplePerson" + id + "@temp.com");
        }
        
        public SimplePerson(Integer id, String name, String address, String 
email)
{
                this.id = id;
                this.name = name;
                this.address = address;
                this.email = email;
        }

        public Integer getId() {
                return id;
        }
        public void setId(Integer id) {
                this.id = id;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
        public String getAddress() {
                return address;
        }
        public void setAddress(String address) {
                this.address = address;
        }
        public String getEmail() {
                return email;
        }
        public void setEmail(String email) {
                this.email = email;
        }


-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/EntityManager-find-returns-an-object-without-its-id-tp5204325p5204325.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to