Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » View as JoinTable causes delete problem
View as JoinTable causes delete problem [message #903670] Fri, 24 August 2012 20:06 Go to next message
Jeremy Purdy is currently offline Jeremy PurdyFriend
Messages: 7
Registered: October 2011
Junior Member
I have a one-to-many mapping that is using an Oracle view as the JoinTable because the relationship between the two objects is complex inside of the database. The mapping is here:

<one-to-many name="bars" fetch="EAGER">
<join-table name="FOO_BARS_VIEW">
<join-column name="FOOID" referenced-column-name="ID" insertable="false" updatable="false" nullable="false"/>
<inverse-join-column name="BARID" referenced-column-name="ID" insertable="false" updatable="false" nullable="false"/>
</join-table>
</one-to-many>

This works fine for queries, etc.

However, when I attempt to delete a FOO object, eclipselink is cascading the delete into the view:
DELETE FROM FOO_BARS_VIEW WHERE (FOOID = ?)
bind => [301]

This statement fails, since you can't delete from a view.

Is there a way to tell JPA not to cascade the delete into the JoinTable?
Re: View as JoinTable causes delete problem [message #903998 is a reply to message #903670] Mon, 27 August 2012 14:17 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I assumed that marking all fields as insertable=false, updatable=false would make the mapping read only, but it looks like you will need to use a customizer to get the mapping and mark it directly using the setIsReadOnly(true) method.

Descriptor customizers are described here:
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Customizers

with the following code being required:
descriptor.getMappingForAttributeName("bars")).setIsReadOnly(true);

Best Regards,
Chris

[Updated on: Mon, 27 August 2012 14:29]

Report message to a moderator

Previous Topic:Problem in running QueryHints.READ_ONLY on GF 3.0
Next Topic:merging returns old value for referenced entity
Goto Forum:
  


Current Time: Wed Apr 24 22:41:32 GMT 2024

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

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

Back to the top