I want to populate JavaFX TableView from result of HQL query. I've model class as follow.
package Entity;
// Generated Nov 23, 2019 12:28:42 AM by Hibernate Tools 4.3.1
import java.util.Date;
/**
* Emp generated by hbm2java
*/
public class Emp implements java.io.Serializable {
private int id;
private String name;
private String designation;
private Date dob;
public Emp() {
}
public Emp(int id) {
this.id = id;
}
public Emp(int id, String name, String designation, Date dob) {
this.id = id;
this.name = name;
this.designation = designation;
this.dob = dob;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getDesignation() {
return this.designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
public Date getDob() {
return this.dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
}
I want to create a function which populates the TableView with rows and columns based on result of HQL query.
@FXML
private TableView tbl;
Query myQry = session.createQuery("select e.id, e.name, e.designation, e.dob from Emp e where e.id<10");
populateTable(myQry);
public void populateTable(Query qry)
{
???
}
How can I populate javaFx table based on result of HQL query?
I had already asked this question Here : Dynamically generate columns and rows of javaFX TableView from result of HQL query but someone marked it as Duplicate without reading my question properly. He suggested this answer : JavaFX MySQL connection example please
But this answer is related to SQL not HQL. It neither talks about HQL nor dynamically create columns. My Question is about Dynamically generating columns and rows of javaFX TableView from result of HQL query.
Thanks.