我在冬眠中要遵循JOIN查询时遇到了麻烦:
来自proposal_evaluate_backoffice pab内部联接pab.proposal pp内部联接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_b proposal Probal = Proposal ]]与根本原因
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),但是由于我也使用Spring MVC,因此我将所有配置都放在了“ applicationContext.xml”中。
遵循我声明了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>
有任何想法吗?
最佳答案
发生这种情况是因为投标字段的名称为sq_proposal。您应该按字段名称获取。
使用实体内部的定义将HQL转换为SQL:实体名称(From子句)和其他子句的字段名称。