@Transactional @Override public Textbook update(Textbook object) { Textbook obj = textbookRepo.findOne(object.getId()); if (obj != null) { updateChapters(object.getChapters(), obj); updateSubject(object.getSubject(), obj); updateName(object.getName(), obj); textbookRepo.saveAndFlush(obj); } return obj; }
@Transactional @Override public Textbook delete(Long id) { Textbook obj = textbookRepo.findOne(id); if (obj != null) { Subject subject = obj.getSubject(); if (subject != null) { subject.removeTextbook(obj); subjectRepo.saveAndFlush(subject); } textbookRepo.delete(obj); textbookRepo.flush(); } return null; }
@Transactional @Override public Textbook read(Long id) { return textbookRepo.findOne(id); }
@Transactional @Override public Textbook create(Textbook object) { return textbookRepo.save(object); }
@Transactional @Override public void deleteAll() { textbookRepo.deleteAll(); }
@Transactional @Override public long getCount() { return textbookRepo.count(); }
@Transactional @Override public List<Textbook> readAll() { return textbookRepo.findAll(); }
@Transactional @Override public int updateChapters(int chapters, Textbook textbook) { textbook.setChapters(chapters); return textbookRepo.updateChapters(chapters, textbook.getId()); }
@Transactional @Override public int updateSubject(Subject subject, Textbook textbook) { textbook.setSubject(subject); return textbookRepo.updateSubject(textbook.getId(), subject); }
@Transactional @Override public int updateName(String name, Textbook object) { return textbookRepo.updateName(name, object.getId()); }
@Transactional @Override public Textbook read(String name) { return textbookRepo.getByName(name); }