ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Zatko <mza...@boscovs.com>
Subject Re: [ResultMap] Can't get primitive types to work
Date Fri, 18 Feb 2005 16:16:23 GMT
*I tried it and it does not work. My error is as follows:*


ResultSetLogProxy.java|41|DEBUG|2005-02-18 
11:13:16,756|3766|{rset-100020} ResultSet
PromotionFacadeSqlMapsImpl.java|71|ERROR|2005-02-18 11:13:16,772|3782| 
--- The error occurred in configs/sqlmaps/promotions-sql.xml. 
--- The error occurred while applying a result map. 
--- Check the adjustment.getPromotionActionMap. 
--- The error happened while setting a property on the result object. 
--- Cause: com.ibatis.common.beans.ProbeException: Could not set 
property 'numberOfItems' for 
com.boscovs.commerce.promotion.dao.ActionDAO.  Cause: 
java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in configs/sqlmaps/promotions-sql.xml. 
--- The error occurred while applying a result map. 
--- Check the adjustment.getPromotionActionMap. 
--- The error happened while setting a property on the result object. 
--- Cause: com.ibatis.common.beans.ProbeException: Could not set 
property 'numberOfItems' for 
com.boscovs.commerce.promotion.dao.ActionDAO.  Cause: 
java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
Caused by: com.ibatis.common.beans.ProbeException: Could not set 
property 'numberOfItems' for 
com.boscovs.commerce.promotion.dao.ActionDAO.  Cause: 
java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:183)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:99)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:97)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:69)
    at 
com.boscovs.commerce.promotion.PromotionFacadeSqlMapsImpl.applyPromotions(PromotionFacadeSqlMapsImpl.java:61)
    at test.PromotionTest.execute(PromotionTest.java:106)
    at test.PromotionTest.main(PromotionTest.java:171)
Caused by: com.ibatis.common.beans.ProbeException: Could not set 
property 'numberOfItems' for 
com.boscovs.commerce.promotion.dao.ActionDAO.  Cause: 
java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
    at 
com.ibatis.common.beans.JavaBeanProbe.setProperty(JavaBeanProbe.java:309)
    at 
com.ibatis.common.beans.JavaBeanProbe.setObject(JavaBeanProbe.java:229)
    at com.ibatis.common.beans.GenericProbe.setObject(GenericProbe.java:73)
    at 
com.ibatis.sqlmap.engine.accessplan.ComplexAccessPlan.setProperties(ComplexAccessPlan.java:34)
    at 
com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(JavaBeanDataExchange.java:112)
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:296)
    at 
com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:60)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:355)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:179)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:200)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:168)
    ... 8 more
Caused by: java.lang.IllegalArgumentException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at 
com.ibatis.common.beans.JavaBeanProbe.setProperty(JavaBeanProbe.java:298)
    ... 18 more


*Is it possible that its my database that is the problem? I am using DB2 
V7.2.*





Brandon Goodin wrote:

