Closed javydreamercsw closed 1 month ago
Please provide a Minimimal Reproducable Example, preferable as a Github repository. Make sure to include the database, either as an in memory database or if that is not possible using Testcontainers.
Especially any web stuff is unrelated and has no place in a minimal reproducer.
Just looking at the keywords this might be related to JPAs 1st level cache.
I attached a zip file with the sample project. Is that not acceptable?
Nope. The project contains over three dozen classes. Seemingly concerned with a Rest/Web interface, logging. Four different test classes.
You describe a problem with an entity with and embedded PK. I therefore expect a reproducer to contain:
I've been unable to develop a reproducer so far after trying for hours. I removed the not relevant tests to get it as close as possible for your requirements and re-attached the project.
I'm sorry, but without a proper reproducer, we can't work on this issue.
I reduced the issue as much as possible. I was unable to reproduce it on a simpler project.
I enabled the SQL in the settings and noticed that the delete query is never done:
Hibernate: select tcss1_0.id,tcss1_0.test_case_id,tcss1_0.test_region_id,tcss1_0.score,tcss1_0.stability,tc1_0.id,tc1_0.class_name,tc1_0.description,tc1_0.test_method,tc1_0.test_name,tcerl1_0.test_case_id,tcerl1_0.id,tcerl1_0.test_case_result_id,tcerl1_0.test_region_id,tcerl1_0.date,tcerl1_0.related_job,tcr1_0.id,tcr1_0.result,tr1_0.id,tr1_0.region_name,tr2_0.id,tr2_0.region_name from test_case_stability_status tcss1_0 join test_case tc1_0 on tc1_0.id=tcss1_0.test_case_id left join test_case_execution_result tcerl1_0 on tc1_0.id=tcerl1_0.test_case_id left join test_case_result tcr1_0 on tcr1_0.id=tcerl1_0.test_case_result_id left join test_region tr1_0 on tr1_0.id=tcerl1_0.test_region_id join test_region tr2_0 on tr2_0.id=tcss1_0.test_region_id where (tcss1_0.id,tcss1_0.test_case_id,tcss1_0.test_region_id) in ((?,?,?)) Hibernate: select tcssl1_0.test_case_id,tcssl1_0.id,tcssl1_0.test_region_id,tcssl1_0.score,tcssl1_0.stability,tr1_0.id,tr1_0.region_name from test_case_stability_status tcssl1_0 left join test_region tr1_0 on tr1_0.id=tcssl1_0.test_region_id where tcssl1_0.test_case_id=? Hibernate: select tchil1_0.test_case_id,tchil1_0.issue_id,i1_0.id,i1_0.issue_reference,i1_0.issue_type_id,iti1_0.id,iti1_0.type from test_case_has_issue tchil1_0 left join issue i1_0 on i1_0.id=tchil1_0.issue_id left join issue_type iti1_0 on iti1_0.id=i1_0.issue_type_id where tchil1_0.test_case_id=?
I'm learning Spring Boot as I go, and everything has been fine so far using Spring JPA to manage the database until I tried deleting an entity with an embedded key. See the attached project. test-stability-api.zip
The relevant entity is as follows:
Have the following test where I basically create the necesary entities and then create a test case execution result which works fine. Then I proceed to delete it but fail when I expect to no longer being able to find it via the API. This is the approach that I use in all the other tests and seem to work fine in those cases. The only difference I can find so far is the key for this entity.