很奇怪的问题org.hibernate.QueryException: Unable to resolve path
[code=XML][/code]今天搞了个测试用myeclipse下oracle8.1.7和hibernate3.0+spring2.0做个测试,平台是tomcate6.0
建了一个表叫test,里面有name,age等等几个属性吧
然后做映射
然后写dao查询
用了HibernateTemplate
然后就出现怪事了
如果用回调,使用createSQLQuery来运行sql语句,就没问题,一切查询正常
如果运行hql语句,比如"from po.test where test.name = sdf"
不管是直接用HibernateTemplate还是用回调,都会报下面这个错
org.hibernate.QueryException: Unable to resolve path [test.name], unexpected token [test] [SELECT * from po.test where test.name = sdf]
配置文件test.hbm.xml,把头部声明去掉了,
<hibernate-mapping> <class name="po.test" table="TEST" schema="TEST"> <id name="id" type="java.lang.Long"> <column name="ID" precision="22" scale="0" /> <generator class="sequence" /> </id> <property name="name" type="java.lang.String"> <column name="NAME" length="12" /> </property> ………………此处省略许多property配置 </class><hibernate-mapping>
<bean id="SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="DataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.Oracle8iDialect </prop> </props> </property> <property name="mappingResources"> <list> <value>po/test.hbm.xml</value> </list> </property> </bean> <bean id="testDAO" class="dao.testDAO"> <property name="sessionFactory"> <ref bean="SessionFactory" /> </property> </bean>