【发布时间】:2019-12-29 18:34:23
【问题描述】:
我正在使用 GraphQL 来重建我的 REST 应用程序。 我遇到的问题之一是 GraphQLResolver 没有重用 GraphQLQueryResolver 中使用的事务。
我知道使用 JPA 和 OpenEntityManagerInViewFilter 会有所帮助,但现在还不能使用 JPA/EntityManager 重写数千个 DAO 来替换 Hibernate Session。
是否有替代方法可以使用“org.springframework.orm.hibernate5.LocalSessionFactoryBean”并仍然为 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) {
...
}
}
【问题讨论】: