b**********g 发帖数: 806 | 1 我又有个问题要打扰大家了
my mapping file is like this
person_id_sequence
然后在UI上删除一个record的时候,发现sequence不连着了,比如0,1,3,4这样子,这是为
什么? | m******t 发帖数: 2416 | 2
Not sure I understand what you mean by "sequence不连着了"?
Also what database?
【在 b**********g 的大作中提到】 : 我又有个问题要打扰大家了 : my mapping file is like this : : : person_id_sequence : : : 然后在UI上删除一个record的时候,发现sequence不连着了,比如0,1,3,4这样子,这是为 : 什么?
| b**********g 发帖数: 806 | 3 database是oracle
不连着就是本来ID应该是0,1,2,3....现在2不见了,只有0,1,3
【在 m******t 的大作中提到】 : : Not sure I understand what you mean by "sequence不连着了"? : Also what database?
| A**o 发帖数: 1550 | 4 2被你删除了?
【在 b**********g 的大作中提到】 : 我又有个问题要打扰大家了 : my mapping file is like this : : : person_id_sequence : : : 然后在UI上删除一个record的时候,发现sequence不连着了,比如0,1,3,4这样子,这是为 : 什么?
| b**********g 发帖数: 806 | 5 嗯,对的,不过删除了是不是应该后面的往前shift?
【在 A**o 的大作中提到】 : 2被你删除了?
| m******t 发帖数: 2416 | 6
No... trust me, you really don't want that to happen. 8-)
A sequence is only responsible for _generating_ a sequence of numbers. Once
they are generated, the sequence no longer keep tracks of them.
【在 b**********g 的大作中提到】 : 嗯,对的,不过删除了是不是应该后面的往前shift?
| b**********g 发帖数: 806 | 7 hmmmm,但是在我们的dev database里,确实是往前shift了
这块儿不是我写的,我现在在maintain.
Once
【在 m******t 的大作中提到】 : : No... trust me, you really don't want that to happen. 8-) : A sequence is only responsible for _generating_ a sequence of numbers. Once : they are generated, the sequence no longer keep tracks of them.
| b**********g 发帖数: 806 | 8 刚刚在dev的环境下试了一下,估计production上是有人从database里手动删行了,所以那
个sequence就不work了
【在 b**********g 的大作中提到】 : hmmmm,但是在我们的dev database里,确实是往前shift了 : 这块儿不是我写的,我现在在maintain. : : Once
| r*****y 发帖数: 264 | 9 下一个sequence id应该是当前sequence的下一个值.删除当中的一条记录,不会把后面
记录的primary key往前移的.
除非是hibernate配置文件里设置了每次启动是都是重新创建table. | A**o 发帖数: 1550 | 10 having fun maintaining that system. //grin
【在 b**********g 的大作中提到】 : hmmmm,但是在我们的dev database里,确实是往前shift了 : 这块儿不是我写的,我现在在maintain. : : Once
| t********k 发帖数: 808 | 11 那应该是有人自己去实现的一个类似sequence的功能
oracle的sequence不会shift的
【在 b**********g 的大作中提到】 : hmmmm,但是在我们的dev database里,确实是往前shift了 : 这块儿不是我写的,我现在在maintain. : : Once
| g*****g 发帖数: 34805 | 12 这是纯粹吃饱了撑的,ID就要一个字,快。
向前找空当那得做多少数据库操作?没见过这么实现的。
【在 t********k 的大作中提到】 : 那应该是有人自己去实现的一个类似sequence的功能 : oracle的sequence不会shift的
| m******t 发帖数: 2416 | 13
It's not just about performance. Having ids that could shift behind your
back simply would not make any sense - talk about moving targets. 8-)
【在 g*****g 的大作中提到】 : 这是纯粹吃饱了撑的,ID就要一个字,快。 : 向前找空当那得做多少数据库操作?没见过这么实现的。
| A**o 发帖数: 1550 | 14 yep, this id field is not an ID in common sense.
what a mess
【在 m******t 的大作中提到】 : : It's not just about performance. Having ids that could shift behind your : back simply would not make any sense - talk about moving targets. 8-)
|
|