Cosium / spring-data-jpa-entity-graph

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories
MIT License
466 stars 51 forks source link

Entitygraph does not work for Microsoft SQL #62

Closed einue closed 2 years ago

einue commented 2 years ago

i am using your repository

<dependency>
    <groupId>com.cosium.spring.data</groupId>
    <artifactId>spring-data-jpa-entity-graph</artifactId>
    <version>2.4.2</version>
    <!--<version>${springframework.boot.version}</version>-->
</dependency>

With spring-boot

2.4.5 The subgraph works really fine, if I have a mysql database. Now I changed my db from mysql to Microsoft sql Server and I return the following error: There was an exception while trying to navigate to 'booking' with the exception message 'failed to lazily initialize a collection of role: sit.app.container.backend.data.entity.LoosePlanningForDay.regularSlots, could not initialize proxy - no Session' For the msyql-variant with subgraph everything works. Do you have some hint for me how to fix this issue? My properties are: ``` datasource: driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver jpa: properties: hibernate: dialect: org.hibernate.dialect.SQLServerDialect ```
reda-alaoui commented 2 years ago

Your issue is certainly caused by something between the ORM (I guess Hibernate) and the JDBC driver. I would start by trying to use the entity graph as a query hint directly passed to the EntityManager.