-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't fetch related entity when retrieving an entity for viewing/updating #23917
Comments
I've updated the "Suggest a Fix" section. Keeping |
Looks like there is another behavior change.
|
Maybe related to Jackson hibernate serializer. This feature should be enabled: https://www.javadoc.io/doc/com.fasterxml.jackson.datatype/jackson-datatype-hibernate5/latest/com/fasterxml/jackson/datatype/hibernate5/Hibernate5Module.Feature.html#SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS |
Certainly, setting public class JacksonConfiguration {
...
/*
* Support for Hibernate types in Jackson.
*/
@Bean
public Hibernate6Module hibernate6Module() {
return new Hibernate6Module().configure(Feature.SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS, true);
} |
I believe one of the following solutions should be implemented before the v8 release.
|
@hide212131 1. should be implemented. Not sure about 2. Please check the jdl:
We need adjusts but the following jdl should work too
|
@mshima Following option 1, I can submit a PR if that's alright. ...I was surprised to learn about the @RelationshipEagerLoad annotation, as I couldn't find it in either the documentation or the source code. Does JDL's annotation have a mechanism to directly modify any specific properties of the generator? |
Every annotation will be loaded to the model. There is so many customizations possible that it’s difficult to document everything. |
Overview of the issue
In JDL:
When retrieving the
Employee
entity for viewing or updating, the relatedDepartment
entity cannot be fetched.JSON in HTTP Response:
As a result, the department information is not displayed.
Motivation for or Use Case
The expected operation does not occur, such as the disappearance of a value that should have been registered.
Reproduce the error
Generated in JDL, including related (at least, occurs in OneToOne, ManyToOne, OneToMany)
Related issues
It appears that the fetch strategy is related to this issue.
#20285
#19791 (comment)
Suggest a Fix
Removing
(fetch = FetchType.LAZY)
from the entity serves as a temporary workaround.For example:
Employee.java:
JSON in HTTP Response:
A more appropriate long-term solution would involve using Entity Graphs.
JHipster Version(s)
8.0.0-rc.1
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
Environment and Tools
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment GraalVM CE 22.3.3 (build 17.0.8+7-jvmci-22.3-b22)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.3 (build 17.0.8+7-jvmci-22.3-b22, mixed mode, sharing)
git version 2.39.3 (Apple Git-145)
node: v18.17.1
npm: 9.6.7
Docker version 24.0.6, build ed223bc
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Browsers and Operating System
The text was updated successfully, but these errors were encountered: