fixing bug associated with getTaxaByCommonName(); benchmarking taxa by common name...
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Fri, 13 Jan 2012 15:05:35 +0000 (15:05 +0000)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Fri, 13 Jan 2012 15:05:35 +0000 (15:05 +0000)
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonDao.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/search/CdmMassIndexer.java
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/ITaxonServiceConfigurator.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceSearchTest.java

index 4a36aa481ea35ef9e67cf822083a9b88930ed644..42842cea4c8184e26952bde1796858e0626bfe7c 100644 (file)
@@ -317,17 +317,17 @@ public class TaxonDaoHibernateImpl extends IdentifiableDaoBase<TaxonBase> implem
      * (non-Javadoc)\r
      * @see eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao#getTaxaByCommonName(java.lang.String, eu.etaxonomy.cdm.model.taxon.Classification, eu.etaxonomy.cdm.persistence.query.MatchMode, java.util.Set, java.lang.Integer, java.lang.Integer, java.util.List)\r
      */\r
      * (non-Javadoc)\r
      * @see eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao#getTaxaByCommonName(java.lang.String, eu.etaxonomy.cdm.model.taxon.Classification, eu.etaxonomy.cdm.persistence.query.MatchMode, java.util.Set, java.lang.Integer, java.lang.Integer, java.util.List)\r
      */\r
-    public List<TaxonBase> getTaxaByCommonName(String queryString, Classification classification,\r
+    public List<Object[]> getTaxaByCommonName(String queryString, Classification classification,\r
             MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageSize,\r
             Integer pageNumber, List<String> propertyPaths) {\r
             boolean doCount = false;\r
             Query query = prepareTaxaByCommonName(queryString, classification, matchMode, namedAreas, pageSize, pageNumber, doCount);\r
             if (query != null){\r
             MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageSize,\r
             Integer pageNumber, List<String> propertyPaths) {\r
             boolean doCount = false;\r
             Query query = prepareTaxaByCommonName(queryString, classification, matchMode, namedAreas, pageSize, pageNumber, doCount);\r
             if (query != null){\r
-                List<TaxonBase> results = query.list();\r
+                List<Object[]> results = query.list();\r
                 defaultBeanInitializer.initializeAll(results, propertyPaths);\r
                 return results;\r
             }\r
                 defaultBeanInitializer.initializeAll(results, propertyPaths);\r
                 return results;\r
             }\r
-            return new ArrayList<TaxonBase>();\r
+            return new ArrayList<Object[]>();\r
 \r
     }\r
 \r
 \r
     }\r
 \r
index 24e8a2a02fb416ff997e116b066811552676947a..a36ab118221d4a6dd02f8fafb14aeea8f32738b6 100644 (file)
@@ -189,7 +189,17 @@ public interface ITaxonDao extends IIdentifiableDao<TaxonBase>, ITitledDao<Taxon
      */\r
     public List<TaxonBase> findByNameTitleCache(boolean doTaxa, boolean doSynonyms, String queryString, Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageNumber, Integer pageSize, List<String> propertyPaths) ;\r
 \r
      */\r
     public List<TaxonBase> findByNameTitleCache(boolean doTaxa, boolean doSynonyms, String queryString, Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageNumber, Integer pageSize, List<String> propertyPaths) ;\r
 \r
-    public List<TaxonBase> getTaxaByCommonName(String queryString, Classification classification,\r
+    /**\r
+     * @param queryString\r
+     * @param classification\r
+     * @param matchMode\r
+     * @param namedAreas\r
+     * @param pageSize\r
+     * @param pageNumber\r
+     * @param propertyPaths\r
+     * @return A List of arrays. Each entry array holds the following entities: Taxon, CommonName, Description, Feature\r
+     */\r
+    public List<Object[]> getTaxaByCommonName(String queryString, Classification classification,\r
     MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageSize,\r
     Integer pageNumber, List<String> propertyPaths);\r
 \r
     MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageSize,\r
     Integer pageNumber, List<String> propertyPaths);\r
 \r
