I have these Entities: @Entity(name = "Empresa") @Table(name = "empresa") public class Empresa { @Id @Column(name = "id_empresa") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; }
and @Entity(name = "Usuario") @Table(name = "usuario") public class Usuario { @Id @Column(name = "id_usuario") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "id_empresa") } I have inserted many of Empresas and now I wanna insert a new Usuario with a inserted Empresa, but I got this exception: javax.persistence.PersistenceException: Error in meta-data for br.com.controlecartao.core.entity.Empresa.id: Cannot have a java.lang.Long primary key and be a child object (owning field is br.com.controlecartao.core.entity.Usuario.empresa). I´m using the method MERGE, but I don´t know if this method is correct to to this. What´s the correct way to do this? Where am I wrong? Thank you. -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.