Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA 2 inserting Parent table when trying to update child table field(Data gets inserted into parent table instead of child table.)
JPA 2 inserting Parent table when trying to update child table field [message #980458] Sun, 11 November 2012 17:50 Go to next message
H R is currently offline H RFriend
Messages: 1
Registered: November 2012
Junior Member
Hi,
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
PCOL1
PCOL2
PCOL3
...
...
LAST_UPDATED_BY
LAST_UPDATED_ON


and in my child table I am having the columns

CCOL1
CCOL2
CCOL3
.....
LAST_UPDATED_BY
LAST_UPDATED_ON

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 /
LAST_UPDATED_ON.

Please help to resolve this issue.
Note:
I cannot change the name of fields as the same entities are used by other applications.

Thanks.
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 15:29 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
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.

See http://www.eclipse.org/eclipselink/api/2.0/javax/persistence/AttributeOverride.html
for info on using @AttributeOverride to change the field names used in the child Entity.

[Updated on: Mon, 12 November 2012 16:14]

Report message to a moderator

Previous Topic:Eclipselink and SQLite
Next Topic:Weird cache thread started
Goto Forum:
  


Current Time: Fri Apr 26 12:18:30 GMT 2024

Powered by FUDForum. Page generated in 0.02806 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top