繁体   English   中英

我无法阻止在 Api Spring 启动应用程序中复制我的实体 object

[英]I can't prevent duplicating of my Entity object in Api Spring Boot Application

在这个 spring 引导应用程序中,我正在从 CSV 文件中检索一些与 Covid19 数据相关的数据,并希望根据该数据制作 Restful API。 使用这种方法,我的Application Entity有问题。 问题是我不知道如何从3 个远程 CSV URL 为我的Application Entity设置值。 我的意思是设置 ID、provinceState 和 countryRegion。

  • 在 JSON output 中,它看起来像这样。 正如您所看到的,它每次使用一种(死亡/恢复/新病例)数据填充ApplicationEntity object。
[
{

    "id": 679,
    "lat": "32.427908",
    "lon": "53.688046",
    "provinceState": "",
    "countryRegion": "Iran",
    "latestTotalNewCases": 0,
    "diffNewCasesFromPrevDay": 0,
    "latestTotalDead": 0,
    "diffDeadFromPrevDay": 0,
    "latestTotalRecovered": 1331162, //first time just this will populate with data
    "diffRecoveredFromPrevDay": 6931 //first time just this will populate with data

},

{

    "id": 421,
    "lat": "32.427908",
    "lon": "53.688046",
    "provinceState": "",
    "countryRegion": "Iran",
    "latestTotalNewCases": 0,
    "diffNewCasesFromPrevDay": 0,
    "latestTotalDead": 59341,//then just this will populate with data
    "diffDeadFromPrevDay": 77,//then just this will populate with data
    "latestTotalRecovered": 0,
    "diffRecoveredFromPrevDay": 0

},


{

    "id": 148,
    "lat": "32.427908",
    "lon": "53.688046",
    "provinceState": "",
    "countryRegion": "Iran",
    "latestTotalNewCases": 1558159,//finally this will populate with data
    "diffNewCasesFromPrevDay": 8017,//finally this will populate with data
    "latestTotalDead": 0,
    "diffDeadFromPrevDay": 0,
    "latestTotalRecovered": 0,
    "diffRecoveredFromPrevDay": 0

}
]

实体

@Entity
@JsonPropertyOrder({"id", "lat", "lon", "provinceState", "countryRegion", "latestTotalNewCases", "diffNewCasesFromPrevDay",
        "latestTotalDead", "diffDeadFromPrevDay", "latestTotalRecovered", "diffRecoveredFromPrevDay"
})
@ApiModel(description = "Class representing an Entity by the application.")
public class ApplicationEntity implements Serializable {


    @Id
    private Long id;

    @ApiModelProperty(notes = "Name of the province", example = "British Columbia", required = true, position = 1)
    private String provinceState;

    @ApiModelProperty(notes = "Name of the country", example = "Canada", required = true, position = 2)
    private String countryRegion;

    @ApiModelProperty(notes = "Latitude of the region", example = "-65.00184", required = true, position = 3)
    private String lat;

    @ApiModelProperty(notes = "Longitude of the region", example = "45.64684", required = true, position = 4)
    private String lon;

    @ApiModelProperty(notes = "Total new cases until today in this specific province/country", example = "1200", required = true, position = 5)
    private int latestTotalNewCases;

    @ApiModelProperty(notes = "The number of new cases since yesterday ", example = "25", required = true, position = 6)
    private int diffNewCasesFromPrevDay;

    @ApiModelProperty(notes = "Total dead until today in this specific province/country", example = "1200", required = true, position = 7)
    private int latestTotalDead;

    @ApiModelProperty(notes = "The number of dead since yesterday ", example = "25", required = true, position = 8)
    private int diffDeadFromPrevDay;


    @ApiModelProperty(notes = "Total recovered until today in this specific province/country", example = "1200", required = true, position = 9)
    private int latestTotalRecovered;

    @ApiModelProperty(notes = "The number of recovered since yesterday ", example = "25", required = true, position = 10)
    private int diffRecoveredFromPrevDay;

    public ApplicationEntity() {
    }

