Hibernate SVN: r19209 - in search/trunk/hibernate-search-archetype: src/main/java and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-04-11 07:17:29 -0400 (Sun, 11 Apr 2010)
New Revision: 19209
Added:
search/trunk/hibernate-search-archetype/src/main/java/com/
search/trunk/hibernate-search-archetype/src/main/java/com/example/
search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java
search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java
search/trunk/hibernate-search-archetype/src/test/java/com/
search/trunk/hibernate-search-archetype/src/test/java/com/example/
search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java
Removed:
search/trunk/hibernate-search-archetype/src/main/java/example/
search/trunk/hibernate-search-archetype/src/test/java/example/
search/trunk/hibernate-search-archetype/src/test/java/java/
Modified:
search/trunk/hibernate-search-archetype/pom.xml
Log:
HSEARCH-503 Generated archetype broken for any package name with dot (.) (Gustavo Fernandes)
Modified: search/trunk/hibernate-search-archetype/pom.xml
===================================================================
--- search/trunk/hibernate-search-archetype/pom.xml 2010-04-10 17:16:15 UTC (rev 19208)
+++ search/trunk/hibernate-search-archetype/pom.xml 2010-04-11 11:17:29 UTC (rev 19209)
@@ -5,7 +5,7 @@
<!--
The link to the hibernate-search parent POM only exists out of convenience.
- If you want to continue using this quickstart proejct you should remove this
+ If you want to continue using this quickstart project you should remove this
entry.
-->
<parent>
Added: search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java (rev 0)
+++ search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java 2010-04-11 11:17:29 UTC (rev 19209)
@@ -0,0 +1,59 @@
+/* $Id: Author.java 17630 2009-10-06 13:38:43Z sannegrinovero $
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package com.example;
+
+import org.hibernate.search.annotations.*;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/*
+ *
+ */
+@Entity
+public class Author {
+ @Id
+ @GeneratedValue
+ private Integer id;
+ private String name;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java (rev 0)
+++ search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java 2010-04-11 11:17:29 UTC (rev 19209)
@@ -0,0 +1,111 @@
+/* $Id: Book.java 17630 2009-10-06 13:38:43Z sannegrinovero $
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package com.example;
+
+import com.example.Author;
+import org.hibernate.search.annotations.*;
+import org.apache.solr.analysis.*;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ *
+ */
+@Entity
+@AnalyzerDef(name = "customanalyzer",
+ tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
+ filters = {
+ @TokenFilterDef(factory = LowerCaseFilterFactory.class),
+ @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
+ @Parameter(name = "language", value = "English")
+ })
+ })
+@Indexed
+public class Book {
+
+ private Integer id;
+ private String title;
+ private String subtitle;
+ private Set<Author> authors = new HashSet<Author>();
+ private Date publicationDate;
+
+ @IndexedEmbedded
+ @ManyToMany
+ public Set<Author> getAuthors() {
+ return authors;
+ }
+
+ public void setAuthors(Set<Author> authors) {
+ this.authors = authors;
+ }
+
+ public Book() {
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ @Analyzer(definition = "customanalyzer")
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Id
+ @DocumentId
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @Analyzer(definition = "customanalyzer")
+ public String getSubtitle() {
+ return subtitle;
+ }
+
+ public void setSubtitle(String subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ @Field(index = Index.UN_TOKENIZED, store = Store.YES)
+ @DateBridge(resolution = Resolution.DAY)
+ public Date getPublicationDate() {
+ return publicationDate;
+ }
+
+ public void setPublicationDate(Date publicationDate) {
+ this.publicationDate = publicationDate;
+ }
+}
\ No newline at end of file
Added: search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java (rev 0)
+++ search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java 2010-04-11 11:17:29 UTC (rev 19209)
@@ -0,0 +1,169 @@
+/* $Id: IndexAndSearchTest.java 18745 2010-02-09 13:00:22Z sannegrinovero $
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package com.example;
+
+import com.example.Book;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.util.Version;
+import org.hibernate.Session;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.jpa.FullTextEntityManager;
+import org.hibernate.search.jpa.FullTextQuery;
+import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Example testcase for Hibernate Search
+ */
+public class IndexAndSearchTest {
+
+ private EntityManagerFactory emf;
+
+ private EntityManager em;
+
+ private static Logger log = LoggerFactory.getLogger(IndexAndSearchTest.class);
+
+ @Before
+ public void setUp() {
+ initHibernate();
+ }
+
+ @After
+ public void tearDown() {
+ purge();
+ }
+
+ @Test
+ public void testIndexAndSearch() throws Exception {
+ List<Book> books = search("hibernate");
+ assertEquals("Should get empty list since nothing is indexed yet", 0, books.size());
+
+ index();
+
+ // search by title
+ books = search("hibernate");
+ assertEquals("Should find one book", 1, books.size());
+ assertEquals("Wrong title", "Java Persistence with Hibernate", books.get(0).getTitle());
+
+ // search author
+ books = search("\"Gavin King\"");
+ assertEquals("Should find one book", 1, books.size());
+ assertEquals("Wrong title", "Java Persistence with Hibernate", books.get(0).getTitle());
+ }
+
+ @Test
+ public void testStemming() throws Exception {
+
+ index();
+
+ List<Book> books = search("refactor");
+ assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
+
+ books = search("refactors");
+ assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
+
+ books = search("refactored");
+ assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
+
+ books = search("refactoring");
+ assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
+ }
+
+
+ private void initHibernate() {
+ Ejb3Configuration config = new Ejb3Configuration();
+ config.configure("hibernate-search-example", new HashMap());
+ emf = config.buildEntityManagerFactory();
+ em = emf.createEntityManager();
+ }
+
+ private void index() {
+ FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
+ try {
+ ftSession.createIndexer().startAndWait();
+ }
+ catch (InterruptedException e) {
+ log.error( "Was interrupted during indexing", e );
+ }
+ }
+
+ private void purge() {
+ FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
+ ftSession.purgeAll(Book.class);
+ ftSession.flushToIndexes();
+ }
+
+ private List<Book> search(String searchQuery) throws ParseException {
+ Query query = searchQuery(searchQuery);
+
+ List<Book> books = query.getResultList();
+
+ for (Book b : books) {
+ log.info("Title: " + b.getTitle());
+ }
+ return books;
+ }
+
+ private Query searchQuery(String searchQuery) throws ParseException {
+
+ String[] bookFields = {"title", "subtitle", "authors.name", "publicationDate"};
+
+ //lucene part
+ Map<String, Float> boostPerField = new HashMap<String, Float>(4);
+ boostPerField.put(bookFields[0], (float) 4);
+ boostPerField.put(bookFields[1], (float) 3);
+ boostPerField.put(bookFields[2], (float) 4);
+ boostPerField.put(bookFields[3], (float) .5);
+
+ FullTextEntityManager ftEm = org.hibernate.search.jpa.Search.getFullTextEntityManager((EntityManager) em);
+ Analyzer customAnalyzer = ftEm.getSearchFactory().getAnalyzer("customanalyzer");
+ QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_29, bookFields,
+ customAnalyzer, boostPerField);
+
+ org.apache.lucene.search.Query luceneQuery;
+ luceneQuery = parser.parse(searchQuery);
+
+ final FullTextQuery query = ftEm.createFullTextQuery(luceneQuery, Book.class);
+
+ return query;
+ }
+
+}
15 years, 5 months
Hibernate SVN: r19208 - search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-04-10 13:16:15 -0400 (Sat, 10 Apr 2010)
New Revision: 19208
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java
Log:
fix SearchIndexerTest not closing all resources
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java 2010-04-10 03:09:01 UTC (rev 19207)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java 2010-04-10 17:16:15 UTC (rev 19208)
@@ -81,6 +81,8 @@
assertFalse( tsii.getRootEntities().contains( Object.class ) );
assertEquals( 2, tsii.getRootEntities().size() );
}
+ fullTextSession.close();
+ ftsb.close();
}
private static class TestableMassIndexerImpl extends MassIndexerImpl {
@@ -133,6 +135,7 @@
//verify index is now containing both DVDs:
assertEquals( 2, countResults( new Term( "title", "trek" ), ftsb, Dvd.class ) );
}
+ ftsb.close();
}
//helper method
15 years, 5 months
Hibernate SVN: r19207 - in search/trunk/hibernate-search/src/test/java/org/hibernate/search/test: worker and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-04-09 23:09:01 -0400 (Fri, 09 Apr 2010)
New Revision: 19207
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java
Log:
HSEARCH-496 Some hudson configurations need more time to run the testsuite
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2010-04-09 19:34:07 UTC (rev 19206)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2010-04-10 03:09:01 UTC (rev 19207)
@@ -29,6 +29,7 @@
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
@@ -125,7 +126,7 @@
es.execute( work );
es.execute( reverseWork );
}
- while ( work.count < iteration - 1 ) {
+ while ( work.count.get() < iteration - 1 ) {
Thread.sleep( 20 );
}
log.debug( iteration + " iterations in " + nThreads + " threads: " + ( System.currentTimeMillis() - start ) );
@@ -134,53 +135,71 @@
protected class Work implements Runnable {
private Random random = new Random();
private SessionFactory sf;
- public volatile int count = 0;
+// public volatile int count = 0;
+ public AtomicInteger count = new AtomicInteger(0);
public Work(SessionFactory sf) {
this.sf = sf;
}
public void run() {
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- QueryParser parser = new MultiFieldQueryParser( getTargetLuceneVersion(),
- new String[] { "name", "physicalDescription", "suspectCharge" },
- SearchTestCase.standardAnalyzer
- );
- FullTextQuery query = getQuery( "John Doe", parser, s );
- assertTrue( query.getResultSize() != 0 );
+ Session s = null;
+ Transaction tx = null;
+ try {
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ QueryParser parser = new MultiFieldQueryParser( getTargetLuceneVersion(),
+ new String[] { "name", "physicalDescription", "suspectCharge" },
+ SearchTestCase.standardAnalyzer );
+ FullTextQuery query = getQuery( "John Doe", parser, s );
+ assertTrue( query.getResultSize() != 0 );
- query = getQuery( "green", parser, s );
- random.nextInt( query.getResultSize() - 15 );
- query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
- query.setMaxResults( 10 );
- query.list();
- tx.commit();
- s.close();
+ query = getQuery( "green", parser, s );
+ random.nextInt( query.getResultSize() - 15 );
+ query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
+ query.setMaxResults( 10 );
+ query.list();
+ tx.commit();
+ s.close();
- s = sf.openSession();
- tx = s.beginTransaction();
+ s = sf.openSession();
+ tx = s.beginTransaction();
- query = getQuery( "John Doe", parser, s );
- assertTrue( query.getResultSize() != 0 );
+ query = getQuery( "John Doe", parser, s );
+ assertTrue( query.getResultSize() != 0 );
- query = getQuery( "thief", parser, s );
- int firstResult = random.nextInt( query.getResultSize() - 15 );
- query.setFirstResult( firstResult );
- query.setMaxResults( 10 );
- List result = query.list();
- Object object = result.get( 0 );
- if ( insert && object instanceof Detective ) {
- Detective detective = ( Detective ) object;
- detective.setPhysicalDescription( detective.getPhysicalDescription() + " Eye" + firstResult );
+ query = getQuery( "thief", parser, s );
+ int firstResult = random.nextInt( query.getResultSize() - 15 );
+ query.setFirstResult( firstResult );
+ query.setMaxResults( 10 );
+ List result = query.list();
+ Object object = result.get( 0 );
+ if ( insert && object instanceof Detective ) {
+ Detective detective = (Detective) object;
+ detective.setPhysicalDescription( detective.getPhysicalDescription() + " Eye"
+ + firstResult );
+ }
+ else if ( insert && object instanceof Suspect ) {
+ Suspect suspect = (Suspect) object;
+ suspect.setPhysicalDescription( suspect.getPhysicalDescription() + " Eye"
+ + firstResult );
+ }
+ tx.commit();
+ s.close();
+ // count++;
+ } catch ( Throwable t ) {
+ t.printStackTrace();
+ } finally {
+ count.incrementAndGet();
+ try {
+ if ( tx != null && tx.isActive() )
+ tx.rollback();
+ if ( s != null && s.isOpen() )
+ s.close();
+ } catch ( Throwable t ) {
+ t.printStackTrace();
+ }
}
- else if ( insert && object instanceof Suspect ) {
- Suspect suspect = ( Suspect ) object;
- suspect.setPhysicalDescription( suspect.getPhysicalDescription() + " Eye" + firstResult );
- }
- tx.commit();
- s.close();
- count++;
}
private FullTextQuery getQuery(String queryString, QueryParser parser, Session s) {
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java 2010-04-09 19:34:07 UTC (rev 19206)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java 2010-04-10 03:09:01 UTC (rev 19207)
@@ -27,6 +27,7 @@
import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.queryParser.ParseException;
@@ -77,7 +78,7 @@
es.execute( work );
es.execute( reverseWork );
}
- while ( work.count < iteration - 1 ) {
+ while ( work.count.get() < iteration - 1 ) {
Thread.sleep( 20 );
}
getSessions().close();
@@ -87,66 +88,85 @@
protected static class Work implements Runnable {
private SessionFactory sf;
- public volatile int count = 0;
+ //public volatile int count = 0;
+ public AtomicInteger count = new AtomicInteger(0);
public Work(SessionFactory sf) {
this.sf = sf;
}
public void run() {
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Employee ee = new Employee();
- ee.setName( "Emmanuel" );
- s.persist( ee );
- Employer er = new Employer();
- er.setName( "RH" );
- s.persist( er );
- tx.commit();
- s.close();
+ Session s = null;
+ Transaction tx = null;
+ try {
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ Employee ee = new Employee();
+ ee.setName( "Emmanuel" );
+ s.persist( ee );
+ Employer er = new Employer();
+ er.setName( "RH" );
+ s.persist( er );
+ tx.commit();
+ s.close();
- s = sf.openSession();
- tx = s.beginTransaction();
- ee = (Employee) s.get( Employee.class, ee.getId() );
- ee.setName( "Emmanuel2" );
- er = (Employer) s.get( Employer.class, er.getId() );
- er.setName( "RH2" );
- tx.commit();
- s.close();
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ ee = (Employee) s.get( Employee.class, ee.getId() );
+ ee.setName( "Emmanuel2" );
+ er = (Employer) s.get( Employer.class, er.getId() );
+ er.setName( "RH2" );
+ tx.commit();
+ s.close();
-// try {
-// Thread.sleep( 50 );
-// }
-// catch (InterruptedException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
+ // try {
+ // Thread.sleep( 50 );
+ // }
+ // catch (InterruptedException e) {
+ // e.printStackTrace(); //To change body of catch statement use
+ // File | Settings | File Templates.
+ // }
- s = sf.openSession();
- tx = s.beginTransaction();
- FullTextSession fts = new FullTextSessionImpl( s );
- QueryParser parser = new QueryParser( getTargetLuceneVersion(), "id", SearchTestCase.stopAnalyzer );
- Query query;
- try {
- query = parser.parse( "name:emmanuel2" );
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ FullTextSession fts = new FullTextSessionImpl( s );
+ QueryParser parser = new QueryParser( getTargetLuceneVersion(), "id",
+ SearchTestCase.stopAnalyzer );
+ Query query;
+ try {
+ query = parser.parse( "name:emmanuel2" );
+ } catch ( ParseException e ) {
+ throw new RuntimeException( e );
+ }
+ boolean results = fts.createFullTextQuery( query ).list().size() > 0;
+ // don't test because in case of async, it query happens before
+ // actual saving
+ // if ( !results ) throw new RuntimeException( "No results!" );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ ee = (Employee) s.get( Employee.class, ee.getId() );
+ s.delete( ee );
+ er = (Employer) s.get( Employer.class, er.getId() );
+ s.delete( er );
+ tx.commit();
+ s.close();
+ // count++;
+ } catch ( Throwable t ) {
+ t.printStackTrace();
+ } finally {
+ count.incrementAndGet();
+ try {
+ if ( tx != null && tx.isActive() )
+ tx.rollback();
+ if ( s != null && s.isOpen() )
+ s.close();
+ } catch ( Throwable t ) {
+ t.printStackTrace();
+ }
}
- catch (ParseException e) {
- throw new RuntimeException( e );
- }
- boolean results = fts.createFullTextQuery( query ).list().size() > 0;
- //don't test because in case of async, it query happens before actual saving
- //if ( !results ) throw new RuntimeException( "No results!" );
- tx.commit();
- s.close();
-
- s = sf.openSession();
- tx = s.beginTransaction();
- ee = (Employee) s.get( Employee.class, ee.getId() );
- s.delete( ee );
- er = (Employer) s.get( Employer.class, er.getId() );
- s.delete( er );
- tx.commit();
- s.close();
- count++;
}
}
15 years, 5 months
Hibernate SVN: r19206 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-04-09 15:34:07 -0400 (Fri, 09 Apr 2010)
New Revision: 19206
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
Log:
HSEARCH-502 update MassIndexer to use new core features
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java 2010-04-09 19:23:01 UTC (rev 19205)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java 2010-04-09 19:34:07 UTC (rev 19206)
@@ -31,7 +31,7 @@
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
+import org.hibernate.LockOptions;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
@@ -85,6 +85,7 @@
Session session = sessionFactory.openSession();
session.setFlushMode( FlushMode.MANUAL );
session.setCacheMode( cacheMode );
+ session.setDefaultReadOnly( true );
try {
Transaction transaction = session.beginTransaction();
indexAllQueue( session );
@@ -107,7 +108,7 @@
else {
log.trace( "received an object {}", take );
//trick to attach the objects to session:
- session.lock( take, LockMode.NONE );
+ session.buildLockRequest( LockOptions.NONE ).lock( take );
index( take, session );
monitor.documentsBuilt( 1 );
session.evict( take );
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2010-04-09 19:23:01 UTC (rev 19205)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2010-04-09 19:34:07 UTC (rev 19206)
@@ -78,6 +78,7 @@
Session session = sessionFactory.openSession();
session.setFlushMode( FlushMode.MANUAL );
session.setCacheMode( cacheMode );
+ session.setDefaultReadOnly( true );
try {
Transaction transaction = session.beginTransaction();
loadAllFromQueue( session );
15 years, 5 months
Hibernate SVN: r19205 - in search/trunk/hibernate-search/src: test/java/org/hibernate/search/test/batchindexing and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-04-09 15:23:01 -0400 (Fri, 09 Apr 2010)
New Revision: 19205
Added:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java
Log:
HSEARCH-490 MassIndexer needs to use distinct on primary key selection
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2010-04-09 19:15:27 UTC (rev 19204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2010-04-09 19:23:01 UTC (rev 19205)
@@ -34,6 +34,7 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.hibernate.criterion.CriteriaSpecification;
import org.hibernate.criterion.Restrictions;
import org.hibernate.search.util.LoggerFactory;
import org.slf4j.Logger;
@@ -126,6 +127,7 @@
.setLockMode( LockMode.NONE )
.setCacheable( false )
.setFlushMode( FlushMode.MANUAL )
+ .setResultTransformer( CriteriaSpecification.DISTINCT_ROOT_ENTITY )
.add( Restrictions.in( "id", listIds ) );
List<?> list = criteria.list();
monitor.entitiesLoaded( list.size() );
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java 2010-04-09 19:15:27 UTC (rev 19204)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AncientBook.java 2010-04-09 19:23:01 UTC (rev 19205)
@@ -24,7 +24,12 @@
*/
package org.hibernate.search.test.batchindexing;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import org.hibernate.search.annotations.Indexed;
@@ -33,6 +38,7 @@
public class AncientBook extends Book {
public String catalogueGroupName = "";
+ public Set<String> alternativeTitles = new HashSet<String>();
public String getCatalogueGroupName() {
return catalogueGroupName;
@@ -41,5 +47,14 @@
public void setCatalogueGroupName(String catalogueGroupName) {
this.catalogueGroupName = catalogueGroupName;
}
+
+ @ElementCollection( fetch=FetchType.EAGER )
+ public Set<String> getAlternativeTitles() {
+ return alternativeTitles;
+ }
+ public void setAlternativeTitles(Set<String> alternativeTitles) {
+ this.alternativeTitles = alternativeTitles;
+ }
+
}
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java 2010-04-09 19:23:01 UTC (rev 19205)
@@ -0,0 +1,92 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.batchindexing;
+
+import junit.framework.Assert;
+
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.MassIndexer;
+import org.hibernate.search.Search;
+import org.hibernate.search.test.SearchTestCase;
+
+public class AvoidDuplicatesTest extends SearchTestCase {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ Session session = openSession();
+ Transaction transaction = session.beginTransaction();
+
+ AncientBook aeneid = new AncientBook();
+ aeneid.setTitle( "Aeneid" );
+ aeneid.getAlternativeTitles().add( "Aeneis" );
+ aeneid.getAlternativeTitles().add( "Eneide" );
+ session.persist( aeneid );
+
+ AncientBook commedia = new AncientBook();
+ commedia.setTitle( "Commedia" );
+ commedia.getAlternativeTitles().add( "La Commedia" );
+ commedia.getAlternativeTitles().add( "La Divina Commedia" );
+ session.persist( commedia );
+
+ transaction.commit();
+ session.close();
+ }
+
+ public void testReindexedOnce() throws InterruptedException {
+ Assert.assertEquals( 2, countBooksInIndex() );
+ Session session = openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ MassIndexer massIndexer = fullTextSession.createIndexer();
+ massIndexer.startAndWait();
+ session.close();
+ Assert.assertEquals( 2, countBooksInIndex() );
+ }
+
+ private int countBooksInIndex() {
+ Session session = openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ fullTextSession.beginTransaction();
+ FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
+ int size = fullTextQuery.list().size();
+ fullTextSession.getTransaction().commit();
+ fullTextSession.close();
+ return size;
+ }
+
+ @Override
+ protected Class<?>[] getMappings() {
+ return new Class[] {
+ AncientBook.class,
+ Book.class
+ };
+ }
+
+}
+
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java 2010-04-09 19:23:01 UTC (rev 19205)
@@ -0,0 +1,66 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.batchindexing;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.MassIndexer;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.backend.impl.batchlucene.LuceneBatchBackend;
+import org.hibernate.search.test.util.FullTextSessionBuilder;
+
+/**
+ * Verifies the batch backend is considering the configuration properties
+ * @author Sanne Grinovero
+ */
+public class BatchBackendConfigurationTest extends TestCase {
+
+ /**
+ * Verifies the batch configuration is read by the backend
+ */
+ public void testConfigurationIsRead() throws InterruptedException {
+ FullTextSessionBuilder fsBuilder = new FullTextSessionBuilder()
+ .addAnnotatedClass( Book.class )
+ // illegal option:
+ .setProperty( LuceneBatchBackend.CONCURRENT_WRITERS, "0" )
+ .build();
+
+ FullTextSession fullTextSession = fsBuilder.openFullTextSession();
+ MassIndexer massIndexer = fullTextSession.createIndexer();
+ try {
+ massIndexer.startAndWait();
+ Assert.fail( "should have thrown an exception as configuration is illegal" );
+ }
+ catch (SearchException e) {
+ // it's ok
+ }
+ fullTextSession.close();
+ fsBuilder.close();
+ }
+
+}
+
15 years, 5 months
Hibernate SVN: r19204 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/exception/impl.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-04-09 15:15:27 -0400 (Fri, 09 Apr 2010)
New Revision: 19204
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/exception/impl/ErrorContextImpl.java
Log:
HSEARCH-421 possible NPE prevented
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/exception/impl/ErrorContextImpl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/exception/impl/ErrorContextImpl.java 2010-04-09 16:38:46 UTC (rev 19203)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/exception/impl/ErrorContextImpl.java 2010-04-09 19:15:27 UTC (rev 19204)
@@ -71,7 +71,7 @@
}
public boolean hasErrors() {
- return failingOperations != null || failingOperations.size() > 0;
+ return failingOperations != null && failingOperations.size() > 0;
}
}
15 years, 5 months
Hibernate SVN: r19203 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-09 12:38:46 -0400 (Fri, 09 Apr 2010)
New Revision: 19203
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java
Log:
HSEARCH-501 use BeforeTransactionCompletionProcess and AfterTransactionCompletionProcess instead of Synchronization to let exceptions go through if needed instead of swallowing.
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java 2010-04-09 15:56:53 UTC (rev 19202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java 2010-04-09 16:38:46 UTC (rev 19203)
@@ -25,12 +25,12 @@
package org.hibernate.search.backend.impl;
import java.io.Serializable;
-
import javax.transaction.Status;
import javax.transaction.Synchronization;
+import org.slf4j.Logger;
+
import org.hibernate.HibernateException;
-import org.hibernate.Transaction;
import org.hibernate.action.AfterTransactionCompletionProcess;
import org.hibernate.action.BeforeTransactionCompletionProcess;
import org.hibernate.engine.ActionQueue;
@@ -42,9 +42,6 @@
import org.hibernate.search.event.FullTextIndexEventListener;
import org.hibernate.search.util.LoggerFactory;
-import com.sun.xml.internal.ws.handler.HandlerException;
-import org.slf4j.Logger;
-
/**
* Implementation of the transactional context on top of an EventSource (Session)
*
15 years, 5 months
Hibernate SVN: r19202 - in search/trunk: hibernate-search and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-09 11:56:53 -0400 (Fri, 09 Apr 2010)
New Revision: 19202
Modified:
search/trunk/hibernate-search/pom.xml
search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml
search/trunk/pom.xml
Log:
HSEARCH-491 make solr mandatory and exclude unnecessary deps. make lucene-analyzers and lucene-snowball mandatory
Modified: search/trunk/hibernate-search/pom.xml
===================================================================
--- search/trunk/hibernate-search/pom.xml 2010-04-09 15:38:14 UTC (rev 19201)
+++ search/trunk/hibernate-search/pom.xml 2010-04-09 15:56:53 UTC (rev 19202)
@@ -64,12 +64,10 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-snowball</artifactId>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers</artifactId>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>jgroups</groupId>
Modified: search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml
===================================================================
--- search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml 2010-04-09 15:38:14 UTC (rev 19201)
+++ search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml 2010-04-09 15:56:53 UTC (rev 19202)
@@ -83,7 +83,7 @@
@Field,...</emphasis>) for which there exists so far no
alternative configuration. The tutorial is tested against version
3.5 of Hibernate Annotations (part of the Hibernate Core
- distribution). </entry>
+ distribution).</entry>
</row>
</tbody>
</tgroup>
@@ -129,55 +129,13 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.0-Final</version>
-</dependency>
-<dependency>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-core</artifactId>
- <version>1.4.0</version>
- <exclusions>
- <exclusion>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>woodstox</groupId>
- <artifactId>wstx-asl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>net.java.dev.stax-utils</groupId>
- <artifactId>stax-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-lucene-core</artifactId>
- </exclusion>
- </exclusions>
-</dependency>
-<dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-snowball</artifactId>
- <version>2.9.2</version>
-</dependency>
-<dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-snowball</artifactId>
- <version>2.9.2</version>
-</dependency>
-<dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-analyzers</artifactId>
- <version>2.9.2</version>
</dependency></programlisting>
</example>
<para>Not all dependencies are required. Only the
<emphasis>hibernate-search</emphasis> dependency is mandatory. This
dependency, together with its required transitive dependencies, contain
- all required classes needed to use Hibernate Search. </para>
+ all required classes needed to use Hibernate Search.</para>
<para><emphasis>hibernate-annotations</emphasis> is needed if you want to
use annotations to configure your domain model but don't want to use JPA's
@@ -188,16 +146,14 @@
XML configuration available for Hibernate Search but we provide a powerful
programmatic mapping API that elegantly replace this kind of deployment
descriptor (see <xref linkend="hsearch-mapping-programmaticapi" /> for
- more information). </para>
+ more information).</para>
<para><emphasis>hibernate-entitymanager</emphasis> is required if you want
- to use Hibernate Search in conjunction with JPA. </para>
+ to use Hibernate Search in conjunction with JPA.</para>
- <para>The Solr dependencies are needed if you want to utilize Solr's
- analyzer framework. More about this later. </para>
-
- <para>And finally, the <literal>lucene-snowball</literal> dependency is
- needed if you want to use Lucene's snowball stemmer.</para>
+ <para>And finally, you might want to add optional dependencies related to
+ Lucene (if you use some of the contribs of Lucene). By default, we add
+ lucene-snowball and lucene-analyzers as dependencies.</para>
</section>
<section>
@@ -540,10 +496,7 @@
more about the factory classes available you can either browse the Solr
JavaDoc or read the corresponding section on the <ulink
url="http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters">Solr
- Wiki.</ulink> Note that depending on the chosen factory class additional
- libraries on top of the Solr dependencies might be required. For example,
- the <classname>PhoneticFilterFactory</classname> depends on <ulink
- url="http://commons.apache.org/codec">commons-codec</ulink>.</para>
+ Wiki.</ulink></para>
<para>In the example below a
<classname>StandardTokenizerFactory</classname> is used followed by two
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2010-04-09 15:38:14 UTC (rev 19201)
+++ search/trunk/pom.xml 2010-04-09 15:56:53 UTC (rev 19202)
@@ -144,11 +144,6 @@
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-core</artifactId>
- <version>1.4.0</version>
- </dependency>
</dependencies>
<dependencyManagement>
@@ -203,7 +198,6 @@
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>1.4.0</version>
- <optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-httpclient</groupId>
@@ -225,6 +219,51 @@
<groupId>org.apache.solr</groupId>
<artifactId>solr-lucene-core</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-commons-csv</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-highlighter</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-queries</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-memory</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-misc</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-spellchecker</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-snowball</artifactId>
+ </exclusion>
+
</exclusions>
</dependency>
<dependency>
15 years, 5 months
Hibernate SVN: r19201 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend: impl and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-09 11:38:14 -0400 (Fri, 09 Apr 2010)
New Revision: 19201
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java
Log:
HSEARCH-501 use BeforeTransactionCompletionProcess and AfterTransactionCompletionProcess instead of Synchronization to let exceptions go through if needed instead of swallowing.
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java 2010-04-09 15:36:40 UTC (rev 19200)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java 2010-04-09 15:38:14 UTC (rev 19201)
@@ -34,8 +34,11 @@
* @author Emmanuel Bernard
*/
public interface Worker {
- //Use of EventSource since it's the common subinterface for Session and SessionImplementor
- //the alternative would have been to do a subcasting or to retrieve 2 parameters :(
+ /**
+ * Declare a work to be done within a given transaction context
+ * @param work
+ * @param transactionContext
+ */
void performWork(Work work, TransactionContext transactionContext);
void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor);
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java 2010-04-09 15:36:40 UTC (rev 19200)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/EventSourceTransactionContext.java 2010-04-09 15:38:14 UTC (rev 19201)
@@ -26,15 +26,23 @@
import java.io.Serializable;
+import javax.transaction.Status;
import javax.transaction.Synchronization;
+import org.hibernate.HibernateException;
import org.hibernate.Transaction;
+import org.hibernate.action.AfterTransactionCompletionProcess;
+import org.hibernate.action.BeforeTransactionCompletionProcess;
+import org.hibernate.engine.ActionQueue;
+import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventSource;
import org.hibernate.event.FlushEventListener;
import org.hibernate.search.SearchException;
import org.hibernate.search.backend.TransactionContext;
import org.hibernate.search.event.FullTextIndexEventListener;
import org.hibernate.search.util.LoggerFactory;
+
+import com.sun.xml.internal.ws.handler.HandlerException;
import org.slf4j.Logger;
/**
@@ -75,8 +83,12 @@
public void registerSynchronization(Synchronization synchronization) {
if ( isRealTransactionInProgress() ) {
- Transaction transaction = eventSource.getTransaction();
- transaction.registerSynchronization( synchronization );
+ //use {Before|After}TransactionCompletionProcess instead of registerTransaction because it does not
+ //swallow transactions.
+ final ActionQueue actionQueue = eventSource.getActionQueue();
+ actionQueue.registerProcess( new DelegateToSynchronizationOnBeforeTx( synchronization ) );
+ actionQueue.registerProcess( new DelegateToSynchronizationOnAfterTx( synchronization ) );
+// eventSource.getTransaction().registerSynchronization( synchronization );
}
else {
//registerSynchronization is only called if isRealTransactionInProgress or if
@@ -122,5 +134,39 @@
}
return realTxInProgress;
}
+
+ private static class DelegateToSynchronizationOnBeforeTx implements BeforeTransactionCompletionProcess {
+ private final Synchronization synchronization;
+
+ DelegateToSynchronizationOnBeforeTx(Synchronization synchronization) {
+ this.synchronization = synchronization;
+ }
+
+ public void doBeforeTransactionCompletion(SessionImplementor sessionImplementor) {
+ try {
+ synchronization.beforeCompletion();
+ }
+ catch ( Exception e ) {
+ throw new HibernateException( "Error while indexing in Hibernate Search (before transaction completion)", e);
+ }
+ }
+ }
+
+ private static class DelegateToSynchronizationOnAfterTx implements AfterTransactionCompletionProcess {
+ private final Synchronization synchronization;
+
+ DelegateToSynchronizationOnAfterTx(Synchronization synchronization) {
+ this.synchronization = synchronization;
+ }
+
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor sessionImplementor) {
+ try {
+ synchronization.afterCompletion( success ? Status.STATUS_COMMITTED : Status.STATUS_ROLLEDBACK );
+ }
+ catch ( Exception e ) {
+ throw new HibernateException( "Error while indexing in Hibernate Search (ater transaction completion)", e);
+ }
+ }
+ }
}
15 years, 5 months
Hibernate SVN: r19200 - in search/trunk/hibernate-search/src: test/java/org/hibernate/search/test/embedded/nested/containedIn and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-09 11:36:40 -0400 (Fri, 09 Apr 2010)
New Revision: 19200
Added:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/LazyM2OContainedInTest.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
Log:
HSEARCH-386 Avoid LIE when processing containedIn collections
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2010-04-09 09:50:30 UTC (rev 19199)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2010-04-09 15:36:40 UTC (rev 19200)
@@ -642,10 +642,27 @@
}
}
else if ( member.isCollection() ) {
- Collection<T> collection = getActualCollection( member, value );
- for ( T collectionValue : collection ) {
- processSingleContainedInInstance( queue, searchFactoryImplementor, collectionValue );
+ Collection<T> collection = null;
+ try {
+ collection = getActualCollection( member, value );
+ collection.size(); //load it
}
+ catch ( Exception e ) {
+ if ( e.getClass().getName().contains( "org.hibernate.LazyInitializationException" ) ) {
+ /* A deleted entity not having its collection initialized
+ * leads to a LIE because the colleciton is no longer attached to the session
+ *
+ * But that's ok as the collection update event has been processed before
+ * or the fk would have been cleared and thus triggering the cleaning
+ */
+ collection = null;
+ }
+ }
+ if ( collection != null ) {
+ for ( T collectionValue : collection ) {
+ processSingleContainedInInstance( queue, searchFactoryImplementor, collectionValue );
+ }
+ }
}
else {
processSingleContainedInInstance( queue, searchFactoryImplementor, value );
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java 2010-04-09 15:36:40 UTC (rev 19200)
@@ -0,0 +1,59 @@
+package org.hibernate.search.test.embedded.nested.containedIn;
+
+import java.io.Serializable;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Version;
+
+/**
+ * Entite 1
+ *
+ * @author grolland
+ */
+(a)javax.persistence.Entity
+(a)org.hibernate.annotations.Proxy(lazy = true)
+(a)org.hibernate.search.annotations.Indexed
+(a)javax.persistence.Table(name = "entity1")
+//@SequenceGenerator( name="ids_generator1", sequenceName = "ids_generator1")
+public class Entity1ForDoc0 implements Serializable {
+
+ private static final long serialVersionUID = -3191273589083411349L;
+
+ @Id
+ @GeneratedValue //(generator = "ids_generator1", strategy = GenerationType.SEQUENCE)
+ private long uid;
+
+ @Version
+ private int optlock;
+
+ @javax.persistence.OneToMany(mappedBy = "entity1", cascade = { })
+ @org.hibernate.search.annotations.IndexedEmbedded
+ private java.util.List<Entity2ForDoc0> entities2 = new java.util.ArrayList<Entity2ForDoc0>();
+
+ public long getUid() {
+ return uid;
+ }
+
+ public void setUid(final long uid) {
+ this.uid = uid;
+ }
+
+ public int getOptlock() {
+ return optlock;
+ }
+
+ public void setOptlock(final int optlock) {
+ this.optlock = optlock;
+ }
+
+ public void setEntities2(final java.util.List<Entity2ForDoc0> entities2) {
+ this.entities2 = entities2;
+ }
+
+ public java.util.List<Entity2ForDoc0> getEntities2() {
+ return entities2;
+ }
+
+}
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java 2010-04-09 15:36:40 UTC (rev 19200)
@@ -0,0 +1,94 @@
+package org.hibernate.search.test.embedded.nested.containedIn;
+
+import java.io.Serializable;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Version;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+/**
+ * Entite 1
+ *
+ * @author grolland
+ */
+(a)javax.persistence.Entity
+(a)org.hibernate.annotations.Proxy(lazy = false)
+(a)org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
+(a)javax.persistence.Table(name = "entity1")
+public class Entity1ForUnindexed implements Serializable {
+
+ private static final long serialVersionUID = -3191273589083411349L;
+
+ @Id
+ @GeneratedValue
+ @Field(index = Index.UN_TOKENIZED)
+ private long uid;
+
+ @Version
+ private int optlock;
+
+ @javax.persistence.OneToMany(mappedBy = "entity1", cascade = { })
+ @org.hibernate.search.annotations.ContainedIn
+ @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
+ private java.util.List<Entity2ForUnindexed> entities2 = new java.util.ArrayList<Entity2ForUnindexed>();
+
+ /**
+ * Getter de l'attribut uid
+ *
+ * @return long : Renvoie uid.
+ */
+ public long getUid() {
+ return uid;
+ }
+
+ /**
+ * Setter de l'attribut uid
+ *
+ * @param uid uid a definir.
+ */
+ public void setUid(long uid) {
+ this.uid = uid;
+ }
+
+ /**
+ * Getter de l'attribut optlock
+ *
+ * @return int : Renvoie optlock.
+ */
+ public int getOptlock() {
+ return optlock;
+ }
+
+ /**
+ * Setter de l'attribut optlock
+ *
+ * @param optlock optlock a definir.
+ */
+ public void setOptlock(int optlock) {
+ this.optlock = optlock;
+ }
+
+ /**
+ * Setter de l'attribut entities2
+ *
+ * @param entities2 entities2 a definir.
+ */
+ public void setEntities2(java.util.List<Entity2ForUnindexed> entities2) {
+ this.entities2 = entities2;
+ }
+
+ /**
+ * Getter de l'attribut entities2
+ *
+ * @return java.util.List<Entity2> : Renvoie entities2.
+ */
+ public java.util.List<Entity2ForUnindexed> getEntities2() {
+ return entities2;
+ }
+
+}
+
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java 2010-04-09 15:36:40 UTC (rev 19200)
@@ -0,0 +1,67 @@
+package org.hibernate.search.test.embedded.nested.containedIn;
+
+import javax.persistence.Basic;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Version;
+
+/**
+ * @author grolland
+ *
+ */
+(a)javax.persistence.Entity
+(a)org.hibernate.annotations.Proxy(lazy = true)
+(a)javax.persistence.Table(name = "entity2")
+// @SequenceGenerator( name="ids_generator2", sequenceName = "ids_generator2")
+public class Entity2ForDoc0 {
+
+ private static final long serialVersionUID = -3191273589083411349L;
+
+ @Id
+ @GeneratedValue //(generator = "ids_generator2", strategy = GenerationType.SEQUENCE)
+ private long uid;
+
+ @Version
+ private int optlock;
+
+ @javax.persistence.ManyToOne(cascade = { }, fetch = javax.persistence.FetchType.LAZY)
+ @org.hibernate.search.annotations.ContainedIn
+ private Entity1ForDoc0 entity1;
+
+ @Basic
+ private String name = null;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public long getUid() {
+ return uid;
+ }
+
+ public void setUid(final long uid) {
+ this.uid = uid;
+ }
+
+ public int getOptlock() {
+ return optlock;
+ }
+
+ public void setOptlock(final int optlock) {
+ this.optlock = optlock;
+ }
+
+ public void setEntity1(final Entity1ForDoc0 entity1) {
+ this.entity1 = entity1;
+ }
+
+ public Entity1ForDoc0 getEntity1() {
+ return entity1;
+ }
+}
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java 2010-04-09 15:36:40 UTC (rev 19200)
@@ -0,0 +1,96 @@
+package org.hibernate.search.test.embedded.nested.containedIn;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Version;
+
+/**
+ * Entite 2
+ *
+ * @author grolland
+ */
+(a)javax.persistence.Entity
+(a)org.hibernate.annotations.Proxy(lazy = false)
+(a)org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
+(a)javax.persistence.Table(name = "entity2")
+(a)org.hibernate.search.annotations.Indexed
+public class Entity2ForUnindexed {
+ /**
+ * Commentaire pour <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = -3191273589083411349L;
+
+ /**
+ * Identifiant unique
+ */
+ @Id
+ @GeneratedValue
+ private long uid;
+
+ /**
+ * Controle de version optimiste
+ */
+ @Version
+ private int optlock;
+
+ @javax.persistence.ManyToOne(cascade = { }, fetch = javax.persistence.FetchType.LAZY)
+ @org.hibernate.search.annotations.IndexedEmbedded()
+ @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
+ private Entity1ForUnindexed entity1;
+
+ /**
+ * Getter de l'attribut uid
+ *
+ * @return long : Renvoie uid.
+ */
+ public long getUid() {
+ return uid;
+ }
+
+ /**
+ * Setter de l'attribut uid
+ *
+ * @param uid uid a definir.
+ */
+ public void setUid(long uid) {
+ this.uid = uid;
+ }
+
+ /**
+ * Getter de l'attribut optlock
+ *
+ * @return int : Renvoie optlock.
+ */
+ public int getOptlock() {
+ return optlock;
+ }
+
+ /**
+ * Setter de l'attribut optlock
+ *
+ * @param optlock optlock a definir.
+ */
+ public void setOptlock(int optlock) {
+ this.optlock = optlock;
+ }
+
+ /**
+ * Setter de l'attribut entity1
+ *
+ * @param entity1 entity1 a definir.
+ */
+ public void setEntity1(Entity1ForUnindexed entity1) {
+ this.entity1 = entity1;
+ }
+
+ /**
+ * Getter de l'attribut entity1
+ *
+ * @return Entity1 : Renvoie entity1.
+ */
+ public Entity1ForUnindexed getEntity1() {
+ return entity1;
+ }
+}
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/LazyM2OContainedInTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/LazyM2OContainedInTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/LazyM2OContainedInTest.java 2010-04-09 15:36:40 UTC (rev 19200)
@@ -0,0 +1,129 @@
+package org.hibernate.search.test.embedded.nested.containedIn;
+
+import java.util.List;
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
+
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class LazyM2OContainedInTest extends SearchTestCase {
+
+ //HSEARCH-385
+ public void testDocumentsAt0() {
+ FullTextSession fts = Search.getFullTextSession( getSessions().openSession() );
+ Transaction tx = fts.beginTransaction();
+ final Entity1ForDoc0 ent1 = new Entity1ForDoc0();
+ final Entity2ForDoc0 ent2 = new Entity2ForDoc0();
+
+ ent2.setEntity1( ent1 );
+ ent1.getEntities2().add( ent2 );
+
+ ent2.setName( "test - 1" );
+
+ fts.persist( ent1 );
+ fts.persist( ent2 );
+
+ tx.commit();
+
+ long uid2 = ent2.getUid();
+ long uid1 = ent1.getUid();
+
+
+ fts.clear();
+
+ tx = fts.beginTransaction();
+
+ assertEquals( 1, fts.createFullTextQuery( new TermQuery( new Term("uid", new Long(uid1).toString() ) ), Entity1ForDoc0.class ).getResultSize() );
+ assertEquals( 1, fts.createFullTextQuery( new TermQuery( new Term("entities2.uid", new Long(uid2).toString() ) ), Entity1ForDoc0.class ).getResultSize() );
+
+
+ tx.commit();
+
+ tx = fts.beginTransaction();
+ for ( Entity2ForDoc0 e : (List<Entity2ForDoc0>) fts.createCriteria( Entity2ForDoc0.class ).list() ) {
+ fts.delete( e );
+ }
+ for ( Entity1ForDoc0 e : (List<Entity1ForDoc0>) fts.createCriteria( Entity1ForDoc0.class ).list() ) {
+ fts.delete( e );
+ }
+ tx.commit();
+ }
+
+ //HSEARCH-386
+ public void testContainedInAndLazy() {
+ FullTextSession fts = Search.getFullTextSession( getSessions().openSession() );
+ Entity1ForUnindexed ent1_0 = new Entity1ForUnindexed();
+ Entity1ForUnindexed ent1_1 = new Entity1ForUnindexed();
+
+ Entity2ForUnindexed ent2_0 = new Entity2ForUnindexed();
+ Entity2ForUnindexed ent2_1 = new Entity2ForUnindexed();
+
+ ent2_0.setEntity1(ent1_0);
+ ent1_0.getEntities2().add(ent2_0);
+
+ ent2_1.setEntity1(ent1_1);
+ ent1_1.getEntities2().add(ent2_1);
+
+ //persist outside the tx
+ fts.persist(ent1_0);
+ fts.persist(ent1_1);
+ fts.persist(ent2_0);
+ fts.persist(ent2_1);
+
+ Transaction tx = fts.beginTransaction();
+ tx.commit(); //flush
+
+ fts.clear();
+
+ Entity1ForUnindexed other = new Entity1ForUnindexed();
+ fts.persist(other);
+
+ fts.getTransaction().begin();
+ fts.getTransaction().commit();
+ fts.clear();
+
+ //FIXME that's not guaranteed to happen before flush
+ long otherId = other.getUid();
+
+ assertEquals( 1, fts.createFullTextQuery( new TermQuery( new Term("entity1.uid", new Long( ent1_0.getUid() ).toString() ) ), Entity2ForUnindexed.class ).getResultSize() );
+ Entity1ForUnindexed toDelete = (Entity1ForUnindexed) fts.get(Entity1ForUnindexed.class, otherId);
+
+ fts.delete(toDelete);
+
+ fts.getTransaction().begin();
+ fts.getTransaction().commit();
+ fts.clear();
+
+ assertEquals( 0, fts.createFullTextQuery( new TermQuery( new Term("entity1.uid", new Long(otherId).toString() ) ), Entity2ForUnindexed.class ).getResultSize() );
+
+ tx = fts.beginTransaction();
+ for ( Entity2ForUnindexed e : (List<Entity2ForUnindexed>) fts.createCriteria( Entity2ForUnindexed.class ).list() ) {
+ fts.delete( e );
+ }
+ for ( Entity1ForUnindexed e : (List<Entity1ForUnindexed>) fts.createCriteria( Entity1ForUnindexed.class ).list() ) {
+ fts.delete( e );
+ }
+ tx.commit();
+
+ fts.close();
+ }
+
+
+
+ @Override
+ protected Class<?>[] getMappings() {
+ return new Class<?>[] {
+ Entity1ForDoc0.class,
+ Entity2ForDoc0.class,
+ Entity1ForUnindexed.class,
+ Entity2ForUnindexed.class
+ };
+ }
+}
15 years, 5 months