ManyToOne and JoinTable [message #987653] |
Tue, 27 November 2012 13:00 |
Sergio a Messages: 3 Registered: November 2012 |
Junior Member |
|
|
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).
I am new using EclipseLink jpa , am I doing something wrong? How I can state that no cascade delete? (default cascade is emtpy array, I've also tried putting cascade = {})
Thanks, regards.
|
|
|
|
Re: ManyToOne and JoinTable [message #987798 is a reply to message #987697] |
Wed, 28 November 2012 08:37 |
Sergio a Messages: 3 Registered: November 2012 |
Junior Member |
|
|
Hi,
Thank you very much for the quick response.
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}})
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06708 seconds