You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "qxo (JIRA)" <ib...@incubator.apache.org> on 2006/09/30 04:38:19 UTC

[jira] Created: (IBATIS-351) Primitive argument type cannot be null(in PropertyAccessPlan. setProperties)

Primitive argument type cannot be null(in PropertyAccessPlan. setProperties) 
-----------------------------------------------------------------------------

                 Key: IBATIS-351
                 URL: http://issues.apache.org/jira/browse/IBATIS-351
             Project: iBatis for Java
          Issue Type: Bug
          Components: SQL Maps
    Affects Versions: 2.2.0, 2.1.7
            Reporter: qxo


ResultObject  has a Primitive attribute and its result value is null,has problem.

I fixed this proble as follow:

public void setProperties(Object object, Object[] values) {
  	int i = 0;
    try {
      Object[] arg = new Object[1];
      for (i = 0; i < propertyNames.length; i++) {
        arg[0] = values[i];
        try {
        	final Class[] parameterTypes = setters[i].getParameterTypes();
        	if( null == arg[0] && parameterTypes[0].isPrimitive()){
        		//FIXME Primitive argument type cannot be null
        		return;
        	}
          setters[i].invoke(object, arg);
        } catch (Throwable t) {
          throw ClassInfo.unwrapThrowable(t);
        }
      }
    } catch (Throwable t) {
      throw new RuntimeException("Error setting property '" + setters[i].getName() + "' of '" +
      		                     object + "'.  Cause: " + t, t);
    }
  }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (IBATIS-351) Primitive argument type cannot be null(in PropertyAccessPlan. setProperties)

Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/IBATIS-351?page=all ]

Clinton Begin closed IBATIS-351.
--------------------------------

    Resolution: Invalid
      Assignee: Clinton Begin

There are already two solutions to this, both of which I find more appropriate than the one suggested.  

1) Don't map primitives to nullable columns << PREFERRED

2) Use a nullValue setting in your result map, that's what it's for.

Clinton

> Primitive argument type cannot be null(in PropertyAccessPlan. setProperties)
> ----------------------------------------------------------------------------
>
>                 Key: IBATIS-351
>                 URL: http://issues.apache.org/jira/browse/IBATIS-351
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.1.7, 2.2.0
>            Reporter: qxo
>         Assigned To: Clinton Begin
>
> ResultObject  has a Primitive attribute and its result value is null,has problem.
> I fixed this proble as follow:
> public void setProperties(Object object, Object[] values) {
>   	int i = 0;
>     try {
>       Object[] arg = new Object[1];
>       for (i = 0; i < propertyNames.length; i++) {
>         arg[0] = values[i];
>         try {
>         	final Class[] parameterTypes = setters[i].getParameterTypes();
>         	if( null == arg[0] && parameterTypes[0].isPrimitive()){
>         		//FIXME Primitive argument type cannot be null
>         		return;
>         	}
>           setters[i].invoke(object, arg);
>         } catch (Throwable t) {
>           throw ClassInfo.unwrapThrowable(t);
>         }
>       }
>     } catch (Throwable t) {
>       throw new RuntimeException("Error setting property '" + setters[i].getName() + "' of '" +
>       		                     object + "'.  Cause: " + t, t);
>     }
>   }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (IBATIS-351) Primitive argument type cannot be null(in PropertyAccessPlan. setProperties)

Posted by "qxo (JIRA)" <ib...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/IBATIS-351?page=comments#action_12438973 ] 
            
qxo commented on IBATIS-351:
----------------------------

But if result is object, "Use a nullValue setting in your result map"  cannot solve the problem!

> Primitive argument type cannot be null(in PropertyAccessPlan. setProperties)
> ----------------------------------------------------------------------------
>
>                 Key: IBATIS-351
>                 URL: http://issues.apache.org/jira/browse/IBATIS-351
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.1.7, 2.2.0
>            Reporter: qxo
>         Assigned To: Clinton Begin
>
> ResultObject  has a Primitive attribute and its result value is null,has problem.
> I fixed this proble as follow:
> public void setProperties(Object object, Object[] values) {
>   	int i = 0;
>     try {
>       Object[] arg = new Object[1];
>       for (i = 0; i < propertyNames.length; i++) {
>         arg[0] = values[i];
>         try {
>         	final Class[] parameterTypes = setters[i].getParameterTypes();
>         	if( null == arg[0] && parameterTypes[0].isPrimitive()){
>         		//FIXME Primitive argument type cannot be null
>         		return;
>         	}
>           setters[i].invoke(object, arg);
>         } catch (Throwable t) {
>           throw ClassInfo.unwrapThrowable(t);
>         }
>       }
>     } catch (Throwable t) {
>       throw new RuntimeException("Error setting property '" + setters[i].getName() + "' of '" +
>       		                     object + "'.  Cause: " + t, t);
>     }
>   }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (IBATIS-351) Primitive argument type cannot be null(in PropertyAccessPlan. setProperties)

Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/IBATIS-351?page=comments#action_12439037 ] 
            
Clinton Begin commented on IBATIS-351:
--------------------------------------


Well if that's the case, use rule #1.  There's absolutely NO reason you should be using a primitive.  Use the object wrapper.  

I can't see any case where you wouldn't have that as a viable option.

Clinton

> Primitive argument type cannot be null(in PropertyAccessPlan. setProperties)
> ----------------------------------------------------------------------------
>
>                 Key: IBATIS-351
>                 URL: http://issues.apache.org/jira/browse/IBATIS-351
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.1.7, 2.2.0
>            Reporter: qxo
>         Assigned To: Clinton Begin
>
> ResultObject  has a Primitive attribute and its result value is null,has problem.
> I fixed this proble as follow:
> public void setProperties(Object object, Object[] values) {
>   	int i = 0;
>     try {
>       Object[] arg = new Object[1];
>       for (i = 0; i < propertyNames.length; i++) {
>         arg[0] = values[i];
>         try {
>         	final Class[] parameterTypes = setters[i].getParameterTypes();
>         	if( null == arg[0] && parameterTypes[0].isPrimitive()){
>         		//FIXME Primitive argument type cannot be null
>         		return;
>         	}
>           setters[i].invoke(object, arg);
>         } catch (Throwable t) {
>           throw ClassInfo.unwrapThrowable(t);
>         }
>       }
>     } catch (Throwable t) {
>       throw new RuntimeException("Error setting property '" + setters[i].getName() + "' of '" +
>       		                     object + "'.  Cause: " + t, t);
>     }
>   }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira