dynamic-insert dynamic-update mutable="false" (让hibernate生成的sql不包括所有字段、指定不可变的实体)
2011-10-17 16:15
507 查看
Hibernate生成update语句,会更新所有的列。
在有些情况下,例如包含几百列的一个遗留表,在该表中,即使最简单的操作的sql语句也很大,必须关闭这个启动时
的sql生成,并切换到运行时生成的动态语句。当大量实体时,也会影响启动时间,因为hibernate必须为CURD提前生
成所有SQL语句:
区别就是:
Hibernate: insert into USER (user_Name) values (?)
Hibernate: insert into USER (user_Name, password) values (?, ?)
配置:
view
plaincopy
to clipboardprint?
<class name="User" table="USER" dynamic-insert="true" dynamic-update="true">
view
plaincopy
to clipboardprint?
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
使实体不可变:
一个特定类的实例可以是不可变的。
效果:
没有sql打印,也没有报错,也就是忽略了更新操作
配置:
view
plaincopy
to clipboardprint?
<class name="User" table="USER" dynamic-insert="true" dynamic-update="true"
mutable="false">
view
plaincopy
to clipboardprint?
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true,mutable=false)
view
plaincopy
to clipboardprint?
@org.hibernate.annotations.AccessType
The
annotation @org.hibernate.annotations.AccessType
should be considered deprecated for FIELD
and PROPERTY access. It is still useful however if you
need to use a custom access type.
在有些情况下,例如包含几百列的一个遗留表,在该表中,即使最简单的操作的sql语句也很大,必须关闭这个启动时
的sql生成,并切换到运行时生成的动态语句。当大量实体时,也会影响启动时间,因为hibernate必须为CURD提前生
成所有SQL语句:
区别就是:
Hibernate: insert into USER (user_Name) values (?)
Hibernate: insert into USER (user_Name, password) values (?, ?)
配置:
view
plaincopy
to clipboardprint?
<class name="User" table="USER" dynamic-insert="true" dynamic-update="true">
view
plaincopy
to clipboardprint?
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
使实体不可变:
一个特定类的实例可以是不可变的。
效果:
没有sql打印,也没有报错,也就是忽略了更新操作
配置:
view
plaincopy
to clipboardprint?
<class name="User" table="USER" dynamic-insert="true" dynamic-update="true"
mutable="false">
view
plaincopy
to clipboardprint?
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true,mutable=false)
view
plaincopy
to clipboardprint?
@org.hibernate.annotations.AccessType
The
annotation @org.hibernate.annotations.AccessType
should be considered deprecated for FIELD
and PROPERTY access. It is still useful however if you
need to use a custom access type.
相关文章推荐
- Hibernate SQL优化小技巧使用dynamic-insert="true" dynamic-update="true"
- PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
- Hibernate_should be mapped with insert="false" update="false"的解决方法
- 【转】Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate中should be mapped with insert="false" update="false"错误
- hibernate的动态更新(dynamic-update = "true")
- hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- java优化Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- (转)PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- hibernate column should be mapped with insert="false" update="false" 错误原因
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
- hibernate配置文件中重复定义导致的错误:should be mapped with insert="false" update="false"