如何在 Seam 引擎发出的调用上设置查询缓存

发布于 2024-11-16 22:13:33 字数 270 浏览 5 评论 0原文

@In
Identity identity;

Boolean newValue = identity.hasPermission(target, action);

对上述方法的任何调用也会执行“从 Role r 选择角色”调用,该调用是从底层 Seam 引擎调用的。如何将此调用的查询缓存设置为查询提示(例如 org.hibernate.cacheable 标志),以便它不会再次被调用。

注意:角色信息永远不会改变,因此我认为这是不必要的 sql 调用。

@In
Identity identity;

Boolean newValue = identity.hasPermission(target, action);

Any call to the above method also does a "select role from Role r" call, which is called from the underlying seam engine. How do I set the query cache for this call as a query hint (e.g. org.hibernate.cacheable flag) so that it doesn't get called again.

Note: Role information is never bound to change, hence I view this as a unnecessary sql call.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎盛开的樱花 2024-11-23 22:13:33

我没有处于休眠状态,但这个问题仍然没有答案:出于多种原因,我们扩展了接缝的标准 Identity 类。您可能还想扩展它以帮助您缓存结果。

由于此缓存是会话范围的,因此它可能有一个好处,即当用户再次登录/注销时它将重新加载 - 但这取决于您的要求。

此致,
亚历山大.

/**
 * Extended Identity to implement i.e. caching
 */
@Name("org.jboss.seam.security.identity")
@Scope(SESSION)
@Install(precedence = Install.APPLICATION)
@BypassInterceptors
@Startup
public class MyIdentity extends Identity {

  // place a concurrent hash map here

  @Override
  public boolean hasPermission(Object name, String action) {
    // either use the use the cached result in the hash map ... 
    // ... or call super.hasPermission() and cache the result
  }

}

I am not in hibernate, but as this question is still unanswered: we extended the standard Identity class of seam for several reasons. You might want to extend it as well to help you caching the results.

As this cache is session scoped, it will have the possible benefit that it will be reloaded when the user logs on/off again - but this depends on your requirements.

Best regards,
Alexander.

/**
 * Extended Identity to implement i.e. caching
 */
@Name("org.jboss.seam.security.identity")
@Scope(SESSION)
@Install(precedence = Install.APPLICATION)
@BypassInterceptors
@Startup
public class MyIdentity extends Identity {

  // place a concurrent hash map here

  @Override
  public boolean hasPermission(Object name, String action) {
    // either use the use the cached result in the hash map ... 
    // ... or call super.hasPermission() and cache the result
  }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文