>I would recommend that you specify the jdbcType in your result.
>
><result property="numberOfItems" column="min_item_quantity"
>jdbcType="INTEGER" javaType="int"/>
>
>On Fri, 18 Feb 2005 06:55:01 -0800 (PST), Karen Koch
><kmkoch@sbcglobal.net> wrote:
>  
>
>>Are you perhaps missing the parameterClass arg on the statement itself?
>>
>>--- Mike Zatko <mzatko@boscovs.com> wrote:
>>
>>    
>>
>>>/*I have a table as follows:*/
>>>
>>>sqltype               sqllen  sqlname.data                    sqlname.length
>>> --------------------  ------  ------------------------------
>>>--------------
>>> 492   BIGINT               8
>>>PROMO_ACTION_ID                             15
>>> 492   BIGINT               8
>>>PROMOTION_ID                                12
>>> 452   CHARACTER            1
>>>ACTIONTYPE                                  10
>>> 497   INTEGER              4
>>>MIN_ITEM_QUANTITY                           17
>>> 485   DECIMAL          20, 5
>>>MIN_SINGLE_ITEM_VALUE                       21
>>> 485   DECIMAL          20, 5
>>>MIN_TOTAL_ITEM_VALUE                        20
>>> 485   DECIMAL          20, 5
>>>MIN_ORDER_VALUE                             15
>>>
>>>
>>>/*I have the following ResultMap*/
>>>
>>>    <resultMap id="getPromotionActionMap"
>>>class="com.boscovs.commerce.promotion.dao.ActionDAO">
>>>        <result property="type" column="actiontype" />
>>>        <result property="numberOfItems" column="min_item_quantity"
>>>javaType="int"/>
>>>        <result property="individualItemValue"
>>>column="min_single_item_value" javaType="double"/>
>>>        <result property="totalItemValue" column="min_total_item_value"
>>>javaType="double"/>
>>>        <result property="totalValue" column="min_order_value"
>>>javaType="double"/>
>>>    </resultMap>
>>>
>>>
>>>    <select id="getPromotionAction" resultMap="getPromotionActionMap">
>>>        <![CDATA[Select a.actiontype, a.min_item_quantity,
>>>            a.min_single_item_value,
>>>            a.min_total_item_value,
>>>            a.min_order_value
>>>            from DB2USR.PROMOTION as p, DB2USR.PROMO_ACTION a
>>>            where p.promotion_id = a.promotion_id
>>>            and p.promotion_id = #value#
>>>            and p.status='A']]>
>>>    </select>
>>>
>>>
>>>/*My bean is as follows*/
>>>
>>>public class ActionDAO {
>>>
>>>    public static enum Selected {
>>>        UNSELECTED, NO_ACTION, ADDS_X_ITEMS, TOTAL_ORDER_VALUE_AT_LEAST_X
>>>    }
>>>
>>>    private Selected selected = Selected.UNSELECTED;
>>>    private XItems xItems;
>>>    private double totalValue;
>>>    private int numberOfItems;
>>>    private double individualItemValue;
>>>    private double totalItemValue;
>>>    private String type;
>>>
>>>
>>>    /**
>>>     * @return
>>>     */
>>>    public Selected getSelected() {
>>>        return selected;
>>>    }
>>>
>>>    /**
>>>     * @return
>>>     */
>>>    public double getTotalValue() {
>>>        return totalValue;
>>>    }
>>>
>>>    /**
>>>     * @return
>>>     */
>>>    public XItems getXItems() {
>>>        return xItems;
>>>    }
>>>
>>>    /**
>>>     * @param i
>>>     */
>>>    public void setSelected(Selected i) {
>>>        selected = i;
>>>    }
>>>
>>>    /**
>>>     * @param d
>>>     */
>>>    public void setTotalValue(double d) {
>>>        totalValue = d;
>>>    }
>>>
>>>    /**
>>>     * @param items
>>>     */
>>>    public void setXItems(XItems items) {
>>>        xItems = items;
>>>    }
>>>
>>>    public void setType(String type) {
>>>        this.type = type;
>>>    }
>>>
>>>    public double getIndividualItemValue() {
>>>        return individualItemValue;
>>>    }
>>>    public void setIndividualItemValue(double individualItemValue) {
>>>        this.individualItemValue = individualItemValue;
>>>    }
>>>    public int getNumberOfItems() {
>>>        return numberOfItems;
>>>    }
>>>    public void setNumberOfItems(int numberOfItems) {
>>>        this.numberOfItems = numberOfItems;
>>>    }
>>>    public double getTotalItemValue() {
>>>        return totalItemValue;
>>>    }
>>>    public void setTotalItemValue(double totalItemValue) {
>>>        this.totalItemValue = totalItemValue;
>>>    }
>>>    /**
>>>     * toString method: creates a String representation of the object
>>>     * @return the String representation
>>>     * @author
>>>     */
>>>    public String toString() {
>>>        StringBuffer buffer = new StringBuffer();
>>>        buffer.append("ActionDAO[");
>>>        buffer.append("individualItemValue = ").append(individualItemValue);
>>>        buffer.append(", numberOfItems = ").append(numberOfItems);
>>>        buffer.append(", selected = ").append(selected);
>>>        buffer.append(", totalItemValue = ").append(totalItemValue);
>>>        buffer.append(", totalValue = ").append(totalValue);
>>>        buffer.append(", type = ").append(type);
>>>        buffer.append(", xItems = ").append(xItems);
>>>        buffer.append("]");
>>>        return buffer.toString();
>>>    }}
>>>
>>>
>>>
>>>/*I get an IllegalArgumentException from all this query. The developers
>>>guide infers that you can use primitives in your definitions. Does it?
>>>Or am I doing something stupid and not realizing it? BTW, it works if I
>>>use Wrapper classes, but I don't want to have to go through all of my
>>>beans and covert them. Thanks for any help.*/
>>>
>>>      
>>>
>>    
>>
>
>  
>


-- 
Michael H. Zatko
Java Enterprise Developer
Boscov's Information Services
Work: 610-929-7317
Home: 610-376-1624
Page: 610-736-4460


Mime
View raw message