在使用JPA的MERGE的时候要注意:
1、将多执行一次SELECT的操作。
2、Either way will add an entity to a PersistenceContext, the difference is in what you do with the entity afterwards.
Persist takes an entity instance, adds it to the context and makes that instance managed (ie future updates to the entity will be tracked)
Merge creates a new instance of your entity, copies the state from the supplied entity, and makes the new copy managed. The instance you pass in will not be managed (any changes you make will not be part of the transaction - unless you call merge again).
所以,在应当使用PERSIST的时候,绝不应该使用MERGE,一是会带性能的损耗,二是如果后续有使用,尤其有多对一的情况,会带来关联了未保存对象的错误!
分享到:
相关推荐
OpenJPA is Apache's implementation of Sun's Java Persistence 2.0 API (JSR-317 JPA 2.0) specification for the transparent persistence of Java objects. This document provides an overview of the JPA ...
JPA教程JPA教程JPA教程JPA教程JPA教程
jpa jpa规范 jpa源码 jpa jpa规范 jpa源码
jpajpajpajpajpajpajpajpajpajpajpajpajpa
Authors Mike Keith, Merrick Schincariol and Massimo Nardone take a hands-on approach, based on their wealth of experience and expertise, by giving examples to illustrate each concept of the API and ...
包括TOPLink JPA,Hibernate JPA,Open Jpa,jpa批注
JPA
JPA视频_PPT及源码 · 1. JPA视频_概述 · 2. JPA视频_HelloWorld · 3. JPA视频_基本注解 · 4. JPA视频_Transient注解 · 5. JPA视频_Temporal注解 · 6. JPA视频_Table主键生成策略 · 7. JPA视频_...
jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联映射jpa 关联...
这是JPA标签配置手册,从ORACLE官方得到的资料,里面对JPA所有的标签都进行详细的说明。 Index of Annotations • A o @AssociationOverride o @AssociationOverrides o @AttributeOverride o @AttributeOverrides ...
Spring Data JPA API。 Spring Data JPA 开发文档。 官网 Spring Data JPA API。
Spring Data JPA 简化 JPA 开发
This refcard will give users enough to understand the basics of JPA and get started writing JPA applications. It covers entities, identifiers, O-R mappings, using an entity manager, creating and ...
JPA学习参考文档 JPA学习参考文档 JPA学习参考文档
4.7脱离/附合(Detach/Merge) 14 5. JPA Query 15 5.1 Query接口 15 5.2简单查询 16 5.3使用参数查询 17 5.4排序(order by) 17 5.5查询部分属性 18 5.6查询中使用构造器(Constructor) 18 5.7聚合查询(Aggregation) 19...
JPA JAPJPA JAPJPA JAPJPA JAPJPA JAPJPA JAPJPA JAPJPA JAPJPA JAPJPA JAP
jpa 全面学习资料 入门 实战 示例 jpa开发手册 JPA_全面讲解 JPA使用入门_基础 JPA学习笔记 JPA注解 JPA简介
JPA的API非常简洁,但是描述很全面 需要的JPA知识全部可以找到
Jpa详细查询实例介绍,教你如何使用JPA,简单,分类实例。
入门级别的jpa 详细解答,教程从简单到入门,容易上手