gpt4 book ai didi

java - 是否可以在 hibernate 状态下将表视为只读?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:22:37 24 4
gpt4 key购买 nike

我有一些我没有理由从应用程序中更新的表,所以我想防止它发生,即使是由于其他地方的错误而意外发生。

我看到了 @Immutable 注释,但它看起来仍然允许插入和删除。我想完全按照石头写的那样对待整个表(而不仅仅是每个实体)。有没有一种简单的方法可以做到这一点?还是我误解了关于@Immutable 的文档?

如果需要示例,假设有一个包含MONTH 表、一个Month 实体和一个APPOINTMENT 表的表与 Appointment 实体关联。我永远不想在月份中删除或插入一行。

最佳答案

您是否尝试过只读缓存策略:

If your application needs to read, but not modify, instances of a persistent class, a read-only cache can be used. This is the simplest and optimal performing strategy. It is even safe for use in a cluster.

发件人:19.2.2. Strategy: read only

关于java - 是否可以在 hibernate 状态下将表视为只读?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9950413/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com