    public ApplicationEntity(Long id, String provinceState, String countryRegion, String lat, String lon, int latestTotalNewCases, int diffNewCasesFromPrevDay, int latestTotalDead, int diffDeadFromPrevDay, int latestTotalRecovered, int diffRecoveredFromPrevDay) {
        this.id = id;
        this.provinceState = provinceState;
        this.countryRegion = countryRegion;
        this.lat = lat;
        this.lon = lon;
        this.latestTotalNewCases = latestTotalNewCases;
        this.diffNewCasesFromPrevDay = diffNewCasesFromPrevDay;
        this.latestTotalDead = latestTotalDead;
        this.diffDeadFromPrevDay = diffDeadFromPrevDay;
        this.latestTotalRecovered = latestTotalRecovered;
        this.diffRecoveredFromPrevDay = diffRecoveredFromPrevDay;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getProvinceState() {
        return provinceState;
    }

    public void setProvinceState(String provinceState) {
        this.provinceState = provinceState;
    }

    public String getCountryRegion() {
        return countryRegion;
    }

    public void setCountryRegion(String countryRegion) {
        this.countryRegion = countryRegion;
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat;
    }

    public String getLon() {
        return lon;
    }

    public void setLon(String lon) {
        this.lon = lon;
    }

    public int getLatestTotalNewCases() {
        return latestTotalNewCases;
    }

    public void setLatestTotalNewCases(int latestTotalNewCases) {
        this.latestTotalNewCases = latestTotalNewCases;
    }

    public int getDiffNewCasesFromPrevDay() {
        return diffNewCasesFromPrevDay;
    }

    public void setDiffNewCasesFromPrevDay(int diffNewCasesFromPrevDay) {
        this.diffNewCasesFromPrevDay = diffNewCasesFromPrevDay;
    }

    public int getLatestTotalDead() {
        return latestTotalDead;
    }

    public void setLatestTotalDead(int latestTotalDead) {
        this.latestTotalDead = latestTotalDead;
    }

    public int getDiffDeadFromPrevDay() {
        return diffDeadFromPrevDay;
    }

    public void setDiffDeadFromPrevDay(int diffDeadFromPrevDay) {
        this.diffDeadFromPrevDay = diffDeadFromPrevDay;
    }

    public int getLatestTotalRecovered() {
        return latestTotalRecovered;
    }

    public void setLatestTotalRecovered(int latestTotalRecovered) {
        this.latestTotalRecovered = latestTotalRecovered;
    }

    public int getDiffRecoveredFromPrevDay() {
        return diffRecoveredFromPrevDay;
    }

    public void setDiffRecoveredFromPrevDay(int diffRecoveredFromPrevDay) {
        this.diffRecoveredFromPrevDay = diffRecoveredFromPrevDay;
    }

    @Override
    public String toString() {
        return "ApplicationEntity{" +
                "id=" + id +
                ", provinceState='" + provinceState + '\'' +
                ", countryRegion='" + countryRegion + '\'' +
                ", lat='" + lat + '\'' +
                ", lon='" + lon + '\'' +
                ", latestTotalNewCases=" + latestTotalNewCases +
                ", diffNewCasesFromPrevDay=" + diffNewCasesFromPrevDay +
                ", latestTotalDead=" + latestTotalDead +
                ", diffDeadFromPrevDay=" + diffDeadFromPrevDay +
                ", latestTotalRecovered=" + latestTotalRecovered +
                ", diffRecoveredFromPrevDay=" + diffRecoveredFromPrevDay +
                '}';
    }
}

CSVHttpRequestHelper

public class CSVHttpRequestHelper {

    public static Iterable<CSVRecord> request(String url) throws IOException, InterruptedException {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder().uri(URI.create(url)).build();
        HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
        StringReader csvBodyReader = new StringReader(httpResponse.body());
        return CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(csvBodyReader);
    }

}

服务抽象



public abstract class ServiceAbstractionLayer {


    private void prepareCSVRequestOperation() throws IOException, InterruptedException {
        List<ApplicationEntity> newStats = new ArrayList<>();
        fillNewCasesProperties(newStats);
        fillDeadProperties(newStats);
        fillRecoveredProperties(newStats);
        getTotalDeadStatistics(newStats);
    }

    public void fetchData() throws IOException, InterruptedException {
        prepareCSVRequestOperation();
    }

// getTotalDeadStatistics is working fine. No problem here
    private void getTotalDeadStatistics(List<ApplicationEntity> applicationEntities) {
        GlobalStatisticEntity globalStatisticEntity = new GlobalStatisticEntity();

        int totalDeadToday = applicationEntities.stream().mapToInt(ApplicationEntity::getDiffDeadFromPrevDay).sum();
        int totalReportedDead = applicationEntities.stream().mapToInt(ApplicationEntity::getLatestTotalDead).sum();

        int totalRecoveredToday = applicationEntities.stream().mapToInt(ApplicationEntity::getDiffRecoveredFromPrevDay).sum();
        int totalReportedRecovered = applicationEntities.stream().mapToInt(ApplicationEntity::getLatestTotalRecovered).sum();

        int totalNewCaseToday = applicationEntities.stream().mapToInt(ApplicationEntity::getDiffNewCasesFromPrevDay).sum();
        int totalReportedNewCase = applicationEntities.stream().mapToInt(ApplicationEntity::getLatestTotalNewCases).sum();

        for (long j = 0; j <= applicationEntities.size(); j++)
            globalStatisticEntity.setId(j);
        globalStatisticEntity.setTotalDeadToday(totalDeadToday);
        globalStatisticEntity.setTotalReportedDead(totalReportedDead);


        globalStatisticEntity.setTotalNewCasesToday(totalNewCaseToday);
        globalStatisticEntity.setTotalReportedNewCases(totalReportedNewCase);

        globalStatisticEntity.setTotalRecoveredToday(totalRecoveredToday);
        globalStatisticEntity.setTotalReportedRecovered(totalReportedRecovered);


        saveGlobalInDB(globalStatisticEntity);
    }



// PROBLEM starts from here that I don't know to handle these three methods.

