我從JPA中的多個表中檢索一些數據。 這裏的第一個實體:如何從與另一個JPA實體相關的JPA實體中檢索JavaFX表的數據?
@Entity
@Table(name = "source")
public class Source implements Serializable {
@Id
@Column(name = "sourceid", nullable = false)
private String sourceId;
@ManyToOne
@JoinTable(name = "flux")
private Flux flux;
// Other attributes
// Constructors, getters and setters
}
這裏是第二個實體,即從第一個引用:
@Entity
@Table(name = "flux")
public class Flux implements Serializable {
@EmbeddedId
private FluxId fluxId = new FluxId();
@Column(name = "value")
private BigDecimal value;
@Column(name = "error")
private BigDecimal error;
// Other attributes
// Constructors, getters and setters
}
我想在一個單一的JavaFX表來顯示這些表的數據。怎麼做?這是我正在嘗試做的,但flux.value
和flux.error
的列總是空的。如何解決這個問題?
// Source table setup
sourceIdColumn.setCellValueFactory(new PropertyValueFactory<>("sourceId"));
fluxColumn.setCellValueFactory(new PropertyValueFactory<>("flux.value")); // Value of the flux
errorColumn.setCellValueFactory(new PropertyValueFactory<>("flux.error")); // Error of the flux
// More columns definition from sources attributes