- 浏览: 413336 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
liyuanhoa_:
...
struts2.0中struts.xml配置文件详解 -
chenmingde:
...
Velocity应用(一) -
weizhikai_ai:
第二十六,当一个线程进入一个对象的一个synchronized ...
Java常见面试题(含答案) -
Aurora_lr:
...
Spring宠物商店学习笔记(一) - -
zs911zs:
all copy from http://www.iteye ...
Mule入门文档
相关文章:
『出错』MS SQL 2000 :驱动不支持指定的SQL类型
求助动态Mapped Statement
springframe 2.5中jpetStore的例子
推荐圈子: JBPM @net
更多相关推荐 程序所涉及的lib版本分别为:
ibatis-common-2.2.0.638.jar
ibatis-dao-2.2.0.638.jar
ibatis-sqlmap-2.2.0.638.jar
spring-1.2.8.jar
junit-3.8.1.jar
程序所涉及的源文件分别为:
// ******************************* iBatis *******************
# classpath:/ibatis/sql-map-config.xml
Java代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings
cacheModelsEnabled ="true"
<!-- 此处为false程序运行正常,但无法延迟,,若此处修改为 true 时,junit test会出现错误,具体错误见文章末尾 -->
enhancementEnabled ="false" // <SPAN style="COLOR: red">****</SPAN>
lazyLoadingEnabled ="true"
errorTracingEnabled ="true"
maxRequests ="32"
maxSessions ="10"
maxTransactions ="5"
useStatementNamespaces ="true"
/>
<sqlMap resource="ibatis/maps/Parent.xml"/>
<sqlMap resource="ibatis/maps/Child.xml"/>
</sqlMapConfig>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings
cacheModelsEnabled ="true"
<!-- 此处为false程序运行正常,但无法延迟,,若此处修改为 true 时,junit test会出现错误,具体错误见文章末尾 -->
enhancementEnabled ="false" // ****
lazyLoadingEnabled ="true"
errorTracingEnabled ="true"
maxRequests ="32"
maxSessions ="10"
maxTransactions ="5"
useStatementNamespaces ="true"
/>
<sqlMap resource="ibatis/maps/Parent.xml"/>
<sqlMap resource="ibatis/maps/Child.xml"/>
</sqlMapConfig>
# classpath:/ibatis/maps/Parent.xml
Java代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Parent">
<resultMap id="result" class="com.domain.Parent">
<result property="id" column="ID"/>
<result property="name" column="PARENT_NAME"/>
</resultMap>
<resultMap id="resultAll" class="com.domain.Parent" extends="result">
<!-- java.util.List children; -->
<result property="children" column="ID" select="Child.findByParent"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_PARENT_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO PARENT
(ID, PARENT_NAME)
values
(#id#, #PARENT_NAME:VARCHAR#)
</statement>
<statement id="update">
update PARENT t
set t.PARENT_NAME = #PARENT_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from PARENT t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from PARENT t
where t.ID = #id#
</statement>
</sqlMap>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Parent">
<resultMap id="result" class="com.domain.Parent">
<result property="id" column="ID"/>
<result property="name" column="PARENT_NAME"/>
</resultMap>
<resultMap id="resultAll" class="com.domain.Parent" extends="result">
<!-- java.util.List children; -->
<result property="children" column="ID" select="Child.findByParent"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_PARENT_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO PARENT
(ID, PARENT_NAME)
values
(#id#, #PARENT_NAME:VARCHAR#)
</statement>
<statement id="update">
update PARENT t
set t.PARENT_NAME = #PARENT_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from PARENT t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from PARENT t
where t.ID = #id#
</statement>
</sqlMap>
# com.domain.base.BaseParent.java
Java代码
package com.domain.base;
import java.io.Serializable;
import java.util.List;
/**
* This is an object that contains data related to the PARENT table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="PARENT"
*
* @author Lincee
*/
public abstract class BaseParent implements Serializable {
public BaseParent(){}
public BaseParent(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private List children;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
package com.domain.base;
import java.io.Serializable;
import java.util.List;
/**
* This is an object that contains data related to the PARENT table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="PARENT"
*
* @author Lincee
*/
public abstract class BaseParent implements Serializable {
public BaseParent(){}
public BaseParent(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private List children;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
# com.domain.Parent.java
Java代码
package com.domain;
import com.domain.base.BaseParent;
public class Parent extends BaseParent {
private static final long serialVersionUID = 1L;
public Parent(){super();}
public Parent(Long id){super(id);}
}
package com.domain;
import com.domain.base.BaseParent;
public class Parent extends BaseParent {
private static final long serialVersionUID = 1L;
public Parent(){super();}
public Parent(Long id){super(id);}
}
# classpath:/ibatis/maps/Child.xml
Java代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Child">
<resultMap id="result" class="com.domain.Child">
<result property="id" column="ID"/>
<result property="name" column="CHILD_NAME"/>
<result property="parentId" column="PARENT_ID"/>
<result property="parent" column="PARENT_ID" select="Parent.get"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_CHILD_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO CHILD
(ID, CHILD_NAME)
values
(#id#, #CHILD_NAME:VARCHAR#)
</statement>
<statement id="update">
update CHILD t
set t.CHILD_NAME = #CHILD_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from CHILD t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from CHILD t
where t.ID = #id#
</statement>
</sqlMap>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Child">
<resultMap id="result" class="com.domain.Child">
<result property="id" column="ID"/>
<result property="name" column="CHILD_NAME"/>
<result property="parentId" column="PARENT_ID"/>
<result property="parent" column="PARENT_ID" select="Parent.get"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_CHILD_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO CHILD
(ID, CHILD_NAME)
values
(#id#, #CHILD_NAME:VARCHAR#)
</statement>
<statement id="update">
update CHILD t
set t.CHILD_NAME = #CHILD_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from CHILD t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from CHILD t
where t.ID = #id#
</statement>
</sqlMap>
# com.domain.base.BaseChild.java
Java代码
package com.domain.base;
import java.io.Serializable;
import com.domain.Parent;
/**
* This is an object that contains data related to the CHILD table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="CHILD"
*
* @author Lincee
*/
public abstract class BaseChild implements Serializable {
public BaseChild(){}
public BaseChild(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private Parent parent;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
package com.domain.base;
import java.io.Serializable;
import com.domain.Parent;
/**
* This is an object that contains data related to the CHILD table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="CHILD"
*
* @author Lincee
*/
public abstract class BaseChild implements Serializable {
public BaseChild(){}
public BaseChild(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private Parent parent;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
# com.domain.Child.java
Java代码
package com.domain;
import com.domain.base.BaseChild;
public class Child extends BaseChild {
private static final long serialVersionUID = 1L;
public Child(){super();}
public Child(Long id){super(id);}
}
package com.domain;
import com.domain.base.BaseChild;
public class Child extends BaseChild {
private static final long serialVersionUID = 1L;
public Child(){super();}
public Child(Long id){super(id);}
}
// ******************************* Spring *******************
Java代码
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:/ibatis/sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="baseDao" abstract="true" class="com.dao.BaseDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:/ibatis/sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="baseDao" abstract="true" class="com.dao.BaseDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
// ******************************* JUnit ********************
# com.framework.test.TestBase
Java代码
package com.framework.test;
import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
*
*
* @author Lincee
*/
public abstract class TestBase extends TestCase {
protected String getSpringContextPath() {
return "spring/*.xml";
}
protected ApplicationContext applicationContext = null;
protected final void setUp() throws Exception {
super.setUp();
applicationContext = new ClassPathXmlApplicationContext(
getSpringContextPath());
initialize();
}
protected abstract void initialize() throws Exception;
public abstract void testDao() throws Exception;
}
package com.framework.test;
import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
*
*
* @author Lincee
*/
public abstract class TestBase extends TestCase {
protected String getSpringContextPath() {
return "spring/*.xml";
}
protected ApplicationContext applicationContext = null;
protected final void setUp() throws Exception {
super.setUp();
applicationContext = new ClassPathXmlApplicationContext(
getSpringContextPath());
initialize();
}
protected abstract void initialize() throws Exception;
public abstract void testDao() throws Exception;
}
# com.dao.TestChildDao
Java代码
package com.dao;
import junit.framework.Assert;
public class TestChildDao extends TestBase {
private ChildDao childDao;
protected void initialize() throws Exception {
childDao = (ChildDao) applicationContext.getBean("childDao");
}
public void testDao() throws Exception {
Assert.assertNotNull(childDao);
}
public void testGet() {
Child child = childDao.get(1L);
System.out.println(child.getName());
// System.out.println(child.getName() + " : " + child.getParent().getName());
}
}
package com.dao;
import junit.framework.Assert;
public class TestChildDao extends TestBase {
private ChildDao childDao;
protected void initialize() throws Exception {
childDao = (ChildDao) applicationContext.getBean("childDao");
}
public void testDao() throws Exception {
Assert.assertNotNull(childDao);
}
public void testGet() {
Child child = childDao.get(1L);
System.out.println(child.getName());
// System.out.println(child.getName() + " : " + child.getParent().getName());
}
}
// ********** enhancementEnabled = "true" 运行的错误信息 ******
Java代码
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in ibatis/maps/Child.xml.
--- The error occurred while applying a result map.
--- Check the Child.resultAll.
--- Check the result mapping for the 'parent' property.
--- Cause: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ibatis/maps/Child.xml.
--- The error occurred while applying a result map.
--- Check the Child.result.
--- Check the result mapping for the 'parent' property.
--- Cause: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ibatis/maps/Child.xml.
--- The error occurred while applying a result map.
--- Check the Child.result.
--- Check the result mapping for the 'parent' property.
--- Cause: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:565)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:540)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:210)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:168)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:208)
at com.framework.dao.impl.BaseDaoImpl.get(BaseDaoImpl.java:78)
at com.dao.TestChildDao.testGet(TestChildDao.java:96)
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:324)
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 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)
Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:566)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:493)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:368)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:280)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:581)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadResult(EnhancedLazyResultLoader.java:104)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader.loadResult(EnhancedLazyResultLoader.java:59)
at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(ResultLoader.java:53)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue(BasicResultMap.java:504)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap.java:340)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:375)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:295)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 22 more
Caused by: net.sf.cglib.proxy.UndeclaredThrowableException: java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.initialize(<generated>)
at com.domain.base.BaseParent.<init>(BaseParent.java:22)
at com.domain.Parent.<init>(Parent.java:18)
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
... 40 more
Caused by: java.lang.IllegalAccessException: Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.reflect.Method.invoke(Method.java:317)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.invoke(EnhancedLazyResultLoader.java:116)
... 49 more
Caused by:
net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:566)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:493)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:368)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:280)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:581)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadResult(EnhancedLazyResultLoader.java:104)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader.loadResult(EnhancedLazyResultLoader.java:59)
at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(ResultLoader.java:53)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue(BasicResultMap.java:504)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap.java:340)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:375)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:295)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:565)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:540)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:210)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:168)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:208)
at com.framework.dao.impl.BaseDaoImpl.get(BaseDaoImpl.java:78)
at com.dao.TestChildDao.testGet(TestChildDao.java:96)
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:324)
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 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)
Caused by: net.sf.cglib.proxy.UndeclaredThrowableException: java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.initialize(<generated>)
at com.domain.base.BaseParent.<init>(BaseParent.java:22)
at com.domain.Parent.<init>(Parent.java:18)
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
... 40 more
Caused by: java.lang.IllegalAccessException: Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.reflect.Method.invoke(Method.java:317)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.invoke(EnhancedLazyResultLoader.java:116)
... 49 more
『出错』MS SQL 2000 :驱动不支持指定的SQL类型
求助动态Mapped Statement
springframe 2.5中jpetStore的例子
推荐圈子: JBPM @net
更多相关推荐 程序所涉及的lib版本分别为:
ibatis-common-2.2.0.638.jar
ibatis-dao-2.2.0.638.jar
ibatis-sqlmap-2.2.0.638.jar
spring-1.2.8.jar
junit-3.8.1.jar
程序所涉及的源文件分别为:
// ******************************* iBatis *******************
# classpath:/ibatis/sql-map-config.xml
Java代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings
cacheModelsEnabled ="true"
<!-- 此处为false程序运行正常,但无法延迟,,若此处修改为 true 时,junit test会出现错误,具体错误见文章末尾 -->
enhancementEnabled ="false" // <SPAN style="COLOR: red">****</SPAN>
lazyLoadingEnabled ="true"
errorTracingEnabled ="true"
maxRequests ="32"
maxSessions ="10"
maxTransactions ="5"
useStatementNamespaces ="true"
/>
<sqlMap resource="ibatis/maps/Parent.xml"/>
<sqlMap resource="ibatis/maps/Child.xml"/>
</sqlMapConfig>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings
cacheModelsEnabled ="true"
<!-- 此处为false程序运行正常,但无法延迟,,若此处修改为 true 时,junit test会出现错误,具体错误见文章末尾 -->
enhancementEnabled ="false" // ****
lazyLoadingEnabled ="true"
errorTracingEnabled ="true"
maxRequests ="32"
maxSessions ="10"
maxTransactions ="5"
useStatementNamespaces ="true"
/>
<sqlMap resource="ibatis/maps/Parent.xml"/>
<sqlMap resource="ibatis/maps/Child.xml"/>
</sqlMapConfig>
# classpath:/ibatis/maps/Parent.xml
Java代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Parent">
<resultMap id="result" class="com.domain.Parent">
<result property="id" column="ID"/>
<result property="name" column="PARENT_NAME"/>
</resultMap>
<resultMap id="resultAll" class="com.domain.Parent" extends="result">
<!-- java.util.List children; -->
<result property="children" column="ID" select="Child.findByParent"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_PARENT_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO PARENT
(ID, PARENT_NAME)
values
(#id#, #PARENT_NAME:VARCHAR#)
</statement>
<statement id="update">
update PARENT t
set t.PARENT_NAME = #PARENT_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from PARENT t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from PARENT t
where t.ID = #id#
</statement>
</sqlMap>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Parent">
<resultMap id="result" class="com.domain.Parent">
<result property="id" column="ID"/>
<result property="name" column="PARENT_NAME"/>
</resultMap>
<resultMap id="resultAll" class="com.domain.Parent" extends="result">
<!-- java.util.List children; -->
<result property="children" column="ID" select="Child.findByParent"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_PARENT_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO PARENT
(ID, PARENT_NAME)
values
(#id#, #PARENT_NAME:VARCHAR#)
</statement>
<statement id="update">
update PARENT t
set t.PARENT_NAME = #PARENT_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from PARENT t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from PARENT t
where t.ID = #id#
</statement>
</sqlMap>
# com.domain.base.BaseParent.java
Java代码
package com.domain.base;
import java.io.Serializable;
import java.util.List;
/**
* This is an object that contains data related to the PARENT table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="PARENT"
*
* @author Lincee
*/
public abstract class BaseParent implements Serializable {
public BaseParent(){}
public BaseParent(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private List children;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
package com.domain.base;
import java.io.Serializable;
import java.util.List;
/**
* This is an object that contains data related to the PARENT table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="PARENT"
*
* @author Lincee
*/
public abstract class BaseParent implements Serializable {
public BaseParent(){}
public BaseParent(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private List children;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
# com.domain.Parent.java
Java代码
package com.domain;
import com.domain.base.BaseParent;
public class Parent extends BaseParent {
private static final long serialVersionUID = 1L;
public Parent(){super();}
public Parent(Long id){super(id);}
}
package com.domain;
import com.domain.base.BaseParent;
public class Parent extends BaseParent {
private static final long serialVersionUID = 1L;
public Parent(){super();}
public Parent(Long id){super(id);}
}
# classpath:/ibatis/maps/Child.xml
Java代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Child">
<resultMap id="result" class="com.domain.Child">
<result property="id" column="ID"/>
<result property="name" column="CHILD_NAME"/>
<result property="parentId" column="PARENT_ID"/>
<result property="parent" column="PARENT_ID" select="Parent.get"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_CHILD_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO CHILD
(ID, CHILD_NAME)
values
(#id#, #CHILD_NAME:VARCHAR#)
</statement>
<statement id="update">
update CHILD t
set t.CHILD_NAME = #CHILD_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from CHILD t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from CHILD t
where t.ID = #id#
</statement>
</sqlMap>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Child">
<resultMap id="result" class="com.domain.Child">
<result property="id" column="ID"/>
<result property="name" column="CHILD_NAME"/>
<result property="parentId" column="PARENT_ID"/>
<result property="parent" column="PARENT_ID" select="Parent.get"/>
</resultMap>
<statement id="save">
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT SEQ_CHILD_ID.NEXTVAL AS id FROM DUAL
</selectKey>
INSERT INTO CHILD
(ID, CHILD_NAME)
values
(#id#, #CHILD_NAME:VARCHAR#)
</statement>
<statement id="update">
update CHILD t
set t.CHILD_NAME = #CHILD_NAME:VARCHAR#
where t.ID = #id#
</statement>
<statement id="delete">
delete from CHILD t
where t.ID = #id#
</statement>
<statement id="get" parameterClass="java.lang.Long" resultMap="result">
select *
from CHILD t
where t.ID = #id#
</statement>
</sqlMap>
# com.domain.base.BaseChild.java
Java代码
package com.domain.base;
import java.io.Serializable;
import com.domain.Parent;
/**
* This is an object that contains data related to the CHILD table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="CHILD"
*
* @author Lincee
*/
public abstract class BaseChild implements Serializable {
public BaseChild(){}
public BaseChild(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private Parent parent;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
package com.domain.base;
import java.io.Serializable;
import com.domain.Parent;
/**
* This is an object that contains data related to the CHILD table. Do
* not modify this class because it will be overwritten if the configuration
* file related to this class is modified.
*
* table="CHILD"
*
* @author Lincee
*/
public abstract class BaseChild implements Serializable {
public BaseChild(){}
public BaseChild(Long id){this.setId(id);}
private int hashCode = Integer.MIN_VALUE;
private Long id;
private String name;
private Parent parent;
// setter, getter;
public boolean equals(Object obj) { ... }
public int hashCode() { ... }
}
# com.domain.Child.java
Java代码
package com.domain;
import com.domain.base.BaseChild;
public class Child extends BaseChild {
private static final long serialVersionUID = 1L;
public Child(){super();}
public Child(Long id){super(id);}
}
package com.domain;
import com.domain.base.BaseChild;
public class Child extends BaseChild {
private static final long serialVersionUID = 1L;
public Child(){super();}
public Child(Long id){super(id);}
}
// ******************************* Spring *******************
Java代码
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:/ibatis/sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="baseDao" abstract="true" class="com.dao.BaseDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:/ibatis/sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="baseDao" abstract="true" class="com.dao.BaseDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
// ******************************* JUnit ********************
# com.framework.test.TestBase
Java代码
package com.framework.test;
import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
*
*
* @author Lincee
*/
public abstract class TestBase extends TestCase {
protected String getSpringContextPath() {
return "spring/*.xml";
}
protected ApplicationContext applicationContext = null;
protected final void setUp() throws Exception {
super.setUp();
applicationContext = new ClassPathXmlApplicationContext(
getSpringContextPath());
initialize();
}
protected abstract void initialize() throws Exception;
public abstract void testDao() throws Exception;
}
package com.framework.test;
import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
*
*
* @author Lincee
*/
public abstract class TestBase extends TestCase {
protected String getSpringContextPath() {
return "spring/*.xml";
}
protected ApplicationContext applicationContext = null;
protected final void setUp() throws Exception {
super.setUp();
applicationContext = new ClassPathXmlApplicationContext(
getSpringContextPath());
initialize();
}
protected abstract void initialize() throws Exception;
public abstract void testDao() throws Exception;
}
# com.dao.TestChildDao
Java代码
package com.dao;
import junit.framework.Assert;
public class TestChildDao extends TestBase {
private ChildDao childDao;
protected void initialize() throws Exception {
childDao = (ChildDao) applicationContext.getBean("childDao");
}
public void testDao() throws Exception {
Assert.assertNotNull(childDao);
}
public void testGet() {
Child child = childDao.get(1L);
System.out.println(child.getName());
// System.out.println(child.getName() + " : " + child.getParent().getName());
}
}
package com.dao;
import junit.framework.Assert;
public class TestChildDao extends TestBase {
private ChildDao childDao;
protected void initialize() throws Exception {
childDao = (ChildDao) applicationContext.getBean("childDao");
}
public void testDao() throws Exception {
Assert.assertNotNull(childDao);
}
public void testGet() {
Child child = childDao.get(1L);
System.out.println(child.getName());
// System.out.println(child.getName() + " : " + child.getParent().getName());
}
}
// ********** enhancementEnabled = "true" 运行的错误信息 ******
Java代码
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in ibatis/maps/Child.xml.
--- The error occurred while applying a result map.
--- Check the Child.resultAll.
--- Check the result mapping for the 'parent' property.
--- Cause: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ibatis/maps/Child.xml.
--- The error occurred while applying a result map.
--- Check the Child.result.
--- Check the result mapping for the 'parent' property.
--- Cause: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ibatis/maps/Child.xml.
--- The error occurred while applying a result map.
--- Check the Child.result.
--- Check the result mapping for the 'parent' property.
--- Cause: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:565)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:540)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:210)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:168)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:208)
at com.framework.dao.impl.BaseDaoImpl.get(BaseDaoImpl.java:78)
at com.dao.TestChildDao.testGet(TestChildDao.java:96)
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:324)
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 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)
Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:566)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:493)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:368)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:280)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:581)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadResult(EnhancedLazyResultLoader.java:104)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader.loadResult(EnhancedLazyResultLoader.java:59)
at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(ResultLoader.java:53)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue(BasicResultMap.java:504)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap.java:340)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:375)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:295)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 22 more
Caused by: net.sf.cglib.proxy.UndeclaredThrowableException: java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.initialize(<generated>)
at com.domain.base.BaseParent.<init>(BaseParent.java:22)
at com.domain.Parent.<init>(Parent.java:18)
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
... 40 more
Caused by: java.lang.IllegalAccessException: Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.reflect.Method.invoke(Method.java:317)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.invoke(EnhancedLazyResultLoader.java:116)
... 49 more
Caused by:
net.sf.cglib.core.CodeGenerationException: net.sf.cglib.proxy.UndeclaredThrowableException-->java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:566)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:493)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:368)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:280)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:581)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadResult(EnhancedLazyResultLoader.java:104)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader.loadResult(EnhancedLazyResultLoader.java:59)
at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(ResultLoader.java:53)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue(BasicResultMap.java:504)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap.java:340)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:375)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:295)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:565)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:540)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:210)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:168)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:208)
at com.framework.dao.impl.BaseDaoImpl.get(BaseDaoImpl.java:78)
at com.dao.TestChildDao.testGet(TestChildDao.java:96)
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:324)
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 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)
Caused by: net.sf.cglib.proxy.UndeclaredThrowableException: java.lang.IllegalAccessException-->Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.initialize(<generated>)
at com.domain.base.BaseParent.<init>(BaseParent.java:22)
at com.domain.Parent.<init>(Parent.java:18)
at com.domain.Parent$$EnhancerByCGLIB$$e337ec8b.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
... 40 more
Caused by: java.lang.IllegalAccessException: Class com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl can not access a member of class com.domain.base.BaseParent with modifiers "protected"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.reflect.Method.invoke(Method.java:317)
at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.invoke(EnhancedLazyResultLoader.java:116)
... 49 more
发表评论
-
iBATIS的代码生成工具-iBATOR 试用
2008-11-28 14:41 2018前两天在javaeye上闲逛, ... -
iBATIS 介绍(by jini)
2008-11-28 14:40 1217相关文章: Hibernate VS iBATIS 鉴 ... -
进一步了解iBATIS-iBATIS官方网站的一些翻译
2008-11-28 14:38 2313序言 对iBATIS框架产生了浓厚的兴趣,在翻译开 ... -
一个iBatis的demo
2008-11-28 14:37 1236相对Hibernate和Apache OJB 等“一站式”OR ... -
IBatis学习总结
2008-11-28 14:34 1067IBatis学习总结 一、 介绍: 相对于Hibernat ...
相关推荐
对于复杂场景,如多表联查、分页、存储过程等,你可以继续深入学习XML配置文件的高级用法,例如使用`<association>`, `<collection>`处理嵌套结果,使用`<resultMap>`定义复杂的映射关系等。 总的来说,iBATIS的XML...
在Java开发领域中,ibatis(现称为MyBatis)是一款优秀的持久层框架,它通过XML或注解的方式将接口方法与SQL语句绑定起来,实现对象关系映射(ORM)功能。ibatis的主要优势在于其强大的SQL查询能力和对结果集的灵活...
### ibatis配置文件详解 #### 一、ibatis概述 ibatis,又称MyBatis,是一种优秀的持久层框架,它支持定制化SQL、存储过程以及高级映射。ibatis避免了几乎所有的JDBC代码和手动设置参数以及获取结果集。ibatis可以...
Ibatis是一款轻量级的Java持久层框架,它在ORM(对象关系映射)领域有着广泛的应用。Ibatis的核心理念是将SQL语句与Java代码分离,使得开发者能够更加灵活地处理数据库操作,同时降低了SQL注入的风险。下面,我们将...
Ibatis是一个轻量级的Java ORM(对象关系映射)框架,它允许我们编写SQL语句并将其与Java对象绑定,从而简化了数据访问层的开发。在传统的XML配置文件中,Ibatis允许我们定义SQL语句、参数映射以及结果集映射。然而...
"spring+ibatis配置实例"这个项目提供了一个完整的开发环境,包含所需的依赖包和标准化的项目结构,对初学者或开发者来说极具价值。 Spring是一个全面的Java应用框架,它提供了依赖注入(Dependency Injection,DI...
总结起来,Ibatis配置文件模板是构建Ibatis项目的基础,`SqlMap.properties`提供数据库连接信息,`SqlMapConfig.xml`负责全局配置,而JavaBean的映射文件则定义了数据库操作与Java对象的对应关系。理解并熟练掌握...
而iBatis(现已更名为MyBatis)则是一个基于Java的持久层框架,主要用于处理SQL语句的执行,并提供对象关系映射(ORM)功能。 当我们将Spring与iBatis进行整合时,可以充分利用Spring的依赖注入(DI)和面向切面...
iBATIS通过配置XML映射文件或注解来定义这种映射关系。映射文件通常包含SQL语句和结果映射,其中结果映射定义了数据库查询结果如何转换为Java对象。 例如,在一对多关系中,一个实体(如用户)可以有多个关联的实体...
在本文档中,我们将详细介绍iBatis在处理多对多关系时的配置和实现。 多对多关系 多对多关系是一种常见的关系数据库设计模式,用于描述两个实体之间的多对多关系。在本例中,我们将使用学生(Student)和教师...
在 iBatis 框架中,SQLMap配置是整个应用程序的核心部分,占据了大部分的开发工作。下面将详细解析 iBatis 中SQLMap配置的关键知识点: 1. **命名空间(Namespace)**: 命名空间是iBatis配置中的一个重要概念,它...
Ibatis 是一个优秀的轻量级 Java ORM(对象关系映射)框架,它允许开发者将 SQL 查询与 Java 代码分离,使得数据库操作更加灵活和可维护。在本文中,我们将深入探讨如何在 MyEclipse 开发环境中安装并配置 Ibatis,...
综上所述,搭建Struts2+Spring+Ibatis环境需要安装相应的jar包,并配置Struts2的`struts.xml`文件,以及可能涉及到的其他如Spring的配置文件。对于初学者来说,这个教程会指导他们如何整合这三个框架,创建一个完整...
2. **配置文件**: Ibatis的配置文件通常为`mybatis-config.xml`,包含了数据源、事务管理器、环境、插件、类型别名、映射文件等全局配置信息。在描述中提到的配置已经成功,意味着这个配置文件被正确解析并且能够...
- Spring框架负责管理这些组件的依赖关系,例如通过`applicationContext.xml`配置文件进行框架集成。 4. 配置文件: - `applicationContext.xml`是Spring的主配置文件,它定义了Spring容器中的bean,包括对Struts...
在本篇文章中,我们将深入探讨Ibatis的配置及其相关知识点。 首先,Ibatis的核心是SqlSessionFactory,它是通过SqlSessionFactoryBuilder创建的。SqlSessionFactoryBuilder从配置源(XML或Java Config)读取信息,...
iBatis的配置通常包括创建SqlMapConfig.xml文件,定义数据源、事务管理器以及映射文件(Mapper XML)。映射文件中包含具体的SQL语句和结果集映射,使得数据与Java对象之间能够进行绑定。 相比之下,Hibernate是一个...
iBatis的配置文件SqlMapConfig.xml是系统启动时加载的关键,它包含了数据源(DataSource)、事务管理器(TransactionManager)和SqlMap配置信息。解析这个XML文件的过程涉及到DOM或SAX解析器,源码中这部分功能通常...