论坛首页 Java企业应用论坛

iBatis 关系的配置,!

浏览 13699 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-01-23  
程序所涉及的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
<?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" // [color=red]****[/color]
		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
<?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
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
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
<?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
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
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 *******************
	<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
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
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" 运行的错误信息 ******
	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	
   发表时间:2007-01-23  
为什么系统把我“”,两个字给删掉了?why?
0 请登录后投票
   发表时间:2007-01-23  
又给删了,,晕。
0 请登录后投票
   发表时间:2007-01-23  

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. 



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" 


查查配置文件Child.xml,看看这个类com.domain.base.BaseParent!
0 请登录后投票
   发表时间:2007-01-23  
应该是少了cglib包,你下载一个cglib-nodep-2.1_3.jar包再试试。
0 请登录后投票
   发表时间:2007-01-23  
com.domain.base.BaseParent 这个类上面有阿?没看到有什么问题?

另外就是因为我有 cglib 的jar才会出现的这个错误,如果我本地没有cglib的jar,那么enhancementEnabled 是false或true, 都不出异常,但是都没有延迟加载!!!
但是我想实现延迟加载。。
们没有一个 能够延迟加载的例子,分享一下么?
0 请登录后投票
   发表时间:2007-01-23  
另外我再说明一下,,
如果没有 com.domain.base.BaseParent 的话,即把所有的信息都放在 com.domain.Parent 中,这样的配置运行是没有问题的,完全正常。

但是我想把一个表中的信息分开,即 com.domain.base.BaseParent是一些基本信息,其中的属性和对应的表一一对应, 而 com.domain.Parent 中加一些扩展信息,比如查询信息,一些需要计算的信息,等,这样方便维护。
但是就会出现上面的错误。不知有何办法解决?

0 请登录后投票
   发表时间:2007-01-23  
问题已解决,,
原来在我实际中
com.domain.base.BaseParent 的构造函数中有一个protected的方法,即
public BaseParent(){
    init();
}
protected void init(){}
把这个方法去掉就可以了
原来需要cglib的po的构造函数中不能加任何别的方法
如果加了 protected 的方法,会出现异常
如果加了 public 的方法,不会出异常,但延迟加载会无效。
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics