@Repository
public interface ICodeUnionBankRepository extends JpaRepository<CodeUnionBankDO, String> {
//返回值用接口类型接收(DicItemVO 为接口类型,无需自己实现)
List<DicItemVO> findByIseffectTrueAndIsdeleteFalse();
}
返回值类型
public interface DicItemVO {
String getId();
String getUValue();
}
@Getter
@Setter
@Table(name = "code_finance_union_bank")
@Entity
@ApiModel("银行联行号字典表")
public class CodeUnionBankDO implements Serializable {
@Id
@ApiModelProperty("主键,银行号")
private String id;
@ApiModelProperty("字典项名称")
private String uName;
@ApiModelProperty("字典项值")
private String uValue;
@ApiModelProperty("排序")
private Integer uSort;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建时间")
private Long createtime;
@ApiModelProperty("操作人id")
private Integer operatorid;
@ApiModelProperty("修改时间")
private Long modifytime;
@ApiModelProperty("修改人id")
private Integer modifierid;
@ApiModelProperty("是否删除")
private Boolean isdelete;
@ApiModelProperty("是否生效")
private Boolean iseffect;
}
测试
public class TestJPA{
@Autowired
ICodeUnionBankRepository iCodeUnionBankRepository;
public void testValue() {
List<DicItemVO> byIseffectTrueAndIsdeleteFalse = iCodeUnionBankRepository.findByIseffectTrueAndIsdeleteFalse();
}
}
执行的 SQL 语句
SELECT
codeunionb0_.id AS col_0_0_,
codeunionb0_.u_value AS col_1_0_
FROM
code_finance_union_bank codeunionb0_
WHERE
codeunionb0_.iseffect = 1
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<!--<version>1.5.8.RELEASE</version>-->
</dependency>