Table of Contents
1. merge跟个save了.
2. POJO对象处于游离态、持久态、托管态。使用merge()的情况。
3. @DynamicInsert @DynamicUpdate
4. 实际调用merge()生成的sql
5. 参考
Home Database Mysql Tutorial atitit.hbntormdb新新增更新最佳实践o7

atitit.hbntormdb新新增更新最佳实践o7

Jun 07, 2016 pm 03:58 PM
New renew optimal

atitit.hbnt orm db 新新增更新最佳实践o7 1. merge跟个save了. 1 2. POJO对象处于游离态、持久态、托管态。使用merge()的情况。 1 3. @DynamicInsert @DynamicUpdate 2 4. 实际调用merge()生成的sql 2 5. 参考 2 1. merge跟个save了. Update UpdateorSa

atitit.hbnt orm db 新新增更新最佳实践o7

1. merge跟个save了. 1

2. POJO对象处于游离态、持久态、托管态。使用merge()的情况。 1

3. @DynamicInsert @DynamicUpdate 2

4. 实际调用merge()生成的sql 2

5. 参考 2

1. merge跟个save了.

Update

UpdateorSave 已经不推荐了...

生成的黑头子有个merge跟个save了...

作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

2. POJO对象处于游离态、持久态、托管态。使用merge()的情况。

测试过程中游离态、持久态、有用

1、游离态ID为空,数据库肯定不存在,调用merge(),直接插入数据库。

2、持久态,pojo对象从数据库中取出的行记录,调用merge(),自动比较该对象和数据库对象是否发生更改,是则更新该行记录。

3、托管态,通过编程的方式指定ID,程序构造的POJO对象,调用merge(),自动比较数据库该ID行记录与POJO对象的属性。不一样则更新。

但通过程序构造的POJO对象,并指定ID。但POJO的ID为native,并指定了数据库的sequence,调用merge()后,程序指定的ID,还是会被改成新的序列ID,则,该POJO对象还是成了ID不为空、数据库不存在该ID的游离态。

3. @DynamicInsert @DynamicUpdate

4. 实际调用merge()生成的sql

首先select在up

select gvmaterial0_.material_id as material1_0_0_, gvmaterial0_.application_type as applicat2_0_0_, gvmaterial0_.can_down_org as can3_0_0_, gvmaterial0_.create_time as create4_0_0_, gvmaterial0_.effectie_time as effectie5_0_0_, gvmaterial0_.failure_time as failure6_0_0_, gvmaterial0_.file_path as file7_0_0_, gvmaterial0_.material_description as material8_0_0_, gvmaterial0_.material_type as material9_0_0_, gvmaterial0_.play_time as play10_0_0_, gvmaterial0_.size as size0_0_, gvmaterial0_.update_time as update12_0_0_, gvmaterial0_.update_user as update13_0_0_ from gv_material gvmaterial0_ where gvmaterial0_.material_id=1

32 Query update gv_material set play_time=125 where material_id=1

5. 参考

Hibernate更新某些字段的几种update方法 - zb0567的专栏 - 博客频道 - CSDN.NET.htm

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to fix Blizzard Battle.net update stuck at 45%? How to fix Blizzard Battle.net update stuck at 45%? Mar 16, 2024 pm 06:52 PM

How to fix Blizzard Battle.net update stuck at 45%?

Epic Seven's February 22nd update: The second week of Miracle Maid Kingdom begins Epic Seven's February 22nd update: The second week of Miracle Maid Kingdom begins Feb 21, 2024 pm 05:52 PM

Epic Seven's February 22nd update: The second week of Miracle Maid Kingdom begins

Simple steps to update pip version: done in 1 minute Simple steps to update pip version: done in 1 minute Jan 27, 2024 am 09:45 AM

Simple steps to update pip version: done in 1 minute

How to install Angular on Ubuntu 24.04 How to install Angular on Ubuntu 24.04 Mar 23, 2024 pm 12:20 PM

How to install Angular on Ubuntu 24.04

How to update MSI graphics card driver? MSI graphics card driver download and installation steps How to update MSI graphics card driver? MSI graphics card driver download and installation steps Mar 13, 2024 pm 08:49 PM

How to update MSI graphics card driver? MSI graphics card driver download and installation steps

Lantern and Dungeon updated on February 29: Remastered version ╳ 'Legend of Nezha' linkage Lantern and Dungeon updated on February 29: Remastered version ╳ 'Legend of Nezha' linkage Feb 28, 2024 am 08:13 AM

Lantern and Dungeon updated on February 29: Remastered version ╳ 'Legend of Nezha' linkage

Windows cannot access the specified device, path, or file Windows cannot access the specified device, path, or file Jun 18, 2024 pm 04:49 PM

Windows cannot access the specified device, path, or file

How to disable automatic updates in Windows 10 Home Edition How to disable automatic updates in Windows 10 Home Edition Jan 22, 2024 pm 09:54 PM

How to disable automatic updates in Windows 10 Home Edition

See all articles