    private void fillNewCasesProperties(List<ApplicationEntity> newEntity) throws IOException, InterruptedException {
        for (CSVRecord record : getCsvConfirmed()) {
            ApplicationEntity locationStats = new ApplicationEntity();

            setPropertyId(newEntity,locationStats);
            locationStats.setProvinceState(record.get("Province/State"));
            locationStats.setCountryRegion(record.get("Country/Region"));
            locationStats.setLat(record.get("Lat"));
            locationStats.setLon(record.get("Long"));
            int latestCases = Integer.parseInt(record.get(record.size() - 1));
            int prevDayCases = Integer.parseInt(record.get(record.size() - 2));
            locationStats.setLatestTotalNewCases(latestCases);
            locationStats.setDiffNewCasesFromPrevDay(latestCases - prevDayCases);
            newEntity.add(locationStats);
            savePropertiesInDB(locationStats);
        }
    }

    private void fillRecoveredProperties(List<ApplicationEntity> newEntity) throws IOException, InterruptedException {
        for (CSVRecord record : getCsvRecovered()) {
            ApplicationEntity locationStats = new ApplicationEntity();
            setPropertyId(newEntity,locationStats);
            locationStats.setProvinceState(record.get("Province/State"));
            locationStats.setCountryRegion(record.get("Country/Region"));
            locationStats.setLat(record.get("Lat"));
            locationStats.setLon(record.get("Long"));
            int latestCases = Integer.parseInt(record.get(record.size() - 1));
            int prevDayCases = Integer.parseInt(record.get(record.size() - 2));

            locationStats.setLatestTotalRecovered(latestCases);
            locationStats.setDiffRecoveredFromPrevDay(latestCases - prevDayCases);

            newEntity.add(locationStats);
            savePropertiesInDB(locationStats);
        }
    }

    private void fillDeadProperties(List<ApplicationEntity> newEntity) throws IOException, InterruptedException {
        for (CSVRecord record : getCsvDead()) {
            ApplicationEntity locationStats = new ApplicationEntity();
            setPropertyId(newEntity,locationStats);
            locationStats.setProvinceState(record.get("Province/State"));
            locationStats.setCountryRegion(record.get("Country/Region"));
            locationStats.setLat(record.get("Lat"));
            locationStats.setLon(record.get("Long"));

            int latestCases = Integer.parseInt(record.get(record.size() - 1));
            int prevDayCases = Integer.parseInt(record.get(record.size() - 2));
            locationStats.setLatestTotalDead(latestCases);
            locationStats.setDiffDeadFromPrevDay(latestCases - prevDayCases);
            newEntity.add(locationStats);
            savePropertiesInDB(locationStats);
        }
    }



    private Iterable<CSVRecord> getCsvDead() throws IOException, InterruptedException {
        return CSVHttpRequestHelper.request(Constants.URL_DEAD);
    }

    private Iterable<CSVRecord> getCsvConfirmed() throws IOException, InterruptedException {
        return CSVHttpRequestHelper.request(Constants.URL_CONFIRMED);
    }

    private Iterable<CSVRecord> getCsvRecovered() throws IOException, InterruptedException {
        return CSVHttpRequestHelper.request(Constants.URL_RECOVERED);
    }


    private void setPropertyId(List<ApplicationEntity> newEntity, ApplicationEntity locationStats) {
        for (long j = 0; j <= newEntity.size(); j++)
            locationStats.setId(j);
    }

    public abstract void savePropertiesInDB(ApplicationEntity locationStats);

    public abstract void saveGlobalInDB(GlobalStatisticEntity globalStatisticEntity);

}

服务


@Service("ApplicationService")
public class ApplicationService extends ServiceAbstractionLayer {

    private final ApplicationRepository applicationRepository;
    private final GlobalRepository globalRepository;
    ExecutorService executorService = Executors.newFixedThreadPool(30);

