ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject RE: How to map a list of double?
Date Tue, 11 Sep 2007 13:48:22 GMT
If you want to be certain, you could always fully qualify the class names.
IIRC they should all be lowercase, for both "double" and "string".  But as a
sanity check, fully qualify them as java.lang.Double and java.lang.String
just as a test.

 

Clinton

 

From: Jonathan Alvarsson [mailto:jonathan.alvarsson@gmail.com] 
Sent: September-11-07 7:11 AM
To: user-java@ibatis.apache.org
Subject: Re: How to map a list of double?

 

No difference. I have tried:
<select id="MoleculeDescriptor.getValueList" resultClass="Double"
parameterClass="String">
        SELECT
            value AS value
        FROM
            DescriptorValue
        WHERE
            abstractDescriptor=#value#
        ORDER BY
            arrayPos
</select>

and

<select id="MoleculeDescriptor.getValueList" resultClass="double"
parameterClass="String"> 
        SELECT
            value AS value
        FROM
            DescriptorValue
        WHERE
            abstractDescriptor=#value#
        ORDER BY
            arrayPos
</select>

both result in ClassCastException. (It reads the file correctly though
because ouble rendered a class not found exception) 

Isn't this supposed to be possible to do?

On 9/11/07, Niels Beekman <n.beekman@wis.nl> wrote: 

Hm, your result class of MoleculeDescriptor.getValueList is wrong, try
changing it to double.

 

  _____  

From: Jonathan Alvarsson [mailto:jonathan.alvarsson@gmail.com] 
Sent: dinsdag 11 september 2007 13:22
To: user-java@ibatis.apache.org
Subject: Re: How to map a list of double?

 

Well that's what I thought I was doing. My field in my bean is 

private List<Double> values;

with setter: 
public void setValues(List<Double> values) {
        this.values = values;
}

Does my mapping somehow not match this?

On 9/11/07, Niels Beekman < n.beekman@wis.nl <mailto:n.beekman@wis.nl> >
wrote:

This seems to be a bug, iBATIS tries to cast a double array to an Object
array. A workaround would probably be to change the double array to a Double
list.

 

Niels

  _____  

From: Jonathan Alvarsson [mailto: jonathan.alvarsson@gmail.com] 
Sent: dinsdag 11 september 2007 11:36
To: user-java@ibatis.apache.org
Subject: How to map a list of double?

 

I am trying to map a list of doubles in my bean but I keep getting a
ClassCastException on it.

<resultMap class="MoleculeDescriptor" id="MoleculeDescriptor"> 
        <result property="id"     column="id"   />
        <result property="name"   column="name" />
        <result property="values" column="id"
select="MoleculeDescriptor.getValueList" />
</resultMap>

<select id="MoleculeDescriptor.getValueList " resultClass="List"
parameterClass="String">
        SELECT
            value AS value
        FROM
            DescriptorValue
        WHERE
            abstractDescriptor=#value#
        ORDER BY
            arrayPos
</select>

CREATE TABLE DescriptorValue (
    id       BIGINT AUTO_INCREMENT NOT NULL,
    value    DOUBLE                NOT NULL,
    arrayPos INT                   NOT NULL,
    abstractDescriptor VARCHAR(36) NOT NULL, 

    PRIMARY KEY (id),
    FOREIGN KEY (abstractDescriptor) REFERENCES AbstractDescriptor(id)
) ENGINE=InnoDB;

How can I do this?

Oh and the exception I get:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation;
uncategorized SQLException for SQL []; SQL state [null]; error code [0];   
--- The error occurred in mapping/MoleculeDescriptor.xml.  
--- The error occurred while applying a result map.  
--- Check the MoleculeDescriptor.  
--- Check the result mapping for the 'values' property.  
--- Cause: java.lang.ClassCastException: [D; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in mapping/MoleculeDescriptor.xml.  
--- The error occurred while applying a result map.  
--- Check the MoleculeDescriptor.  
--- Check the result mapping for the 'values' property.  
--- Cause: java.lang.ClassCastException: [D
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException :   
--- The error occurred in mapping/MoleculeDescriptor.xml.  
--- The error occurred while applying a result map.  
--- Check the MoleculeDescriptor.  
--- Check the result mapping for the 'values' property.  
--- Cause: java.lang.ClassCastException: [D
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWith
Callback(GeneralStatement.java:188)
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForO
bject (GeneralStatement.java:104)
    at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
ecutorDelegate.java:566)
    at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
ecutorDelegate.java :541)
    at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSession
Impl.java:106)
    at
org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMa
pClientTemplate.java:243)
    at
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemp
late.java:193)
    at
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapCli
entTemplate.java:241)
    at net.bioclipse.pcm.dao.GenericDao.getById (GenericDao.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source)
    at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopU
tils.java:296)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
(ReflectiveMethodInvocation.java:177)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflect
iveMethodInvocation.java:144)
    at net.bioclipse.pcm.dao.FetchIntroductionInterceptor.invoke
(FetchIntroductionInterceptor.java:22)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflect
iveMethodInvocation.java:166)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke
(JdkDynamicAopProxy.java:204)
    at $Proxy0.getById(Unknown Source)
    at
net.bioclipse.pcm.dao.GenericDaoTest.testGetById(GenericDaoTest.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest (TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at
org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.jav
a:69)
    at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTest
s.access$001 (AbstractAnnotationAwareTransactionalTests.java:47)
    at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTest
s$1.run(AbstractAnnotationAwareTransactionalTests.java:115)
    at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTest
s.runTest (AbstractAnnotationAwareTransactionalTests.java:180)
    at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTest
s.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:153)
    at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTest
s.runBare (AbstractAnnotationAwareTransactionalTests.java:111)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run (TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run
(JUnit3TestReference.java:130)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
8)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException: [D
    at
com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.listToArray(Resu
ltLoader.java:85)
    at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.getResult
(ResultLoader.java:75)
    at
com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(Resul
tLoader.java:59)
    at
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappin
gValue(BasicResultMap.java :502)
    at
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResul
tMap.java:340)
    at
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.jav
a:381)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults
(SqlExecutor.java:301)
    at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java
:190)
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(
GeneralStatement.java :205)
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWith
Callback(GeneralStatement.java:173)
    ... 44 more



-- 
// Jonathan 




-- 
// Jonathan 




-- 
// Jonathan 


Mime
View raw message