views:

111

answers:

1

My application have a Stateless EJB. And Now I need to do some db operation via Stateful. Can this Stateless EJB can access the DB Utility which will open connection stateful? Will this lead to any design / performance Issue?

A: 

which will open connection stateful?

Do you mean:

  1. Open a stateful connection that will stay open between calls to the server and not commit automatically when returning to the client?
  2. Open a connection using the security credentials available from the session context to obtain a connection with the user's own database user/password?

In the first case although it might be possible to do using a StatefulSessionBean (SFSB) in front of the StatelessSessionBean (SLSB), there are probably much better approaches (e.g. using the command pattern to collect the interactions between remote calls until you are ready to commit).

In the second case, DataSource.lookup(username, password) might help, although your DataSource lookups probably need to consistently provide the username and password to guarantee receiving the same connection.

Will this lead to any design / performance Issue?

In both cases you have to be very careful not to make basic security errors (like sending passwords in plain text). I've never used either approach and would be inclined to redesign a solution that included either.

I'd be less worried about performance issues than security and other design issues such as fragility under maintenance.

richj