2017-06-02 2 views
0

Ich habe die folgende Klasse ReportReview, wenn ich die Daten mit der Projektion bekomme, gibt es mir die folgenden Daten, aber ich möchte auch Daten ratedProperty in PropertyRating Klasse mit Bericht Bericht, wenn ich dies verwenden Projektion Es gibt mir die folgende AntwortWie bekomme ich Daten mit Projektion im Frühjahr

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 
    } 

PropertyRating.class

@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

@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": "[email protected]", 
      "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" 
      } 
     } 
     } 
    ] 
    }, 

EDITED Property.class

public class Property implements PropertyGetters, Serializable { 
    private static final long serialVersionUID = 1L; 

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

    @ManyToOne(fetch = FetchType.EAGER, targetEntity = User.class) 
    private User owner; 

    @OneToMany(fetch=FetchType.LAZY,targetEntity=UniversityDistance.class,mappedBy="property") 
    private List<UniversityDistance> universityDistances; 

    @OneToMany(fetch=FetchType.LAZY,targetEntity=Room.class, mappedBy="property") 
    private Set<Room> rooms; 


    @JsonIgnore 
    @OneToMany(mappedBy="property",targetEntity=PropertyPhoto.class) 
    private List<PropertyPhoto> photos ; 

// @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 
// ) 
// private Set<UniversityDistance> universityDistances = new HashSet<UniversityDistance>(); 
//  

    @Enumerated(EnumType.STRING) 
    private PropertyType propertyType; 

    @Enumerated(EnumType.STRING) 
    private ContractType contractType; 

    private String propertyTitle; 

    @Enumerated(EnumType.STRING) 
    private PropertyStatus propertyStatus; 

    private String address; 
    @ManyToOne 
    private City city; 

    @Column(length=1000) 
    private String description; 

    private Double latitude; 
    private Double longitude; 
    private boolean wifi; 
    private boolean kitchenAppliances; 
    private boolean laundry; 
    private boolean heating; 
    private boolean cable; 
    private boolean furnished; 
    private boolean gasBill; 
    private boolean hydroBill; 
    private boolean cooling; 
    private boolean parking; 
    private boolean waterBill; 



    private boolean cctv; 
    private boolean maintenance; 
    private boolean secureEntry; 
    private boolean petAllowed; 
    private boolean smokingAllowed; 
    private boolean guestAllowed; 


    private int noOfRoom; 

    @JsonIgnore 
    private float meanRating; 


    @ManyToOne() 
    private Business business; 
    } 

Antwort

0
@JoinColumn(name="ratedProperty") 
    @ManyToOne (cascade = CascadeType.REMOVE, targetEntity = Property.class, fetch = FetchType.EAGER) 
    private Property ratedProperty; 
+0

Wo ich das hinzufügen? – SFAH

+0

Dies ist das gleiche Feld wie in der Klasse 'PropertyRating'. I jave jsut hinzugefügt 'fetch = FetchType.EAGER' – pvpkiran

+0

Nichts ist passiert: | – SFAH

Verwandte Themen