When I'm trying to commit Transaction I'm getting:
javax.persistence.RollbackException: Transaction failed to commit
javax.persistence.PersistenceException: Object with id "" is managed by a different
org.datanucleus.exceptions.NucleusUserException: Object with id "" is managed by a different Object ManagerObject Manager
My Code is:
@Entity
public class Profile implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long profileId;
private String m_Name;
private String m_Email;
private String m_Password;
@ManyToOne()
private List<MyPoint> m_points = null;
.
.
}
@Entity
public class MyPoint implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
private int pointId;
private int m_LatitudeE6;
private int m_LongitudeE6;
.
.
}
- If I'm deleting m_points with his annotations everything works fine.
- I'm using JPA 1.0 with Google App Engine
What am I doing wrong?
Thanks.
Not a GAE expert, but there are some obvious things wrong with your entity mappings that need to be fixed.
First, it makes no sense to apply a
@ManyToOne
to a list (think about it, your are indicating, when you use that annotation, that many of this entity relate to one of the mapped entity).Second, you have not specified the actual mapping columns for the embedded collection of points. You must either define the mapping from point to profile on the point class, or use a join table. Below is an example (very rough pseudo-code):
Quite obviously, the above example presumes that there is a foreign key named
profileId
on the MyPoint table that references the primary key on the Profile table.