users@glassfish.java.net

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

From: <glassfish_at_javadesktop.org>
Date: Thu, 31 Jan 2008 18:08:10 PST

With the first issue the problem is that you have mapped the same column twice once in the many-to-one and once as the "id". The exception can be resolved by marking the id mapping as being non writable.

<id name="charMenuId"><column name="charMenuId" updatable="false" insertable="false"/></id>

make sure that the setter on ListMenuItemType "charMenuId" also sets the id attribute on ListMenuItemType. As per spec requirements you will need to specify a separate attribute on your ListMenuItemType for the id. A single attribute can not be mapped twice.

For the second issue how is the data getting into the database? Is it created in the same test case that reads the data? How are you verifying that the data is not loaded? Your example does not access the relationship, is it a lazy relationship issue?
[Message sent by forum member 'gyorke' (gyorke)]

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