You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Dain Sundstrom (JIRA)" <ji...@apache.org> on 2008/03/01 20:32:51 UTC

[jira] Updated: (OPENEJB-756) Allow CMP2 ejbSelect returning void for UPDATE and DELETE queries

     [ https://issues.apache.org/jira/browse/OPENEJB-756?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dain Sundstrom updated OPENEJB-756:
-----------------------------------

      Assignee: Dain Sundstrom
    Issue Type: Improvement  (was: Bug)
       Summary: Allow CMP2 ejbSelect returning void for UPDATE and DELETE queries  (was: CMP2 Select Generation does not include VOID return type)

I will implement option 2.  When an ejbSelect method returns void, the CMP engine will assume that the query is an UPDATE or DELETE query, and will execute javax.persistence.Query.executeUpdate().  Unfortunately, there is no way to propagate the return value from the executeUpdate method since the ejbSelect method returns void.   This feature is outside of the EJB spec and therefore will most likely not work in other application servers.

> Allow CMP2 ejbSelect returning void for UPDATE and DELETE queries
> -----------------------------------------------------------------
>
>                 Key: OPENEJB-756
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-756
>             Project: OpenEJB
>          Issue Type: Improvement
>          Components: cmp2
>    Affects Versions: 3.0-beta-2
>         Environment: N/A
>            Reporter: scott selikoff
>            Assignee: Dain Sundstrom
>            Priority: Minor
>             Fix For: 3.0
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.