• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Flush old data and make query for a new data  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! It's my first topic)

Spring Data JPA | Hibernate

In a nutshell, I get data from one table, do some stuff like inserting or updating data in the bounded tables. Try to fetch data from the first table, but spring returns me old data.

In details.
In my controller I fetch order:


Then I get order products:


I have amount of specific product from HTTP request.
Update order's product amount :


It's okay, I updated amount of product, but I need to count and update total price of order. I try to get order with assosiated products again in another method, but i get old data:


Full code of class is here: https://github.com/VitaliyGoncharov/AutoSupplies/blob/master/server/src/main/java/com/carssps/controller/manager/OrderController.java

How to tell spring that data was changed and i need to flush old data and fetch new?

 
David Belcher
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did wrong search requests in google. I found a solution. I added

to controller method updateTotal() right before fetching data one more time.
 
Ranch Hand
Posts: 83
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I viewed your source code and was impressed.
Is this a tutorial you are following?
If so, would you share the link?
 
David Belcher
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Nachreiner wrote:I viewed your source code and was impressed.
Is this a tutorial you are following?
If so, would you share the link?


Thank you!
No, I don't use any specific tutorial. It's my first project on java. I google almost everything that I don't know. Stackoverflow, baeldung, etc.
 
Tim Nachreiner
Ranch Hand
Posts: 83
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What tool are you using to develop the Angular piece?
 
David Belcher
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Nachreiner wrote:What tool are you using to develop the Angular piece?


I use visual studio code!
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!