0

I am using GraphQL to rebuild my REST applications. One of the problems I have is that the GraphQLResolver does not reuse the transaction used in GraphQLQueryResolver.

I know that using JPA and OpenEntityManagerInViewFilter can help, but rewriting thousands of DAO using JPA/EntityManager to replace Hibernate Session is not an option right now.

Is there an alternative to use "org.springframework.orm.hibernate5.LocalSessionFactoryBean" and still keep the transaction opened for GraphQLResolver?

@Component
@Transactional
public class CountryQuery implements GraphQLQueryResolver {

    public List<Country> countries() {
        ...
    }
}

@Component
@Transactional
public class CountryResolver implements GraphQLResolver<Country> {
  public List<Locale> locales(Country country) {
     ...
  }
}

1 Answers1

0

I found AsyncTransactionalExecutionStrategy works in this post

LazyInitializationException with graphql-spring