Ich versuche, ein Ergebnis, das durch einen Fremdschlüssel gesetzt zu filtern:kann keinen Feldwert durch Reflexion Getter bekommen
createCriteria(Person.class).add(Restrictions.ne("position", 1L)).list()
Aber immer diese Ausnahme: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.example.model.Position.id
hier die notwendigen JPA Entitäten (auf die erforderlichen Felder abgespeckte):
@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;
}
}
Versuchen 'Restrictio Versuchen ns.ne ("position.id", 1L) ' –
Danke! Das hat mein Problem gelöst. Kannst du es als Antwort geben? Also kann ich es akzeptieren. – dtrunk