简体   繁体   English

休眠,序列和版本问题

[英]Nhibernate, sequence and version problems

I have the following situation on my oracle db: 我的oracle数据库上存在以下情况:

When a new record need to be insert, the pk field is generated by sequence, and thats working fine. 当需要插入新记录时,将按顺序生成pk字段,这可以正常工作。

I got another field, lets call him A, not the pk, that needs to get his value from another sequence, I also got another column that needs to get the same value as the A field got, on some cases, and on other cases not. 我有另一个字段,需要称他为A,而不是pk,它需要从另一个序列中获取他的值,在某些情况下,在某些情况下,我还有另一列需要与A字段获得相同的值不。

Another field I got called B is defined as a version column, on some cases I need to copy this value to another field. 我称为B的另一个字段定义为版本列,在某些情况下,我需要将此值复制到另一个字段。

All of this logic is simple to implement, but I wanna know how can I do all this stuff on a single insert command where is the best place to intercept the insert command, whats recommended on this special cases? 所有这些逻辑都易于实现,但是我想知道如何在单个插入命令上执行所有这些操作,在哪里是拦截插入命令的最佳位置,在这种特殊情况下建议什么?

实现IInterceptor,或者如果您想用肮脏的方式实现它:更新触发器中的这些列,并将字段映射为Generated =“ Always”(或Insert)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM