-
-
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
JPA not able to render entities with relationships in JHipster 7.6 #17794
Comments
This is probably caused by the Hibernate Enhance Maven Plugin that I added for Spring Native.
I'm using the recommended default configuration as recommended by the here. <plugins>
[...]
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>$currentHibernateVersion</version>
<executions>
<execution>
<configuration>
<failOnError>true</failOnError>
<enableLazyInitialization>true</enableLazyInitialization>
<enableDirtyTracking>true</enableDirtyTracking>
<enableAssociationManagement>true</enableAssociationManagement>
<enableExtendedEnhancement>false</enableExtendedEnhancement>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
[...]
</plugins> |
@mshima How do you think we should go about fixing this? |
@mraible I still think the PR is the best approach. |
@mshima AFAICT this only happens when running your JHipster app as a native executable. It doesn't happen when running in JVM mode. I just tested with https://github.com/oktadev/auth0-full-stack-java-example (
|
The initial bug report states that it’s both JVM and native. I think the settings enableLazyInitialization and enableAssociationManagement should be set to false. |
I updated the description to note that it only happens in native mode. If I change the Hibernate plugin's configuration to have the following: <configuration>
<failOnError>true</failOnError>
<enableLazyInitialization>false</enableLazyInitialization>
<enableDirtyTracking>true</enableDirtyTracking>
<enableAssociationManagement>false</enableAssociationManagement>
<enableExtendedEnhancement>false</enableExtendedEnhancement>
</configuration> It fixes save for tags, but not for photos. Adding a photo still fails with the following error.
If I remove the Hibernate plugin, I get the same error as above (saving albums and tags still works). If I remove the Hibernate plugin and add your public interface PhotoRepository extends JpaRepository<Photo, Long> {
@Query(
value = "select distinct photo from Photo photo left join fetch photo.tags left join photo.album",
countQuery = "select count(distinct photo) from Photo photo"
)
Page<Photo> findAllWithEagerRelationships(Pageable pageable);
@Query("select distinct photo from Photo photo left join fetch photo.tags left join photo.album")
List<Photo> findAllWithEagerRelationships();
@Query("select photo from Photo photo left join fetch photo.tags where photo.id =:id")
Optional<Photo> findOneWithEagerRelationships(@Param("id") Long id);
} ... the error still happens too. |
One last thing I thought of is to add
I added a type hint for this class (and others that resulted in a similar error) too:
Then, I get an error about Charsets:
So I added
This solves the problem! None of these classes are related to a freshly-generated JHipster app, so I tried commenting out the code that uses them in public ResponseEntity<Photo> createPhoto(@Valid @RequestBody Photo photo) throws Exception {
...
/*try {
photo = setMetadata(photo);
} catch (ImageProcessingException ipe) {
log.error(ipe.getMessage());
}*/
...
} Saving a photo works in this scenario with See this commit for what I changed. One other thing I'm wondering: is it possible to change the |
@sdeleuze I discovered today that adding a type hint for |
Overview of the issue
If you try to view an entity's list screen that has relationships to other entities, you'll get an error.
Motivation for or Use Case
Relationships between entities should work.
Reproduce the error
Create a blog app with PostgreSQL, run it, and try to view posts. If there is no data, try to create a new entity and you'll see the failure. You can also run
npm run e2e
to see the failures.You can also do the following if you'd like to clone an existing example:
Related issues
I thought this was a Spring Native issue, but it happens in JVM mode too.
#16498
Edit: this only happens with Spring Native, not in JVM mode.
JHipster Version(s)
7.6.0. No, it is not a regression.
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment GraalVM CE 22.0.0.2 (build 17.0.2+8-jvmci-22.0-b05)
OpenJDK 64-Bit Server VM GraalVM CE 22.0.0.2 (build 17.0.2+8-jvmci-22.0-b05, mixed mode, sharing)
git version 2.32.0 (Apple Git-132)
node: v16.13.2
npm: 8.1.2
Docker version 20.10.12, build e91ed57
Docker Compose version v2.2.3
The text was updated successfully, but these errors were encountered: