0
그래서 CodeCenterApplications라는 엔티티의 투영을하고 있습니다.스프링 엔티티를 사용한 프로젝션 오류
@Entity
@Table(name = "CODE_CENTER_APPLICATIONS")
public class CodeCenterApplication {
@Id
@Column(columnDefinition = "BIGINT")
protected Integer id;
protected String name;
protected String version;
@JsonFormat(pattern = "yyyy-MM-dd")
protected Date insertionDate;
@ManyToMany
@JoinTable(name = "APPROVALS", joinColumns = {@JoinColumn(name = "APPLICATION_ID", columnDefinition = "BIGINT")},
inverseJoinColumns = {@JoinColumn(name = "API_ID")})
private List<API> apis;
public CodeCenterApplication() {
}
public CodeCenterApplication(Integer id, String name, String version) {
this.id = id;
this.name = name;
this.version = version;
}
public CodeCenterApplication(Integer id, String name, String version, Date insertionDate) {
this.id = id;
this.name = name;
this.version = version;
this.insertionDate = insertionDate;
}
public List<API> getApis() {
return apis;
}
public void setApis(List<API> apis) {
this.apis = apis;
}
/**
* Can be used if you wish to generate a table with the appropriate headers.
*
* @return
*/
@JsonIgnore
public String[] getColumnNames() {
String[] header = {"NAME", "VERSION", "INSERTION_DATE"};
return header;
}
/**
* A giant 'getter' for all all attributes save for id.
*
* @return
*/
@JsonIgnore
public String[] getAttributeList() {
String insertionDateString = "2016-01-01"; //insertionDate.toString();
String[] attributeList = {name, version, insertionDateString};
return attributeList;
}
public int getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String Name) {
this.name = Name;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Date getInsertionDate() {
return insertionDate;
}
public void setInsertionDate(Date insertionDate) {
this.insertionDate = insertionDate;
}
}
아래의 실체를 참조 투사 당신은 내가 이름 만 원하는 참조
마지막으로public interface NameOnly {
String getName();
}
, 여기를
/**
* The following strings are used in creating queries.
*/
String fuzzySchema = "\"FROODES2\"";
String fuzzyTable = "\"APPLICATIONS\"";
String fuzzyColumns = "\"NAME\"";
String fuzzySearchInput = ":name";
String fuzzyGroupSearchString = "SELECT " + fuzzyColumns + " FROM " + fuzzySchema + "." + fuzzyTable
+ " WHERE CONTAINS((" + fuzzyColumns + "), " + fuzzySearchInput + ", FUZZY(0.75)) GROUP BY " +
fuzzyColumns + ", SCORE()" + " ORDER BY " + "SCORE() " + "DESC " + "LIMIT :limit OFFSET :offset";
@Query(value = fuzzyGroupSearchString, nativeQuery = true)
List<NameOnly> findByNameGrouped(@Param("name") String name, @Param("offset") int offset, @Param("limit") int
limit);
를 사용하는 저장소의 방법입니다 수있는, 다음과 같다
그러나이 저장소 메서드를 호출하려고하면 다음 오류가 발생합니다.
org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: Invalid property 'name' of bean class [java.lang.String]: Could not find field for property during fallback access! (through reference chain: java.util.ArrayList[0]->$Proxy136["name"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid property 'name' of bean class [java.lang.String]: Could not find field for property during fallback access! (through reference chain: java.util.ArrayList[0]->$Proxy136["name"])
getName()이 엔티티를 참조하는 것으로 감지되지 않고, 대신 String의 속성을 가져 오는 것으로 생각됩니다.
또한 이것은 첫 번째 질문이기 때문에 비평을 환영합니다.