[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao ...

Christian Bauer christian at hibernate.org
Thu Apr 26 01:29:18 EDT 2007


  User: cbauer  
  Date: 07/04/26 01:29:18

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/core/dao 
                        NodeDAO.java
  Log:
  Broken Hibernate Search integration, to debug for Emmanuel
  
  Revision  Changes    Path
  1.13      +27 -2     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/NodeDAO.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeDAO.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/NodeDAO.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- NodeDAO.java	19 Apr 2007 18:36:12 -0000	1.12
  +++ NodeDAO.java	26 Apr 2007 05:29:18 -0000	1.13
  @@ -12,8 +12,15 @@
   import org.hibernate.Session;
   import org.hibernate.Criteria;
   import org.hibernate.ScrollableResults;
  +import org.hibernate.search.Search;
  +import org.hibernate.search.FullTextSession;
   import org.hibernate.transform.DistinctRootEntityResultTransformer;
   import org.hibernate.criterion.*;
  +import org.apache.lucene.queryParser.QueryParser;
  +import org.apache.lucene.queryParser.ParseException;
  +import org.apache.lucene.queryParser.MultiFieldQueryParser;
  +import org.apache.lucene.analysis.StopAnalyzer;
  +import org.apache.lucene.analysis.standard.StandardAnalyzer;
   
   import javax.persistence.EntityManager;
   import javax.persistence.EntityNotFoundException;
  @@ -251,8 +258,26 @@
           return null;
       }
   
  +    public List<Node> search(String searchTerm) {
       
  -    public <N extends Node> Map<Long,Long> findCommentCount(Directory directory) {
  +        System.out.println("######### GOT HIBERNATE SESSION");
  +        FullTextSession session = Search.createFullTextSession(getSession());
  +        System.out.println("######### GOT FT SESSION");
  +        QueryParser parser = new QueryParser("Document", new StandardAnalyzer());
  +        System.out.println("######### GOT PARSER");
  +        try {
  +            System.out.println("######### PARSING");
  +            org.apache.lucene.search.Query query = parser.parse("content: " + searchTerm);
  +            System.out.println("######### QUERYING");
  +            //noinspection unchecked
  +            return session.createFullTextQuery(query).list();
  +        } catch (ParseException e) {
  +            // TODO: We need to talk to the lucene guys, this is ridiculous
  +            throw new RuntimeException(e);
  +        }
  +    }
  +    
  +    public Map<Long,Long> findCommentCount(Directory directory) {
           //noinspection unchecked
           List<Object[]> result = restrictedEntityManager
                   .createQuery("select n.nodeId, count(c) from Node n, Comment c where c.document = n and n.parent is :parent group by n.nodeId")
  @@ -294,7 +319,6 @@
       }
   
       private int getRowCount(Criteria criteria) {
  -        restrictedEntityManager.joinTransaction();
           ScrollableResults cursor = criteria.scroll();
           cursor.last();
           int count = cursor.getRowNumber() + 1;
  @@ -316,6 +340,7 @@
       }
   
       private Session getSession() {
  +        restrictedEntityManager.joinTransaction();
           return ((Session)((org.jboss.seam.persistence.EntityManagerProxy) restrictedEntityManager).getDelegate());
       }
   }
  
  
  



More information about the jboss-cvs-commits mailing list