我在hibernate中遵循JOIN查询时遇到麻烦:
来自proposal_evaluate_backoffice pab INNER JOIN pab.proposal pp INNER JOIN pab.analisys_backoffice ab其中pp.sq_proposal =:sqProposal
其中“proposal_evaluate_backoffice”表将“proposal”和“analisys_backoffice”表引用为@JoinColumn > @ManyToOne
注释
我得到了关注错误:
org.hibernate.QueryException:无法解析属性:提议:com.skyautomate.model.Proposal_Evalaute_Backoffice [来自com.skyautomate.model.Proposal_Evaluate_Backoffice pab INNER JOIN pab.proposal pp INNER JOIN pab.analisys_backoffice ab其中pp.sq_proposal =:sqProposal]]有根本原因 org.hibernate.QueryException:无法解析属性:提议:com.skyautomate.model.Proposal_Evaluate_Backoffice
按照我的代码:
@Entity
@Table(name="proposal_evaluate_backoffice")
public class Proposal_Evaluate_Backoffice implements Serializable {
@Id
@ManyToOne
@JoinColumn(name="sq_proposal")
private Proposal sq_proposal;
@Id
@ManyToOne
@JoinColumn(name="sq_evaluate_backoffice")
private Evaluate_Backoffice sq_evaluate_backoffice;
我没有针对Hibernate(Hibernate.cfg.xml)的特定文件配置,但我已将所有配置放在“applicationContext.xml”中,因为我也使用了Spring MVC。
遵循我声明bean的applicationContext.xml文件的代码:
<!-- Hibernate 4 SessionFactory Bean definition -->
<beans:bean id="hibernate4AnnotatedSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>com.skyautomate.model.Proposal</beans:value>
<beans:value>com.skyautomate.model.Evaluate_Backoffice</beans:value>
<beans:value>com.skyautomate.model.Proposal_Evaluate_Backoffice</beans:value>
</beans:list>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect
</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
<beans:prop key="hibernate.default_schema">spweb</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
有什么想法吗?
答案 0 :(得分:1)
这是因为提案字段的名称是sq_proposal。你应该通过字段名称来获取。
使用实体内部的定义将HQL转换为SQL:实体的名称(From子句)和其他子句的字段名称。