Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.websystique.springboot.service;
- import java.util.Collection;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.websystique.springboot.model.AnimalEntity;
- import com.websystique.springboot.repository.AnimalEntityRepository;
- @Service
- public class AnimalEntityServiceImpl implements AnimalEntityService{
- @Autowired
- private AnimalEntityRepository animalEntityRepo;
- public Collection<AnimalEntity> findAllAnimals() {
- return animalEntityRepo.findAll();
- }
- public AnimalEntity findById(long id) {
- return animalEntityRepo.findOne(id);
- }
- public void saveAnimal(AnimalEntity animal) {
- animalEntityRepo.save(animal);
- }
- public void updateAnimal(AnimalEntity animal) {
- animalEntityRepo.save(animal);
- }
- public void deleteAnimalById(long id) {
- animalEntityRepo.delete(id);
- }
- public boolean isAnimalExist(AnimalEntity animal) {
- return animalEntityRepo.exists(animal.getId());
- }
- public void deleteAllAnimals(){
- animalEntityRepo.deleteAll();
- }
- }
Add Comment
Please, Sign In to add comment