Hi
I am new in the list, in these days i am trying save data between two
entity beans using JPA but without success, i am cheking the log nd
says:

Uncaught exception from servlet
javax.persistence.PersistenceException: Error in meta-data for
beans.distritos.id: Cannot have a java.lang.Long primary key and be a
child object (owning field is beans.evento.distrito).



this is my servlet:
            Long id =
Long.parseLong(request.getParameter("idDistrito"));
            response.setContentType("text/html");
            EntityManager cn = emf.get().createEntityManager();

            Query q = cn.createQuery("SELECT d FROM distritos d WHERE
d.id = :codigo");
            q.setParameter("codigo",id);
            distritos dist = (distritos) q.getSingleResult();

            EntityManager cn2 = emf.get().createEntityManager();
            cn2.getTransaction().begin();

            evento e = new evento();
            e.setDistrito(dist);
            Date fecha = new Date();
            e.setFechaCreacion(fecha);

            try{
                cn2.persist(e);
                response.getWriter().write("ok");
            }finally{
                cn2.getTransaction().commit();
                cn2.close();
            }


this is my entity bean

Evento:
@Entity
public class evento implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Long id;

    @Temporal(javax.persistence.TemporalType.DATE)
    private Date fechaCreacion;

    @JoinColumn
    @OneToMany(cascade = CascadeType.ALL)
    private distritos distrito;

   --getter and setter--



Distrito:
@Entity
public class distritos implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Long id;
    private String distrito;

    --getter and setter--


i hope anyone help me, Thank!



Johan

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to