This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ejbCreate calling beans finder methods  RSS feed

Mark Lybarger
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a slsb (slsb1) that needs some "static" data, (default customer number, default user id, etc). it uses another slsb (slsb2) which goes to the db and gets that data. we currently have in the ejbCreate call of slsb1, to call slsb2.getDefaultCustomerNumber. if the call to slsb2.getDefaultCustomerNumber fails perhaps because it can't get a db connection,then i think according to the spec, that slsb1 gets destroyed by the container. i don't understand what would happen if i have a slsb3, and i call a business method (that's marked as required transaction) that goes something like:

what if, when i call the slsb2's method here, is when the create actually runs (reading that head first ejb book says that ejbCreate is called on slsb when you first call a business method), and when that happens, it goes to slsb1 to get the default customer number? what if when slsb1 at that point can't get a database connection it needs, thus slsb2 throws a create exception when invoking/calling a business method. now let's also say that slsb1 is nice and it always calls context.setRollBackOnly() when ever it encounters any sql exception like not being able to get a connection.

so, is this a potential problem? if so, where should i put the call from slsb1 to slsb2.getDefaultCustomerNumber()?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!