我的Spring Boot应用程序从Oracle数据库中提取了错误的数据,如中所述,它检索了正确数量的行,但内容不正确(数据丢失,[适当地]重复了其他行)。
我是Spring Boot和Oracle数据库的新手。我阅读了很多教程并进行了编码。现在,我尝试创建我的第一个Web服务原型,该原型从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的每一行。
如果需要,我可以提供有关表内容的更多详细信息。
我希望有人可以帮助我并指出我的错误。 在此先感谢:)
编辑: 这是表中的内容:
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;
}
}
答案 0 :(得分:3)
如果我没记错的话,您的DailyJobsRepository使用ClassTemp2
来指示主键ID是DailyJobsRepository extends JpaRepository<DailyJobsEntity, Integer>
类型,而您的实体Integer
则将ID定义为String类型。 :
DailyJobsEntity
jobTitle是实体的主键吗?因为我希望PK的类型为Integer。