Edmond M. wrote:
...
I've been facing the same kind of problem ; my program keeps complaining
about "unmanaged object" despite using EntityManager.getReference() as
suggested by Patrick. I wonder what I've been doing wrong. Would you show
the piece of code (and possibly the related configuration part in orm.xml)
that made your program run ?

This is really an old thread. :)

Something like:

    em.getTransaction().begin();
    Child c = new Child();
    c.setName("Bob");
    c.setParent(em.getReference(Parent.class, 123););
    em.persist(predmet);
    em.getTransaction().commit();

should work. More or less, thats what I'm doing. Maybe you could post your code, and exact stack trace?

Regards,
Ognjen

Reply via email to