org.springframework.boot spring-boot-starter-data-jpaorg.projectlombok lombok1.18.12
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://127.0.0.1:3306/duidui?charset=utf8mb4&useSSL=false spring.datasource.username=root spring.datasource.password=123456 spring.datasource.hikari.maximum-pool-size=200 spring.datasource.hikari.minimum-idle=50 spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect spring.jpa.show-sql=false spring.jpa.hibernate.ddl-auto=create
entity
import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.*; import java.util.*; @Entity @Table(name = "dataexchange_task") @Data @Builder @NoArgsConstructor @AllArgsConstructor public class TaskDO { @Id @Column(name = "task_id", nullable = false) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long taskID; private Date taskStartTime; private String serviceID; private Integer status; private int isDelete; private Integer version; }
dao
import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import paas.dao.model.TaskDO; @Repository public interface TaskDao extends JpaRepository{ @Query(value = "SELECT * FROM dataexchange_task t WHERe t.status = ?1 AND t.is_delete = ?2 ", countQuery = "SELECT count(*) FROM dataexchange_task t WHERe t.status = ?1 AND t.is_delete = ?2", nativeQuery = true) public Page findUnExecuteTask(int status ,int isDelete, Pageable pageable); }
启动类
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication(scanbasePackages = "paas") @EnableJpaRepositories("paas.dao") @EntityScan("paas.dao.model") public class WebApiApplication { public static void main(String[] args) { SpringApplication.run(WebApiApplication.class, args); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)