我正在做一些带有休眠、休眠搜索、lucene 和挂毯的网络应用程序。现在,一切正常,直到我将这部分代码部署到我的应用程序中。我不断收到此错误
Render queue error in SetupRender[Index:layout.listarticles.grid]: Failure reading parameter 'source' of component Index:layout.listarticles.grid: java.lang.Object is not an indexed entity or a subclass of an indexed entity
即使我已经用 @Indexed 注释指定了我的 Article 类。什么可能导致此问题?我的继承类可能会导致这个问题,因为我的文章是许多其他子类的顶部,而 HS 或 Lucene 不能提供多态搜索或什么?我现在被困了半个小时。任何帮助表示赞赏。提前致谢。
public class ListArticles {
@Property
@SuppressWarnings("unused")
private Article article;
@Inject
private Session hibernate;
@SessionState // changed from ApplicationState
@Property
private User user;
@Property
private boolean ifUserExists;
private static Logger logger = Logger.getLogger(ListArticles.class);
@Inject
private HibernateSessionManager hibernateSessionManager;
@Property
@Persist(PersistenceConstants.FLASH)
private String searchText;
/**
*
*
* @return list
*/
@CommitAfter
@SuppressWarnings("unchecked")
public List<Article> getArticles() {
if (article != null) {
return hibernate.createCriteria(Article.class).list();
} else if (searchText != null && searchText.trim().length() > 0) {
FullTextSession fullTextSession = Search.getFullTextSession(hibernateSessionManager.getSession());
try {
fullTextSession.createIndexer().startAndWait();
} catch (java.lang.InterruptedException e) {
logger.warn("Lucene Indexing was interrupted by something " + e);
}
QueryBuilder qb = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Article.class).get();
org.apache.lucene.search.Query luceneQuery = qb
.keyword()
.onFields("name, desc")
.matching(searchText)
.createQuery();
return fullTextSession.createFullTextQuery(luceneQuery, Article.class).list();
} else {
// default - unfiltered - all entitites list
return hibernate.createCriteria(Article.class).list();
}
}
// 1520 lines of code trimmed using Built-in plugin CodeTrimmer
我的 ListArticles.tml 文件如下所示
<PostDisplay xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
<p>${message:newestArticles}</p>
<form t:type="Form" t:id="searchForm">
<input t:type="TextField" t:id="searchText" size="30" value="searchText" />
<t:submit t:id="search" value="Search" /><t:submit t:id="clear" value="Clear/Show All" />
</form>
<t:grid source="articles" row="article" include="name, desc" >
<p:nameCell>${article.name}</p:nameCell>
<p:descriptionCell>${article.desc}</p:descriptionCell>
<p:empty>
<p>No articles could be found!</p>
</p:empty>
</t:grid>
</PostDisplay>
我的 Article.java 类看起来像
@Entity
@Table(name="Article")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="ART_TYPE",discriminatorType = DiscriminatorType.STRING)
@Indexed(index="indexes/essays")
public abstract class Article
{
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ART_ID")
@DocumentId
private Long id;
@Basic(optional = false)
@Column(name = "ART_NAME")
@Field
private String name;
@Basic(optional = true)
@Column(name = "ART_DESC")
@Field
private String desc;
@Basic(optional = true)
@Column(name = "ART_IMAGE")
@Field
private String image;
@Basic(optional = true)
@Column(name = "ART_TYPE")
@Field
private String articleType; // hard-coded, make it more pro
@Basic(optional = true)
@Column(name = "ART_SUBTYPE")
@Field
private String articleSubType; // hard-coded, make it more pro
//to change or not to change this ...
@OneToMany(mappedBy = "article", cascade={CascadeType.ALL})
private Collection<Picture> collectionOfPictures;
@OneToMany(mappedBy = "article")
private Collection<StarRates> collectionOfStarRates;
//148 lines of code trimmed using Built-in plugin CodeTrimmer