atom feed3 messages in org.apache.ibatis.user-javaRe: SqlMapDaoTemplate.getSqlMapExecut...
FromSent OnAttachments
al pivonkaJul 17, 2006 10:41 am 
Graeme J SweeneyJul 17, 2006 11:28 am 
al pivonkaJul 17, 2006 11:34 am 
Subject:Re: SqlMapDaoTemplate.getSqlMapExecutor ClassCastException
From:al pivonka (AL_P@YAHOO.COM)
Date:Jul 17, 2006 11:34:26 am
List:org.apache.ibatis.user-java

Many Thanks... its simple.. Here is the JUnit test code and the xml config regarding the table I am trying
to hit...

DAO.xml <daoConfig>

<context> <transactionManager type="JDBC"> <property name="DataSource" value="SIMPLE"/> <property name="JDBC.Driver" value="com.edb.Driver"/> <property name="JDBC.ConnectionURL" value="jdbc:edb://localhost:5444/testing"/> <property name="JDBC.Username" value="miso"/> <property name="JDBC.Password" value="miso"/> <property name="JDBC.DefaultAutoCommit" value="true" /> <property name="Pool.MaximumActiveConnections" value="10"/> <property name="Pool.MaximumIdleConnections" value="1"/> <property name="Pool.MaximumCheckoutTime" value="120000"/> </transactionManager> <dao interface="com.ibator.dao.PersonDAO" implementation="com.ibator.dao.PersonDAOImpl"/> <dao interface="com.ibator.dao.PersionAddressDAO" implementation="com.ibator.dao.PersionAddressDAOImpl"/> <dao interface="com.ibator.dao.AddressDAO" implementation="com.ibator.dao.AddressDAOImpl"/> </context> </daoConfig>

Junit Test: package com.ibator.dao.test; import java.io.Reader; import com.ibatis.common.resources.Resources; import com.ibatis.dao.client.DaoManager; import com.ibatis.dao.client.DaoManagerBuilder; import com.ibatis.sqlmap.client.SqlMapClient; import com.ibator.dao.PersonDAO; import com.ibator.map.java.Person; import junit.framework.TestCase;

public class PersonDAOTest extends TestCase { String resource = resource = "com/ibator/properties/dao.xml"; Reader reader = null; SqlMapClient sqlMap = null; DaoManager daoManager =null; PersonDAO personDAO = null;

public static void main(String[] args) { junit.textui.TestRunner.run(PersonDAOTest.class); }

public PersonDAOTest(String name) { super(name); }

protected void setUp() throws Exception { super.setUp(); reader = Resources.getResourceAsReader (resource); daoManager = DaoManagerBuilder.buildDaoManager(reader); personDAO = buildPerson(); }

protected void tearDown() throws Exception { super.tearDown(); reader=null; sqlMap=null; }

/* * Test method for 'com.ibator.dao.PersonDAOImpl.insert(Person)' */ public void testInsertPerson() { try{ Person person = new Person(); person.setFirstName("New Person"); person.setLastName("Last Name"); person.setId(new Integer(5)); personDAO.insert(person); }catch(Exception e){ e.printStackTrace(); fail(e.getMessage()); } }

private PersonDAO buildPerson(){ PersonDAO newPersonDAO = (PersonDAO)daoManager.getDao(PersonDAO.class); return newPersonDAO; } }

Exception stacktrace: java.lang.ClassCastException at
com.ibatis.dao.client.template.SqlMapDaoTemplate.getSqlMapExecutor(SqlMapDaoTemplate.java:60) at
com.ibatis.dao.client.template.SqlMapDaoTemplate.insert(SqlMapDaoTemplate.java:100) at com.ibator.dao.PersonDAOImpl.insert(PersonDAOImpl.java:31) 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 com.ibatis.dao.engine.impl.DaoProxy.invoke(DaoProxy.java:72) at $Proxy0.insert(Unknown Source) at com.ibator.dao.test.PersonDAOTest.testInsertPerson(PersonDAOTest.java:53) 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:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

----- Original Message ---- From: Graeme J Sweeney <ibat@gjsweeney.com> To: iBatis List <user@ibatis.apache.org> Sent: Monday, July 17, 2006 2:28:38 PM Subject: Re: SqlMapDaoTemplate.getSqlMapExecutor ClassCastException

On Mon, 17 Jul 2006, al pivonka wrote:

HELP.... I'm getting a ClassCastException on SqlMapDaoTemplate.getSqlMapExecutor

Never used it, can you post your code and the exception trace.