    @Autowired
    public ApplicationService(ApplicationRepository applicationRepository, GlobalRepository globalRepository) {
        this.applicationRepository = applicationRepository;
        this.globalRepository = globalRepository;
    }


    public List<ApplicationEntity> getApplicationEntities() {
        return applicationRepository.findAll();
    }


    public ApplicationEntity getApplicationEntityById(Long id) {
        return applicationRepository.findApplicationEntityById(id).orElseThrow(() -> new ApiRequestException("Case by id " + id + " was not found!"));
    }

    public List<ApplicationEntity> getApplicationEntityByCountryRegionIgnoreCase(String countryRegion) {
        return applicationRepository.findApplicationEntityByCountryRegionIgnoreCase(countryRegion).orElseThrow(() -> new ApiRequestException("Case by countryRegion " + countryRegion + " was not found!"));
    }

    public ApplicationEntity getApplicationEntityByLatAndLon(String lat, String lon) {
        return applicationRepository.findApplicationEntityByLatAndLon(lat, lon).orElseThrow(() -> new ApiRequestException("Case by lat " + lat + " lon " + lon + " was not found!"));
    }

    public List<GlobalStatisticEntity> getGlobalEntities() {
        return globalRepository.findAll();
    }

    public void deleteGlobalRepository(){
        globalRepository.deleteAll();
    }
    public void deleteApplicationRepository(){
        applicationRepository.deleteAll();
    }

    @Scheduled(cron = "0 0 0/1 * * *")
    @PostConstruct
    @Override
    public void fetchData() throws IOException, InterruptedException {
        super.fetchData();
    }

    @Override
    public void savePropertiesInDB(ApplicationEntity locationStats) {
      executorService.execute(() -> applicationRepository.save(locationStats));
        //applicationRepository.save(locationStats);
    }

    @Override
    public void saveGlobalInDB(GlobalStatisticEntity globalStatisticEntity) {
        globalRepository.save(globalStatisticEntity);
    }

日志


2021-02-21 19:37:32.918  INFO 61944 --- [           main] c.f.s.C.Covid19RestApiApplication        : Starting Covid19RestApiApplication using Java 11.0.8 on Faramarz with PID 61944 (E:\InteliJSpringProjects\Covid19RestApi\target\classes started by Faramarz in E:\InteliJSpringProjects\Covid19RestApi)
2021-02-21 19:37:32.924  INFO 61944 --- [           main] c.f.s.C.Covid19RestApiApplication        : No active profile set, falling back to default profiles: default
2021-02-21 19:37:34.318  INFO 61944 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-02-21 19:37:34.371  INFO 61944 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 45 ms. Found 2 JPA repository interfaces.
2021-02-21 19:37:35.012  INFO 61944 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8090 (http)
2021-02-21 19:37:35.021  INFO 61944 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-02-21 19:37:35.021  INFO 61944 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-02-21 19:37:35.124  INFO 61944 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-02-21 19:37:35.125  INFO 61944 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2068 ms
2021-02-21 19:37:35.350  INFO 61944 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-02-21 19:37:35.388  INFO 61944 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.27.Final
2021-02-21 19:37:35.489  INFO 61944 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-02-21 19:37:35.584  INFO 61944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-02-21 19:37:35.961  INFO 61944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-02-21 19:37:35.975  INFO 61944 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2021-02-21 19:37:38.195  INFO 61944 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-02-21 19:37:38.225  INFO 61944 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
Hibernate: select globalstat0_.id as id1_1_0_, globalstat0_.total_dead_today as total_de2_1_0_, globalstat0_.total_new_cases_today as total_ne3_1_0_, globalstat0_.total_recovered_today as total_re4_1_0_, globalstat0_.total_reported_dead as total_re5_1_0_, globalstat0_.total_reported_new_cases as total_re6_1_0_, globalstat0_.total_reported_recovered as total_re7_1_0_ from global_statistic_entity globalstat0_ where globalstat0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
2021-02-21 19:37:51.082  WARN 61944 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-02-21 19:37:51.645  INFO 61944 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-21 19:37:51.941  INFO 61944 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
2021-02-21 19:37:52.026  INFO 61944 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8090 (http) with context path ''
2021-02-21 19:37:52.530  INFO 61944 --- [           main] c.f.s.C.Covid19RestApiApplication        : Started Covid19RestApiApplication in 20.711 seconds (JVM running for 22.169)


在这个 spring 引导应用程序中,我正在从 CSV 文件中检索一些与 Covid19 数据相关的数据,并希望根据该数据制作 Restful API。 使用这种方法,我的Application Entity有问题。 问题是我不知道如何从3 个远程 CSV URL 为我的Application Entity设置值。 我的意思是设置 ID、provinceState 和 countryRegion。

