Could not resolve property Hibernate

两盒软妹~` 提交于 2020-01-25 06:10:48

问题


I have 2 entities whose extracts are like these:

public class Visita {
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="pdv_uid")
    private PuntoDeVenta pdv;
}

public class PuntoDeVenta {
    private Integer idclient;

    private String zona;

    @ManyToOne
    @JoinColumn(name="pdv_categoria_uid", nullable=true)
    private PuntoDeVentaCategoria categoria;
}

public class PuntoDeVentaCategoria {
    private String descripcion;
}

I try to do restrictions with the differents fields and some of them work, some of them don't.

With this root criteria:

Criteria criteria =   sessionFactory.getCurrentSession().createCriteria(Visita.class).createAlias("pdv", "pdv");

I try to make restrictions with the differents fields of "PuntoDeVenta" and "PuntoDeVentaCategoria" (with and without the createAlias) and I get the exception "could not resolve property", for example:

Criteria criteria =   sessionFactory.getCurrentSession().createCriteria(Visita.class).createAlias("pdv", "pdv").add(Restrictions.eq("pdv.categoria.descripcion", "example"));

I've researching and I didn't found anything for my case.

Thank you in advance

来源:https://stackoverflow.com/questions/26176915/could-not-resolve-property-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!