On Jul 5, 8:33 pm, Jens <[email protected]> wrote: > I think its not a RequestFactory problem but more a JPA problem. For some
I suppose so. > reason EclipseLink things it has to insert the User object although it > already exists and has an id. Exactly. > In your case I think you have to do something like: > > User attachedUser = entityManager.merge(booking.getUser()); > booking.setUser(attachedUser); //maybe thats not needed. > entityManager.persist(booking). I've added the following annotation: @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.DETACH/MERGE) which reports the following error now: com.google.web.bindery.requestfactory.server.UnexpectedException: The persisted entity with id 1 has a null version > > That way you tell the EntityManager that the user already exists. > > A second way would be to fetch the already existing user: > > User attachedUser = entityManager.find(User.class, > booking.getUser().getId()); > booking.setUser(user); //maybe thats not needed > entityManager.persist(booking); Same as above. -Alex -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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-web-toolkit?hl=en.
