0 Replies Latest reply on Oct 16, 2001 7:47 PM by msquance

    Accessing entity beans from within the same entity bean

    msquance

      I have a design question regarding entity beans.

      My entity bean needs to validate that other instances ('parent' instances) of the same type of entity bean exist before allowing an ejbCreate to proceed.

      I can see two obvious approaches:

      1. Access the database directly (through the DAO) to see if the 'parent' exists.
      2. Get the home interface of the bean from the entity context and do a findByPrimaryKey to see if it exists.

      It seems the latter approach would be safer, but slower. Are there any locking issues if you access the bean's home interface from inside itself?

      Any thoughts on the recommended approach in this scenario would be appreciated.

      Thanks,
      Mike.