Author: hardy.ferentschik
Date: 2008-11-21 08:58:05 -0500 (Fri, 21 Nov 2008)
New Revision: 15604
Modified:
search/trunk/src/java/org/hibernate/search/FullTextSession.java
search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java
search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
Log:
Made sure the FulltextSession and FullTextEntityManager interfaces are consistent; updated
javadoc
Modified: search/trunk/src/java/org/hibernate/search/FullTextSession.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/FullTextSession.java 2008-11-20 16:42:49
UTC (rev 15603)
+++ search/trunk/src/java/org/hibernate/search/FullTextSession.java 2008-11-21 13:58:05
UTC (rev 15604)
@@ -11,6 +11,7 @@
* @author Emmanuel Bernard
*/
public interface FullTextSession extends Session {
+
/**
* Create a fulltext query on top of a native Lucene query returning the matching
objects
* of type <code>entities</code> and their respective subclasses.
@@ -20,6 +21,8 @@
* the specified types and their respective subtype. If no class is specified no type
filtering will take place.
*
* @return A <code>FullTextQuery</code> wrapping around the native Lucene
wuery.
+ *
+ * @throws IllegalArgumentException if entityType is <code>null</code> or
not a class or superclass annotated with <code>@Indexed</code>.
*/
FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery,
Class<?>... entities);
@@ -47,7 +50,7 @@
* @param entityType The type of the entity to delete.
* @param id The id of the entity to delete.
*
- * @throws IllegalArgumentException if entityType is <code>null</codE> or
not an @Indexed entity type.
+ * @throws IllegalArgumentException if entityType is <code>null</code> or
not a class or superclass annotated with <code>@Indexed</code>.
*/
public <T> void purge(Class<T> entityType, Serializable id);
@@ -56,13 +59,12 @@
*
* @param entityType The class of the entities to remove.
*
- * @throws IllegalArgumentException if entityType is <code>null</code> or
not an @Indexed entity type.
+ * @throws IllegalArgumentException if entityType is <code>null</code> or
not a class or superclass annotated with <code>@Indexed</code>.
*/
public <T> void purgeAll(Class<T> entityType);
/**
- * flush full text changes to the index
- * Force Hibernate Search to apply all changes to the index no waiting for the batch
limit
+ * Flush all index changes forcing Hibernate Search to apply all changes to the index
not waiting for the batch limit.
*/
public void flushToIndexes();
}
Modified: search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java 2008-11-20
16:42:49 UTC (rev 15603)
+++ search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java 2008-11-21
13:58:05 UTC (rev 15604)
@@ -12,48 +12,60 @@
* @author Emmanuel Bernard
*/
public interface FullTextEntityManager extends EntityManager {
+
/**
- * Create a Query on top of a native Lucene Query returning the matching objects
+ * Create a fulltext query on top of a native Lucene query returning the matching
objects
* of type <code>entities</code> and their respective subclasses.
- * If no entity is provided, no type filtering is done.
+ *
+ * @param luceneQuery The native Lucene query to be rn against the Lucene index.
+ * @param entities List of classes for type filtering. The query result will only return
entities of
+ * the specified types and their respective subtype. If no class is specified no type
filtering will take place.
+ *
+ * @return A <code>FullTextQuery</code> wrapping around the native Lucene
wuery.
+ *
+ * @throws IllegalArgumentException if entityType is <code>null</code> or
not a class or superclass annotated with <code>@Indexed</code>.
*/
- FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class...
entities);
+ FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery,
Class<?>... entities);
/**
* Force the (re)indexing of a given <b>managed</b> object.
* Indexation is batched per transaction: if a transaction is active, the operation
* will not affect the index at least until commit.
- *
+ *
+ * @param entity The entity to index - must not be <code>null</code>.
+ *
* @throws IllegalArgumentException if entity is null or not an @Indexed entity
*/
- void index(Object entity);
+ <T> void index(T entity);
/**
- * return the SearchFactory
+ * @return the <code>SearchFactory</code> instance.
*/
SearchFactory getSearchFactory();
+
/**
- * Remove a particular entity from a particular class of an index.
+ * Remove the entity with the type <code>entityType</code> and the
identifier <code>id</code> from the index.
+ * If <code>id == null</code> all indexed entities of this type and its
indexed subclasses are deleted. In this
+ * case this method behaves like {@link #purgeAll(Class)}.
*
- * @param entityType
- * @param id
+ * @param entityType The type of the entity to delete.
+ * @param id The id of the entity to delete.
*
- * @throws IllegalArgumentException if entityType is null or not an @Indexed entity
type
+ * @throws IllegalArgumentException if entityType is <code>null</code> or
not a class or superclass annotated with <code>@Indexed</code>.
*/
- public void purge(Class entityType, Serializable id);
+ public <T> void purge(Class<T> entityType, Serializable id);
/**
- * Remove all entities from a particular class of an index.
+ * Remove all entities from of particular class and all its subclasses from the index.
*
- * @param entityType
+ * @param entityType The class of the entities to remove.
*
- * @throws IllegalArgumentException if entityType is null or not an @Indexed entity
type
+ * @throws IllegalArgumentException if entityType is <code>null</code> or
not a class or superclass annotated with <code>@Indexed</code>.
*/
- public void purgeAll(Class entityType);
+ public <T> void purgeAll(Class<T> entityType);
/**
- * flush index change
- * Force Hibernate Search to apply all changes to the index no waiting for the batch
limit
+ * Flush all index changes forcing Hibernate Search to apply all changes to the index
not waiting for the batch limit.
*/
public void flushToIndexes();
Modified:
search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
===================================================================
---
search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2008-11-20
16:42:49 UTC (rev 15603)
+++
search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2008-11-21
13:58:05 UTC (rev 15604)
@@ -31,26 +31,34 @@
if ( ftSession == null ) {
Object delegate = em.getDelegate();
if ( delegate == null ) {
- throw new SearchException("Trying to use Hibernate Search without an Hibernate
EntityManager (no delegate)");
+ throw new SearchException(
+ "Trying to use Hibernate Search without an Hibernate EntityManager (no
delegate)"
+ );
}
else if ( Session.class.isAssignableFrom( delegate.getClass() ) ) {
- ftSession = Search.getFullTextSession( (Session) delegate );
+ ftSession = Search.getFullTextSession( ( Session ) delegate );
}
else if ( EntityManager.class.isAssignableFrom( delegate.getClass() ) ) {
//Some app servers wrap the EM twice
- delegate = ( (EntityManager) delegate).getDelegate();
+ delegate = ( ( EntityManager ) delegate ).getDelegate();
if ( delegate == null ) {
- throw new SearchException("Trying to use Hibernate Search without an Hibernate
EntityManager (no delegate)");
+ throw new SearchException(
+ "Trying to use Hibernate Search without an Hibernate EntityManager (no
delegate)"
+ );
}
else if ( Session.class.isAssignableFrom( delegate.getClass() ) ) {
- ftSession = Search.getFullTextSession( (Session) delegate );
+ ftSession = Search.getFullTextSession( ( Session ) delegate );
}
else {
- throw new SearchException("Trying to use Hibernate Search without an Hibernate
EntityManager: " + delegate.getClass() );
+ throw new SearchException(
+ "Trying to use Hibernate Search without an Hibernate EntityManager: " +
delegate.getClass()
+ );
}
}
else {
- throw new SearchException("Trying to use Hibernate Search without an Hibernate
EntityManager: " + delegate.getClass() );
+ throw new SearchException(
+ "Trying to use Hibernate Search without an Hibernate EntityManager: " +
delegate.getClass()
+ );
}
}
return ftSession;
@@ -61,7 +69,7 @@
return new FullTextQueryImpl( ftSession.createFullTextQuery( luceneQuery, entities ),
ftSession );
}
- public void index(Object entity) {
+ public <T> void index(T entity) {
getFullTextSession().index( entity );
}
@@ -69,11 +77,11 @@
return getFullTextSession().getSearchFactory();
}
- public void purge(Class entityType, Serializable id) {
+ public <T> void purge(Class<T> entityType, Serializable id) {
getFullTextSession().purge( entityType, id );
}
- public void purgeAll(Class entityType) {
+ public <T> void purgeAll(Class<T> entityType) {
getFullTextSession().purgeAll( entityType );
}
@@ -81,7 +89,6 @@
getFullTextSession().flushToIndexes();
}
-
public void persist(Object entity) {
em.persist( entity );
}
Show replies by date