hibernate JPA 中注解version的用法

zhouyusunquan 2013-10-25 10:37:47
请使用过的人讲解一下,不要从jpa的注解帮助文档直接copy,那不是我需要的,
...全文
749 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
baidu_33754003 2016-01-15
  • 打赏
  • 举报
回复
引用 3 楼 zhuchao_ko 的回复:
[quote=引用 2 楼 zhouyusunquan 的回复:] [quote=引用 1 楼 zhuchao_ko 的回复:] 有帮助文档还看不懂 要怎么帮你?
帮助文档写的不详细,都是省略号,你要是没用过,就不要发帖,[/quote] 不详细你百度 谷歌啊,你多大了? 百度“@version”第二条就是。 你出去聚会吃饭,菜够不到还要别人来喂你吗? 我当然搞过,这些东西真是懒的打给你知道, 今天不知道@version明天又不知道另一个, 你还真以为四海之内皆版主啊?[/quote] 那你为什么要上学校读书呢?直接买完书在家里自学不好么?到时候直接去考研吧!
夜鹰_限量版 2015-04-01
  • 打赏
  • 举报
回复
@Version一般配合乐观锁用,假如用Hibernate提供的乐观锁实现,你在Update数据的时候试图用低版本的对象去更新的话,在对应事务commit()的时候会抛StaleObjectStateException异常。想加什么操作把异常捕获就行了。
zhouyusunquan 2013-10-31
  • 打赏
  • 举报
回复
引用 5 楼 zhouyusunquan 的回复:
[quote=引用 3 楼 zhuchao_ko 的回复:] [quote=引用 2 楼 zhouyusunquan 的回复:] [quote=引用 1 楼 zhuchao_ko 的回复:] 有帮助文档还看不懂 要怎么帮你?
帮助文档写的不详细,都是省略号,你要是没用过,就不要发帖,[/quote] 不详细你百度 谷歌啊,你多大了? 百度“@version”第二条就是。 你出去聚会吃饭,菜够不到还要别人来喂你吗? 我当然搞过,这些东西真是懒的打给你知道, 今天不知道@version明天又不知道另一个, 你还真以为四海之内皆版主啊?[/quote] 草,估计你也不知道,不知道就不要回复[/quote]
引用 4 楼 forgetsam 的回复:
引用
This annotation specifies the version field or property of an entity class that serves as its optimistic lock value. The version is used to ensure integrity when performing the merge operation and for optimistic concurrency control. Only a single Version property or field should be used per class; applications that use more than one Version property or field will not be portable. The Version property should be mapped to the primary table for the entity class; applications that map the Version property to a table other than the primary table will not be portable. The following types are supported for version properties: int, Integer, short, Short, long, Long, Timestamp. Example: @Version @Column(name="OPTLOCK") protected int getVersionNum() { return versionNum; } Since: Java Persistence 1.0
哪看见省略号了。这不就是 hibernate乐观锁吗。
仅仅是 @Version @Column(name="OPTLOCK") protected int getVersionNum() { return versionNum; } 是不够的,比如说两个人公用一个账号,怎么扣款,难道是比较一下,如果说版本号不对,就直接返回支付失败, 这样也太好了,要是简单的这样,我自己也会
zhouyusunquan 2013-10-31
  • 打赏
  • 举报
回复
引用 4 楼 forgetsam 的回复:
引用
This annotation specifies the version field or property of an entity class that serves as its optimistic lock value. The version is used to ensure integrity when performing the merge operation and for optimistic concurrency control. Only a single Version property or field should be used per class; applications that use more than one Version property or field will not be portable. The Version property should be mapped to the primary table for the entity class; applications that map the Version property to a table other than the primary table will not be portable. The following types are supported for version properties: int, Integer, short, Short, long, Long, Timestamp. Example: @Version @Column(name="OPTLOCK") protected int getVersionNum() { return versionNum; } Since: Java Persistence 1.0
哪看见省略号了。这不就是 hibernate乐观锁吗。
你这有个毛用,我要处理,并不是仅仅一个配置,如果说版本号不对,是会怎么样,怎么处理
zhouyusunquan 2013-10-31
  • 打赏
  • 举报
回复
引用 3 楼 zhuchao_ko 的回复:
[quote=引用 2 楼 zhouyusunquan 的回复:] [quote=引用 1 楼 zhuchao_ko 的回复:] 有帮助文档还看不懂 要怎么帮你?
帮助文档写的不详细,都是省略号,你要是没用过,就不要发帖,[/quote] 不详细你百度 谷歌啊,你多大了? 百度“@version”第二条就是。 你出去聚会吃饭,菜够不到还要别人来喂你吗? 我当然搞过,这些东西真是懒的打给你知道, 今天不知道@version明天又不知道另一个, 你还真以为四海之内皆版主啊?[/quote] 草,估计你也不知道,不知道就不要回复
宁波朱超 2013-10-31
  • 打赏
  • 举报
回复
楼主人品素质太差
引用 4 楼 forgetsam 的回复:
引用
This annotation specifies the version field or property of an entity class that serves as its optimistic lock value. The version is used to ensure integrity when performing the merge operation and for optimistic concurrency control. Only a single Version property or field should be used per class; applications that use more than one Version property or field will not be portable. The Version property should be mapped to the primary table for the entity class; applications that map the Version property to a table other than the primary table will not be portable. The following types are supported for version properties: int, Integer, short, Short, long, Long, Timestamp. Example: @Version @Column(name="OPTLOCK") protected int getVersionNum() { return versionNum; } Since: Java Persistence 1.0
哪看见省略号了。这不就是 hibernate乐观锁吗。
完了,你我摊上这2货了。
宁波朱超 2013-10-25
  • 打赏
  • 举报
回复
有帮助文档还看不懂 要怎么帮你?
forgetsam 2013-10-25
  • 打赏
  • 举报
回复
引用
This annotation specifies the version field or property of an entity class that serves as its optimistic lock value. The version is used to ensure integrity when performing the merge operation and for optimistic concurrency control. Only a single Version property or field should be used per class; applications that use more than one Version property or field will not be portable. The Version property should be mapped to the primary table for the entity class; applications that map the Version property to a table other than the primary table will not be portable. The following types are supported for version properties: int, Integer, short, Short, long, Long, Timestamp. Example: @Version @Column(name="OPTLOCK") protected int getVersionNum() { return versionNum; } Since: Java Persistence 1.0
哪看见省略号了。这不就是 hibernate乐观锁吗。
宁波朱超 2013-10-25
  • 打赏
  • 举报
回复
引用 2 楼 zhouyusunquan 的回复:
[quote=引用 1 楼 zhuchao_ko 的回复:] 有帮助文档还看不懂 要怎么帮你?
帮助文档写的不详细,都是省略号,你要是没用过,就不要发帖,[/quote] 不详细你百度 谷歌啊,你多大了? 百度“@version”第二条就是。 你出去聚会吃饭,菜够不到还要别人来喂你吗? 我当然搞过,这些东西真是懒的打给你知道, 今天不知道@version明天又不知道另一个, 你还真以为四海之内皆版主啊?
zhouyusunquan 2013-10-25
  • 打赏
  • 举报
回复
引用 1 楼 zhuchao_ko 的回复:
有帮助文档还看不懂 要怎么帮你?
帮助文档写的不详细,都是省略号,你要是没用过,就不要发帖,

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