Hibernate: org.hibernate.QueryException


Criano:

I have an org.hibernate.QueryException and I'm having a hard time understanding why.

The property langue_id which hibernate condition cannot resolve is defined in my entity Conditionnement.

stack trace

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

@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;
}

Finally the method in my 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();
  }

Do you know what is causing this exception?

thank you for your help.

cнŝdk :

The exception is simple, it says:

Caused by: org.hibernate.QueryException: Cannot resolve property: langue_id: fr.sita.g2fm.domain.referentiel.Conditionnement

So, the problem is that it Hibernatecan't find the property langue_idin your Conditionnemententity, which is treated as Hibernatean Object/Relational Mapping (ORM) framework, so instead , it will look for classes and not tables .objects/entitiestablespropertiescolumns

In your entity you have:

private Langue langue;

So you need to execute the following query:

@Override
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();
}

Related


Hibernate: org.hibernate.QueryException

Criano: I have an org.hibernate.QueryException and I'm having a hard time understanding why. The property langue_id which hibernate condition cannot resolve is defined in my entity Conditionnement. stack trace Caused by: org.hibernate.QueryException: could not

Hibernate: org.hibernate.QueryException

Criano: I have an org.hibernate.QueryException and I'm having a hard time understanding why. The property langue_id which hibernate condition cannot resolve is defined in my entity Conditionnement. stack trace Caused by: org.hibernate.QueryException: could not

Hibernate: org.hibernate.QueryException

Criano: I have an org.hibernate.QueryException and I'm having a hard time understanding why. The property langue_id which hibernate condition cannot resolve is defined in my entity Conditionnement. stack trace Caused by: org.hibernate.QueryException: could not

org.hibernate.QueryException: not an association

Jones I want to add order by restricting a condition in Hibernate. I have two tables Event and MainEvent with a one-to-many relationship (MainEvent has many events). final Criteria criteria = getCurrentSession().createCriteria( Event.class);

org.hibernate.QueryException: Cannot resolve property

TO: I have the following JPA class. /** * The persistent class for the ACCOUNT database table. * */ @Entity @Table(name="ACCOUNT") public class Account implements Serializable { private static final long serialVersionUID = 1L; @Id @XmlID @Column(name="ACC

org.hibernate.QueryException: Cannot resolve property

TO: I have the following JPA class. /** * The persistent class for the ACCOUNT database table. * */ @Entity @Table(name="ACCOUNT") public class Account implements Serializable { private static final long serialVersionUID = 1L; @Id @XmlID @Column(name="ACC

org.hibernate.QueryException: Cannot resolve property

South Africa I have the following JPA class. /** * The persistent class for the ACCOUNT database table. * */ @Entity @Table(name="ACCOUNT") public class Account implements Serializable { private static final long serialVersionUID = 1L; @Id @XmlID @Column(

org.hibernate.QueryException: Cannot resolve property

TO: I have the following JPA class. /** * The persistent class for the ACCOUNT database table. * */ @Entity @Table(name="ACCOUNT") public class Account implements Serializable { private static final long serialVersionUID = 1L; @Id @XmlID @Column(name="ACC

org.hibernate.QueryException: Cannot resolve property

Chen Yuhua I want to get the sum of a column in a table. public class PaymentLogDAO extends AbstractModel<PaymentLog> { public PaymentLogDAO() { super(PaymentLog.class); } public BigDecimal sum(String keyword) { try {

org.hibernate.QueryException: Cannot resolve property: filename

Ankit Lamba: I am using Hibernate to get values Criteriafrom filenamea column of a table contaque_recording_log. but when i get the result it throws an exception org.hibernate.QueryException: Cannot resolve property: filename of com.contaque.hibernateTableMapp

org.hibernate.QueryException: Cannot resolve property: filename

Ankit Lamba: I am using Hibernate to get values Criteriafrom filenamea column of a table contaque_recording_log. but when i get the result it throws an exception org.hibernate.QueryException: Cannot resolve property: filename of com.contaque.hibernateTableMapp

org.hibernate.QueryException: Cannot resolve property: filename

Ankit Lamba: I am using Hibernate to get values Criteriafrom filenamea column of a table contaque_recording_log. but when i get the result it throws an exception org.hibernate.QueryException: Cannot resolve property: filename of com.contaque.hibernateTableMapp