  • 在 JSON output 中,它看起来像这样。 正如您所看到的,它每次使用一种(死亡/恢复/新病例)数据填充ApplicationEntity object。
[
{

    "id": 679,
    "lat": "32.427908",
    "lon": "53.688046",
    "provinceState": "",
    "countryRegion": "Iran",
    "latestTotalNewCases": 0,
    "diffNewCasesFromPrevDay": 0,
    "latestTotalDead": 0,
    "diffDeadFromPrevDay": 0,
    "latestTotalRecovered": 1331162, //first time just this will populate with data
    "diffRecoveredFromPrevDay": 6931 //first time just this will populate with data

},

{

    "id": 421,
    "lat": "32.427908",
    "lon": "53.688046",
    "provinceState": "",
    "countryRegion": "Iran",
    "latestTotalNewCases": 0,
    "diffNewCasesFromPrevDay": 0,
    "latestTotalDead": 59341,//then just this will populate with data
    "diffDeadFromPrevDay": 77,//then just this will populate with data
    "latestTotalRecovered": 0,
    "diffRecoveredFromPrevDay": 0

},


{

    "id": 148,
    "lat": "32.427908",
    "lon": "53.688046",
    "provinceState": "",
    "countryRegion": "Iran",
    "latestTotalNewCases": 1558159,//finally this will populate with data
    "diffNewCasesFromPrevDay": 8017,//finally this will populate with data
    "latestTotalDead": 0,
    "diffDeadFromPrevDay": 0,
    "latestTotalRecovered": 0,
    "diffRecoveredFromPrevDay": 0

}
]

实体

@Entity
@JsonPropertyOrder({"id", "lat", "lon", "provinceState", "countryRegion", "latestTotalNewCases", "diffNewCasesFromPrevDay",
        "latestTotalDead", "diffDeadFromPrevDay", "latestTotalRecovered", "diffRecoveredFromPrevDay"
})
@ApiModel(description = "Class representing an Entity by the application.")
public class ApplicationEntity implements Serializable {


    @Id
    private Long id;

    @ApiModelProperty(notes = "Name of the province", example = "British Columbia", required = true, position = 1)
    private String provinceState;

    @ApiModelProperty(notes = "Name of the country", example = "Canada", required = true, position = 2)
    private String countryRegion;

    @ApiModelProperty(notes = "Latitude of the region", example = "-65.00184", required = true, position = 3)
    private String lat;

    @ApiModelProperty(notes = "Longitude of the region", example = "45.64684", required = true, position = 4)
    private String lon;

    @ApiModelProperty(notes = "Total new cases until today in this specific province/country", example = "1200", required = true, position = 5)
    private int latestTotalNewCases;

    @ApiModelProperty(notes = "The number of new cases since yesterday ", example = "25", required = true, position = 6)
    private int diffNewCasesFromPrevDay;

    @ApiModelProperty(notes = "Total dead until today in this specific province/country", example = "1200", required = true, position = 7)
    private int latestTotalDead;

    @ApiModelProperty(notes = "The number of dead since yesterday ", example = "25", required = true, position = 8)
    private int diffDeadFromPrevDay;


    @ApiModelProperty(notes = "Total recovered until today in this specific province/country", example = "1200", required = true, position = 9)
    private int latestTotalRecovered;

    @ApiModelProperty(notes = "The number of recovered since yesterday ", example = "25", required = true, position = 10)
    private int diffRecoveredFromPrevDay;

    public ApplicationEntity() {
    }

