Weblogic Entity Bean Primary Key Problem Help!!


EJB programming & troubleshooting: Weblogic Entity Bean Primary Key Problem Help!!

  1. Hello Experts,
             I am using weblogic 8.1 App server and MS SQL 2000 as database server for my EJB Application. I have an entity bean called Session which has a sessionId as its primary key.This primary key is an identity field in the database. I have used weblogic's automatic-key-generation for generating the primary key whenever i create a new 'Session' entity. I also create the entity bean in a transaction.
    Now the problem is that after creating a 'Session' entity using create() method, when i try to retrieve the generated primary key using getSessionId() , i get an older value of sessionId than the one which is currently created in the database.
    For example if the current row inserted in the database after calling SessionHome.create() has a primary key value '21' , on calling getSessionId() i get the value as '20'. I must remind that this occurs in a transaction.
    Has anyone come across such a problem
  2. Where do you call that method ?

    If inside create, I think that primary key can't be accessed in create method (you can in postcreate).

    Please, correct me if I'm wrong.