实体类中(一定要声明构造函数与dao层相等)
@Entity
@Data
@Table(name = "表名")
public class xx{
@Id
private String id;
private String name;
private String password;
//重点需要这个构造函数与dao层相对应
public JobDataSource(String id, String name,String password) {
this.id = id;
this.name = name;
this.password = password;
}
}
dao层
@Query(value = "select new com.xxx.entity.类名(id,name,password)"+
"from 类名 where id =?1")
类名 findByDataid(String id);
最后
以上就是纯真海燕最近收集整理的关于springBootjpa中@Query返回自定义对象类型的全部内容,更多相关springBootjpa中@Query返回自定义对象类型内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复