Java 如何在休眠中实现触发器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4486413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to implement triggers in hibernate
提问by Juzer Arsiwala
I want to implement something similar to triggers in hibernate.
我想在休眠中实现类似于触发器的东西。
What I need is when a column in a table attains a specific value, a row should be inserted in another table or some other table should be updated.
我需要的是当表中的列达到特定值时,应在另一个表中插入一行或更新某个其他表。
How do I implement this in hibernate ?
我如何在休眠中实现它?
采纳答案by Diego Mijelshon
That's described in Chapter 14. Interceptors and events.
这在第 14 章拦截器和事件中进行了描述。
You can, for example, intercept a post-update event.
例如,您可以拦截更新后事件。
However, using the event system for businessoperations might not be the best idea (they are best used for infrastructure concerns). You should use a higher level layer for that.
但是,将事件系统用于业务操作可能不是最好的主意(它们最适合用于基础设施问题)。您应该为此使用更高级别的图层。