users@glassfish.java.net

Re: ManyToMany insert/update jointable

From: <glassfish_at_javadesktop.org>
Date: Mon, 12 Feb 2007 16:37:10 PST

Hi Shannon,

Please try the following:

@PersistenceContext
EntityManager em;

em.getTransaction().begin();
Person person = em.find(Person.class, new Integer(1));
Group group = em.find(Group.class, new Integer(1));
Set groups = new HashSet();
groups.add(group);
person.setGroups(groups);
em.getTransaction().commit();

Above should synchronize the relationship to the database.
[Message sent by forum member 'mf125085' (mf125085)]

http://forums.java.net/jive/thread.jspa?messageID=203547