是这样的,
如果你不写对象名称,直接写字段,那么hibernate就按照数据库字段进行查找如果你写 (对象名.对象属性),那么hibernate就按照ormapping中的映射字段进行查找这是hibernate的灵活之处!!
hql2:修改位 sql = " from VSubjects as V where V.fkExamName = ? order by V.cnumber, V.mnumber desc";( fkExamName为 ormapping中的 属性名称 )
如果你不写对象名称,直接写字段,那么hibernate就按照数据库字段进行查找如果你写 (对象名.对象属性),那么hibernate就按照ormapping中的映射字段进行查找这是hibernate的灵活之处!!
hql2:修改位 sql = " from VSubjects as V where V.fkExamName = ? order by V.cnumber, V.mnumber desc";( fkExamName为 ormapping中的 属性名称 )
解决方案 »
- tomcat服务器部署项目
- 表单提交编码问题 utf-8 你到底哪里去了。。。
- java问题,如何做一个让一个文本域A自动获取另一个文本域B里的内容。并跟A已有的文字拼接在一起。急……
- 求助一个struts2+tomcat的问题,百思不得其解啊
- 实现QQ在线状态WEB服务时报错,请大牛门指教。
- 如何将一个string类型的字符串转化成URL类型呀~~~
- 谁来救救我,我的WEBSPHERE近这几个星期常常死掉服务!
- 请问一个问题:ant和junit的问题
- struts数据库连接老是出错误,在线等,帮看一下,
- 为啥jsp中显示不出当前日期
- commons fileupload 上传文件路径问题
- 关于相对路径的问题!!!十万火急!!!
下面是错误,无法识别属性,,你看到我的hql没有,我前面是对象名,后面的是数据库视图的字段名,正常情况下写HQL,用的都是对象的属性啊。。
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: fkExamName of: com.ems.database.hibernate3.pojo.VExamSubjects [ from com.ems.database.hibernate3.pojo.VExamSubjects as v where v.fkExamName = ? order by cnumber, mnumber desc]; nested exception is org.hibernate.QueryException: could not resolve property: fkExamName of: com.ems.database.hibernate3.pojo.VExamSubjects [ from com.ems.database.hibernate3.pojo.VExamSubjects as v where v.fkExamName = ? order by cnumber, mnumber desc]
org.hibernate.QueryException: could not resolve property: fkExamName of: com.ems.database.hibernate3.pojo.VExamSubjects [ from com.ems.database.hibernate3.pojo.VExamSubjects as v where v.fkExamName = ? order by cnumber, mnumber desc]
...
检查一下个有关找个属性得 配置,还有它得get,set方法
对应的pojo类的get set方法也要有对应!
hql1:
sql = " from VSubjects where fk_Exam_Name = ? order by cnumber, mnumber desc";
用视图字段名是可以的fk_Exam_Name。。??为什么
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.ems.database.hibernate3.pojo.VSubjects" table="V_SUBJECTS" schema="EMS">
<composite-id name="id" class="com.ems.database.hibernate3.pojo.VSubjectsId">
<key-property name="classpk" type="string">
<column name="CLASSPK" length="32" />
</key-property>
<key-property name="name" type="string">
<column name="NAME" length="50" />
</key-property>
<key-property name="pk" type="string">
<column name="PK" length="32" />
</key-property>
<key-property name="fkExamName" type="string">
<column name="FK_EXAM_NAME" length="32" />
</key-property>
<key-property name="subject" type="string">
<column name="SUBJECT" length="50" />
</key-property>
<key-property name="fkSetPaperTeacher" type="string">
<column name="FK_SET_PAPER_TEACHER" length="32" />
</key-property>
<key-property name="isntUnifiedSubject" type="string">
<column name="ISNT_UNIFIED_SUBJECT" length="4" />
</key-property>
<key-property name="subjectAlias" type="string">
<column name="SUBJECT_ALIAS" length="50" />
</key-property>
<key-property name="cnumber" type="long">
<column name="CNUMBER" precision="22" scale="0" />
</key-property>
<key-property name="unumber" type="long">
<column name="UNUMBER" precision="22" scale="0" />
</key-property>
<key-property name="mnumber" type="long">
<column name="MNUMBER" precision="22" scale="0" />
</key-property>
<key-property name="nnumber" type="long">
<column name="NNUMBER" precision="22" scale="0" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>