Bug 395739 - ManyToOne and JoinTable. Problem: isForeignKeyRelationship() check is wrong
Summary: ManyToOne and JoinTable. Problem: isForeignKeyRelationship() check is wrong
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 critical with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-04 12:15 EST by Sergio a CLA
Modified: 2022-06-09 10:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio a CLA 2012-12-04 12:15:50 EST
Hello,

My eclipseLink version is 2.1.3, im using both @ManyToOne and @JoinTable to mapping this situation:

   @ManyToOne(fetch = FetchType.EAGER)
   @JoinTable(name = "TABLE_USER_ADDRESS", joinColumns = @JoinColumn(name = "USER_ID", referencedColumnName = "USERID"),
       inverseJoinColumns = @JoinColumn(name = "ADDR_ID", referencedColumnName = "ADDRESSID"))
   private Address address;


When remove an User, jpa try to remove the Address associated. Although the address is associated with more users (hence ManyToOne).

Forum post: http://www.eclipse.org/forums/index.php/t/440677/


The SQL log:
[EL Fine]: 2012-11-28 09:19:30.276--ServerSession(219730313)--Connection(764103883)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--SELECT USERID FROM USER WHERE (USERID = ?)
	bind => [administrationUser]
[EL Fine]: 2012-11-28 09:19:30.278--ServerSession(219730313)--Connection(764103883)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--SELECT t1.USERID FROM TABLE_USER_ADDRESS t0, USER t1 WHERE ((t0.USER_ID = ?) AND (t1.USERID = t0.USER_ID))
	bind => [administrationUser]
[EL Fine]: 2012-11-28 09:19:30.283--ClientSession(1080497174)--Connection(764103883)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--DELETE FROM TABLE_USER_ADDRESS WHERE (USER_ID = ?)
	bind => [administrationUser]
[EL Fine]: 2012-11-28 09:19:30.287--ClientSession(1080497174)--Connection(764103883)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--DELETE FROM USER WHERE (USER_USERGROUP = ?)
	bind => [administrationUser]
[EL Fine]: 2012-11-28 09:19:30.308--ServerSession(219730313)--Connection(764103883)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--SELECT ADDRID FROM ADDRESS WHERE (ADDRID = ?)
	bind => [addrIDUserAdministration]
[EL Fine]: 2012-11-28 09:19:30.31--ClientSession(909751202)--Connection(764103883)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--DELETE FROM ADDRESS WHERE (ADDRID = ?)
	bind => [addrIDUserAdministration]
[EL Fine]: 2012-11-28 09:19:30.391--ClientSession(909751202)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--SELECT 1 FROM DUAL
[EL Warning]: 2012-11-28 09:19:30.411--UnitOfWork(1335606662)--Thread(Thread[DistributedCache:MetadataCache,10,Cluster])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (USERADDR_TABLE_USER_ADDRESSSRID) violated - child record found

Error Code: 2292
Call: DELETE FROM ADDRESS WHERE (ADDRID = ?)
	bind => [addrIDUserAdministration]
Query: DeleteObjectQuery(Address{key=AddressKey{key=addrIDUserAdministration}})
Comment 1 Tom Ware CLA 2013-01-03 15:52:35 EST
Does it still fail in 2.4.0?
Comment 2 Sergio a CLA 2013-01-04 06:34:55 EST
(In reply to comment #1)
> Does it still fail in 2.4.0?

Sorry, I have not been able to check it.
Comment 3 Tom Ware CLA 2013-01-04 07:57:05 EST
2.4.x is the earliest stream we are likely to patch.
Comment 4 Tom Ware CLA 2013-02-12 08:58:37 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:04:27 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink