public boolean addLoan(Comic c, Person p, String d) { Loan l = new Loan(); l.setComic(c); l.setPerson(p); l.setDate(d); boolean rta = loandao.add(l); return rta; }
public List<Loan> getAll() { List<Loan> list = new ArrayList<Loan>(); try { PreparedStatement ps; ResultSet res; ps = conn.getConn().prepareStatement(SQL_GET_ALL); res = ps.executeQuery(); Comic c = new Comic(); Person p = new Person(); while (res.next()) { Loan l = new Loan(); l.setIdLoan(res.getInt("idLoan")); l.setComic(c); c.setNameComic(res.getString("nameComic")); l.setPerson(p); p.setNamePerson(res.getString("namePerson")); l.setDate(res.getString("date")); list.add(l); } } catch (SQLException e) { e.printStackTrace(); } finally { conn.closeConnection(); } return list; }