0 Replies Latest reply on May 27, 2016 1:48 PM by jashan07

    Migration EJB 2.1 to EJB 3.0 on JBOSS EAP 6.3

    jashan07 Newbie



      I am facing issue while migrating EJB 2.1 to EJB 3.0. My task is to migrate Call back methods in EJB 2.1 to EJB 3.0 annotations in Entity Beans. Can anyone pls help me to understand how can I migrate callback methods. Below is my EJB 2.1 entity bean ejbCreate():


      public String ejbCreate(String cuid, int authLevel, int centerCode, String statusCode) throws CreateException


            String error = "";


            CUID = cuid;

            AUTH_LEVEL_CODE = authLevel;

            CENTER_CODE = centerCode;

            STATUS_CODE = statusCode;


            Connection con = null;

            PreparedStatement ps = null;


            String insertString = "INSERT into user_profiles (cuid, auth_level_code, center_code, status_code) values (?, ?, ?, ?)";




               con = this.getConnection();

               ps = con.prepareStatement(insertString);

               ps.setString(1, cuid);

               ps.setInt(2, authLevel);

               ps.setInt(3, centerCode);

               ps.setString(4, statusCode);


               if (ps.executeUpdate() != 1)



                  throw new CreateException("Unable to create User row in database);

                  throw new SQLException("Unable to create User row in database);




               return cuid;


            catch (SQLException se)


               // Check to see if this SQLException is due to a unique constraint

               // violation on our database table (ie. there is already a pk with the

               // value of cuid in the table).  If so, throw a

               // DuplicateKeyException else throw a CreateException.






               catch(ObjectNotFoundException sqe)


                 error = "SQLException: " + sqe;


                 throw new CreateException (error);

                 throw new SQLException (error);



               error = "An User already exists in the database with Primary Key " + uid;

               throw new DuplicateKeyException(error);




               cleanup(con, ps);



      And this ejbCreate() of Entitybean is invoked when I am calling create method in SessionBean class.

      Profile    = (ProfileReader) home.create(uid,  auth, center, status);


      I want to replace this whole code in EJB 3.0. Can anyone pls help me out in this?