users@jpa-spec.java.net

[jpa-spec users] Will getSingularAttribute(String) supplied with a bad String roll the transaction back?

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Wed, 20 Nov 2013 18:18:20 -0800

I have to build a set of query criteria using the criteria builder APIs.

Some old code I'm looking at uses the following construct to test for the
presence of an attribute on an EntityType:

    boolean exists = true;
    try {
      managedType.getSingularAttribute(name, javaType);
    } catch (final IllegalArgumentException noSuchAttribute) {
      // transaction is OK here, yes?
      exists = false;
    }

It just now occurred to me that this might roll the transaction back. Is
that true? If there's specification crosstalk issues, I'm doing this from
within a stateless EJB if that helps.

The specification does not explicitly call out the criteria API methods as
leading to transaction rollback (if, for example, RuntimeExceptions are
thrown), but I thought I'd ask in case I'm overlooking something. We've
gotten burned by a hidden/swallowed IllegalArgumentException before.

My apologies if this is better addressed by a different spec group.
 Figured I'd start here.

Best,
Laird

-- 
http://about.me/lairdnelson