Object不是索引实体或索引实体的子类

时间:2013-05-14 17:01:57

标签: hibernate web lucene tapestry hibernate-search

我正在做一些带有hibernate,hibernate搜索,lucene和tapestry的web应用程序。现在,一切都很好,直到我将这部分代码部署到我的应用程序中。我一直收到这个错误

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

0 个答案:

没有答案