• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ejbCreate calling beans finder methods

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()?
reply
    Bookmark Topic Watch Topic
  • New Topic