    public ApplicationEntity(Long id, String provinceState, String countryRegion, String lat, String lon, int latestTotalNewCases, int diffNewCasesFromPrevDay, int latestTotalDead, int diffDeadFromPrevDay, int latestTotalRecovered, int diffRecoveredFromPrevDay) {
        this.id = id;
        this.provinceState = provinceState;
        this.countryRegion = countryRegion;
        this.lat = lat;
        this.lon = lon;
        this.latestTotalNewCases = latestTotalNewCases;
        this.diffNewCasesFromPrevDay = diffNewCasesFromPrevDay;
        this.latestTotalDead = latestTotalDead;
        this.diffDeadFromPrevDay = diffDeadFromPrevDay;
        this.latestTotalRecovered = latestTotalRecovered;
        this.diffRecoveredFromPrevDay = diffRecoveredFromPrevDay;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getProvinceState() {
        return provinceState;
    }

    public void setProvinceState(String provinceState) {
        this.provinceState = provinceState;
    }

    public String getCountryRegion() {
        return countryRegion;
    }

    public void setCountryRegion(String countryRegion) {
        this.countryRegion = countryRegion;
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat;
    }

    public String getLon() {
        return lon;
    }

    public void setLon(String lon) {
        this.lon = lon;
    }

    public int getLatestTotalNewCases() {
        return latestTotalNewCases;
    }

    public void setLatestTotalNewCases(int latestTotalNewCases) {
        this.latestTotalNewCases = latestTotalNewCases;
    }

    public int getDiffNewCasesFromPrevDay() {
        return diffNewCasesFromPrevDay;
    }

    public void setDiffNewCasesFromPrevDay(int diffNewCasesFromPrevDay) {
        this.diffNewCasesFromPrevDay = diffNewCasesFromPrevDay;
    }

    public int getLatestTotalDead() {
        return latestTotalDead;
    }

    public void setLatestTotalDead(int latestTotalDead) {
        this.latestTotalDead = latestTotalDead;
    }

    public int getDiffDeadFromPrevDay() {
        return diffDeadFromPrevDay;
    }

    public void setDiffDeadFromPrevDay(int diffDeadFromPrevDay) {
        this.diffDeadFromPrevDay = diffDeadFromPrevDay;
    }

    public int getLatestTotalRecovered() {
        return latestTotalRecovered;
    }

    public void setLatestTotalRecovered(int latestTotalRecovered) {
        this.latestTotalRecovered = latestTotalRecovered;
    }

    public int getDiffRecoveredFromPrevDay() {
        return diffRecoveredFromPrevDay;
    }

    public void setDiffRecoveredFromPrevDay(int diffRecoveredFromPrevDay) {
        this.diffRecoveredFromPrevDay = diffRecoveredFromPrevDay;
    }

    @Override
    public String toString() {
        return "ApplicationEntity{" +
                "id=" + id +
                ", provinceState='" + provinceState + '\'' +
                ", countryRegion='" + countryRegion + '\'' +
                ", lat='" + lat + '\'' +
                ", lon='" + lon + '\'' +
                ", latestTotalNewCases=" + latestTotalNewCases +
                ", diffNewCasesFromPrevDay=" + diffNewCasesFromPrevDay +
                ", latestTotalDead=" + latestTotalDead +
                ", diffDeadFromPrevDay=" + diffDeadFromPrevDay +
                ", latestTotalRecovered=" + latestTotalRecovered +
                ", diffRecoveredFromPrevDay=" + diffRecoveredFromPrevDay +
                '}';
    }
}

CSVHttpRequestHelper

public class CSVHttpRequestHelper {

    public static Iterable<CSVRecord> request(String url) throws IOException, InterruptedException {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder().uri(URI.create(url)).build();
        HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
        StringReader csvBodyReader = new StringReader(httpResponse.body());
        return CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(csvBodyReader);
    }

}

服务抽象



public abstract class ServiceAbstractionLayer {


    private void prepareCSVRequestOperation() throws IOException, InterruptedException {
        List<ApplicationEntity> newStats = new ArrayList<>();
        fillNewCasesProperties(newStats);
        fillDeadProperties(newStats);
        fillRecoveredProperties(newStats);
        getTotalDeadStatistics(newStats);
    }

    public void fetchData() throws IOException, InterruptedException {
        prepareCSVRequestOperation();
    }

// getTotalDeadStatistics is working fine. No problem here
    private void getTotalDeadStatistics(List<ApplicationEntity> applicationEntities) {
        GlobalStatisticEntity globalStatisticEntity = new GlobalStatisticEntity();

        int totalDeadToday = applicationEntities.stream().mapToInt(ApplicationEntity::getDiffDeadFromPrevDay).sum();
        int totalReportedDead = applicationEntities.stream().mapToInt(ApplicationEntity::getLatestTotalDead).sum();

        int totalRecoveredToday = applicationEntities.stream().mapToInt(ApplicationEntity::getDiffRecoveredFromPrevDay).sum();
        int totalReportedRecovered = applicationEntities.stream().mapToInt(ApplicationEntity::getLatestTotalRecovered).sum();

        int totalNewCaseToday = applicationEntities.stream().mapToInt(ApplicationEntity::getDiffNewCasesFromPrevDay).sum();
        int totalReportedNewCase = applicationEntities.stream().mapToInt(ApplicationEntity::getLatestTotalNewCases).sum();

        for (long j = 0; j <= applicationEntities.size(); j++)
            globalStatisticEntity.setId(j);
        globalStatisticEntity.setTotalDeadToday(totalDeadToday);
        globalStatisticEntity.setTotalReportedDead(totalReportedDead);


        globalStatisticEntity.setTotalNewCasesToday(totalNewCaseToday);
        globalStatisticEntity.setTotalReportedNewCases(totalReportedNewCase);

        globalStatisticEntity.setTotalRecoveredToday(totalRecoveredToday);
        globalStatisticEntity.setTotalReportedRecovered(totalReportedRecovered);


        saveGlobalInDB(globalStatisticEntity);
    }



// PROBLEM starts from here that I don't know to handle these three methods.

