Can I call a stored procedure from session bean??


EJB design: Can I call a stored procedure from session bean??

  1. Hi,
    Normally in our application we are using entity bean for all the database operation. but due to some restriction in one module we are using stored procedure for updation of data instead of doing it by entity bean. we are calling stored procedure from our session which in turn update the data in the database in multiple rows and multiple tables. now the problem is that wheather this situation will take care of transcation part?? i mean while updatation of data by stored procedure if any entity bean already loaded how can we ensure that entity bean gets the updated data?
    Kindly Help.
    Thanks and Regards,
  2. Sorry, that's impossible: entity beans are not aware of changes made behind their backs. They will dutifully keep the state they've read from the database. Actually it depends on container implementation: the advanced containers will not go to the DB just to check, less advanced might do that.
  3. We are using JRun3.1 as application server. tell me how can we handle the transaction in this case??
    please help
    Thanks and Regards,
  4. That will depend upon the transaction isolation attribute and whether entity bean methods are in transaction. When not in transaction (depending upon your trans-attribute in ejb-far), the get and set method will not refresh/write from/to database. Only when the method is called within a transaction scope will it result in database read/write. Using transaction isolation level of "READ COMMITED" or more strigent will solve your issue. Your application Server may or may/not provide the ability to set transaction isolation level.
  5. Hi,

    A lot of app servers have a setting to indicate if the database is shared. If you set this then at the start of each transaction the Entity Bean will be reloaded from the database,

  6. If u set db is shared property to true then this will lead to a lot of ejbLoad() calls and thus so many hits to DB which makes me cringe..... a bit.