Java 春季如何利用投影获取数据

Java 春季如何利用投影获取数据,java,spring,entity,getter-setter,projection,Java,Spring,Entity,Getter Setter,Projection,我有以下类ReportReview当我通过投影获得数据时,它会给我以下数据,但我也想在PropertyRating类中通过报告审查获得ratedProperty数据,当我使用此投影时,它会给我以下响应 ReportReview.class private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long i

我有以下类
ReportReview
当我通过投影获得数据时,它会给我以下数据,但我也想在
PropertyRating
类中通过报告审查获得
ratedProperty
数据,当我使用此投影时,它会给我以下响应

ReportReview.class

private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    private User repoter;

    @ManyToOne
    private PropertyRating reportedReview;

   // @OneToOne(mappedBy="PropertyRating",targetEntity=PropertyRating.class)
    //private Property propertyRating;


    @Column(length=1024)
    private String Report;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
      .... Getters and Setters
    }
@EntityListeners(AuditingEntityListener.class)
public class PropertyRating implements PropertyRatingGetters{


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @JsonDeserialize(using = CustomDateDeserializer.class)
    @JsonSerialize(using = CustomDateSerializer.class)
    private Date createdDate;

    @JsonDeserialize(using = CustomDateDeserializer.class)
    @JsonSerialize(using = CustomDateSerializer.class)
    private Date modifiedDate;

    @JoinColumn(name="rater")
    @CreatedBy
    @ManyToOne
    private User rater;

    @JoinColumn(name="ratedProperty")
    @ManyToOne (cascade = CascadeType.REMOVE, targetEntity = Property.class)
    private Property ratedProperty;

    private float rating;


    @Column(length=1024)
    private String reviewText;

..getter and setter
}
PropertyRating.class

private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    private User repoter;

    @ManyToOne
    private PropertyRating reportedReview;

   // @OneToOne(mappedBy="PropertyRating",targetEntity=PropertyRating.class)
    //private Property propertyRating;


    @Column(length=1024)
    private String Report;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
      .... Getters and Setters
    }
@EntityListeners(AuditingEntityListener.class)
public class PropertyRating implements PropertyRatingGetters{


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @JsonDeserialize(using = CustomDateDeserializer.class)
    @JsonSerialize(using = CustomDateSerializer.class)
    private Date createdDate;

    @JsonDeserialize(using = CustomDateDeserializer.class)
    @JsonSerialize(using = CustomDateSerializer.class)
    private Date modifiedDate;

    @JoinColumn(name="rater")
    @CreatedBy
    @ManyToOne
    private User rater;

    @JoinColumn(name="ratedProperty")
    @ManyToOne (cascade = CascadeType.REMOVE, targetEntity = Property.class)
    private Property ratedProperty;

    private float rating;


    @Column(length=1024)
    private String reviewText;

..getter and setter
}
投影

@Projection(name="PropertyWithReportReview", types=ReportReview.class)
public interface PropertyWithReportReview extends ReportReviewGetter {

}
reportReviewGetter

 public interface ReportReviewGetter {

         Long getId();
         User getRepoter();
         PropertyRating getReportedReview();
         String getReport();
    }

**Response I get** 
"reportReviews": [
      {
        "id": 1,
        "report": "abc",
        "repoter": {
          "id": 2,
          "logonEmail": "student@gmail.com",
          "name": "Student",
          "emailVerified": true,
          "address": "A-213",
          "postcode": "888",
          "phoneNo": "2342",
          "passportNo": null,
          "description": null,
          "meanRating": 2
        },
        "reportedReview": {
          "id": 1,
          "createdDate": null,
          "modifiedDate": null,
          "rating": 3,
          "reviewText": "gfhdvfb"
        },
        "_links": {
          "self": {
            "href": "http://localhost:8555/api/reportReviews/1"
          },
          "reportReview": {
            "href": "http://localhost:8555/api/reportReviews/1{?projection}",
            "templated": true
          },
          "repoter": {
            "href": "http://localhost:8555/api/reportReviews/1/repoter"
          },
          "reportedReview": {
            "href": "http://localhost:8555/api/reportReviews/1/reportedReview"
          }
        }
      }
    ]
  },
已编辑 属性类

private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    private User repoter;

    @ManyToOne
    private PropertyRating reportedReview;

   // @OneToOne(mappedBy="PropertyRating",targetEntity=PropertyRating.class)
    //private Property propertyRating;


    @Column(length=1024)
    private String Report;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
      .... Getters and Setters
    }
@EntityListeners(AuditingEntityListener.class)
public class PropertyRating implements PropertyRatingGetters{


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @JsonDeserialize(using = CustomDateDeserializer.class)
    @JsonSerialize(using = CustomDateSerializer.class)
    private Date createdDate;

    @JsonDeserialize(using = CustomDateDeserializer.class)
    @JsonSerialize(using = CustomDateSerializer.class)
    private Date modifiedDate;

    @JoinColumn(name="rater")
    @CreatedBy
    @ManyToOne
    private User rater;

    @JoinColumn(name="ratedProperty")
    @ManyToOne (cascade = CascadeType.REMOVE, targetEntity = Property.class)
    private Property ratedProperty;

    private float rating;


    @Column(length=1024)
    private String reviewText;

..getter and setter
}
公共类属性实现可序列化的PropertyGatters{
私有静态最终长serialVersionUID=1L;
@身份证
@GeneratedValue(策略=GenerationType.IDENTITY)
私人长id;
@manytone(fetch=FetchType.EAGER,targetEntity=User.class)
私人用户所有者;
@OneToMany(fetch=FetchType.LAZY,targetEntity=UniversityDistance.class,mappedBy=“property”)
私立大学距离;
@OneToMany(fetch=FetchType.LAZY,targetEntity=Room.class,mappedBy=“property”)
私人套房;
@杰索尼奥雷
@OneToMany(mappedBy=“property”,targetEntity=PropertyPhoto.class)
私人名单照片;
//@ManyToMany(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE})
////@JoinTable(name=“tbu1213”,joinColumns={@JoinColumn(name=“businessid”,referencedColumnName=“businessid”)},inverseJoinColumns=@JoinColumn(name=“userid”))
//@org.hibernate.annotations.LazyCollection(
//org.hibernate.annotations.LazyCollectionOption.EXTRA
//  )   
//私有集universitydistance=新HashSet();
//    
@枚举(EnumType.STRING)
私有属性类型属性类型;
@枚举(EnumType.STRING)
私人契约型契约型;
私有字符串propertyTitle;
@枚举(EnumType.STRING)
私人财产状态;财产状态;
私有字符串地址;
@许多酮
私人城市;
@列(长度=1000)
私有字符串描述;
私人双纬度;
私人双经度;
专用无线网络;
私人厨房用具;
私人洗衣房;
私人供暖;
专用布尔电缆;
私人住宅;
私人煤气单;
私人票据;
私有布尔冷却;
私人停车场;
私人水疗;
私人电视台;
私有布尔维护;
私有布尔安全入口;
允许私有布尔值;
禁止私自吸烟;
私人布尔宾馆;
诺夫罗姆私人酒店;
@杰索尼奥雷
私人浮动利率;
@ManyToOne()
私营企业;
}

我在哪里添加此字段?此字段与“PropertyRating”类中的字段相同。我jave jsut添加了
fetch=FetchType.EAGER
什么也没发生:|您的
属性
类在哪里。它看起来怎么样?检查你的投影界面。这是不对的。