dtr*_*unk 14 java hibernate hibernate-criteria
我正在尝试通过外键过滤结果集:
createCriteria(Person.class).add(Restrictions.ne("position", 1L)).list()
但得到这个例外: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.example.model.Position.id
以下是必要的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;
    }
}
| 归档时间: | 
 | 
| 查看次数: | 14666 次 | 
| 最近记录: |