index 6902348ea567df002bce960a958555de8f306c3b..af9dad3c42cbcbd59373a3ad5c7f13592cc7e200 100644 (file)
@@ -62,7 +62,7 @@ public class CdmMassIndexer implements ICdmMassIndexer {
         fullTextSession.setFlushMode(FlushMode.MANUAL);
         fullTextSession.setCacheMode(CacheMode.IGNORE);
 
         fullTextSession.setFlushMode(FlushMode.MANUAL);
         fullTextSession.setCacheMode(CacheMode.IGNORE);
 
-        logger.error("start indexing " + type.getName());
+        logger.info("start indexing " + type.getName());
         Transaction transaction = fullTextSession.beginTransaction();
 
         Object countResultObj = getSession().createQuery("select count(*) from " + type.getName()).uniqueResult();
         Transaction transaction = fullTextSession.beginTransaction();
 
         Object countResultObj = getSession().createQuery("select count(*) from " + type.getName()).uniqueResult();
@@ -78,21 +78,21 @@ public class CdmMassIndexer implements ICdmMassIndexer {
             if (index % BATCH_SIZE == 0 || index == countResult) {
                 fullTextSession.flushToIndexes(); // apply changes to indexes
                 fullTextSession.clear(); // clear since the queue is processed
             if (index % BATCH_SIZE == 0 || index == countResult) {
                 fullTextSession.flushToIndexes(); // apply changes to indexes
                 fullTextSession.clear(); // clear since the queue is processed
-                logger.error("\tbatch " + index / BATCH_SIZE + "/" + numOfBatches + " processed");
+                logger.info("\tbatch " + index / BATCH_SIZE + "/" + numOfBatches + " processed");
                 //if(index / BATCH_SIZE > 10 ) break;
             }
         }
 
         //transaction.commit(); // no need to commit, transaction will be committed automatically
                 //if(index / BATCH_SIZE > 10 ) break;
             }
         }
 
         //transaction.commit(); // no need to commit, transaction will be committed automatically
-        logger.error("end indexing " + type.getName());
+        logger.info("end indexing " + type.getName());
     }
 
     protected <T extends CdmBase>void purge(Class<T> type) {
 
         FullTextSession fullTextSession = Search.getFullTextSession(getSession());
 
     }
 
     protected <T extends CdmBase>void purge(Class<T> type) {
 
         FullTextSession fullTextSession = Search.getFullTextSession(getSession());
 
-        logger.error("purging " + type.getName());
-//        Transaction transaction = fullTextSession.beginTransaction();
+        logger.info("purging " + type.getName());
+
         fullTextSession.purgeAll(type);
         //transaction.commit(); // no need to commit, transaction will be committed automatically
     }
         fullTextSession.purgeAll(type);
         //transaction.commit(); // no need to commit, transaction will be committed automatically
     }
