开发者

Ibatis + j2ee + web service layer + statless bean

开发者 https://www.devze.com 2023-01-30 17:53 出处:网络
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 d开发者_如何转开发oubt

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 d开发者_如何转开发oubt

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.


  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?
0

精彩评论

暂无评论...
验证码 换一张
取 消