How to handle lock on a db entity in a multithreaded application

Questions : How to handle lock on a db entity in a multithreaded application

154

I have the following two methods:

public void retrieveAndInsert(String _OFFSET);  number){
     Entity e = (-SMALL  repository.findByNumber(number).orElseGet(() _left).offset  -> new Entity());
     //...update arrowImgView.mas  some part of the entity... 
     (self.  repository.save(e);
}
public void equalTo  deleteEntity(String number){
  make.right.  repository.deleteByNumber(number);
}

Those two methods can be called from programming batches and I'm afraid of the following Learning sequence:

  • Retrieve is called by a thread and retrieves the entity, starting the update
  • Meanwhile the delete is called and the underlying row is deleted
  • What happens when save() is called on the first method? Theoretically the entity will be detached from the database while still preserving the ID

Is there a way to work around this Earhost issue?

Total Answers 0

Top rated topics

"open with" menu point missing in Android Studio on linux

WPF combobox - select the first item as default

Efficient Recording of Downtime datas in database table whenever the application is down using Springboot

NodeJS - unable to create a recursive MySQL request properly

Google Sheets - Using regex to pull all data from a multi-line json file

Remove digits and the last space if exist from a string

Keep boost asio io_service

Copy data from Grid View to another (is there a better way)

How to order table after SELECT that generates table

Not able to assign user to new role in Azure App Registration

Android Studio | Java | Convert SQlite Database to CSV and store it on the phone

How to know which package in `package.json` needs specific version of another required package?

Counting occurrences based on condition in R (using dplyr ?)

Performing a XML-Request against Czech Trade Licensing Register(RŽP) in Python

Joining two dataset based on date range

How to match the whole String using String Handling functions

How to get the values from CheckboxListTile together with TextField inputs for a model class

Predeployment approval in azure devops

Problem with expression in xPath jsel library

Google Reporting API v4 - Filters page results by regex?

Spring RepositoryEventHandler for link modification missing link target reference

How to manage tenants programatically in Google Cloud Platform

Center ngx-pagination

How to change font_name property for lables in Kivy?

First and last pivot element vs generic placement with very large N

How to select a specific part of the element in XPath?

SVN pre-commit hook Max size file

SQL Can I use CASE statement with addition condition in a JOIN condition

Made a <div> display:block with onmouseover() but i can't click on it becasue as soon as I move my mouse away it disappears because of onmouseout()

Truncate table. Error Msg = sqlcode -668 sqlerrmc=7

Converting multiple text value in one column into different column

Flutter Getting snapshot.hasError

ActiveMQ Artemis: Zombie replica (slave) instance

Varargs lambda gives illegal instruction - bug in clang or UB?

How to get Custom Field data on WPGraphQL

How to clear redux state once the user visit another route?

MinGW64 cannot compile 32bit code

Error creating entityManagerFactory.Unable building Hibernate SessionF.SchemaManagementException:Export identifier[new_user]encountered more than once

Create a stored procedure for APPROVED OR REJECT USERS

How to remove null from a array using Jolt transformation

Adding columns to data frames in double for loop

Decompressing varbinary column having xml data and insert it into hive table

Gradle in Compute Arm Instance: jcenter.bintray.com FORBIDDEN

Using packages of the project inside a Ray Task

Check condition of all values in a vector

Convert .dat file into DataFrame when there is extra whitespace at the end of rows

PHP: search recursively for specific file extensions, exclude certain directories

How to change object of an observable in angular?

I'm trying to use Javascript Fetch rest API in spring boot project by catogeryId

Laravel faker inside controller unknown format for mobileNumber

Top