Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Cascade Issue(@OnetoOne Cascade perform multiple updates overrides updated value to existing in DB)
Cascade Issue [message #1852197] Wed, 04 May 2022 14:32 Go to next message
Deepesh Mundra is currently offline Deepesh MundraFriend
Messages: 1
Registered: May 2022
Junior Member
Below is the parent table dto which has requestStatus as IN_PROGRESS which gets updated to DONE on updating child table as below:

@OneToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="vendorServiceability", targetEntity=ServiceabilityStatusDTO.class)
private IServiceabilityStatus serviceabilityStatus;

@Column(name="REQUEST_STATUS", length=15)
private String requestStatus;

Below is the child table dto which insert record and update requestStatus to DONE in parent table dto

@JoinColumn(name="SERVICEABILITY_KEY", unique=true)
private IVendorServiceability vendorServiceability;

We checked when running for 100 products, for each product while saving child table, it updates parent table requestStatus to Done and again it updates to IN_PROGRESS from another thread. So, final status is like out of 100, around 50 are marked as Done and remaining as InProgress.

We tried using flush and clear entitymanager but issue still persist.

please suggest.
Re: Cascade Issue [message #1854241 is a reply to message #1852197] Mon, 08 August 2022 18:08 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 43
Registered: December 2021
What is 'it' in the context of "it updates parent table requestStatus to Done and again it updates to IN_PROGRESS from another thread. " Does this mean in a single transaction you see the state change from one state and then back again? It isn't clear what product is, as you mention a parent and child, but then switch to using product in your description; it would help to show an example in code of what you are doing, and what state you expect vs what state is actually occurring.

From just guessing, this appears to be a non-deterministic problem that you are experiencing; I'd guess further you are calling merge on an object model (parent) that has bidirectional relationships but with an incomplete/inaccurate graph built, such that parent1 -> child1 -> parent1'. This might allow the state of the parent as referenced by the child to be inconsistent with the state of the parent instance that references the child, and what gets into the database then depends on how the mappings are processed by merge calls. I'd suggest you look closely at the object model being worked on and how it is built in your threads (especially of JSON serialization is used) to ensure that the object graph maintains identity before passing it into JPA merge operations, and that the cascade operations on references are appropriate.

Best Regards,
Previous Topic:Wrong detected type for MIN operator - I think?
Next Topic:XA data source connection in EclipseLink in SpringBoot application.
Goto Forum:

Current Time: Fri Dec 01 11:13:16 GMT 2023

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

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

Back to the top