|JPA 2 inserting Parent table when trying to update child table field [message #980458]
||Sun, 11 November 2012 12:50
| H R
Registered: November 2012
I am facing a problem when I am trying to insert/update the fields in the child table.
In my parent table I am having columns
and in my child table I am having the columns
From my application when I try to persist/merge the child entities
public class Child extends Parent
The values are getting inserted/updated into Parent table's LAST_UPDATED_BY /
LAST_UPDATED_ON instead of child table's LAST_UPDATED_BY /
Please help to resolve this issue.
I cannot change the name of fields as the same entities are used by other applications.
|Re: JPA 2 inserting Parent table when trying to update child table field [message #981643 is a reply to message #980458]
||Mon, 12 November 2012 10:29
| Chris Delahunt
Registered: July 2009
You have not shown any of the mappings or inheritance setup from JPA. The table structure you've shown looks like the child table duplicates the parent table, so my guess is you have the mappings in a parent table and no additional fields in the child, but marked the inheritance to use a joined table strategy. Joined table inheritance means a row for the child entity must exist in both parent and child tables, so probably isn't what you want. You might want a table per class strategy, but you will need to override the field names used in the child since they do not match what is mapped in the parent. You might be better avoiding Inheritance, and have the classes treated as separate independent entities with their own mappings.|
for info on using @AttributeOverride to change the field names used in the child Entity.
[Updated on: Mon, 12 November 2012 11:14]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02415 seconds