I'm working with JavaFX and I want to implement a filter that is accesing data from a database. The code below access data from two tables in a database. The data is retrivied and put in a tableview, using javaFx. My problem is that the last column from the tableview remains empty. The code is ruing well, is working fine but that last column should not be empty. I must say that data for the last column comes from one table and the data for the others columns come from the other table.
So, why my last column is empty?
@FXML
private void handleButtonAction(ActionEvent e) throws SQLException {
tableFilter.getItems().clear();
DBMain.createCoection();
DBMain.setStatement(DBMain.getCoection().createStatement());
ResultSet results=null;
CheckBox[] boxes = new CheckBox[]{checkAn1, checkAn2, checkAn3, checkSemestrul1, checkSemestrul2,
sdd, soo, analiza, algebra, marketing, economie, poo, cibeetica, contabilitate,curs1,curs2,curs3,curs4,curs5,curs6,curs7};
List<Function<Boolean, String>> clausesConstructor = Arrays.asList(
b -> b ? "an=1" : null,
b -> b ? "an=2" : null,
b -> b ? "an=3" : null,
b -> b ? "semestru=1" : null,
b -> b ? "semestru=2" : null,
b -> b ? "lower(denumire)='structuri de date'": null,
b -> b ? "lower(denumire)='sisteme de operare'": null,
b -> b ? "lower(denumire)='analiza'": null,
b -> b ? "lower(denumire)='algebra'": null,
b -> b ? "lower(denumire)='marketing'": null,
b -> b ? "lower(denumire)='economie'": null,
b -> b ? "lower(denumire)='programare orientata obiect'": null,
b -> b ? "lower(denumire)='cibeetica'": null,
b -> b ? "lower(denumire)='contabilitate'": null,
b -> b ? "numar_curs=1": null,
b -> b ? "numar_curs=2": null,
b -> b ? "numar_curs=3": null,
b -> b ? "numar_curs=4": null,
b -> b ? "numar_curs=5": null,
b -> b ? "numar_curs=6": null,
b -> b ? "numar_curs=7": null
);
List<String> list = IntStream.range(0, boxes.length)
.mapToObj(i -> clausesConstructor.get(i).apply(boxes[i].isSelected()))
.filter(Objects::nonNull).collect(Collectors.toList());
results=DBMain.getStatement().executeQuery(list.isEmpty() ? "SELECT * FROM discipline d, curs c " : list.stream().collect(Collectors.joining(") AND (", "SELECT * FROM discipline d, curs c WHERE c.id_disciplina=d.id_disciplina AND (", ")")));
System.out.println(list.isEmpty() ? "SELECT * FROM table" : list.stream().collect(Collectors.joining(") AND (", "SELECT * FROM discipline d, curs c WHERE c.id_disciplina=d.id_disciplina AND (", ")")));
while(results.next()){
String denumire=results.getString("denumire");
int an=(results.getInt("an"));
int semestru=(results.getInt("semestru"));
int numar_curs=(results.getInt("numar_curs"));
this.masterData.add(new Disciplina(denumire,an,semestru,numar_curs));
}
results.close();
DBMain.getStatement().close();
// Initialize the person table
Denumire.setCellValueFactory(
new PropertyValueFactory<Disciplina, String>("denumire"));
An.setCellValueFactory(
new PropertyValueFactory<Disciplina, Integer>("an"));
Semestru.setCellValueFactory(
new PropertyValueFactory<Disciplina, Integer>("semestru"));
numarCurs.setCellValueFactory(
new PropertyValueFactory<Disciplina, Integer>("numar_curs"));
tableFilter.setItems(masterData);
}
@FXML
private TableView<Disciplina> tableFilter;
@FXML
private TableColumn<Disciplina, String> Denumire;
@FXML
private TableColumn<Disciplina, Integer> An;
@FXML
private TableColumn<Disciplina, Integer> Semestru;
@FXML
private TableColumn<Disciplina, Integer> numarCurs;

