Hi all,

The following is the ejbCreate method from one of my entity beans:

    public Long ejbCreate (String name,
                        Integer orgStatusId)
                throws
OrganizationNameExistsException,DuplicateKeyException,CreateException {

        _name = name;
        _orgStatusId = orgStatusId.intValue();

        try {
            OrganizationDAO dao = getDAO();
            dao.setName(_name);
            dao.setStatusId(_orgStatusId);
            dao.create();
            _organizationId = new Long(dao.getOrganizationId());
            return (_organizationId);
        } catch(OrganizationDAOException se) {
            Debug.println("ejbCreate: " + se.getMessage());

            // check to see if the problem is a UK violation
            if (se.getMessage().indexOf("ORA-00001: unique constraint")
!= -1 &&
                 se.getMessage().indexOf("violated") != -1 ) {
                _context.setRollbackOnly();
                throw new OrganizationNameExistsException (se.getMessage());
            } else {
                // general failure.  throw create exception
                _context.setRollbackOnly();
                throw new CreateException (se.getMessage());
            }
        }
    }

I have noticed that if an OrganizationDAOException is thrown by dao, the
client receives neither a CreateException or
OrganizationNameExistsException, rather it receives
'javax.transaction.RollbackException'.  Furthermore, I have found that if I
comment out the _context.setRollbackOnly() calls, the client receives either
a CreateException or OrganizationNameExistsException, whatever is
appropriate.  Why would calling _context.setRollbackOnly affect the sort of
exceptions thrown by EJBCreate?  Is this proper behavior?


I am running jonas2.3 and jdk1.3 and here are some relevant snippets from
the deployment descriptor for this entity EJB:
<persistence-type>Bean</persistence-type>
<trans-attribute>Required</trans-attribute>

Thanks for any help,

Neal



Neal Evans, Ph.D.
Senior Applications Architect
Knowledge Management Objects, LLC
(703) 841-4287

----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to