示例#1
0
文件: Daps.java 项目: ideaesb/epiko
  @SuppressWarnings("unchecked")
  public List<Dap> getDaps() {

    if (dapExample != null) {
      Example example =
          Example.create(dapExample).excludeFalse().ignoreCase().enableLike(MatchMode.ANYWHERE);
      return session.createCriteria(Dap.class).add(example).list();
    } else if (searchText != null && searchText.trim().length() > 0) {
      FullTextSession fullTextSession = Search.getFullTextSession(sessionManager.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(Dap.class).get();
      org.apache.lucene.search.Query luceneQuery =
          qb.keyword().onFields("name").matching(searchText).createQuery();

      return fullTextSession.createFullTextQuery(luceneQuery, Dap.class).list();
    } else {
      // default - unfiltered - all entitites list
      return session.createCriteria(Dap.class).list();
    }
  }
  @Override
  public void advise(MethodInvocation invocation) {
    Session session = manager.getSession();

    Transaction transaction = session.beginTransaction();

    try {
      invocation.proceed();

      // Note: as per EJB specs, a checked exception is still considered
      // success, and the transaction still commits.

      transaction.commit();
    } catch (RuntimeException e) {
      transaction.rollback();

      throw e;
    }
  }
示例#3
0
  void onActivate() {
    //        flags = flagDAO.FindAllByContentType(ContentType.Question);
    //        questions = new ArrayList<Question>();
    sess = sessionManager.getSession();
    sess.beginTransaction();
    Criteria crit = sess.createCriteria(Flag.class);
    crit.add(Restrictions.eq("contentType", ContentType.Question));
    crit.setFetchMode("question", FetchMode.JOIN);

    flags = crit.list();

    System.out.println("first question of " + flags.size());
    // sess.close();

    //
    //        flags = new ArrayList();
    //        for (int i = 0; i < temp.size(); i++) {
    //            if(flags.contains(temp.get(i)) != true) {
    //               flags.add(temp.get(i));
    //            }
    //        }
  }