package com.jpa.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
使用Query 查询如何接收下面的返回结果,我要的不是一个属性,而是一个对或者一个集合
/**
-
用户信息类
*
*/
@Data
@ApiModel
@Table(name="users")
@Entity(name = "userVO")
@EntityListeners(AuditingEntityListener.class)
@NamedEntityGraph(name ="UserVO.roles",attributeNodes ={
@NamedAttributeNode("roles")
})
public class UserVO implements Serializable {private Role
List roles;
}
在网上搜到了一个封装返回结果的,但只有一个字段属性,没有接收那个 对象和集合的
@SqlResultSetMapping(name = "ItemResults",
entities = {
@EntityResult(
entityClass = MySqlRenameTableStatement.Item.class, //就是当前这个类的名字
fields = {
@FieldResult(name = "roleId", column = "role_Id"),
@FieldResult(name = "roleName", column = "role_name"),
}
)
},
columns = {
@ColumnResult(name = "item_id")
})
public class RoleVO implements Serializable {