    private void fillNewCasesProperties(List<ApplicationEntity> newEntity) throws IOException, InterruptedException {
        for (CSVRecord record : getCsvConfirmed()) {
            ApplicationEntity locationStats = new ApplicationEntity();

            setPropertyId(newEntity,locationStats);
            locationStats.setProvinceState(record.get("Province/State"));
            locationStats.setCountryRegion(record.get("Country/Region"));
            locationStats.setLat(record.get("Lat"));
            locationStats.setLon(record.get("Long"));
            int latestCases = Integer.parseInt(record.get(record.size() - 1));
            int prevDayCases = Integer.parseInt(record.get(record.size() - 2));
            locationStats.setLatestTotalNewCases(latestCases);
            locationStats.setDiffNewCasesFromPrevDay(latestCases - prevDayCases);
            newEntity.add(locationStats);
            savePropertiesInDB(locationStats);
        }
    }

    private void fillRecoveredProperties(List<ApplicationEntity> newEntity) throws IOException, InterruptedException {
        for (CSVRecord record : getCsvRecovered()) {
            ApplicationEntity locationStats = new ApplicationEntity();
            setPropertyId(newEntity,locationStats);
            locationStats.setProvinceState(record.get("Province/State"));
            locationStats.setCountryRegion(record.get("Country/Region"));
            locationStats.setLat(record.get("Lat"));
            locationStats.setLon(record.get("Long"));
            int latestCases = Integer.parseInt(record.get(record.size() - 1));
            int prevDayCases = Integer.parseInt(record.get(record.size() - 2));

            locationStats.setLatestTotalRecovered(latestCases);
            locationStats.setDiffRecoveredFromPrevDay(latestCases - prevDayCases);

            newEntity.add(locationStats);
            savePropertiesInDB(locationStats);
        }
    }

    private void fillDeadProperties(List<ApplicationEntity> newEntity) throws IOException, InterruptedException {
        for (CSVRecord record : getCsvDead()) {
            ApplicationEntity locationStats = new ApplicationEntity();
            setPropertyId(newEntity,locationStats);
            locationStats.setProvinceState(record.get("Province/State"));
            locationStats.setCountryRegion(record.get("Country/Region"));
            locationStats.setLat(record.get("Lat"));
            locationStats.setLon(record.get("Long"));

            int latestCases = Integer.parseInt(record.get(record.size() - 1));
            int prevDayCases = Integer.parseInt(record.get(record.size() - 2));
            locationStats.setLatestTotalDead(latestCases);
            locationStats.setDiffDeadFromPrevDay(latestCases - prevDayCases);
            newEntity.add(locationStats);
            savePropertiesInDB(locationStats);
        }
    }



    private Iterable<CSVRecord> getCsvDead() throws IOException, InterruptedException {
        return CSVHttpRequestHelper.request(Constants.URL_DEAD);
    }

    private Iterable<CSVRecord> getCsvConfirmed() throws IOException, InterruptedException {
        return CSVHttpRequestHelper.request(Constants.URL_CONFIRMED);
    }

    private Iterable<CSVRecord> getCsvRecovered() throws IOException, InterruptedException {
        return CSVHttpRequestHelper.request(Constants.URL_RECOVERED);
    }


    private void setPropertyId(List<ApplicationEntity> newEntity, ApplicationEntity locationStats) {
        for (long j = 0; j <= newEntity.size(); j++)
            locationStats.setId(j);
    }

    public abstract void savePropertiesInDB(ApplicationEntity locationStats);

    public abstract void saveGlobalInDB(GlobalStatisticEntity globalStatisticEntity);

}

服务


@Service("ApplicationService")
public class ApplicationService extends ServiceAbstractionLayer {

    private final ApplicationRepository applicationRepository;
    private final GlobalRepository globalRepository;
    ExecutorService executorService = Executors.newFixedThreadPool(30);

    @Autowired
    public ApplicationService(ApplicationRepository applicationRepository, GlobalRepository globalRepository) {
        this.applicationRepository = applicationRepository;
        this.globalRepository = globalRepository;
    }


    public List<ApplicationEntity> getApplicationEntities() {
        return applicationRepository.findAll();
    }


    public ApplicationEntity getApplicationEntityById(Long id) {
        return applicationRepository.findApplicationEntityById(id).orElseThrow(() -> new ApiRequestException("Case by id " + id + " was not found!"));
    }

