Accessing DAO from Session bean


EJB programming & troubleshooting: Accessing DAO from Session bean

  1. Accessing DAO from Session bean (1 messages)

    May be a simple question... but i am struggling for the answer.!!

    I have a stateless session bean that has a method that simply inserts a record using a DAO class into the oracle database. This method should return the last inserted record's sequence number(autogenerated by oracle).In a multi-user real time environment, if i dont synchronize the access to "insert and fetch" block of code, there is a possibility of my code retrieving the sequence number of some one else' record.

    I need to avoid such a situation. Is there any other way achieving this functionality?

    Need help urgently.. got stuck badly at this moment!!

  2. Accessing DAO from Session bean[ Go to top ]

    Your DAO must return the generated key. If your DAO uses pure JDBV, do so by using getGeneratedKeys() on your statement object. This approach does NOT require any java synchronization and tolerates simultanious database from other threads.

    If your dao uses any orm technique, you should manage to retrieve the key from the orm object.

    Niklas G