public Filial obter(String nome) throws ClassNotFoundException, SQLException, IOException { Filial loaded = null; FilialRecord result = GerenciadorBD.getContext().selectFrom(FILIAL).where(FILIAL.NOME.eq(nome)).fetchOne(); if (result != null) { loaded = new Filial(result.getIdfilial(), result.getNome()); } return (loaded); }
@Override public Filial novo(Filial novo) throws ClassNotFoundException, SQLException, IOException { FilialRecord created = GerenciadorBD.getContext() .insertInto(FILIAL, FILIAL.NOME) .values(novo.getNome()) .returning() .fetchOne(); if (created != null) { novo.setId(created.getIdfilial()); return (novo); } return (null); }
@Override public Collection<Filial> obterTodos() throws ClassNotFoundException, SQLException, IOException { ArrayList<Filial> loaded = null; Result<FilialRecord> result = GerenciadorBD.getContext().selectFrom(FILIAL).fetch(); if (result != null) { loaded = new ArrayList<>(); for (FilialRecord f : result) { Filial tmp = new Filial(f.getIdfilial(), f.getNome()); loaded.add(tmp); } } return (loaded); }