在hibernate中,从主表查询没有问题,但是从子表查询就报问题了,郁闷中在线等,马上结贴Hibernate: select this_.ID as ID9_1_, this_.NAME as NAME9_1_, this_.AMOUNT as AMOUNT9_1_, this_.ADDRESS as ADDRESS9_1_, this_.PLACE_ID as PLACE5_9_1_, place2_.ID as ID8_0_, place2_.Name as Name8_0_, place2_.ADDRESS as ADDRESS8_0_ from CLASSROOM this_, PLACE place2_ where this_.PLACE_ID=place2_.ID
2006-09-13 17:25:30,093 INFO [org.hibernate.type.IntegerType] - <could not read column value from result set: ADDRESS9_1_; 无法转换为内部表示>
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.ID as ID9_1_, this_.NAME as NAME9_1_, this_.AMOUNT as AMOUNT9_1_, this_.ADDRESS as ADDRESS9_1_, this_.PLACE_ID as PLACE5_9_1_, place2_.ID as ID8_0_, place2_.Name as Name8_0_, place2_.ADDRESS as ADDRESS8_0_ from CLASSROOM this_, PLACE place2_ where this_.PLACE_ID=place2_.ID]; SQL state [null]; error code [17059]; 无法转换为内部表示; nested exception is java.sql.SQLException: 无法转换为内部表示
Caused by: java.sql.SQLException: 无法转换为内部表示
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.CharCommonAccessor.getInt(CharCommonAccessor.java:132)
at oracle.jdbc.driver.OracleResultSetImpl.getInt(OracleResultSetImpl.java:521)
at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1563)2006-09-13 17:25:30,093 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 17059, SQLState: null>
2006-09-13 17:25:30,093 ERROR [org.hibernate.util.JDBCExceptionReporter] - <无法转换为内部表示> at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:236)
at org.hibernate.type.IntegerType.get(IntegerType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1983)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1562)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.springframework.orm.hibernate3.HibernateTemplate$5.doInHibernate(HibernateTemplate.java:526)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.loadAll(HibernateTemplate.java:522)
at com.xjj.core.commons.AbstractHibernateDao.getAll(AbstractHibernateDao.java:64)
at com.xjj.rlt.classroom.dao.junit.ClassroomDaoJunitTest.testGetAllClassroom(ClassroomDaoJunitTest.java:24)
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)
主:place
<set name="classroom" table="CLASSROOM" inverse="true" cascade="save-update">
        <key column="place_id" foreign-key="fk"/>
<one-to-many class="Classroom"/>
   </set>从:classroom
<many-to-one name="place" column="PLACE_ID" class="Place" not-null="true"/>dao:
public class ClassroomDao extends BaseHibernateDao {
protected Class getEntityClass() {
return Classroom.class;
} public List getAllClassroom(){
System.out.println("----------");
Criteria criteria = getSession().createCriteria(getEntityClass());
criteria.addOrder(Order.asc("id"));
return criteria.list();

}

}junit: public void testGetAllClassroom(){
try{
ApplicationContext context = new ClassPathXmlApplicationContext("springConfigDaoTest.xml");

ClassroomDao cd = (ClassroomDao)context.getBean("classroom");
List lst = cd.getAll();
System.out.println("----" + lst.size());
}catch(Exception e){
e.printStackTrace();
}
}