got a bug where when i checkout the 2nd item gets deleted from the order
the weird thing is that the 3 and 4 item are getting added using springboot angular and postgres for fullstack
53 Replies
β
This post has been reserved for your question.
Hey @timo! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.





so the picture is the gui and first you have the price in order wich is 1978 but when you press checkout the 2nd item will be deleted so 1978 - 380= 1598 see picture on the left top
2 the left bottom pic is my controller in springboot and handle it with a delete mapping wich continues with dao dto and model
3 the picture in the middle is my cart.component.ts wich i wrote the functions and also have a cart.service.ts
can but the src of the backend in zip but dunno if you guys like that
@dan1st | Daniel
what do you think?
I cannot tell you anything about the TS code
and images of code are hard to read
but it's probably an issue with your backend code, try debugging that
idk what endpoint is being called lol
it goes threw the cartcomponent
then to order dto and ordermodel also tried debugging but didn t get much further π
there's no need to tell me about TS/angular stuff lol
huh this is springboot
what happens in the backend?
ah ok
what partπ
quite a lot happens
First check which endpoints are actually called
@deleteMapping is being called
then check whether each of them is doing what it's supposed to/which results in something happing you don't want
deleteById?
correct
came with debugging on the delete request
what does the corresponding service do?
So before the delete request, you have 2 entries and after it, you have no entry?
before the delete request i have 2 datbases with data
1 shoppingcart
2 order
shopping cart will be empty after chekout and order will only be cleaned if 1 item gets deleted but after the checout it should stay the same
what should stay the same? What is deleted? What should be deleted?
right bottom is the order once checout get s pressed that should stay and cart_components should delete all
cuz when you checkout/pay you don t want any items in your shoppingcart
so the order shouldn't be removed?
maybe it's because of a
ON DELETE CASCADE
?could be ig the order shouldn t be removed only the cart
doesn t make much sense to me tho XD
Can you share the code of the relevant service?
Does the order table reference the card table?
can i sent the zip or is that not allowed for security reasons?
I can't really read ZIPs on my mobile properly anyways
just send the relevant code using the codeblock
or even better, a minimal, complete and verifiable example
but not sure what to sent cuz got controller dao dto repo and model
cuz just sent it as txt but not sure what to even sent
As I said, the service
deleteOrderCartComponentBycartitemid
this?
π
Can you also show the order entity?
what do you mean by entity?
the
@Entity
class
CartComponents
you mean the ordermodel sorry im confused
Do you have a class called
CartComponents
?a model yeah
Can you show it?
and that has entity within with class
Removing the
cascade = CascadeType.MERGE
doesn't help, right?dunno have it in those 3 but maybe im stupid but why are we looking in the model of cart when the problem is with the orderdatabse?

I wanted to make sure that deleting the card doesn't delete the order
actually can you also show your order model?
seems to me to cart gets first then order and order gets called once and is 2nd or something and that is why the 2nd item is deleted and the rest is fine but not sure
Can you check the following?
Before calling
deleteOrderCartComponentsBycartimtemId
, the order is there in the DB
- after calling that, the DB entry for the order disappears (which you don't want)
- There are no other requests handled while that happens
Also you could try enabling logging of SQL statements to find out what deletes itwhen debugging and pressing checkout i came out on that delete thing so think that is the only request running in that action don t know logging on sql statements
getting kinda tired tho so thnaks a lot for your help but dunno how much longer i can be sharp pretty late in europeπ
I live in Austria so same
nice i have worked as a skiteacher in austria π
Stack Overflow
How can I log SQL statements in Spring Boot?
I want to log SQL statements to a file.
I have the following properties in application.properties:
spring.datasource.url=...
spring.datasource.username=user
spring.datasource.password=1234
spring.
added it then i should rerun my backend and what should be different then?
it would print all SQL statements it's executing to the console
so kinda a debugging tool for sql?
kinda
the idea is that it should also include the statement that's deleting the thing
good to know do you mind i will continue tomorrow cuz feel kinda braindead rn sorry
π
π€
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.