users@glassfish.java.net

Re: JPA - One-To-Many relationship query problem

From: <glassfish_at_javadesktop.org>
Date: Thu, 31 Jan 2008 20:14:40 PST

I tried setting the id mapping as not insertable and updatable, and that still didnt solve the initialization problem with cardinality.

However, changing the one-to-many mapping to use fetch=EAGER solved the issue with the empty list being returned. Now I get the list everytime on every query.

But I am still having issues with inserting. When I send a ListMenuType with all of the list elements set in it, when I do a persist, the main entry gets saved, the list of entries doesnt get saved into the other table. I am still looking at it. Is there something that is fetch equivalent that needs to be done for inserts or updates?
The code I am using is pretty straight forward.

        //Persist this object,
                        entityManager.persist(menuEntity);
                        entityManager.flush();

This is the sql statement i see, there is none for the related table.

[TopLink Fine]: 2008.01.31 07:30:29.242--ClientSession(23584771)--Connection(10749831)--Thread(Thread[TCP server transport connection thread,5,main])--INSERT INTO char_menu (charMenuId, NAME, OWNER, VERSION, SMOBJPROP, HELPTEXT, SAFEGUARD, CHANGEDIARY, OBJPROP, TIMESTAMP, REFRESHCODE, LASTCHANGED, menuType) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
        bind => [35, TestListMenu, Prasad, null, FA4gQnHPGX9eAdMpwds4X6XNjbLt+yu4xJirTot4zyENYCxzjNNFtZftVCg8xbjg4n0F4jcugsD1yZQjlBXapQ==, Testing list menus, dPsB5yRBY9i2x2wmeQk+XUE53slQ+bQbrycFtWfxKMYoWIcG41bWutDhOsDBqUogv3KjC8HEA6AJJvAyKndjJ9LC5IHV4MZ/, , 0\, 1201836628, 1, Demo, 1]
[Message sent by forum member 'pmysore' (pmysore)]

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