Spring data Jpa 返回实体类的指定字段

在使用spring data jpa 时需要返回实体类的特定字段时,定义一个接口类,编写需要返回字段的getter方法。

public interface DoctorDTO {
    Integer getId();
    String getName();
    String getSex();
    String getIdCard();
    String getEmail();
    Long getMobile();
    LocalDate getBirthday();
    String getAvatar();
    String getUsername();
    Integer getDepartment_id();
    Integer getHospital_id();
    Integer getTitle_id();
    Integer getEthnic_id();

}

原理是在运行时会使用动态代理生成实体类

参考:
https://blog.csdn.net/u013905744/article/details/90765048



来自为知笔记(Wiz)


posted on 2022-11-03 09:29  白衣风云  阅读(404)  评论(0编辑  收藏  举报

导航