使用JPA存储库的Hibernate提取配置文件 [英] Hibernate Fetch Profiles with JPA Repositories

查看:95
本文介绍了使用JPA存储库的Hibernate提取配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Hibernate和JPA存储库,我想知道为什么我不能设置FetchProfiles并将其与这样的存储库一起使用:

I am working with Hibernate and JPA repositories and i wonder why I can't set up FetchProfiles and use them with a repository like this:

entityManager.unwrap(Session.class).enableFetchProfile("example");
repository.findAll()

第一行对第二行没有任何影响. 相反,我需要通过条件查询(例如在文档中)获取数据:

The first line does not have any effect to the second. Instead I need to get my data via criteria query(like in the docs):

List<EntityA> entities = session.createCriteria(EntityA.class)
            .list();

是否有可能将提取配置文件与JPA存储库一起使用?

Is there any possibility to use fetch profiles together with JPA repositories?

推荐答案

Hibernate Fetch Profiles,而应使用JPA Entity Graphs.这是一个很好的开始教程.

Hibernate Fetch Profiles aren't supported in JPA 2.1, you should use JPA Entity Graphs instead. Here is a good starting tutorial.

这篇关于使用JPA存储库的Hibernate提取配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