index c2993962f1d5a2ceb6d4bc29923681f88daba08b..8f404d2e5b2c06267288c44bc881b8cb33ed444a 100644 (file)
@@ -1000,13 +1000,13 @@ public class TaxonDaoHibernateImplTest extends CdmTransactionalIntegrationTest {
     public void testGetCommonName(){\r
 \r
 \r
     public void testGetCommonName(){\r
 \r
 \r
-        List textData = taxonDao.getTaxaByCommonName("common%", null,\r
+        List<Object[]> commonNameResults = taxonDao.getTaxaByCommonName("common%", null,\r
                 MatchMode.BEGINNING, null, null, null, null);\r
 \r
                 MatchMode.BEGINNING, null, null, null, null);\r
 \r
-        assertNotNull("getTaxaByCommonName should return a list", textData);\r
-        assertFalse("the list should not be empty", textData.isEmpty());\r
-        assertEquals("There should be one Taxon with common name", 1,textData.size());\r
-//     System.err.println("Number of common names: " +textData.size());\r
+        assertNotNull("getTaxaByCommonName should return a list", commonNameResults);\r
+        assertFalse("the list should not be empty", commonNameResults.isEmpty());\r
+        assertEquals("There should be one Taxon with common name", 1,commonNameResults.size());\r
+        assertEquals(" sec. ???", ((TaxonBase)commonNameResults.get(0)[0]).getTitleCache());\r
 \r
     }\r
 \r
 \r
     }\r
 \r
index 0891308198bbe9bce9fc55a8c1f7133e3f914af4..32dd4cf5fde0efdc1b948b5c6a25b9feb9fe5d1d 100644 (file)
@@ -527,13 +527,13 @@ public class TaxonServiceImpl extends IdentifiableServiceBase<TaxonBase,ITaxonDa
         // Taxa and synonyms\r
         long numberTaxaResults = 0L;\r
 \r
         // Taxa and synonyms\r
         long numberTaxaResults = 0L;\r
 \r
-        \r
+\r
         List<String> propertyPath = new ArrayList<String>();\r
         if(configurator.getTaxonPropertyPath() != null){\r
             propertyPath.addAll(configurator.getTaxonPropertyPath());\r
         }\r
         List<String> propertyPath = new ArrayList<String>();\r
         if(configurator.getTaxonPropertyPath() != null){\r
             propertyPath.addAll(configurator.getTaxonPropertyPath());\r
         }\r
-        \r
-        \r
+\r
+\r
        if (configurator.isDoMisappliedNames() || configurator.isDoSynonyms() || configurator.isDoTaxa()){\r
             if(configurator.getPageSize() != null){ // no point counting if we need all anyway\r
                 numberTaxaResults =\r
        if (configurator.isDoMisappliedNames() || configurator.isDoSynonyms() || configurator.isDoTaxa()){\r
             if(configurator.getPageSize() != null){ // no point counting if we need all anyway\r
                 numberTaxaResults =\r
@@ -581,13 +581,16 @@ public class TaxonServiceImpl extends IdentifiableServiceBase<TaxonBase,ITaxonDa
         // Taxa from common names\r
 \r
         if (configurator.isDoTaxaByCommonNames()) {\r
         // Taxa from common names\r
 \r
         if (configurator.isDoTaxaByCommonNames()) {\r
-            taxa = null;\r
+            taxa = new ArrayList<TaxonBase>();\r
             numberTaxaResults = 0;\r
             if(configurator.getPageSize() != null){// no point counting if we need all anyway\r
                 numberTaxaResults = dao.countTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas());\r
             }\r
             if(configurator.getPageSize() == null || numberTaxaResults > configurator.getPageSize() * configurator.getPageNumber()){\r
             numberTaxaResults = 0;\r
             if(configurator.getPageSize() != null){// no point counting if we need all anyway\r
                 numberTaxaResults = dao.countTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas());\r
             }\r
             if(configurator.getPageSize() == null || numberTaxaResults > configurator.getPageSize() * configurator.getPageNumber()){\r
-                taxa = dao.getTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas(), configurator.getPageSize(), configurator.getPageNumber(), configurator.getTaxonPropertyPath());\r
+                List<Object[]> commonNameResults = dao.getTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas(), configurator.getPageSize(), configurator.getPageNumber(), configurator.getTaxonPropertyPath());\r
+                for( Object[] entry : commonNameResults ) {\r
+                    taxa.add((TaxonBase) entry[0]);\r
+                }\r
             }\r
             if(taxa != null){\r
                 results.addAll(taxa);\r
             }\r
             if(taxa != null){\r
                 results.addAll(taxa);\r
index 9fb7f2096ea38d629f2b3feda99dfd6751aa7983..78c645d63725e3301e37f65d85a2c40ee9ba9156 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$\r
 /**\r
 * Copyright (C) 2009 EDIT\r
 // $Id$\r
 /**\r
 * Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
 * http://www.e-taxonomy.eu\r
 * http://www.e-taxonomy.eu\r
-* \r
+*\r
 * The contents of this file are subject to the Mozilla Public License Version 1.1\r
 * See LICENSE.TXT at the top of this package for the full license terms.\r
 */\r
 * The contents of this file are subject to the Mozilla Public License Version 1.1\r
 * See LICENSE.TXT at the top of this package for the full license terms.\r
 */\r
@@ -24,47 +24,47 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
  */\r
 public interface ITaxonServiceConfigurator<T extends TaxonBase> extends IIdentifiableEntityServiceConfigurator<T>{\r
 \r
  */\r
 public interface ITaxonServiceConfigurator<T extends TaxonBase> extends IIdentifiableEntityServiceConfigurator<T>{\r
 \r
-       public boolean isDoTaxa();\r
-       \r
-       public void setDoTaxa(boolean doTaxa);\r
-\r
-       public boolean isDoSynonyms();\r
-       \r
-       public void setDoSynonyms(boolean doSynonyms);\r
-       \r
-       public boolean isDoNamesWithoutTaxa();\r
-       \r
-       public void setDoNamesWithoutTaxa(boolean doNamesWithoutTaxa);\r
-\r
-       public boolean isDoTaxaByCommonNames();\r
-       \r
-       public void setDoTaxaByCommonNames(boolean doTaxaByCommonNames);\r
-\r
-       public Classification getClassification();\r
-       \r
-       public void setClassification(Classification classification);\r
-       \r
-       public Set<NamedArea> getNamedAreas();\r
-\r
-       public void setNamedAreas(Set<NamedArea> areas);\r
-       \r
-       public List<String> getTaxonPropertyPath();\r
-\r
-       public void setTaxonPropertyPath(List<String> taxonPropertyPath);\r
-       \r
-       public List<String> getTaxonNamePropertyPath();\r
-\r
-       public void setTaxonNamePropertyPath(List<String> taxonNamePropertyPath);\r
-\r
-       public List<String> getCommonNamePropertyPath();\r
-\r
-       public void setCommonNamePropertyPath(List<String> commonNamePropertyPath);\r
-\r
-       public List<String> getSynonymPropertyPath();\r
-       \r
-       public void setSynonymPropertyPath(List<String> synonymPropertyPath);\r
-       \r
-       public boolean isDoMisappliedNames();\r
-       \r
-       public void setDoMisappliedNames(boolean doMisappliedNames);\r
+    public boolean isDoTaxa();\r
+\r
+    public void setDoTaxa(boolean doTaxa);\r
+\r
+    public boolean isDoSynonyms();\r
+\r
+    public void setDoSynonyms(boolean doSynonyms);\r
+\r
+    public boolean isDoNamesWithoutTaxa();\r
+\r
+    public void setDoNamesWithoutTaxa(boolean doNamesWithoutTaxa);\r
+\r
+    public boolean isDoTaxaByCommonNames();\r
+\r
+    public void setDoTaxaByCommonNames(boolean doTaxaByCommonNames);\r
+\r
+    public Classification getClassification();\r
+\r
+    public void setClassification(Classification classification);\r
+\r
+    public Set<NamedArea> getNamedAreas();\r
+\r
+    public void setNamedAreas(Set<NamedArea> areas);\r
+\r
+    public List<String> getTaxonPropertyPath();\r
+\r
+    public void setTaxonPropertyPath(List<String> taxonPropertyPath);\r
+\r
+    public List<String> getTaxonNamePropertyPath();\r
+\r
+    public void setTaxonNamePropertyPath(List<String> taxonNamePropertyPath);\r
+\r
+    public List<String> getCommonNamePropertyPath(); //unused\r
+\r
+    public void setCommonNamePropertyPath(List<String> commonNamePropertyPath);\r
+\r
+    public List<String> getSynonymPropertyPath(); // unused\r
+\r
+    public void setSynonymPropertyPath(List<String> synonymPropertyPath);\r
+\r
+    public boolean isDoMisappliedNames();\r
+\r
+    public void setDoMisappliedNames(boolean doMisappliedNames);\r
 }\r
 }\r
index 8eec93e021aeb9940a78f16a12409fb1dd2ffbf9..f416c667e01de087534c2e97f82f1111a8be733e 100644 (file)
@@ -1,11 +1,11 @@
 /**\r
 /**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
+ * Copyright (C) 2009 EDIT\r
+ * European Distributed Institute of Taxonomy\r
+ * http://www.e-taxonomy.eu\r
+ *\r
+ * The contents of this file are subject to the Mozilla Public License Version 1.1\r
+ * See LICENSE.TXT at the top of this package for the full license terms.\r
+ */\r
 \r
 package eu.etaxonomy.cdm.api.service;\r
 \r
 \r
 package eu.etaxonomy.cdm.api.service;\r
 \r
@@ -14,31 +14,27 @@ import static org.junit.Assert.assertTrue;
 \r
 import java.io.IOException;\r
 import java.util.List;\r
 \r
 import java.io.IOException;\r
 import java.util.List;\r
-import java.util.UUID;\r
 \r
 \r
+import org.apache.commons.lang.RandomStringUtils;\r
 import org.apache.log4j.Logger;\r
 import org.apache.lucene.index.CorruptIndexException;\r
 import org.apache.lucene.queryParser.ParseException;\r
 import org.apache.log4j.Logger;\r
 import org.apache.lucene.index.CorruptIndexException;\r
 import org.apache.lucene.queryParser.ParseException;\r
-import org.hibernate.Hibernate;\r
 import org.junit.Assert;\r
 import org.junit.Assert;\r
+import org.junit.Ignore;\r
 import org.junit.Test;\r
 import org.unitils.dbunit.annotation.DataSet;\r
 import org.junit.Test;\r
 import org.unitils.dbunit.annotation.DataSet;\r
-import org.unitils.hibernate.HibernateUnitils;\r
 import org.unitils.spring.annotation.SpringBeanByType;\r
 \r
 import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.TaxonServiceConfiguratorImpl;\r
 import eu.etaxonomy.cdm.api.service.pager.Pager;\r
 import eu.etaxonomy.cdm.api.service.search.SearchResult;\r
 import org.unitils.spring.annotation.SpringBeanByType;\r
 \r
 import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.TaxonServiceConfiguratorImpl;\r
 import eu.etaxonomy.cdm.api.service.pager.Pager;\r
 import eu.etaxonomy.cdm.api.service.search.SearchResult;\r
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;\r
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
 import eu.etaxonomy.cdm.model.common.Language;\r
 import eu.etaxonomy.cdm.model.description.CommonTaxonName;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
 import eu.etaxonomy.cdm.model.common.Language;\r
 import eu.etaxonomy.cdm.model.description.CommonTaxonName;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
-import eu.etaxonomy.cdm.model.description.Feature;\r
 import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
 import eu.etaxonomy.cdm.model.description.TextData;\r
 import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
 import eu.etaxonomy.cdm.model.description.TextData;\r
-import eu.etaxonomy.cdm.model.description.TextFormat;\r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 import eu.etaxonomy.cdm.model.name.NonViralName;\r
 import eu.etaxonomy.cdm.model.name.Rank;\r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 import eu.etaxonomy.cdm.model.name.NonViralName;\r
 import eu.etaxonomy.cdm.model.name.Rank;\r
@@ -46,11 +42,9 @@ import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.reference.Reference;\r
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;\r
 import eu.etaxonomy.cdm.model.taxon.Synonym;\r
 import eu.etaxonomy.cdm.model.reference.Reference;\r
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;\r
 import eu.etaxonomy.cdm.model.taxon.Synonym;\r
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;\r
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;\r
 import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
 import eu.etaxonomy.cdm.search.ICdmMassIndexer;\r
 import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;\r
 import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
 import eu.etaxonomy.cdm.search.ICdmMassIndexer;\r
 import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;\r
@@ -61,6 +55,9 @@ import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
  * @version 1.0\r
  */\r
 public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {\r
  * @version 1.0\r
  */\r
 public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {\r
+\r
+    private static final int NUM_OF_NEW_RADOM_ENTITIES = 1000;\r
+\r
     private static Logger logger = Logger.getLogger(TaxonServiceSearchTest.class);\r
 \r
     @SpringBeanByType\r
     private static Logger logger = Logger.getLogger(TaxonServiceSearchTest.class);\r
 \r
     @SpringBeanByType\r
@@ -74,6 +71,7 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
     @SpringBeanByType\r
     private ICdmMassIndexer indexer;\r
 \r
     @SpringBeanByType\r
     private ICdmMassIndexer indexer;\r
 \r
+    private static final int BENCHMARK_ROUNDS = 10;\r
 \r
     @Test\r
     public void testDbUnitUsageTest() throws Exception {\r
 \r
     @Test\r
     public void testDbUnitUsageTest() throws Exception {\r
@@ -82,14 +80,14 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
     }\r
 \r
     /**\r
     }\r
 \r
     /**\r
-     * Test method for {@link eu.etaxonomy.cdm.api.service.TaxonServiceImpl#findTaxaAndNames(eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator)}.\r
+     * Test method for\r
+     * {@link eu.etaxonomy.cdm.api.service.TaxonServiceImpl#findTaxaAndNames(eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator)}\r
+     * .\r
      */\r
     @Test\r
     @DataSet\r
     public final void testFindTaxaAndNames() {\r
 \r
      */\r
     @Test\r
     @DataSet\r
     public final void testFindTaxaAndNames() {\r
 \r
-        printDataSet(System.err, new String[] {"TaxonBase"});\r
-\r
         ITaxonServiceConfigurator configurator = new TaxonServiceConfiguratorImpl();\r
         configurator.setTitleSearchString("Abies*");\r
         configurator.setMatchMode(MatchMode.BEGINNING);\r
         ITaxonServiceConfigurator configurator = new TaxonServiceConfiguratorImpl();\r
         configurator.setTitleSearchString("Abies*");\r
         configurator.setMatchMode(MatchMode.BEGINNING);\r
@@ -104,18 +102,19 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
             for (int i = 0; i < list.size(); i++) {\r
                 String nameCache = "";\r
                 if (list.get(i) instanceof NonViralName) {\r
             for (int i = 0; i < list.size(); i++) {\r
                 String nameCache = "";\r
                 if (list.get(i) instanceof NonViralName) {\r
-                    nameCache = ((NonViralName<?>)list.get(i)).getNameCache();\r
+                    nameCache = ((NonViralName<?>) list.get(i)).getNameCache();\r
                 } else if (list.get(i) instanceof TaxonBase) {\r
                 } else if (list.get(i) instanceof TaxonBase) {\r
-                    TaxonNameBase taxonNameBase= ((TaxonBase)list.get(i)).getName();\r
-                    nameCache = ((NonViralName)taxonNameBase).getNameCache();\r
-                } else {}\r
-                logger.debug(list.get(i).getClass() + "(" + i +")" +\r
-                        ": Name Cache = " + nameCache + ", Title Cache = " + list.get(i).getTitleCache());\r
+                    TaxonNameBase taxonNameBase = ((TaxonBase) list.get(i)).getName();\r
+                    nameCache = ((NonViralName) taxonNameBase).getNameCache();\r
+                } else {\r
+                }\r
+                logger.debug(list.get(i).getClass() + "(" + i + ")" + ": Name Cache = " + nameCache + ", Title Cache = "\r
+                        + list.get(i).getTitleCache());\r
             }\r
         }\r
 \r
             }\r
         }\r
 \r
-        logger.debug("number of taxa: "+list.size());\r
-        assertTrue(list.size()==7);\r
+        logger.debug("number of taxa: " + list.size());\r
+        assertTrue(list.size() == 7);\r
     }\r
 \r
     /**\r
     }\r
 \r
     /**\r
@@ -124,7 +123,7 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
      * .\r
      */\r
     @Test\r
      * .\r
      */\r
     @Test\r
-//    @DataSet\r
+    @DataSet\r
     public final void testSearchTaxaByName() {\r
         logger.warn("testSearchTaxaByName not yet implemented"); // TODO\r
     }\r
     public final void testSearchTaxaByName() {\r
         logger.warn("testSearchTaxaByName not yet implemented"); // TODO\r
     }\r
@@ -134,15 +133,12 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
     @DataSet\r
     public final void testFindByDescriptionElementFullText() throws CorruptIndexException, IOException, ParseException {\r
 \r
     @DataSet\r
     public final void testFindByDescriptionElementFullText() throws CorruptIndexException, IOException, ParseException {\r
 \r
-        indexer.reindex();\r
-        //\r
-        endTransaction();\r
-        startNewTransaction();\r
+        refreshLuceneIndex();\r
 \r
         Pager<SearchResult<TaxonBase>> pager;\r
 \r
         pager = taxonService.findByDescriptionElementFullText(CommonTaxonName.class, "Weiß*", null, null, null, null);\r
 \r
         Pager<SearchResult<TaxonBase>> pager;\r
 \r
         pager = taxonService.findByDescriptionElementFullText(CommonTaxonName.class, "Weiß*", null, null, null, null);\r
-        Assert.assertEquals("Expecting one entity", Integer.valueOf(1),  pager.getCount());\r
+        Assert.assertEquals("Expecting one entity", Integer.valueOf(1), pager.getCount());\r
         Assert.assertEquals("Abies alba sec. ", pager.getRecords().get(0).getEntity().getTitleCache());\r
         Assert.assertEquals("Abies alba sec. ", pager.getRecords().get(0).getDoc().get("inDescription.taxon.titleCache"));\r
 \r
         Assert.assertEquals("Abies alba sec. ", pager.getRecords().get(0).getEntity().getTitleCache());\r
         Assert.assertEquals("Abies alba sec. ", pager.getRecords().get(0).getDoc().get("inDescription.taxon.titleCache"));\r
 \r
@@ -150,16 +146,18 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
         TaxonBase taxon = pager.getRecords().get(0).getEntity();\r
 \r
         String newName = "Quercus robur";\r
         TaxonBase taxon = pager.getRecords().get(0).getEntity();\r
 \r
         String newName = "Quercus robur";\r
-        // TODO setting the taxon.titleCache indirectly via the taxonName doe not work for some reason ...\r
-//        BotanicalName name = HibernateProxyHelper.deproxy(taxon.getName(), BotanicalName.class);\r
-//        name.setProtectedNameCache(false);\r
-//        name.setGenusOrUninomial("Quercus");\r
-//        name.setSpecificEpithet("robur");\r
-//        name.setNameCache(newNameCache, true);\r
-//        name.setFullTitleCache(newNameCache, true);\r
-//        name.setTitleCache(newNameCache, true);\r
+        // TODO setting the taxon.titleCache indirectly via the taxonName doe\r
+        // not work for some reason ...\r
+        // BotanicalName name = HibernateProxyHelper.deproxy(taxon.getName(),\r
+        // BotanicalName.class);\r
+        // name.setProtectedNameCache(false);\r
+        // name.setGenusOrUninomial("Quercus");\r
+        // name.setSpecificEpithet("robur");\r
+        // name.setNameCache(newNameCache, true);\r
+        // name.setFullTitleCache(newNameCache, true);\r
+        // name.setTitleCache(newNameCache, true);\r
         // TODO (continued) ... need to set it directly:\r
         // TODO (continued) ... need to set it directly:\r
-        taxon.setTitleCache(newName  + " sec. ", true);\r
+        taxon.setTitleCache(newName + " sec. ", true);\r
 \r
         taxonService.saveOrUpdate(taxon);\r
 \r
 \r
         taxonService.saveOrUpdate(taxon);\r
 \r
@@ -167,7 +165,7 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
         endTransaction();\r
         startNewTransaction();\r
 \r
         endTransaction();\r
         startNewTransaction();\r
 \r
-        printDataSet(System.err, new String[] {"TaxonBase", "TaxonNameBase"});\r
+        // printDataSet(System.err, new String[] {"TaxonBase", "TaxonNameBase"});\r
 \r
         taxon = taxonService.load(taxon.getUuid());\r
         Assert.assertEquals(newName + " sec. ", taxon.getTitleCache());\r
 \r
         taxon = taxonService.load(taxon.getUuid());\r
         Assert.assertEquals(newName + " sec. ", taxon.getTitleCache());\r
@@ -179,8 +177,74 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
 \r
     }\r
 \r
 \r
     }\r
 \r
+    /**\r
+     *\r
+     */\r
+    private void refreshLuceneIndex() {\r
+        indexer.purge();\r
+        indexer.reindex();\r
+\r
+        endTransaction();\r
+        startNewTransaction();\r
+    }\r
+\r
+    @SuppressWarnings("rawtypes")\r
+    @Test\r
+    @Ignore //there seems to be a bug in unitils 1.0 which prevents from adding data to an non blank db. This problem might be fixed in recent versions of unitils version > 3.3\r
+    @DataSet\r
+    public final void testFindByCommonNameHqlBenchmark() throws CorruptIndexException, IOException, ParseException {\r
+\r
+        printDataSet(System.err, new String[] { "TaxonBase" });\r
+\r
+        createRandomTaxonWithCommonName(NUM_OF_NEW_RADOM_ENTITIES);\r
 \r
 \r
-//     @Test\r
+        ITaxonServiceConfigurator configurator = new TaxonServiceConfiguratorImpl();\r
+        configurator.setTitleSearchString("Weiß%");\r
+        configurator.setMatchMode(MatchMode.BEGINNING);\r
+        configurator.setDoTaxa(false);\r
+        configurator.setDoSynonyms(false);\r
+        configurator.setDoNamesWithoutTaxa(false);\r
+        configurator.setDoTaxaByCommonNames(true);\r
+\r
+        Pager<IdentifiableEntity> pager;\r
+\r
+        long startMillis = System.currentTimeMillis();\r
+        for (int indx = 0; indx < BENCHMARK_ROUNDS; indx++) {\r
+            pager = taxonService.findTaxaAndNames(configurator);\r
+            if (logger.isDebugEnabled()) {\r
+                logger.debug("[" + indx + "]" + pager.getRecords().get(0).getTitleCache());\r
+            }\r
+        }\r
+        double duration = ((double) (System.currentTimeMillis() - startMillis)) / BENCHMARK_ROUNDS;\r
+        logger.info("Benchmark result - [find taxon by CommonName via HQL] : " + duration + "ms (" + BENCHMARK_ROUNDS + " benchmark rounds )");\r
+    }\r
+\r
+    @SuppressWarnings("rawtypes")\r
+    @Test\r
+    @Ignore //there seems to be a bug in unitils 1.0 which prevents from adding data to an non blank db. This problem might be fixed in recent versions of unitils version > 3.3\r
+    @DataSet\r
+    public final void testFindByCommonNameLuceneBenchmark() throws CorruptIndexException, IOException, ParseException {\r
+\r
+//        printDataSet(System.err, new String[] { "TaxonBase" });\r
+\r
+        createRandomTaxonWithCommonName(NUM_OF_NEW_RADOM_ENTITIES);\r
+\r
+        refreshLuceneIndex();\r
+\r
+        Pager<SearchResult<TaxonBase>> pager;\r
+\r
+        long startMillis = System.currentTimeMillis();\r
+        for (int indx = 0; indx < BENCHMARK_ROUNDS; indx++) {\r
+            pager = taxonService.findByDescriptionElementFullText(CommonTaxonName.class, "Weiß*", null, null, null, null);\r
+            if (logger.isDebugEnabled()) {\r
+                logger.debug("[" + indx + "]" + pager.getRecords().get(0).getEntity().getTitleCache());\r
+            }\r
+        }\r
+        double duration = ((double) (System.currentTimeMillis() - startMillis)) / BENCHMARK_ROUNDS;\r
+        logger.info("Benchmark result - [find taxon by CommonName via lucene] : " + duration + "ms (" + BENCHMARK_ROUNDS + " benchmark rounds )");\r
+    }\r
+\r
+//    @Test\r
     @DataSet("BlankDataSet.xml")\r
     public final void createDataSet() {\r
 \r
     @DataSet("BlankDataSet.xml")\r
     public final void createDataSet() {\r
 \r
@@ -228,15 +292,54 @@ public class TaxonServiceSearchTest extends CdmTransactionalIntegrationTest {
         d_abies_alba.addElement(CommonTaxonName.NewInstance("silver fir", Language.ENGLISH()));\r
 \r
         TaxonDescription d_abies_balsamea = TaxonDescription.NewInstance(t_abies_balsamea);\r
         d_abies_alba.addElement(CommonTaxonName.NewInstance("silver fir", Language.ENGLISH()));\r
 \r
         TaxonDescription d_abies_balsamea = TaxonDescription.NewInstance(t_abies_balsamea);\r
-        d_abies_balsamea.addElement(TextData.NewInstance("Die Balsam-Tanne (Abies balsamea) ist eine Pflanzenart aus der Gattung der Tannen (Abies). Sie wächst im nordöstlichen Nordamerika, wo sie sowohl Tief- als auch Bergland besiedelt. Sie gilt als relativ anspruchslos gegenüber dem Standort und ist frosthart. In vielen Teilen des natürlichen Verbreitungsgebietes stellt sie die Klimaxbaumart dar.", Language.GERMAN(), null));\r
-        d_abies_balsamea.addElement(TextData.NewInstance("Бальзам ньыв (лат. Abies balsamea) – быдмассэзлӧн пожум котырись ньыв увтырын торья вид. Ньывпуыс быдмӧ 14–20 метра вылына да овлӧ 10–60 см кыза диаметрын. Ньывпу пантасьӧ Ойвыв Америкаын.", Language.RUSSIAN(), null));\r
+        d_abies_balsamea\r
+                .addElement(TextData\r
+                        .NewInstance(\r
+                                "Die Balsam-Tanne (Abies balsamea) ist eine Pflanzenart aus der Gattung der Tannen (Abies). Sie wächst im nordöstlichen Nordamerika, wo sie sowohl Tief- als auch Bergland besiedelt. Sie gilt als relativ anspruchslos gegenüber dem Standort und ist frosthart. In vielen Teilen des natürlichen Verbreitungsgebietes stellt sie die Klimaxbaumart dar.",\r
+                                Language.GERMAN(), null));\r
+        d_abies_balsamea\r
+                .addElement(TextData\r
+                        .NewInstance(\r
+                                "Бальзам ньыв (лат. Abies balsamea) – быдмассэзлӧн пожум котырись ньыв увтырын торья вид. Ньывпуыс быдмӧ 14–20 метра вылына да овлӧ 10–60 см кыза диаметрын. Ньывпу пантасьӧ Ойвыв Америкаын.",\r
+                                Language.RUSSIAN(), null));\r
 \r
         descriptionService.save(d_abies_alba);\r
 \r
         setComplete();\r
         endTransaction();\r
 \r
 \r
         descriptionService.save(d_abies_alba);\r
 \r
         setComplete();\r
         endTransaction();\r
 \r
-        printDataSet(System.out, new String[] {"TAXONBASE", "TAXONNAMEBASE", "SYNONYMRELATIONSHIP", "REFERENCE", "DESCRIPTIONELEMENTBASE", "DESCRIPTIONBASE", "AGENTBASE", "HOMOTYPICALGROUP"});\r
+        printDataSet(System.out, new String[] { "TAXONBASE", "TAXONNAMEBASE", "SYNONYMRELATIONSHIP", "REFERENCE", "DESCRIPTIONELEMENTBASE",\r
+                "DESCRIPTIONBASE", "AGENTBASE", "HOMOTYPICALGROUP" });\r
+    }\r
+\r
+    /**\r
+     * @param numberOfNew\r
+     *\r
+     */\r
+    private void createRandomTaxonWithCommonName(int numberOfNew) {\r
+\r
+        logger.debug(String.format("creating %1$s random taxan with CommonName", numberOfNew));\r
+\r
+        Reference sec = ReferenceFactory.newBook();\r
+        referenceService.save(sec);\r
+\r
+        for (int i = numberOfNew; i < numberOfNew; i++) {\r
+            RandomStringUtils.randomAlphabetic(10);\r
+            String radomName = RandomStringUtils.randomAlphabetic(5) + " " + RandomStringUtils.randomAlphabetic(10);\r
+            String radomCommonName = RandomStringUtils.randomAlphabetic(10);\r
+\r
+            BotanicalName name = BotanicalName.NewInstance(Rank.SPECIES());\r
+            name.setNameCache(radomName, true);\r
+            Taxon taxon = Taxon.NewInstance(name, sec);\r
+            taxonService.save(taxon);\r
+\r
+            TaxonDescription description = TaxonDescription.NewInstance(taxon);\r
+            description.addElement(CommonTaxonName.NewInstance(radomCommonName, Language.GERMAN()));\r
+            descriptionService.save(description);\r
+        }\r
+\r
+        commitAndStartNewTransaction(null);\r
+\r
     }\r
 \r
 }\r
     }\r
 \r
 }\r