    public List<ApplicationEntity> getApplicationEntityByCountryRegionIgnoreCase(String countryRegion) {
        return applicationRepository.findApplicationEntityByCountryRegionIgnoreCase(countryRegion).orElseThrow(() -> new ApiRequestException("Case by countryRegion " + countryRegion + " was not found!"));
    }

    public ApplicationEntity getApplicationEntityByLatAndLon(String lat, String lon) {
        return applicationRepository.findApplicationEntityByLatAndLon(lat, lon).orElseThrow(() -> new ApiRequestException("Case by lat " + lat + " lon " + lon + " was not found!"));
    }

    public List<GlobalStatisticEntity> getGlobalEntities() {
        return globalRepository.findAll();
    }

    public void deleteGlobalRepository(){
        globalRepository.deleteAll();
    }
    public void deleteApplicationRepository(){
        applicationRepository.deleteAll();
    }

    @Scheduled(cron = "0 0 0/1 * * *")
    @PostConstruct
    @Override
    public void fetchData() throws IOException, InterruptedException {
        super.fetchData();
    }

    @Override
    public void savePropertiesInDB(ApplicationEntity locationStats) {
      executorService.execute(() -> applicationRepository.save(locationStats));
        //applicationRepository.save(locationStats);
    }

    @Override
    public void saveGlobalInDB(GlobalStatisticEntity globalStatisticEntity) {
        globalRepository.save(globalStatisticEntity);
    }

日志


2021-02-21 19:37:32.918  INFO 61944 --- [           main] c.f.s.C.Covid19RestApiApplication        : Starting Covid19RestApiApplication using Java 11.0.8 on Faramarz with PID 61944 (E:\InteliJSpringProjects\Covid19RestApi\target\classes started by Faramarz in E:\InteliJSpringProjects\Covid19RestApi)
2021-02-21 19:37:32.924  INFO 61944 --- [           main] c.f.s.C.Covid19RestApiApplication        : No active profile set, falling back to default profiles: default
2021-02-21 19:37:34.318  INFO 61944 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-02-21 19:37:34.371  INFO 61944 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 45 ms. Found 2 JPA repository interfaces.
2021-02-21 19:37:35.012  INFO 61944 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8090 (http)
2021-02-21 19:37:35.021  INFO 61944 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-02-21 19:37:35.021  INFO 61944 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-02-21 19:37:35.124  INFO 61944 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-02-21 19:37:35.125  INFO 61944 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2068 ms
2021-02-21 19:37:35.350  INFO 61944 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-02-21 19:37:35.388  INFO 61944 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.27.Final
2021-02-21 19:37:35.489  INFO 61944 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-02-21 19:37:35.584  INFO 61944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-02-21 19:37:35.961  INFO 61944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-02-21 19:37:35.975  INFO 61944 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2021-02-21 19:37:38.195  INFO 61944 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-02-21 19:37:38.225  INFO 61944 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
Hibernate: select globalstat0_.id as id1_1_0_, globalstat0_.total_dead_today as total_de2_1_0_, globalstat0_.total_new_cases_today as total_ne3_1_0_, globalstat0_.total_recovered_today as total_re4_1_0_, globalstat0_.total_reported_dead as total_re5_1_0_, globalstat0_.total_reported_new_cases as total_re6_1_0_, globalstat0_.total_reported_recovered as total_re7_1_0_ from global_statistic_entity globalstat0_ where globalstat0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
Hibernate: select applicatio0_.id as id1_0_0_, applicatio0_.country_region as country_2_0_0_, applicatio0_.diff_dead_from_prev_day as diff_dea3_0_0_, applicatio0_.diff_new_cases_from_prev_day as diff_new4_0_0_, applicatio0_.diff_recovered_from_prev_day as diff_rec5_0_0_, applicatio0_.lat as lat6_0_0_, applicatio0_.latest_total_dead as latest_t7_0_0_, applicatio0_.latest_total_new_cases as latest_t8_0_0_, applicatio0_.latest_total_recovered as latest_t9_0_0_, applicatio0_.lon as lon10_0_0_, applicatio0_.province_state as provinc11_0_0_ from application_entity applicatio0_ where applicatio0_.id=?
2021-02-21 19:37:51.082  WARN 61944 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-02-21 19:37:51.645  INFO 61944 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-21 19:37:51.941  INFO 61944 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
2021-02-21 19:37:52.026  INFO 61944 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8090 (http) with context path ''
2021-02-21 19:37:52.530  INFO 61944 --- [           main] c.f.s.C.Covid19RestApiApplication        : Started Covid19RestApiApplication in 20.711 seconds (JVM running for 22.169)


暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM