Open vw98075 opened 4 months ago
Suggest a Fix
In the Parent entity, add the following configuration
cascade = CascadeType.REMOVE, orphanRemoval = true
to
@OneToOne(fetch = FetchType.LAZY, mappedBy = "parent")
"normally" the @onDelete
is something that's happening on database level. I wonder, why it isn't the case in this special situation.
JHipster has completed the sample check
.yo-rc.json
:
Entities JDL:
Application: successfully generated
Frontend check: skipped
Backend check: skipped
E2E check: skipped
This check uses jhipster info
output from the issue description to generate the sample.
Bug report that does not contain this information will be marked as invalid.
For the User one-to-one case, the annotation @OnDelete("CASCADE") initiates a cascade operation within the DB schema. This approach, while functional, is somewhat of a workaround, likely stemming from the "immutable" constraint of the built-in entity User, rather than the standard procedure for cascade operations in JPA/Hibernate. If this annotation serves solely as a workaround, it should be clearly documented as such.
In the context of open source collaboration, it's essential to respect the design and functionality of dependent projects. While it's acceptable to propose changes or improvements, directly altering the behavior of another open-source project is generally discouraged.
how to use orphanRemoval, dont work when add to "relationships": [ { "orphanRemoval": true, "otherEntityName": "listAttachment", "relationshipName": "attachments", "relationshipSide": "left", "relationshipType": "one-to-many" },
dont apply to after generation:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "lists")
@JsonIgnoreProperties(value = { "lists" }, allowSetters = true)
private Set<ListAttachment> attachments = new HashSet<>();
Overview of the issue
With the following relationship definition,
, deleting a Parent with a Child in the admin UI isn't working: a pop-up panel confirms the deletion, but the data entry is still on the refreshed list. A similar JDL for the built-in User entity works, however.
There is a related issue, the parent column is blank while parent data shows up in both view and edit pages.
Motivation for or Use Case
That is a basic entity data operation.
Reproduce the error
With the provided JDL, this bug can be reproduced.
Related issues
Suggest a Fix
In the Parent entity, add the following configuration
to
JHipster Version(s)
8.3
JHipster configuration
{ "generator-jhipster": { "applicationType": "monolith", "authenticationType": "jwt", "baseName": "oto", "buildTool": "gradle", "cacheProvider": "caffeine", "clientFramework": "vue", "clientTestFrameworks": [], "clientTheme": "none", "creationTimestamp": 1712685614957, "databaseType": "sql", "devDatabaseType": "h2Memory", "devServerPort": 9060, "enableGradleEnterprise": false, "enableHibernateCache": false, "enableSwaggerCodegen": false, "enableTranslation": false, "entities": ["Address", "Parent", "Child"], "feignClient": null, "gradleEnterpriseHost": null, "jhipsterVersion": "8.3.0", "jwtSecretKey": "...", "lastLiquibaseTimestamp": 1712686072000, "messageBroker": false, "microfrontend": null, "microfrontends": [], "nativeLanguage": "en", "packageName": "com.mycompany.myapp", "prodDatabaseType": "postgresql", "reactive": false, "searchEngine": false, "serverPort": null, "serverSideOptions": [], "serviceDiscoveryType": false, "syncUserWithIdp": null, "testFrameworks": [], "websocket": false, "withAdminUi": true } }