The basic EJB philosophy is to make the Bean & Application developer's
lives simpler by forcing the container developer to worry about all
resource/object pooling, object caching, etc. In other words, all of the
things you're used to doing, the container should do, plus pool the
database connections so you can (given the right application
architecture) get greater parallelism. JBoss, and, AFAIK, most other
containers, does do caching of PreparedStatements, also. As you've
noticed, when you try to do part of the container's job, bad things can
happen.
danch
Jeff Markham wrote:
>
> I don't believe I quite have an understanding of EJBs as most of the people
> on this list so I'd like to ask a couple questions on BMP EJB design
> best-practices.
>
> In all the examples I've ever seen of BMPs, every persistence and finder
> method both 1) finds a DataSource and gets a Connection from it and 2)
> instantiates a PreparedStatement.
>
> Before looking into EJBs, I just went to the database from a servlet via
> JDBC. In the servlet, I would get a Connection and do all my
> PreparedStatements in the init() method of the servlet. On any requests
> that required the services of any PreparedStatement, I'd synchronize
> clearParameters and run it.
>
> Couldn't this same concept be done in an BMP's setEntityContext() method?
> Couldn't I get the Connection and do all the PreparedStatements there? It
> just seems that by doing a PreparedStatement in each call to the BMP's
> persistence and finder methods, it defeats the purpose of a
> PreparedStatement.
>
> Just for kicks, I gave it a try but transactions weren't completed and
> they'd just hang out there forever, blocking every other persistence and
> finder method until they timed out.
>
> Thoughts? Feedback? Maybe I'm misunderstanding some fundamental EJB
> concepts. In any case, I'd like to know what the best practices are for
> BMPs. Thank you.
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user