JpaRepository主要用于数据库数据查询,在springboot的项目中,有如下使用场景:
首先,针对数据库的某张业务表创建一个实体类。需要使用注解声明,与表对应。如果是存储在es,使用
@Document(indexName = "big_log")
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author l 2021/4/28
*/
@Entity
@Table(
name = "T_Alarm"
)
@Component
@Scope("prototype")
public class BigEntity extends BaseBean implements Serializable {
private static final long serialVersionUID = 1325859442141576908L;
@Id
@GeneratedValue(
strategy = GenerationType.AUTO
)
@Column(
name = "ID"
)
private Integer id;
@Column(
length = 50,
nullable = false,
name = "O