如何将JavaFX属性bean映射到DBUtils BeanHandler

时间:2018-07-23 01:12:43

标签: java apache javafx tableview apache-commons-dbutils

我有一个用JavaFX设置的TableView,它由一个数据模型备份,该数据模型将这些类型的字段与getter和setter一起使用:

javafx.beans.property.SimpleIntegerProperty;
javafx.beans.property.SimpleStringProperty;

获取器和设置器如下:

public String getName()
{
    return this.name.get();
}

public void setName(String name)
{
    this.name.set(name);
}

我想像这样使用Apache DBUtils从SQL填充数据:

    ResultSetHandler<Person> resultHandler = new BeanHandler<Person>(Person.class);

错误提示:

java.sql.SQLException: Cannot set id: null

等效类适用于常规String,Integer,getName()等...

有没有一种方法可以为TableView重用数据模型?我不想使用其他类,然后再手动对其进行映射...

0 个答案:

没有答案