次のマップされたエンティティがあります。
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "eKey-field-1", "eKey-field-2", "eKey-field-3" }))
class EntityMapped {
@Id
@GeneratedValue...
Long Id;
@Embedded
EntityKeyMapped eKey;
更新も削除もありません。特定の eKey にセキュリティがない場合、新しいレコードが追加されます。
選択クエリは非常に単純ですが、1 日あたり最大 100 万件以上のクエリが並行して実行されます (+新しいレコードが追加されることもあります)。ということで、なんとかキャッシュしようと思います。
Dao 内には次のようなものがあります。
return (EntityMapped) getSession().createCriteria(EntityMapped.class).add(Example.create(example)).uniqueResult();
このリクエストをキャッシュする最善の方法を考えています。Atm 私が考える:
return (EntityMapped) getSession().createCriteria(EntityMapped.class).add(Example.create(example)).setCacheable(true).uniqueResult();
しかし、この場合、キャッシュするためのより良い (より簡単な) 方法があるでしょうか?