Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个关于在使用休眠注释时限制实体类的数据库事务的问题。准确地说,我正在使用带有注释的休眠,如果我想将我的事务限制为仅保存和查看,那么应该限制更新和删除操作。此功能需要从 Entity 类中获得,其中通过 hibernate 注释指定表和列名。
这可能不是一个干净的解决方案,但它仍然应该工作您可以使用实体侦听器方法实现您的意图
@PreRemove @PreUpdate public void remove() throws Exception{ throw new Exception("cant remove/update entity"); }