伊巴蒂斯 + j2ee + Web服务层+无状态bean

发布于 2024-10-07 18:50:51 字数 269 浏览 0 评论 0原文

我有一个 j2ee 项目,使用 ibatis 连接到数据库和无状态 bean 来创建 Web 服务,它可以工作,但

每次调用该服务时我都有疑问:

  1. 解析 ibatis xml 配置文件。
  2. ibatis 连接到数据库
  3. 并生成查询。

可以避免1和2吗?或者至少 1 个?

正确的做法是什么?

我认为有可能在有状态的 ejb 中调用一次 ibatis xml 吗?

谢谢。

I have a j2ee project using ibatis to connect to the database and stateless bean to create web service and it works but i have a doubt

every time i call the service:

  1. parse the ibatis xml configuration file.
  2. ibatis connect to the database
  3. and generate the query.

It is possible to avoid 1 and 2? or at least 1?

What is the correct way to do it?.

I think that may be it is possible to call the ibatis xml once in a stateful ejb?

Thanks.

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

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

发布评论

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

评论(1

  1. 从逻辑上讲,配置文件应该只解析一次,并将结果对象存储在应用程序范围的变量中。最简单但令人皱眉的方法是使用单例。首选方法是使用某种依赖注入框架,如 Guice 或 Spring。
  2. iBatis 需要一个连接对象来连接到数据库,因此这是无法避免的。您目前如何在代码中处理连接管理?
  1. Logically speaking, the configuration file should be parsed only once and the resulting object be stored in an application scoped variable. The simplest but frowned upon way for that would be using Singletons. The preferred way would be to use some sort of dependency injection framework like Guice or Spring.
  2. iBatis would require a connection object to connect to the database so this can't be avoided. How are you currently handling connection management in your code?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文