Using any Springboot with these Hibernate dependencies breaks Hibernate after exporting the Project with maven.
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.1.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-community-dialects</artifactId>
<version>6.1.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-hikaricp</artifactId>
<version>6.1.6.Final</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.0.1</version>
</dependency>
Im facing this Issue in my own projekt here https://github.com/Ree6-Applications/Webinterface
To repdroduce this you will need atleast 2 entries in a table and then just try to access both of these as entites over the SQLWorker
class by using getEntityList
.
The wanted result is that the getEntityList
method gives out a list of R which is a filled class instance, but running the project outside an IDE in this case a maven packaged runnable it always returns a List of Strings and the given strings are the primary keys set in the Entity class.
To be exact after exporting the Spring Application the Hibernate mapping breaks and the Native Query that is being called does not produce a filled out entity instance anymore, but a list of primary keys. As said this Issue does not happen while running the application in an IDE or exporting a none spring application as runnable jar.
CodePudding user response:
For anyone else facing this Issue while using the org.reflections package to add all their annotated classes, you will need to use the ClassPathHelpers static classloader because of the way Springboot works.