|
Hi Jake, Now i have this error Log : javax.persistence.PersistenceException: Transaction is still active. You should always close your transactions correctly using commit() or rollback(). this is my code : EntityManager cn2 = emf.get().createEntityManager(); distritos dist2 = cn2.find(distritos.class, id); evento e = new evento(); e.setDistrito(dist2); Date fecha = new Date(); e.setFechaCreacion(fecha); try{ cn2.getTransaction().begin(); cn2.persist(e); cn2.getTransaction().commit(); response.getWriter().write("ok"); }finally{ cn2.close(); } Distrito : @Entity public class distritos implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Extension (vendorName="datanucleus", key="gae.encoded-pk", value="true") Key id; --getter and setter-- El 08/02/2010 03:37 p.m., Jake escribió: Hello,The Google Datastore has four ways that you can store a Primary Key ID: String, Long, and two variations on Google's own Key object. If you want to create a parent/child relationship between two persisted objects (in your case, evento is the parent and distritos is the child), then you need to use Google's Key object as the primary ID. See: http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys "If the class is used as a "child" class in a relationship, the key field must be of a type capable of representing an entity group parent: either a Key instance, or a Key value encoded as a string." So, you have two options: 1. Change your Long id values to Key id values. 2. Instead of storing "private distritos distrito" directly in your evento object, store a reference to the id: "private Long distrito_id" Jake On Feb 6, 4:06 pm, chevelle <[email protected]> wrote: -- 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. |
- [appengine-java] Persistence with JPA + GAE chevelle
- [appengine-java] Re: Persistence with JPA + GAE Jake
- Re: [appengine-java] Re: Persistence with JP... Johan Vallejo
- Re: [appengine-java] Re: Persistence with JP... Johan Vallejo
- [appengine-java] Re: Persistence with JP... Jake
- Re: [appengine-java] Re: Persistence wit... Diego Osse Fernandes
- Re: [appengine-java] Re: Persistence... Johan Vallejo
- Re: [appengine-java] Re: Persis... Diego Osse Fernandes
