current position:Home>In the SSM project, multiple users submit requests at the same time. What happens when the same object is operated in the service layer

In the SSM project, multiple users submit requests at the same time. What happens when the same object is operated in the service layer

2022-01-27 00:02:10 CSDN Q & A

For example serviceimpl In the use @Autowired Inject an entity object , Then set the value, such as id Or the date .
Then query the data in the database table through these two values , If multiple users request at the same time , Is there a mistake , It is the two values that are set to half and changed by another user, and then the previous user finds the data of the following people ? Is it possible




Refer to the answer 1:

therefore You see, someone else injected this ghost - - If it's an entity class , The probability also corresponds to the relevant configuration file , It's almost unchangeable , If you do the same with business data , Then the whole flower will live




Refer to the answer 2:



Refer to the answer 3:

Injecting entity objects is not recommended , There will be thread safety issues . If you must save , You can try to use ThreadLocal.




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270002080722.html

Random recommended