I couldn't find an exact reference in the spec either that states that exception subtypes are allowed. But, JPA sort of sets a precedence with the PersistenceException. Here's the javadoc for the persist() method:
/** * Make an instance managed and persistent. * @param entity * @throws EntityExistsException if the entity already exists. * (The EntityExistsException may be thrown when the persist * operation is invoked, or the EntityExistsException or * another PersistenceException may be thrown at flush or * commit time.) * @throws IllegalArgumentException if not an entity * @throws TransactionRequiredException if invoked on a * container-managed entity manager of type * PersistenceContextType.TRANSACTION and there is * no transaction. */ public void persist(Object entity); This indicates that it's okay for a Persistence Provider to throw either EntityExistsException or another PersistenceException at flush or commit time. It would seem that it's acceptable to throw a subtype of PersistenceException, so why wouldn't it follow that it's acceptable to throw a subtype of EntityExistsException? As long as the catch clause still catches the exception, I don't see why subtypes wouldn't be accepted. Kevin On Wed, May 28, 2008 at 8:47 PM, Patrick Linskey <[EMAIL PROTECTED]> wrote: > I believe that subtypes are compliant. > > -Patrick > > > On May 29, 2008, at 6:57 AM, Pinaki Poddar wrote: > > >> Hi, >> Currently, EntityManager facade translates exceptions raised by kernel >> using a RuntimeExceptionTranslator that passes through any exception whose >> class name starts with "org.apache.openjpa.persistence." >> >> This policy, thereby, produces user-visible exceptions that are not >> *strictly* what JPA spec says (though loosely they are, because many of >> these pass-through OpenJPA-specific exceptions inherit from their >> JPA-defined counterparts). Does spec say something about the exact runtime >> type of raised exception by EntityManager methods, for example, will a >> subclass be spec-compliant? >> >> I don't seem to locate any statements w.r.t. above question. >> >> Regards -- >> >> Pinaki >> -- >> View this message in context: >> http://www.nabble.com/Exception-translation-by-EntityManager-facade-tp17521307p17521307.html >> Sent from the OpenJPA Developers mailing list archive at Nabble.com. >> >> > -- > Patrick Linskey > 202 669 5907 > >
