Uploaded image for project: 'OpenEJB'
  1. OpenEJB
  2. OPENEJB-756

Allow CMP2 ejbSelect returning void for UPDATE and DELETE queries

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0-beta-2
    • Fix Version/s: 3.0
    • Component/s: cmp2
    • Labels:
      None
    • Environment:
      N/A

      Description

      The method Cmp2Generator.createSelectMethod() does not support "none" return type. If an ejb.select method is created with result-type-mapping="none", then the return type will return type will get converted to void. This will throw a non-descriptive NullPointerException on line 778, since the return of Cmp2Generator.Convert.getConversion() will be null.

      Recommendations:

      FIX #1: Better error message than NullPointerException

      A better error message would be appreciated here as is seen in the fromObjectTo() method such as:

      public static void fromObjectTo(MethodVisitor mv, Class to) {
      if (to.equals(Object.class))

      { // direct assignment will work }

      else if (!to.isPrimitive())

      { mv.visitTypeInsn(CHECKCAST, Type.getInternalName(to)); }

      else

      { Convert conversion = getConversion(to); if (conversion == null) throw new NullPointerException("unsupported conversion for EJB select return type " + from.getName()); conversion.objectToPrimitive(mv); }

      }

      FIX #2: Add void as a supported type. Also, verify doing so would not be a spec violation.

      TO REPRODUCE: Create a bean method such as the following:

      /**

      • @ejb.transaction
      • type="Mandatory"
      • @ejb.select
      • query="DELETE FROM someSCHEMA as a WHERE a.someId=?1"
      • result-type-mapping="none"
      • @param someId
        */
        public abstract void ejbSelectRemoveById(java.lang.Integer someId) throws FinderException;

      Disclaimer: I take no responsibility in the code sample... I was the one charged with debugging it when upgrading from Geronimo 1 to 2.1, not writing it. I understand there are better ways to do this.

        Attachments

          Activity

            People

            • Assignee:
              dain Dain Sundstrom
              Reporter:
              selikoff scott selikoff
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified