public void save(final WKPaper paper) { jdbcAux.execute( new StatementCreator() { @Override public PreparedStatement createStatement(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement( "insert into wk_paper(name, description, score, name_publisher)values(?,?,?,?)"); ps.setString(1, paper.name); ps.setString(2, paper.description); ps.setInt(3, paper.score); ps.setString(4, paper.name_publisher); return ps; } }); }
public void update(final WKPaper paper) { jdbcAux.execute( new StatementCreator() { @Override public PreparedStatement createStatement(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement( "update wk_paper set name=?,description=?,score=?,name_publisher=? where id=?"); ps.setString(1, paper.name); ps.setString(2, paper.description); ps.setInt(3, paper.score); ps.setString(4, paper.name_publisher); ps.setInt(5, paper.id); return ps; } }); }
public void delete(int id) { jdbcAux.execute("DELETE from wk_paper where id = ?", id); jdbcAux.execute("DELETE from wk_question_meta where id_paper = ?", id); }
public void addChapter(int paperId, int chapterId) { jdbcAux.execute( "insert into r_paper_chapter(id_paper, id_chapter)values(?,?)", paperId, chapterId); }
public WKPaper get(int id) { return jdbcAux.queryForObject("select * from wk_paper where id = " + id, MAPPING); }
public List<WKPaper> getAll() { return jdbcAux.queryForList(SELECT, MAPPING); }