gpt4 book ai didi

java - hibernate : org. hibernate .QueryException

转载 作者:行者123 更新时间:2023-11-29 08:25:47 25 4
gpt4 key购买 nike

我有一个 org.hibernate.QueryException,我很难理解为什么。

hibernate 未解析的属性 langue_id 在我的实体 Conditionnement 中定义。

堆栈跟踪

Caused by: org.hibernate.QueryException: could not resolve property: langue_id of: fr.sita.g2fm.domain.referentiel.Conditionnement
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:62) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:56) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1805) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.criteria.EntityCriteriaInfoProvider.getType(EntityCriteriaInfoProvider.java:39) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getPathInfo(CriteriaQueryTranslator.java:228) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.criteria.CriteriaQueryTranslator.createCriteriaEntityNameMap(CriteriaQueryTranslator.java:212) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:94) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:71) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1760) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:363) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]

实体

@Entity
@Data
@Table(uniqueConstraints = @UniqueConstraint(name = "UNIQUE_CONDITIONNEMENT_DESIGNATION", columnNames = {
"designation"}))
public class Conditionnement implements IdObject, Serializable {
private static final long serialVersionUID = 7096113289274101792L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private Long codeConditionnement;

@NotNull(message = ERROR_CODE_MANDATORY_FIELD)
private String designation;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "langue_id")
@NotNull(message = ERROR_CODE_MANDATORY_FIELD)
@ForeignKey(name = "FK_CONDITIONNEMENT_LANGUE")
private Langue langue;
}

终于是我DAO中的方法了

  @Override
public List<Conditionnement> find(ConditionnementCriteria conditionnementCriteria) {
Criteria criteria = getHibernateSession().createCriteria(Conditionnement.class, "c");
criteria.createCriteria("c.langue_id", "l", JoinType.LEFT_OUTER_JOIN);

return criteria.list();
}

你知道是什么导致了这个异常吗?

感谢您的帮助。

最佳答案

c.langue_id 更改为 c.langue 如下所示,因为 hibernate 无法找到名称为 langue_id 的列。

public List<Conditionnement> find(ConditionnementCriteria conditionnementCriteria) {
Criteria criteria = getHibernateSession().createCriteria(Conditionnement.class, "c");
criteria.createCriteria("c.langue", "l", JoinType.LEFT_OUTER_JOIN);

return criteria.list();
}

关于java - hibernate : org. hibernate .QueryException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53322717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com