users@glassfish.java.net

Re: RE: Many to Many bidirectional relationship

From: <glassfish_at_javadesktop.org>
Date: Thu, 08 Mar 2007 14:39:37 PST

[b]> This seems strange are you performing the
> getTestTables() on a Story from a different
> Persistence Context?

Nope, same persistence context.

> How is the Story retrieved?
> Can you provide the code where you are accessing the
> getTestTables() list?
> -Gordon

Here is my destory method:[/b]


    public void destroy(TestTable testTable) {
        
        Collection<Story> stories = testTable.getStories();
        Collection<TestTable> testTables = new ArrayList();

        for(Story s: stories){
           // s = story.findStoryByName(s.getStoryName());
            s = em.find(Story.class,s.getId());
            testTables = s.getTestTables();
            testTables.remove(testTable);
            em.merge(s);
        }
        
        stories.clear();
        testTable.setStories(stories);
        testTable = em.merge(testTable);
        em.remove(testTable);
    }

[b]Both :
s = story.findStoryByName(s.getStoryName());
s = em.find(Story.class,s.getId());
retreive a Story.[/b]
[Message sent by forum member 'ptm' (ptm)]

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