Checkpoint config
This commit is contained in:
parent
4eabc194fc
commit
430e8c9e7d
@ -48,8 +48,10 @@ public class FileToDatabaseMigrator {
|
||||
lecturer_surname = surname_cell.toString();
|
||||
}
|
||||
|
||||
if (lecturerService.getLecturer(lecturer_title, lecturer_name, lecturer_surname) == null) {
|
||||
Lecturer newLecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
|
||||
lecturerService.save(newLecturer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,12 @@ package com.plannaplan.repositories;
|
||||
import com.plannaplan.entities.Lecturer;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface LecturerRepository extends JpaRepository<Lecturer, Long> {
|
||||
|
||||
@Query(value = "SELECT * FROM lecturer WHERE name = :name AND surname = :surname AND title = :title ", nativeQuery = true)
|
||||
Lecturer find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
|
||||
}
|
@ -11,6 +11,10 @@ public class LecturerService {
|
||||
@Autowired
|
||||
private LecturerRepository repo;
|
||||
|
||||
public Lecturer getLecturer(String title, String name, String surname) {
|
||||
return repo.find(title, name, surname);
|
||||
}
|
||||
|
||||
public void save(Lecturer lecturer) {
|
||||
repo.save(lecturer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user