简体   繁体   English

无法通过反射getter获取字段值

[英]Could not get a field value by reflection getter

I'm trying to filter a result set by a foreign key: 我正在尝试通过外键过滤结果集:

createCriteria(Person.class).add(Restrictions.ne("position", 1L)).list()

But getting this exception: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.example.model.Position.id 但是得到这个异常: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.example.model.Position.id

Here are the necessary JPA entities (trimmed down to the necessary fields): 以下是必要的JPA实体(修剪到必要的字段):

@Entity
@Table
public class Person {
    @Id
    @GeneratedValue
    private Long id;

    @ManyToOne
    @JoinColumn(nullable = false)
    @ForeignKey(name = "person_position_fkey")
    private Position position;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Position getPosition() {
        return position;
    }

    public void setPosition(Position position) {
        this.position = position;
    }
}

@Entity
@Table
public class Position {
    @Id
    @GeneratedValue
    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}

试试Restrictions.ne("position.id", 1L)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PropertyAccessException:无法通过反射获取器获取字段值 - PropertyAccessException: could not get a field value by reflection getter JPA-Hibernate-“无法通过继承的反射获取器获取字段值 - JPA-Hibernate - “could not get a field value by reflection getter of with inheritance PropertyAccessException:使用Hibernate时无法通过反射getter获取字段值 - PropertyAccessException: could not get a field value by reflection getter While using Hibernate org.hibernate.PropertyAccessException:无法通过反射getter获取字段值 - org.hibernate.PropertyAccessException: could not get a field value by reflection getter of 休眠-此映射正确吗? 无法通过反射吸气剂获得字段值? - Hibernate - Is this mapping correct? could not get a field value by reflection getter? 错误:-org.hibernate.PropertyAccessException:无法通过反射获取器获取字段值 - Error :- org.hibernate.PropertyAccessException: could not get a field value by reflection getter 简单的Hibernate应用程序无法正常工作:PropertyAccessException:无法通过反射getter获取字段值 - Simple Hibernate Application not working: PropertyAccessException: could not get a field value by reflection getter of 无法通过反射getter和查询来求和一个字段,以求纯Hibernate中的多列求和 - could not get a field value by reflection getter and query to sum multiple columns in pure Hibernate 无法通过反射休眠获取字段值 - could not get a field value by reflection hibernate 无法通过反射设置字段值 - Could not set field value by reflection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM