浏览 2804 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2007-05-03
domain User 类里有一个 address类的属性 如下 public class User { /** @pdOid bc66dbcf-5b84-4673-a9f8-fe17a8b07387 */ private java.lang.String id; /** @pdOid 47caf74d-6d89-4d94-9746-608859015ec4 */ private java.lang.String name; /** @pdOid 07c34ea6-5ae1-464a-92b3-e36d888fadd5 */ private Address address; /** @pdOid 6d6129f5-9fdd-496e-8436-9a0dfb2c8efe */ public java.lang.String getId() { return id; } /** @param newId * @pdOid 53d4304a-f789-4f7d-ad22-0aef4e20949c */ public void setId(java.lang.String newId) { id = newId; } /** @pdOid 612a03d8-3b1b-4d2b-bd24-30015821ae97 */ public java.lang.String getName() { return name; } /** @param newName * @pdOid 338694a9-9ccf-49aa-a960-3a84cfa91e82 */ public void setName(java.lang.String newName) { name = newName; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } public class Address { /** @pdOid 33ce27ec-a4d1-42a9-9cdd-4bba14c0ee79 */ private java.lang.String id; /** @pdOid e4d9b0f7-d8b5-40c1-b6fb-f8376c1ca34e */ private java.lang.String addname; /** @pdRoleInfo migr=no name=User assc=association1 mult=1..1 type=Composition */ public User user; /** @pdOid c6be2677-fd4e-446c-9995-3022e36c0171 */ public java.lang.String getId() { return id; } /** @param newId * @pdOid 14928d3a-2953-4b2a-bd6c-b3b2d202c1ef */ public void setId(java.lang.String newId) { id = newId; } /** @pdOid de1d8ee3-422c-4295-97b1-d36f6baf8ab0 */ public java.lang.String getAddname() { return addname; } /** @param newAddname * @pdOid 3efc3bb5-9fed-479a-a58f-028eeb29349b */ public void setAddname(java.lang.String newAddname) { addname = newAddname; } 1.配置文件如下 <sqlMap namespace="user"> <typeAlias alias="user" type="com.yirong.ums.domain.User"/> <typeAlias alias="address" type="com.yirong.ums.domain.Address"/> <resultMap id="userResult" class="user"> <result property="id" column="ID"/> <result property="name" column="NAME"/> <result property="address" column="ADDRESSID" select="user.retriveaddress" /> </resultMap> <resultMap id="addressResult" class="address"> <result property="id" column="ID"/> <result property="addname" column="ADDNAME"/> </resultMap> <statement id="retriveuser" resultMap="userResult" parameterClass="string"> select * from T_USER where ID=#value# </statement> <statement id="retriveaddress" resultMap="addressResult" parameterClass="string" > select * from ADDRESS where ID=#value# </statement> </sqlMap> 为什么关联查询的时候就是查不了呢.? 我要通过 address 这个属性来关联查询就是查不了. 报出如下错误 java.lang.NullPointerException at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:782) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:176) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:154) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:883) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:573) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:83) at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.getResult(ResultLoader.java:77) at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadObject(EnhancedLazyResultLoader.java:130) at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.invoke(EnhancedLazyResultLoader.java:113) at com.yirong.ums.domain.Address$$EnhancerByCGLIB$$89dbf808.toString(<generated>) at java.lang.String.valueOf(String.java:2615) at java.lang.StringBuffer.append(StringBuffer.java:220) at com.yirong.ums.service.UserTest.testRetriveUser(UserTest.java:31) 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 junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69) 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.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.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) 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |