You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Mike Zatko <mz...@boscovs.com> on 2005/02/18 15:00:21 UTC
[ResultMap] Can't get primitive types to work
/*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.*/
Re: [ResultMap] Can't get primitive types to work
Posted by Mike Zatko <mz...@boscovs.com>.
DB2 7.2 FixPack 12 using the db2java.zip driver.
If this is a case of DB2 sucking or something, I wouldn't bother with
it. When I get time, I'll try running the exact same code on mysql and
see what happens. Thanks.
Brandon Goodin wrote:
>what is the driver and database that you are using?
>
>
>On Fri, 18 Feb 2005 11:26:35 -0500, Mike Zatko <mz...@boscovs.com> wrote:
>
>
>>2.0.9
>>
>>Brandon Goodin wrote:
>>
>>
>>
>>>what version of ibatis are you using?
>>>
>>>
>>>On Fri, 18 Feb 2005 11:16:23 -0500, Mike Zatko <mz...@boscovs.com> wrote:
>>>
>>>
>>>
>>>
>>>>*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
>>>>><km...@sbcglobal.net> wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Are you perhaps missing the parameterClass arg on the statement itself?
>>>>>>
>>>>>>--- Mike Zatko <mz...@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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>--
>>Michael H. Zatko
>>Java Enterprise Developer
>>Boscov's Information Services
>>Work: 610-929-7317
>>Home: 610-376-1624
>>Page: 610-736-4460
>>
>>
>>
>>
>
>
>
--
Michael H. Zatko
Java Enterprise Developer
Boscov's Information Services
Work: 610-929-7317
Home: 610-376-1624
Page: 610-736-4460
Re: [ResultMap] Can't get primitive types to work
Posted by Brandon Goodin <br...@gmail.com>.
No problem Mike. These things are good to know. However, I'm still
curious as to why it failed. If you ever figure it out. Please post it
here and we could possibly add it to the wiki for future reference.
Branon
On Fri, 18 Feb 2005 11:48:09 -0500, Mike Zatko <mz...@boscovs.com> wrote:
> DB2 7 blows. I went and tried the same code on a workstation with a DB2
> 8 client and it worked. Sorry for wasting your time.
>
> Brandon Goodin wrote:
>
> >what is the driver and database that you are using?
> >
> >
> >On Fri, 18 Feb 2005 11:26:35 -0500, Mike Zatko <mz...@boscovs.com> wrote:
> >
> >
> >>2.0.9
> >>
> >>Brandon Goodin wrote:
> >>
> >>
> >>
> >>>what version of ibatis are you using?
> >>>
> >>>
> >>>On Fri, 18 Feb 2005 11:16:23 -0500, Mike Zatko <mz...@boscovs.com> wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>*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
> >>>>><km...@sbcglobal.net> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>Are you perhaps missing the parameterClass arg on the statement itself?
> >>>>>>
> >>>>>>--- Mike Zatko <mz...@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
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>--
> >>Michael H. Zatko
> >>Java Enterprise Developer
> >>Boscov's Information Services
> >>Work: 610-929-7317
> >>Home: 610-376-1624
> >>Page: 610-736-4460
> >>
> >>
> >>
> >>
> >
> >
> >
>
> --
> Michael H. Zatko
> Java Enterprise Developer
> Boscov's Information Services
> Work: 610-929-7317
> Home: 610-376-1624
> Page: 610-736-4460
>
>
Re: [ResultMap] Can't get primitive types to work
Posted by Mike Zatko <mz...@boscovs.com>.
DB2 7 blows. I went and tried the same code on a workstation with a DB2
8 client and it worked. Sorry for wasting your time.
Brandon Goodin wrote:
>what is the driver and database that you are using?
>
>
>On Fri, 18 Feb 2005 11:26:35 -0500, Mike Zatko <mz...@boscovs.com> wrote:
>
>
>>2.0.9
>>
>>Brandon Goodin wrote:
>>
>>
>>
>>>what version of ibatis are you using?
>>>
>>>
>>>On Fri, 18 Feb 2005 11:16:23 -0500, Mike Zatko <mz...@boscovs.com> wrote:
>>>
>>>
>>>
>>>
>>>>*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
>>>>><km...@sbcglobal.net> wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Are you perhaps missing the parameterClass arg on the statement itself?
>>>>>>
>>>>>>--- Mike Zatko <mz...@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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>--
>>Michael H. Zatko
>>Java Enterprise Developer
>>Boscov's Information Services
>>Work: 610-929-7317
>>Home: 610-376-1624
>>Page: 610-736-4460
>>
>>
>>
>>
>
>
>
--
Michael H. Zatko
Java Enterprise Developer
Boscov's Information Services
Work: 610-929-7317
Home: 610-376-1624
Page: 610-736-4460
Re: [ResultMap] Can't get primitive types to work
Posted by Brandon Goodin <br...@gmail.com>.
what is the driver and database that you are using?
On Fri, 18 Feb 2005 11:26:35 -0500, Mike Zatko <mz...@boscovs.com> wrote:
> 2.0.9
>
> Brandon Goodin wrote:
>
> >what version of ibatis are you using?
> >
> >
> >On Fri, 18 Feb 2005 11:16:23 -0500, Mike Zatko <mz...@boscovs.com> wrote:
> >
> >
> >>*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
> >>><km...@sbcglobal.net> wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>Are you perhaps missing the parameterClass arg on the statement itself?
> >>>>
> >>>>--- Mike Zatko <mz...@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
> >>
> >>
> >>
> >>
> >
> >
> >
>
> --
> Michael H. Zatko
> Java Enterprise Developer
> Boscov's Information Services
> Work: 610-929-7317
> Home: 610-376-1624
> Page: 610-736-4460
>
>
Re: [ResultMap] Can't get primitive types to work
Posted by Mike Zatko <mz...@boscovs.com>.
2.0.9
Brandon Goodin wrote:
>what version of ibatis are you using?
>
>
>On Fri, 18 Feb 2005 11:16:23 -0500, Mike Zatko <mz...@boscovs.com> wrote:
>
>
>>*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
>>><km...@sbcglobal.net> wrote:
>>>
>>>
>>>
>>>
>>>>Are you perhaps missing the parameterClass arg on the statement itself?
>>>>
>>>>--- Mike Zatko <mz...@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
>>
>>
>>
>>
>
>
>
--
Michael H. Zatko
Java Enterprise Developer
Boscov's Information Services
Work: 610-929-7317
Home: 610-376-1624
Page: 610-736-4460
Re: [ResultMap] Can't get primitive types to work
Posted by Brandon Goodin <br...@gmail.com>.
what version of ibatis are you using?
On Fri, 18 Feb 2005 11:16:23 -0500, Mike Zatko <mz...@boscovs.com> wrote:
> *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
> ><km...@sbcglobal.net> wrote:
> >
> >
> >>Are you perhaps missing the parameterClass arg on the statement itself?
> >>
> >>--- Mike Zatko <mz...@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
>
>
Re: [ResultMap] Can't get primitive types to work
Posted by Mike Zatko <mz...@boscovs.com>.
*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
><km...@sbcglobal.net> wrote:
>
>
>>Are you perhaps missing the parameterClass arg on the statement itself?
>>
>>--- Mike Zatko <mz...@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
Re: [ResultMap] Can't get primitive types to work
Posted by Brandon Goodin <br...@gmail.com>.
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
<km...@sbcglobal.net> wrote:
> Are you perhaps missing the parameterClass arg on the statement itself?
>
> --- Mike Zatko <mz...@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.*/
> >
>
>
Re: iBATIS vs jakarta-beans
Posted by Takacs Otto <ta...@freemail.hu>.
Hello
I have implemented a DynaProbe into iBATIS.
1. I did not want to break the existing library so i have re-factored
the ProbeFactory part of the library
I have moved all ProbeFactory functionality into ProbeFactoryBean and
its subclasses.
The ProbeFactory simply delegate the calls to the given factory bean.
There are two implementation of ProbeFactoryBean. The (almost)
copy-paste created DefaultProbeFactoryBean (created from the original
ProbeFactory)
and the TakacsotProbeFactoryBean (Of course the name can be anything
else :) )
The second factory bean always returns a DynaBeanProbe instance.
2. As you see the default implementations is the same as the original.
So if you want to use DynaProbe
call the following:
ProbeFactory.setCurrentProbeFactory(new TakacsotProbeFactoryBean());
Here is the current implementation.
If you say that it is OK tell me how could i integrate it into the trunk
(of course if you have the responsibility copy-paste the rest of the mail :)
1 package com.ibatis.common.beans;
2 /**
3 * An abstract factory for getting Probe implementations.
4 */
5 public class ProbeFactory {
15 private static ProbeFactoryBean currentProbeFactory;
16
17 static{
18 currentProbeFactory = new DefaultProbeFactoryBean();
19 }
20 /**
21 * Factory method for getting a Probe object
22 *
23 * @return An implementation of the Probe interface
24 */
25 public static Probe getProbe() {
26 return currentProbeFactory.getProbe();
28 }
29 /**
30 * Factory method for getting a Probe object that is the
best choice for the
31 * type of object supplied by the object parameter.
32 *
33 * @param object
34 * The object to get a Probe for
35 * @return An implementation of the Probe interface
36 */
37 public static Probe getProbe(Object object) {
38 return currentProbeFactory.getProbe(object);
51 }
52 /**
53 * @return Returns the currentProbeFactory.
54 */
55 public synchronized static ProbeFactoryBean
getCurrentProbeFactory() {
56 return currentProbeFactory;
57 }
58 /**
59 * @param currentProbeFactory
60 * The currentProbeFactory to set.
61 */
62 public synchronized static void setCurrentProbeFactory(
63 ProbeFactoryBean currentProbeFactory) {
64 ProbeFactory.currentProbeFactory = currentProbeFactory;
65 }
66 }
6 package com.ibatis.common.beans;
7 /**
8 * TODO Document the type!
9 *
10 * @author takacsot
11 *
12 */
13 public abstract class ProbeFactoryBean {
14 public abstract Probe getProbe();
15 public abstract Probe getProbe(Object object);
16 }
6 package com.ibatis.common.beans;
7 import java.util.Map;
8 /**
9 * TODO Document the type!
10 *
11 * @author takacsot
12 *
13 */
14 public class DefaultProbeFactoryBean extends ProbeFactoryBean {
15
16 private static final Probe DOM = new DomProbe();
17 private static final Probe MAP = new ComplexBeanProbe(); //
Yes, use the complex one.
18 private static final Probe BEAN = new JavaBeanProbe();
19 private static final Probe GENERIC = new GenericProbe();
20 private static final Probe LEGACY = new ComplexBeanProbe();
21 /**
22 * Factory method for getting a Probe object
23 *
24 * @return An implementation of the Probe interface
25 */
26 public Probe getProbe() {
27 return GENERIC;
28 }
29 /**
30 * Factory method for getting a Probe object that is
31 * the best choice for the type of object supplied
32 * by the object parameter.
33 *
34 * @param object The object to get a Probe for
35 * @return An implementation of the Probe interface
36 */
37 public Probe getProbe(Object object) {
38 if (object instanceof Map) {
39 return MAP;
40 } else if (object instanceof org.w3c.dom.Document) {
41 return DOM;
42 } else if (object instanceof Class) {
43 return LEGACY;
44 } else {
45 return BEAN;
46 }
47 }
48 }
6 package com.ibatis.common.beans;
7 import org.apache.commons.beanutils.DynaBean;
8 /**
9 * TODO Document the type!
10 *
11 * @author takacsot
12 *
13 */
14 public class TakacsotProbeFactoryBean extends
DefaultProbeFactoryBean {
15
16 private static final Probe DYNA= new DynaBeanProbe();
17
18 /**
19 * @see
com.ibatis.common.beans.ProbeFactoryBean#getProbe(java.lang.Object)
20 */
21 public Probe getProbe(Object object) {
22 //
23 if (object instanceof DynaBean) {
24 return DYNA;
25 }
26
27 return super.getProbe(object);
28 }
29 /**
30 * @see com.ibatis.common.beans.ProbeFactoryBean#getProbe()
31 */
32 public Probe getProbe() {
33 //
34 return DYNA;
35 }
36 }
1 /* $Id$
2 *
3 * Created on 2005.02.22.
4 *
5 */
6 package com.ibatis.common.beans;
7 import java.lang.reflect.InvocationTargetException;
8 import org.apache.commons.beanutils.PropertyUtils;
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11 /**
12 * DynaBeanProbe provide methods that allow access to DynaBeans.
13 * Of course it can be use with <emph>any</emph> kind of bean
which follows
14 * the JavaBean conventions.
15 *
16 * @author takacsot
17 *
18 */
19 public class DynaBeanProbe implements Probe {
20 private static Log log =
LogFactory.getLog(DynaBeanProbe.class.getName());
21 /**
22 * @see
com.ibatis.common.beans.Probe#getObject(java.lang.Object, java.lang.String)
23 */
24 public Object getObject(Object object, String name) {
25 //
26 try {
27 return PropertyUtils.getProperty(object, name);
28 }
29 catch (IllegalAccessException t) {
30 log.error(t,t);
31 throw new ProbeException(t);
32 }
33 catch (InvocationTargetException t) {
34 log.error(t,t);
35 throw new ProbeException(t);
36 }
37 catch (NoSuchMethodException t) {
38 log.error(t,t);
39 throw new ProbeException(t);
40 }
41 catch (RuntimeException e){
42 log.fatal(e,e);
43 throw new ProbeException(e);
44 }
45 }
46 /**
47 * @see
com.ibatis.common.beans.Probe#setObject(java.lang.Object,
java.lang.String, java.lang.Object)
48 */
49 public void setObject(Object object, String name, Object
value) {
50 //
51 try {
52 PropertyUtils.setProperty(object, name, value);
53 }
54 catch (IllegalAccessException t) {
55 log.error(t,t);
56 throw new ProbeException(t);
57 }
58 catch (InvocationTargetException t) {
59 log.error(t,t);
60 throw new ProbeException(t);
61 }
62 catch (NoSuchMethodException t) {
63 log.error(t,t);
64 throw new ProbeException(t);
65 }
66 catch (RuntimeException e){
67 log.fatal(e,e);
68 throw new ProbeException(e);
69 }
70 }
71 /**
72 * @see
com.ibatis.common.beans.Probe#getPropertyTypeForSetter(java.lang.Object,
java.lang.String)
73 */
74 public Class getPropertyTypeForSetter(Object object, String
name) {
75 //
76 try {
77 return PropertyUtils.getPropertyType(object, name);
78 }
79 catch (IllegalAccessException t) {
80 log.error(t,t);
81 throw new ProbeException(t);
82 }
83 catch (InvocationTargetException t) {
84 log.error(t,t);
85 throw new ProbeException(t);
86 }
87 catch (NoSuchMethodException t) {
88 log.error(t,t);
89 throw new ProbeException(t);
90 }
91 catch (RuntimeException e){
92 log.fatal(e,e);
93 throw new ProbeException(e);
94 }
95 }
96 /**
97 * @see
com.ibatis.common.beans.Probe#getPropertyTypeForGetter(java.lang.Object,
java.lang.String)
98 */
99 public Class getPropertyTypeForGetter(Object object, String
name) {
100 //
101 try {
102 return PropertyUtils.getPropertyType(object, name);
103 }
104 catch (IllegalAccessException t) {
105 log.error(t,t);
106 throw new ProbeException(t);
107 }
108 catch (InvocationTargetException t) {
109 log.error(t,t);
110 throw new ProbeException(t);
111 }
112 catch (NoSuchMethodException t) {
113 log.error(t,t);
114 throw new ProbeException(t);
115 }
116 catch (RuntimeException e){
117 log.fatal(e,e);
118 throw new ProbeException(e);
119 }
120 }
121 /**
122 * @see
com.ibatis.common.beans.Probe#hasWritableProperty(java.lang.Object,
java.lang.String)
123 */
124 public boolean hasWritableProperty(Object object, String
propertyName) {
125 //
126 return PropertyUtils.isWriteable(object,propertyName);
127 }
128 /**
129 * @see
com.ibatis.common.beans.Probe#hasReadableProperty(java.lang.Object,
java.lang.String)
130 */
131 public boolean hasReadableProperty(Object object, String
propertyName) {
132 //
133 return PropertyUtils.isReadable(object,propertyName);
134 }
135 }
--
Takacs Otto takacsot@freemail.hu
Re: iBATIS vs jakarta-beans
Posted by Clinton Begin <cl...@gmail.com>.
Sure, you could easily do that. There's no way to extend
ProbeFactory, but if you do simply add a new Probe implementation for
dynabeans and create the appropriate condition in the
PropeFacroty.getProbe() method, then it should work fine.
Once you've made the patch, send us what you have....we can consider
adding it to the framework.
...after all DynaBeans are quite a bit safer than Maps!
Cheers,
Clinton
On Mon, 21 Feb 2005 12:13:56 +0100, Takacs Otto <ta...@freemail.hu> wrote:
> My ide is to extend (or hack) the /com/ibatis/common/beans/ProbeFactory.java
> File becouse its getPrbe method could help me! But i am no sure! I need
> confirmation before the hacking!
>
> friendVU admin wrote:
> > Most people still write get/sets for domain model and form model.
> >
> > If you want dynamic, you can use this at form model:
> >
> > http://jakarta.apache.org/commons/beanutils/apidocs/org/apache/commons/beanutils/LazyDynaMap.html
> > (this avoids mainntining get/sets at form model)
> > or
> > return a HashMap (ArrayList of HashMaps) from iBatis for a dyanmic
> > domain model. (this avoids maintaing gets/sets at domain/model)
> >
> > .V
> >
> --
> Takacs Otto takacsot@freemail.hu
>
>
Re: iBATIS vs jakarta-beans
Posted by friendVU admin <ma...@friendvu.com>.
It does not look like a good idea.
.V
Takacs Otto wrote:
> My ide is to extend (or hack) the
> /com/ibatis/common/beans/ProbeFactory.java
> File becouse its getPrbe method could help me! But i am no sure! I
> need confirmation before the hacking!
>
> friendVU admin wrote:
>
>> Most people still write get/sets for domain model and form model.
>>
>> If you want dynamic, you can use this at form model:
>>
>> http://jakarta.apache.org/commons/beanutils/apidocs/org/apache/commons/beanutils/LazyDynaMap.html
>> (this avoids mainntining get/sets at form model)
>> or
>> return a HashMap (ArrayList of HashMaps) from iBatis for a dyanmic
>> domain model. (this avoids maintaing gets/sets at domain/model)
>>
>> .V
>>
Re: iBATIS vs jakarta-beans
Posted by Takacs Otto <ta...@freemail.hu>.
My ide is to extend (or hack) the /com/ibatis/common/beans/ProbeFactory.java
File becouse its getPrbe method could help me! But i am no sure! I need
confirmation before the hacking!
friendVU admin wrote:
> Most people still write get/sets for domain model and form model.
>
> If you want dynamic, you can use this at form model:
>
> http://jakarta.apache.org/commons/beanutils/apidocs/org/apache/commons/beanutils/LazyDynaMap.html
> (this avoids mainntining get/sets at form model)
> or
> return a HashMap (ArrayList of HashMaps) from iBatis for a dyanmic
> domain model. (this avoids maintaing gets/sets at domain/model)
>
> .V
>
--
Takacs Otto takacsot@freemail.hu
Re: iBATIS vs jakarta-beans
Posted by friendVU admin <ma...@friendvu.com>.
Most people still write get/sets for domain model and form model.
If you want dynamic, you can use this at form model:
http://jakarta.apache.org/commons/beanutils/apidocs/org/apache/commons/beanutils/LazyDynaMap.html
(this avoids mainntining get/sets at form model)
or
return a HashMap (ArrayList of HashMaps) from iBatis for a dyanmic
domain model. (this avoids maintaing gets/sets at domain/model)
.V
Takacs Otto wrote:
> I have a problem I have to use dynamic object (dynamic - DynaBean in
> Jakarta beans) but as I see only Java Beans and other "standard"
> objects are supported.
>
iBATIS vs jakarta-beans
Posted by Takacs Otto <ta...@freemail.hu>.
Hello
I am new user if iBATIS. It is a great product.
I have a problem I have to use dynamic object (dynamic - DynaBean in
Jakarta beans) but as I see only Java Beans and other "standard" objects
are supported.
How can I plug jakarta beans into the system? I have found a place but i
am not sure whether it is the correct place or not.
Best regards
--
Takacs Otto takacsot@freemail.hu
Re: [ResultMap] Can't get primitive types to work
Posted by Karen Koch <km...@sbcglobal.net>.
Are you perhaps missing the parameterClass arg on the statement itself?
--- Mike Zatko <mz...@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.*/
>