由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 问一个Collection Update的问题
相关主题
大家拍我吧,自己太弱了EHCache --- hibernate question
搞不懂为什么hibernate为什么这么流行?.Net developer doing Java
为什么call hibernate service 要比直接用store procedures慢啊?Hibernate in Eclipse
hibernate 的两个问题hibernate和ejb3
Hibernate的优势具体体现在哪里?Some corrections to Hibernate tutorial
How is the Jboss AS performance?j2ee web 方向的职业规划
separate Web server application server请问各位(巨,大,中,小,微,不)牛
How to disable hibernate second-level cache for an entityjava所有工具里面,就数spring最简单了
相关话题的讨论汇总
话题: collection话题: update话题: hibernate话题: db话题: 问题
进入Java版参与讨论
1 (共1页)
A**o
发帖数: 1550
1
如果你有setter要把一个Collection更新到db里面,
Collection里面没有的从数据库里面删除,
两边都有的,更新,
Collection单方面有的插入。
有没有什么design pattern来处理类似问题?
B*****g
发帖数: 34098
2
问题:database里的数据有啥用?全删了再全加进去不是很好?

【在 A**o 的大作中提到】
: 如果你有setter要把一个Collection更新到db里面,
: Collection里面没有的从数据库里面删除,
: 两边都有的,更新,
: Collection单方面有的插入。
: 有没有什么design pattern来处理类似问题?

A**o
发帖数: 1550
3
看来只有这个样子了……:(

【在 B*****g 的大作中提到】
: 问题:database里的数据有啥用?全删了再全加进去不是很好?
g*****g
发帖数: 34805
4
If you use hibernate, just set all-delete-orphan in the
one to many relationship and it's automatic.

【在 A**o 的大作中提到】
: 如果你有setter要把一个Collection更新到db里面,
: Collection里面没有的从数据库里面删除,
: 两边都有的,更新,
: Collection单方面有的插入。
: 有没有什么design pattern来处理类似问题?

A**o
发帖数: 1550
5
thanks, other than hibernate ne?

【在 g*****g 的大作中提到】
: If you use hibernate, just set all-delete-orphan in the
: one to many relationship and it's automatic.

h****n
发帖数: 101
6

nod

【在 B*****g 的大作中提到】
: 问题:database里的数据有啥用?全删了再全加进去不是很好?
F****n
发帖数: 3271
7
Use a persistent Collection implementation. Hibernate has one. You don't
want to do it yourself because it has been done and it will be a waste of
time.

【在 A**o 的大作中提到】
: thanks, other than hibernate ne?
F****n
发帖数: 3271
8
If you have thousands of records you don't want rewrite them each time you
update the DB.

【在 h****n 的大作中提到】
:
: nod

B*****g
发帖数: 34098
9
That will be depends.
Based on LZ's case, I believe rewrite is much faster than checking each
record exists or not.

【在 F****n 的大作中提到】
: If you have thousands of records you don't want rewrite them each time you
: update the DB.

g*****g
发帖数: 34805
10
Not necessarily, if performance is your concern, a solution like
Hibernate + JBoss Cache can eliminate all unneccesary writing.
In most products for most cases, you change a small portion of
records every time.

【在 B*****g 的大作中提到】
: That will be depends.
: Based on LZ's case, I believe rewrite is much faster than checking each
: record exists or not.

B*****g
发帖数: 34098
11
you sure check a dup will be faster than add a new one?

【在 g*****g 的大作中提到】
: Not necessarily, if performance is your concern, a solution like
: Hibernate + JBoss Cache can eliminate all unneccesary writing.
: In most products for most cases, you change a small portion of
: records every time.

B*****g
发帖数: 34098
12
sorry, correct it.
Rename the table, the recreate same table, then load.

【在 B*****g 的大作中提到】
: 问题:database里的数据有啥用?全删了再全加进去不是很好?
g*****g
发帖数: 34805
13
Depends, your record may be big. You may be able to play tricks like
lazy-loading, prefetching with ORM, you'll save a ton of read with ORM
caching. In any case, it's always easier and cheaper to cluster the
application server and make the DB server the bottleneck.
If you are really talking about highly scalable application, that's
the direction you go, avoid extra DB read/write at all cost.

【在 B*****g 的大作中提到】
: you sure check a dup will be faster than add a new one?
B*****g
发帖数: 34098
14
Still can loading by clustered application server.

【在 g*****g 的大作中提到】
: Depends, your record may be big. You may be able to play tricks like
: lazy-loading, prefetching with ORM, you'll save a ton of read with ORM
: caching. In any case, it's always easier and cheaper to cluster the
: application server and make the DB server the bottleneck.
: If you are really talking about highly scalable application, that's
: the direction you go, avoid extra DB read/write at all cost.

1 (共1页)
进入Java版参与讨论
相关主题
java所有工具里面,就数spring最简单了Hibernate的优势具体体现在哪里?
PreparedStatement 有没有失效期啊?How is the Jboss AS performance?
Jboss Failover (unplug network cable)separate Web server application server
puzzles about load balancing and failover of JBoss clusterHow to disable hibernate second-level cache for an entity
大家拍我吧,自己太弱了EHCache --- hibernate question
搞不懂为什么hibernate为什么这么流行?.Net developer doing Java
为什么call hibernate service 要比直接用store procedures慢啊?Hibernate in Eclipse
hibernate 的两个问题hibernate和ejb3
相关话题的讨论汇总
话题: collection话题: update话题: hibernate话题: db话题: 问题