Мое приложение Spring Boot извлекает неверные данные из моей базы данных Oracle, так как в нем извлекается правильное количество строк, но содержимое неверно (данные отсутствуют, другие строки [вероятно] дублированы).
Я новичок в Spring Boot и в базах данных Oracle. Я прочитал много учебников и написал вместе. Теперь я пытаюсь создать свой первый прототип веб-сервиса, который получает данные из базы данных Oracle 12c и делает их доступными через конечную точку HTTP.
Я использую SQL Developer, чтобы проверить содержимое таблицы, которую я хочу отобразить, и она показывает разные вещи, чем в моем приложении Spring Boot.
Я использую Spring Boot 2.1.4.
Таблица, которую я хочу отобразить, содержит информацию о ежедневных cronjobs.
Это Контроллер
import de.dat.verguetung.entity.DailyJobsEntity;
import de.dat.verguetung.service.DailyJobsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping("/dailyjobs")
public class DailyJobsController {
@Autowired
DailyJobsService dailyJobsService;
@CrossOrigin(origins = "*")
@RequestMapping(value = "/all", method = RequestMethod.GET)
public List<DailyJobsEntity> getAllDailyJobs() {
return dailyJobsService.getAllDailyJobs();
}
}
Это мой Интерфейс репозитория
import de.prototype.entity.DailyJobsEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface DailyJobsRepository extends JpaRepository<DailyJobsEntity, Integer> {
}
Это моя модель
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "LOG_DAILY_JOBS")
public class DailyJobsEntity {
@Id
@Column(name = "JOB_TITLE", nullable = false, length = 100)
private String jobTitle;
@Column(name = "OK", nullable = false, length = 10)
private Integer ok;
@Column(name = "JOB_RESULT", nullable = true, length = 1000)
private String jobResult;
@Column(name = "EXECUTION_DATE", nullable = false)
@Temporal(TemporalType.DATE)
private Date executionDate;
protected DailyJobsEntity() {}
public DailyJobsEntity(String jobTitle, Integer ok, String jobResult, Date executionDate) {
this.jobTitle = jobTitle;
this.ok = ok;
this.jobResult = jobResult;
this.executionDate = executionDate;
}
public Date getExecutionDate() {return executionDate;}
public void setExecutionDate(Date executionDate) {this.executionDate = executionDate;}
public String getJobResult() {return jobResult;}
public void setJobResult(String jobResult) {this.jobResult = jobResult;}
public Integer getOk() {return ok;}
public void setOk(Integer ok) {this.ok = ok;}
public String getJobTitle() {return jobTitle;}
public void setJobTitle(String jobTitle) {this.jobTitle = jobTitle;}
}
Это мой Сервис
import de.dat.verguetung.dao.DailyJobsRepository;
import de.dat.verguetung.entity.DailyJobsEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class DailyJobsService {
@Autowired
DailyJobsRepository dailyJobsRepository;
public List<DailyJobsEntity> getAllDailyJobs(){
return this.dailyJobsRepository.findAll();
}
}
А это мой Главный класс
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class VerguetungApplication {
public static void main(String[] args) {
SpringApplication.run(VerguetungApplication.class, args);
}
}
В таблице 156 строк. Приложение выбирает 156 строк. Все в порядке.
Но 95% этих строк заполнены с неправильным содержанием.
У меня есть столбец с именем «EXECUTION_DATE».
Записи для этого столбца находятся в диапазоне от 2019-04-02 до 2019-04-16.
Приложение отображает каждую строку с датой выполнения 2019-04-02.
При необходимости могу предоставить более подробную информацию о содержании таблицы.
Я надеюсь, что кто-то может помочь мне и указать на мои ошибки.
Заранее спасибо:)
Edit:
Это содержание в таблице:
58 1 58 02.04.19
58 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 58 02.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 0 ORA-01403: Keine Daten gefunden 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 0 ORA-01403: Keine Daten gefunden 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 146 03.04.19
get_vsu_movement_count 1 85 04.04.19
get_vsu_movement_count 1 76 05.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 23 15.04.19
get_vsu_movement_count 1 96 16.04.19
get_vsu_movement_count 1 96 16.04.19
get_vsu_movement_count 1 96 16.04.19
get_vsu_movement_count 1 96 16.04.19
get_vsu_movement_count 1 96 16.04.19
get_vsu_movement_count 1 96 16.04.19
get_vsu_movement_count 1 96 16.04.19
get_vsu_movement_count 1 96 16.04.19
И это то, что отображается приложением
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
58 | 1 | 58 | 2019-04-02
58 | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
get_vsu_movement_count | 1 | 58 | 2019-04-02
Редактировать 2
Код для печати выбранных строк
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping("/dailyjobs")
public class DailyJobsController {
@Autowired
DailyJobsService dailyJobsService;
@CrossOrigin(origins = "*")
@RequestMapping(value = "/all", method = RequestMethod.GET)
public List<DailyJobsEntity> getAllDailyJobs() {
List<DailyJobsEntity> dJobs = dailyJobsService.getAllDailyJobs();
dJobs.stream().forEach(job -> {
System.out.println(job.getJobTitle() + " | " + job.getOk() + " | " + job.getJobResult() + " | " + job.getExecutionDate());
});
System.out.println(dJobs.size());
return dJobs;
}
}