如何将数据从hibernate显示到JavaFX的textarea并使用Button迭代它

时间:2015-08-29 09:33:58

标签: database hibernate javafx-8

我无法从测验表中获取测验并按下下一个按钮逐一显示在textarea中..请帮我找出解决方案

public class QuizesController implements Initializable {
    int id=1;

    @FXML
    private Label l1;
    @FXML
    private Label l2;
    @FXML
    private Label l3;
    @FXML
    private Label l4;
    @FXML
    private TextArea txtQuiz;
    @FXML
    private RadioButton c1;
    @FXML
    private RadioButton c2;
    @FXML
    private RadioButton c3;
    @FXML
    private Button btnNext;
    @FXML
    private Button btnStart;


    /**
     *
     * @param event
     * @throws IOException
     */
    @FXML
    public void setBtnNextclicked(javafx.event.ActionEvent event) throws IOException{

        SessionFactory sessionfactory=new Configuration().configure().buildSessionFactory();
        Session sessin=sessionfactory.openSession();
        sessin.beginTransaction();
        id++;
    //    String query="select question,choicea,choiceb,choicec from student where id=:id";
    //    Query hql=sessin.createQuery(query).setParameter("id",id);
        Quiz q=(Quiz) sessin.get(Quiz.class,id);
        txtQuiz.setText(q.question);
        c1.setText(q.getChoicea());
        c2.setText(q.getChoiceb());
        c3.setText(q.getChoicec());

        sessin.close();


    }

0 个答案:

没有答案