users@glassfish.java.net

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

From: <glassfish_at_javadesktop.org>
Date: Thu, 31 Jan 2008 18:21:36 PST

Thanks for your reply. I will try your suggestion for the first option.

As for your question, I am working with a database thats already setup by our legacy systems. So no, I am not trying to retrieve data that I inserted, I am trying to get data that already exists in the database. The object is sent all the way back to the client that prints out details, for one. Thats where I found the problem. But I verified it by debugging through the code. When I debug and set a breakpoint, I can see that the list is empty.

I do have a test case for inserting data as well. That doesnt work either. It doesnt insert the list of items into the second table nor the join table.

 As I mentioned in my post, from the "get" test case, I can see from the log that, there are two sql statements executed, one to fetch the ListMenuType itself, and then one to fetch the ListMenuItemType list. That sql statement is perfect and it works if I run it in the query analyzer. The weird thing also is that, this sql statement shows up int he log only the first time, on subsequent get calls, there is only the first sql statement printed in the log.
See below..

[TopLink Fine]: 2008.01.31 05:20:17.423--ServerSession(21314930)--Connection(15891676)--Thread(Thread[TCP server transport connection thread,5,main])--SELECT t0.charMenuId, t0.menuType, t0.OWNER, t0.LASTCHANGED, t0.OBJPROP, t0.TIMESTAMP, t0.SMOBJPROP, t0.CHANGEDIARY, t0.VERSION, t0.HELPTEXT, t0.NAME, t0.SAFEGUARD, t0.REFRESHCODE, t1.charMenuId, t1.NAMETYPE, t1.VALUEFORMAT, t1.SERVER, t1.STRUCTSUBTYPE, t1.PATH, t1.ARSCHEMA, t1.STRUCTTYPE, t1.HIDDENTOO, t2.charMenuId, t2.FILELOCATION, t2.PATH, t2.FILENAME, t3.charMenuId, t3.LABELFIELD5, t3.VALUEFIELD, t3.SERVER, t3.SORTONLABEL, t3.LABELFIELD, t3.KEYWORDLIST, t3.LABELFIELD3, t3.PARAMETERLIST, t3.PATH, t3.EXTERNLIST, t3.LABELFIELD2, t3.SAMPLESCHEMA, t3.ARSCHEMA, t3.SAMPLESERVER, t3.LABELFIELD4, t3.QUERYSHORT, t3.QUERYLONG, t4.charMenuId, t4.LABELINDEX5, t4.PATH, t4.VALUEINDEX, t4.LABELINDEX, t4.SQLCMDSHORT, t4.LABELINDEX3, t4.SQLCMDLONG, t4.SERVER, t4.KEYWORDLIST, t4.LABELINDEX4, t4.PARAMETERLIST, t4.LABELINDEX2, t4.EXTERNLIST FROM char_menu t0 LEFT OUTER JOIN char_menu_dd t1 ON (t1.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_file t2 ON (t2.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_query t3 ON (t3.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_sql t4 ON (t4.charMenuId = t0.charMenuId) WHERE (t0.NAME = ?)
        bind => [MsgCat: MsgType Menu]

[b][TopLink Fine]: 2008.01.31 05:20:33.283--ServerSession(21314930)--Connection(6507439)--Thread(Thread[TCP server transport connection thread,5,main])--SELECT t1.charMenuId, t1.path, t1.LABEL, t1.CHILDTYPE, t1.VALUE FROM char_menu_list_join t0, char_menu_list t1 WHERE ((t0.charMenuId = ?) AND ((t1.path = t0.path) AND (t1.charMenuId = t0.charMenuId)))
        bind => [1][/b]

[TopLink Fine]: 2008.01.31 05:22:24.534--ServerSession(21314930)--Connection(28149392)--Thread(Thread[TCP server transport connection thread,5,main])--SELECT t0.charMenuId, t0.menuType, t0.OWNER, t0.LASTCHANGED, t0.OBJPROP, t0.TIMESTAMP, t0.SMOBJPROP, t0.CHANGEDIARY, t0.VERSION, t0.HELPTEXT, t0.NAME, t0.SAFEGUARD, t0.REFRESHCODE, t1.charMenuId, t1.NAMETYPE, t1.VALUEFORMAT, t1.SERVER, t1.STRUCTSUBTYPE, t1.PATH, t1.ARSCHEMA, t1.STRUCTTYPE, t1.HIDDENTOO, t2.charMenuId, t2.FILELOCATION, t2.PATH, t2.FILENAME, t3.charMenuId, t3.LABELFIELD5, t3.VALUEFIELD, t3.SERVER, t3.SORTONLABEL, t3.LABELFIELD, t3.KEYWORDLIST, t3.LABELFIELD3, t3.PARAMETERLIST, t3.PATH, t3.EXTERNLIST, t3.LABELFIELD2, t3.SAMPLESCHEMA, t3.ARSCHEMA, t3.SAMPLESERVER, t3.LABELFIELD4, t3.QUERYSHORT, t3.QUERYLONG, t4.charMenuId, t4.LABELINDEX5, t4.PATH, t4.VALUEINDEX, t4.LABELINDEX, t4.SQLCMDSHORT, t4.LABELINDEX3, t4.SQLCMDLONG, t4.SERVER, t4.KEYWORDLIST, t4.LABELINDEX4, t4.PARAMETERLIST, t4.LABELINDEX2, t4.EXTERNLIST FROM char_menu t0 LEFT OUTER JOIN char_menu_dd t1 ON (t1.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_file t2 ON (t2.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_query t3 ON (t3.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_sql t4 ON (t4.charMenuId = t0.charMenuId) WHERE (t0.NAME = ?)
        bind => [MsgCat: MsgType Menu]

[TopLink Fine]: 2008.01.31 05:23:22.770--ServerSession(21314930)--Connection(9985954)--Thread(Thread[TCP server transport connection thread,5,main])--SELECT t0.charMenuId, t0.menuType, t0.OWNER, t0.LASTCHANGED, t0.OBJPROP, t0.TIMESTAMP, t0.SMOBJPROP, t0.CHANGEDIARY, t0.VERSION, t0.HELPTEXT, t0.NAME, t0.SAFEGUARD, t0.REFRESHCODE, t1.charMenuId, t1.NAMETYPE, t1.VALUEFORMAT, t1.SERVER, t1.STRUCTSUBTYPE, t1.PATH, t1.ARSCHEMA, t1.STRUCTTYPE, t1.HIDDENTOO, t2.charMenuId, t2.FILELOCATION, t2.PATH, t2.FILENAME, t3.charMenuId, t3.LABELFIELD5, t3.VALUEFIELD, t3.SERVER, t3.SORTONLABEL, t3.LABELFIELD, t3.KEYWORDLIST, t3.LABELFIELD3, t3.PARAMETERLIST, t3.PATH, t3.EXTERNLIST, t3.LABELFIELD2, t3.SAMPLESCHEMA, t3.ARSCHEMA, t3.SAMPLESERVER, t3.LABELFIELD4, t3.QUERYSHORT, t3.QUERYLONG, t4.charMenuId, t4.LABELINDEX5, t4.PATH, t4.VALUEINDEX, t4.LABELINDEX, t4.SQLCMDSHORT, t4.LABELINDEX3, t4.SQLCMDLONG, t4.SERVER, t4.KEYWORDLIST, t4.LABELINDEX4, t4.PARAMETERLIST, t4.LABELINDEX2, t4.EXTERNLIST FROM char_menu t0 LEFT OUTER JOIN char_menu_dd t1 ON (t1.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_file t2 ON (t2.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_query t3 ON (t3.charMenuId = t0.charMenuId) LEFT OUTER JOIN char_menu_sql t4 ON (t4.charMenuId = t0.charMenuId) WHERE (t0.NAME = ?)
        bind => [MsgCat: MsgType Menu]


Is the default
[Message sent by forum member 'pmysore' (pmysore)]

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