spring-data-solrを使用して spring -data-jpa を solr と統合していますが、SolrOperations を使用して saveBean(org.domain.Article) を実行すると、例外がスローされます。
org.springframework.data.solr.UncategorizedSolrException: タイプ org.kb.domain.Article からタイプ org.apache.solr.common.SolrInputDocument への値 'Article [id=1,title=test-1, description= test-1、content=test-1、author=test-1、link=test-1、attachment=test-1、date=Sat Jan 05 20:06:12 CST 2013、category=org.kb.domain.Category @ 67e6cf07]'; ネストされた例外は org.apache.solr.client.solrj.beans.BindingException: Invalid setter method です。パラメータは 1 つだけ持つ必要があります。ネストされた例外は org.springframework.core.convert.ConversionFailedException: Failed to convert type org.kb.domain.Article to type org.apache.solr.common.SolrInputDocument for value 'Article [id=1,title=test-1] 、説明 = テスト 1、内容 = テスト 1、作成者 = テスト 1、リンク = テスト 1、添付ファイル = テスト 1、日付 = 2013 年 1 月 5 日土曜日 20:06:12 CST、カテゴリ = org.kb。domain.Category@67e6cf07]'; ネストされた例外は org.apache.solr.client.solrj.beans.BindingException: Invalid setter method です。パラメータは 1 つだけ指定する必要があります
ここに私の豆があります:
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.solr.client.solrj.beans.Field;
import com.fasterxml.jackson.annotation.JsonFormat;
@Entity
@Table(name="article")
public class Article extends IdEntity{
private static final long serialVersionUID = -5170398606065544445L;
private String title;
private String description;
private String content;
private String author;
private String link;
private String attachment;
private Date date;
private Category category;
public Article() {
super();
}
@ManyToOne
@JoinColumn(name="category_id")
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
@Column(name="title")
@Field("title")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Column(name="description")
@Field("description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name="content")
@Field("content")
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Column(name="author")
@Field("author")
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
@Column(name="link")
@Field("link")
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
@Column(name="attachment")
@Field("attachment")
public String getAttachment() {
return attachment;
}
public void setAttachment(String attachment) {
this.attachment = attachment;
}
@Column(name="date")
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+08:00")
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
@Override
public String toString() {
return "Article [id=" + id + ",title=" + title + ", description=" + description
+ ", content=" + content + ", author=" + author + ", link="
+ link + ", attachment=" + attachment + ", date=" + date
+ ", category=" + category + "]";
}
}
import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.apache.solr.client.solrj.beans.Field;
@MappedSuperclass
public abstract class IdEntity implements Serializable{
/**
*
*/
private static final long serialVersionUID = -5676694680777491651L;
protected Long id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Field("id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}