Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2007 Daniel Spiewak
  * 
  * Licensed under the Apache License, Version 2.0 (the "License"); 
  * you may not use this file except in compliance with the License. 
  * You may obtain a copy of the License at
  * 
  *	    http://www.apache.org/licenses/LICENSE-2.0 
  * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.java.ao;

A superinterface for entities which are related to each other using Lucene heuristics. This is not required as a superinterface for entities related to one another at the database level. Thus, this interface is only relevant to those already using full-text indexing.

While this entity does not extend RawEntity itself, it should only be inherited by interfaces which do. In fact, this is enforced by the type parameterization of this interface. Example:

public interface Post extends Entity, RelatedEntity<Post> {
     // ...
     
     @Searchable
     @SQLType(Types.BLOB)
     public String getBody();
     
     @Searchable
     @SQLType(Types.BLOB)
     public void setBody(String body);
 }
 
 // ...
 Post p = manager.get(Post.class, 123);
 Post[] relatedPosts = p.getRelated();      // searches Lucene index for related posts

Under most circumstances, the type parameter used when inheriting from this interface should be the entity interface itself, as in the above example.

Author(s):
Daniel Spiewak
See also:
SearchableEntityManager
public interface RelatedEntity<T extends RelatedEntity<T> & RawEntity<?>> {

Retrieves the entities related to this by using full-text search heuristics. No database invocation is involved in calling this method. Also, the results are uncached, relying instead on the underlying performance optimizations of Lucene itself.

Returns:
Any entities of the relevant type which relate to the current instance in the full-text index.
	public T[] getRelated();
New to GrepCode? Check out our FAQ X