openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From idan <>
Subject EntityManager.find returns an object without its id
Date Mon, 21 Jun 2010 13:54:12 GMT


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....



My code:

		SimplePerson p = (SimplePerson) _em.find(SimplePerson.class, 100);

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

	private Integer id;
	private String name;
	private String address;
	private String email;
	public SimplePerson(Integer id) {
		this(id, "SimplePerson #" + id, "SimplePerson # " + id + " Address",
"SimplePerson" + id + "");
	public SimplePerson(Integer id, String name, String address, String email)
{ = id; = name;
		this.address = address; = email;

	public Integer getId() {
		return id;
	public void setId(Integer id) { = id;
	public String getName() {
		return name;
	public void setName(String 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) { = email;

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message