简体   繁体   English

本机查询和JPA

[英]native query and jpa

when using jpa native query 使用JPA本机查询时
is transaction propagation the only feature of proper JPA we are using ? 事务传播是我们正在使用的正确JPA的唯一功能吗?

I me in my opinio is just like using plain old jdbc pluc jpa transaction propagation 我在我的观点中就像使用普通的旧jdbc pluc jpa事务传播一样

So there's no concept of persistence context ? 因此,没有持久性上下文的概念吗?

Can you validate my ideas , and point me to some me official docs about this ? 您可以验证我的想法,并为此找到一些官方文档吗?

EDIT: 编辑:

One thing to be careful of with SQL queries that return entities is that the resulting entity instances become managed by the persistence context, just like the results of a JP QL query. 返回实体的SQL查询要注意的一件事是,所产生的实体实例将由持久性上下文管理,就像JP QL查询的结果一样。

I'm reading the book PRO JPA, and from what I understood 我正在阅读《 PRO JPA》这本书,据我了解
when we use jpa native query to get a set of scalar values (much the same way we do with jdbc) ther's really no concept of managed entities and persistence context. 当我们使用jpa本机查询来获取一组标量值时(与使用jdbc的方式几乎相同),实际上并没有托管实体和持久性上下文的概念。 Things change of course when through native queries we retrieve Entities. 当通过本地查询检索实体时,事情当然会改变。

In my experience, there's a big difference in the time it takes to execute JPA native queries and JDBC queries. 以我的经验,执行JPA本机查询和JDBC查询的时间差异很大。 Probably due to the creation of the persistence context. 可能是由于创建了持久性上下文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM