org.compass.core.impl
Class ExistingCompassSession

java.lang.Object
  extended by org.compass.core.impl.ExistingCompassSession
All Implemented Interfaces:
CompassIndexSession, CompassOperations, CompassSearchSession, CompassSession, InternalCompassSession

public class ExistingCompassSession
extends Object
implements InternalCompassSession

Author:
kimchy

Constructor Summary
ExistingCompassSession(InternalCompassSession session)
           
 
Method Summary
 void addDelegateClose(InternalSessionDelegateClose delegateClose)
           
 CompassAnalyzerHelper analyzerHelper()
          Returns an Analyzer helper.
 CompassTransaction beginLocalTransaction()
          Begins a unit of work using a Compass local transaction.
 CompassTransaction beginTransaction()
          Begin a unit of work and return the associated CompassTranscation object.
 void close()
          Closes the CompassSession.
 void commit()
          Same as CompassSession.close().
 void create(Object obj)
          Creates a NEW object in Compass.
 void create(Object object, DirtyOperationContext context)
           
 void create(String alias, Object obj)
          Creates a NEW object in Compass that shares mapping alais with multiple objects.
 void create(String alias, Object object, DirtyOperationContext context)
           
 void delete(Class clazz, Object... ids)
          Deletes an object from Compass that match the mapping specified for the defined class based on its ids.
 void delete(Class clazz, Object obj)
          Deletes an object from Compass that match the mapping specified for the defined class.
 void delete(Class clazz, Object obj, DirtyOperationContext context)
           
 void delete(CompassQuery query)
          Deletes all entries in the index that match the given query.
 void delete(Object obj)
          Deletes an object from Compass.
 void delete(Object obj, DirtyOperationContext context)
           
 void delete(Resource resource)
          Deletes a resource with the specified alias.
 void delete(String alias, Object... ids)
          Deletes an object from Compass with multiple alias's based on its ids.
 void delete(String alias, Object obj)
          Deletes an object from Compass with multiple alias's.
 void delete(String alias, Object obj, DirtyOperationContext context)
           
 void evict(Object obj)
          Evicts the given object from the first level cache (transaction scoped cache).
 void evict(Resource resource)
          Evicts the given resource from the first level cache (transaction scoped cache).
 void evict(String alias, Object id)
          Evicts the given object from the first level cache (transaction scoped cache).
 void evictAll()
          Evicts all the objects and the resources from the first level cache.
 CompassHits find(String query)
          Finds a list of objects that match the specified query.
 void flush()
          Flush the current transaction.
 void flushCommit(String... aliases)
          Flush commit all the provided aliases (or all of them, if none is provided).
<T> T
get(Class<T> clazz, Object... ids)
          Returns an object that match the mapping specified for the defined class, and matches the specified ids.
<T> T
get(Class<T> clazz, Object id)
          Returns an object that match the mapping specified for the defined class, and matches the specified id.
 Object get(String alias, Object... ids)
          Returns an object that match the mapping specified for the defined alias, and matches the specified ids.
 Object get(String alias, Object id)
          Returns an object that match the mapping specified for the defined alias, and matches the specified id.
 Object get(String alias, Object id, MarshallingContext context)
           
 InternalCompassSession getActualSession()
           
 Object getByResource(Resource resource)
           
 InternalCompass getCompass()
           
 FirstLevelCache getFirstLevelCache()
           
 CompassMapping getMapping()
           
 MarshallingStrategy getMarshallingStrategy()
           
 CompassMetaData getMetaData()
           
 Resource getResource(Class clazz, Object... ids)
          Returns a Resource that match the mapping specified for the defined class type, and specified ids.
 Resource getResource(Class clazz, Object id)
          Returns a Resource that match the mapping specified for the defined class type, and specified id.
 Resource getResource(String alias, Object... ids)
          Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified ids.
 Resource getResource(String alias, Object id)
          Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified id.
 Resource getResourceByIdResource(Resource idResource)
           
 Resource getResourceByIdResourceNoCache(Resource idResource)
           
 SearchEngine getSearchEngine()
           
 CompassSettings getSettings()
          Runtimes settings that apply on the session level.
 boolean isClosed()
          Returns true if the session is closed.
 boolean isReadOnly()
          Returns true if the session is read only.
<T> T
load(Class<T> clazz, Object... ids)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.
<T> T
load(Class<T> clazz, Object id)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified id.
 Object load(String alias, Object... ids)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.
 Object load(String alias, Object id)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified id.
 Resource loadResource(Class clazz, Object... ids)
          Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified ids.
 Resource loadResource(Class clazz, Object id)
          Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified id.
 Resource loadResource(String alias, Object... ids)
          Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified ids.
 Resource loadResource(String alias, Object id)
          Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified id.
 CompassQueryBuilder queryBuilder()
          Creats a new query builder, used to build queries programmatically.
 CompassQueryFilterBuilder queryFilterBuilder()
          Creats a new query filter builder, used to build filters of queries programmatically.
 ResourceFactory resourceFactory()
          Returns a resource factory allowing to create resources and properties.
 void rollback()
          When not using explicit CompassTransaction in order to manage transactions, can be called to rollback the current running transaction.
 void save(Object obj)
          Saves an object in Compass.
 void save(Object object, DirtyOperationContext context)
           
 void save(String alias, Object obj)
          Saves an object in Compass that shares mapping alais with multiple objects.
 void save(String alias, Object object, DirtyOperationContext context)
           
 void setReadOnly()
          Indicates that the session will be used for read only operations.
 void startTransactionIfNeeded()
           
 CompassTermFreqsBuilder termFreqsBuilder(String... names)
          Creates a new terms frequencies builder used to get terms names and freqs for a list of property names.
 void unbindTransaction()
           
 CompassSession useLocalTransaction()
          When not using the CompassTransaction interface, will begin a local transaction instead of the configured transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExistingCompassSession

public ExistingCompassSession(InternalCompassSession session)
Method Detail

getActualSession

public InternalCompassSession getActualSession()

rollback

public void rollback()
              throws CompassException
Description copied from interface: CompassIndexSession
When not using explicit CompassTransaction in order to manage transactions, can be called to rollback the current running transaction. Effectively also closes the session.

Specified by:
rollback in interface CompassIndexSession
Specified by:
rollback in interface CompassSession
Throws:
CompassException

commit

public void commit()
            throws CompassException
Description copied from interface: CompassIndexSession
Same as CompassSession.close().

Specified by:
commit in interface CompassIndexSession
Specified by:
commit in interface CompassSession
Throws:
CompassException

close

public void close()
           throws CompassException
Description copied from interface: CompassIndexSession
Closes the CompassSession. Note, if this session is "contained" within another session, it won't actually be closed, and defer closing the session to the other session.

If there is an on going transaction associated with the session that has not been committed / rolledback yet, will commit the transaction (and in case of failure, will roll it back). Failed commits will throw an exception from the close method.

Specified by:
close in interface CompassIndexSession
Specified by:
close in interface CompassSearchSession
Specified by:
close in interface CompassSession
Throws:
CompassException
See Also:
Compass.openSession()

getCompass

public InternalCompass getCompass()
Specified by:
getCompass in interface InternalCompassSession

getSearchEngine

public SearchEngine getSearchEngine()
Specified by:
getSearchEngine in interface InternalCompassSession

getMarshallingStrategy

public MarshallingStrategy getMarshallingStrategy()
Specified by:
getMarshallingStrategy in interface InternalCompassSession

getFirstLevelCache

public FirstLevelCache getFirstLevelCache()
Specified by:
getFirstLevelCache in interface InternalCompassSession

get

public Object get(String alias,
                  Object id,
                  MarshallingContext context)
           throws CompassException
Specified by:
get in interface InternalCompassSession
Throws:
CompassException

getByResource

public Object getByResource(Resource resource)
                     throws CompassException
Specified by:
getByResource in interface InternalCompassSession
Throws:
CompassException

getResourceByIdResource

public Resource getResourceByIdResource(Resource idResource)
                                 throws CompassException
Specified by:
getResourceByIdResource in interface InternalCompassSession
Throws:
CompassException

getResourceByIdResourceNoCache

public Resource getResourceByIdResourceNoCache(Resource idResource)
                                        throws CompassException
Specified by:
getResourceByIdResourceNoCache in interface InternalCompassSession
Throws:
CompassException

getMapping

public CompassMapping getMapping()
Specified by:
getMapping in interface InternalCompassSession

getMetaData

public CompassMetaData getMetaData()
Specified by:
getMetaData in interface InternalCompassSession

addDelegateClose

public void addDelegateClose(InternalSessionDelegateClose delegateClose)
Specified by:
addDelegateClose in interface InternalCompassSession

startTransactionIfNeeded

public void startTransactionIfNeeded()
Specified by:
startTransactionIfNeeded in interface InternalCompassSession

unbindTransaction

public void unbindTransaction()
Specified by:
unbindTransaction in interface InternalCompassSession

create

public void create(String alias,
                   Object object,
                   DirtyOperationContext context)
            throws CompassException
Specified by:
create in interface InternalCompassSession
Throws:
CompassException

create

public void create(Object object,
                   DirtyOperationContext context)
            throws CompassException
Specified by:
create in interface InternalCompassSession
Throws:
CompassException

save

public void save(String alias,
                 Object object,
                 DirtyOperationContext context)
          throws CompassException
Specified by:
save in interface InternalCompassSession
Throws:
CompassException

save

public void save(Object object,
                 DirtyOperationContext context)
          throws CompassException
Specified by:
save in interface InternalCompassSession
Throws:
CompassException

delete

public void delete(String alias,
                   Object obj,
                   DirtyOperationContext context)
            throws CompassException
Specified by:
delete in interface InternalCompassSession
Throws:
CompassException

delete

public void delete(Class clazz,
                   Object obj,
                   DirtyOperationContext context)
            throws CompassException
Specified by:
delete in interface InternalCompassSession
Throws:
CompassException

delete

public void delete(Object obj,
                   DirtyOperationContext context)
            throws CompassException
Specified by:
delete in interface InternalCompassSession
Throws:
CompassException

setReadOnly

public void setReadOnly()
Description copied from interface: CompassSession
Indicates that the session will be used for read only operations. Allowing to optimize search and read.

Specified by:
setReadOnly in interface CompassSession

isReadOnly

public boolean isReadOnly()
Description copied from interface: CompassSession
Returns true if the session is read only.

Specified by:
isReadOnly in interface CompassSession
See Also:
CompassSession.setReadOnly()

useLocalTransaction

public CompassSession useLocalTransaction()
Description copied from interface: CompassSearchSession
When not using the CompassTransaction interface, will begin a local transaction instead of the configured transaction.

Specified by:
useLocalTransaction in interface CompassSearchSession
Specified by:
useLocalTransaction in interface CompassSession

resourceFactory

public ResourceFactory resourceFactory()
Description copied from interface: CompassIndexSession
Returns a resource factory allowing to create resources and properties.

Specified by:
resourceFactory in interface CompassIndexSession
Specified by:
resourceFactory in interface CompassSession

getSettings

public CompassSettings getSettings()
Description copied from interface: CompassIndexSession
Runtimes settings that apply on the session level.

Specified by:
getSettings in interface CompassIndexSession
Specified by:
getSettings in interface CompassSearchSession
Specified by:
getSettings in interface CompassSession
Returns:
Runtime settings applies on the session level

flush

public void flush()
           throws CompassException
Description copied from interface: CompassIndexSession
Flush the current transaction.

Specified by:
flush in interface CompassIndexSession
Specified by:
flush in interface CompassSession
Throws:
CompassException

flushCommit

public void flushCommit(String... aliases)
                 throws CompassException
Description copied from interface: CompassIndexSession
Flush commit all the provided aliases (or all of them, if none is provided). Flush commit means that all operations up to this point will be made available in the index, and other sessions will be able to see it. It also means that the operations up to this point will not be rolledback.

Specified by:
flushCommit in interface CompassIndexSession
Specified by:
flushCommit in interface CompassSession
Throws:
CompassException

beginTransaction

public CompassTransaction beginTransaction()
                                    throws CompassException
Description copied from interface: CompassSession
Begin a unit of work and return the associated CompassTranscation object. If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction. The class of the returned CompassTransaction object is determined by the property compass.transaction.factory.

Specified by:
beginTransaction in interface CompassSession
Returns:
a CompassTransaction instance
Throws:
CompassException
See Also:
CompassTransaction

beginLocalTransaction

public CompassTransaction beginLocalTransaction()
                                         throws CompassException
Description copied from interface: CompassSession
Begins a unit of work using a Compass local transaction. Very handy when using transaction strategy other than local transaction factory but still wish to use a local one for example to perform serach (which will be faster as it won't start and externa transaction).

Specified by:
beginLocalTransaction in interface CompassSession
Throws:
CompassException

queryBuilder

public CompassQueryBuilder queryBuilder()
                                 throws CompassException
Description copied from interface: CompassSearchSession
Creats a new query builder, used to build queries programmatically.

Specified by:
queryBuilder in interface CompassSearchSession
Specified by:
queryBuilder in interface CompassSession
Returns:
The query builder.
Throws:
CompassException

queryFilterBuilder

public CompassQueryFilterBuilder queryFilterBuilder()
                                             throws CompassException
Description copied from interface: CompassSearchSession
Creats a new query filter builder, used to build filters of queries programmatically.

Specified by:
queryFilterBuilder in interface CompassSearchSession
Specified by:
queryFilterBuilder in interface CompassSession
Returns:
The query filter builder.
Throws:
CompassException

termFreqsBuilder

public CompassTermFreqsBuilder termFreqsBuilder(String... names)
                                         throws CompassException
Description copied from interface: CompassSearchSession
Creates a new terms frequencies builder used to get terms names and freqs for a list of property names.

Note, term frequencies are updated to reflect latest changes to the index only after an optimization has taken place (note, calling optimize might not cause optimization).

Specified by:
termFreqsBuilder in interface CompassSearchSession
Specified by:
termFreqsBuilder in interface CompassSession
Parameters:
names - The property names
Returns:
A term freqs builder
Throws:
CompassException

analyzerHelper

public CompassAnalyzerHelper analyzerHelper()
                                     throws CompassException
Description copied from interface: CompassSearchSession
Returns an Analyzer helper. Can be used to help analyze given texts.

Specified by:
analyzerHelper in interface CompassSearchSession
Specified by:
analyzerHelper in interface CompassSession
Returns:
the analyzer helper
Throws:
CompassException

isClosed

public boolean isClosed()
Description copied from interface: CompassIndexSession
Returns true if the session is closed. Note, if this session "joined" another session, it won't actually be closed, and defer closing the session to the outer session.

Specified by:
isClosed in interface CompassIndexSession
Specified by:
isClosed in interface CompassSession

delete

public void delete(Resource resource)
            throws CompassException
Description copied from interface: CompassIndexSession
Deletes a resource with the specified alias. Note that the resource must have the defined ids in the mapping files set and an alias set.

Specified by:
delete in interface CompassIndexSession
Specified by:
delete in interface CompassOperations
Parameters:
resource - The resource to be deleted.
Throws:
CompassException

getResource

public Resource getResource(Class clazz,
                            Object id)
                     throws CompassException
Description copied from interface: CompassOperations
Returns a Resource that match the mapping specified for the defined class type, and specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Specified by:
getResource in interface CompassOperations
Specified by:
getResource in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The resource, returns null if not found
Throws:
CompassException

getResource

public Resource getResource(Class clazz,
                            Object... ids)
                     throws CompassException
Description copied from interface: CompassOperations
Returns a Resource that match the mapping specified for the defined class type, and specified ids.

Specified by:
getResource in interface CompassOperations
Specified by:
getResource in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource, returns null if not found
Throws:
CompassException

getResource

public Resource getResource(String alias,
                            Object id)
                     throws CompassException
Description copied from interface: CompassOperations
Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Specified by:
getResource in interface CompassOperations
Specified by:
getResource in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

getResource

public Resource getResource(String alias,
                            Object... ids)
                     throws CompassException
Description copied from interface: CompassOperations
Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified ids. Returns null if the object is not found.

Specified by:
getResource in interface CompassOperations
Specified by:
getResource in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

public Resource loadResource(Class clazz,
                             Object id)
                      throws CompassException
Description copied from interface: CompassOperations
Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Specified by:
loadResource in interface CompassOperations
Specified by:
loadResource in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

public Resource loadResource(Class clazz,
                             Object... ids)
                      throws CompassException
Description copied from interface: CompassOperations
Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified ids. Throws an exception if the resource is not found.

Specified by:
loadResource in interface CompassOperations
Specified by:
loadResource in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

public Resource loadResource(String alias,
                             Object id)
                      throws CompassException
Description copied from interface: CompassOperations
Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Specified by:
loadResource in interface CompassOperations
Specified by:
loadResource in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

public Resource loadResource(String alias,
                             Object... ids)
                      throws CompassException
Description copied from interface: CompassOperations
Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified ids. Throws an exception if the resource is not found.

Specified by:
loadResource in interface CompassOperations
Specified by:
loadResource in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource
Throws:
CompassException

delete

public void delete(Object obj)
            throws CompassException
Description copied from interface: CompassIndexSession
Deletes an object from Compass. The object must have been either loaded by Compass or it's ids must be set if already known.

Specified by:
delete in interface CompassIndexSession
Specified by:
delete in interface CompassOperations
Parameters:
obj - The object to delete
Throws:
CompassException

delete

public void delete(String alias,
                   Object obj)
            throws CompassException
Description copied from interface: CompassIndexSession
Deletes an object from Compass with multiple alias's. The object can either be the id (or an array of ids), or the actual data object with it's property ids set.

Specified by:
delete in interface CompassIndexSession
Specified by:
delete in interface CompassOperations
Parameters:
alias - The alias that the objects maps under
obj - The object to delete
Throws:
CompassException

delete

public void delete(String alias,
                   Object... ids)
            throws CompassException
Description copied from interface: CompassIndexSession
Deletes an object from Compass with multiple alias's based on its ids.

Specified by:
delete in interface CompassIndexSession
Specified by:
delete in interface CompassOperations
Parameters:
alias - The alias that the objects maps under
ids - The ids of the object to delete
Throws:
CompassException

delete

public void delete(Class clazz,
                   Object obj)
            throws CompassException
Description copied from interface: CompassIndexSession
Deletes an object from Compass that match the mapping specified for the defined class. The object can either be the id (or an array of ids), or the actual data object with it's property ids set.

Specified by:
delete in interface CompassIndexSession
Specified by:
delete in interface CompassOperations
Parameters:
clazz - The class that represtents the required mapping
obj - The object to delete
Throws:
CompassException

delete

public void delete(Class clazz,
                   Object... ids)
            throws CompassException
Description copied from interface: CompassIndexSession
Deletes an object from Compass that match the mapping specified for the defined class based on its ids.

Specified by:
delete in interface CompassIndexSession
Specified by:
delete in interface CompassOperations
Parameters:
clazz - The class that represtents the required mapping
ids - The object ids to delete
Throws:
CompassException

get

public <T> T get(Class<T> clazz,
                 Object id)
      throws CompassException
Description copied from interface: CompassOperations
Returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Specified by:
get in interface CompassOperations
Specified by:
get in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

get

public <T> T get(Class<T> clazz,
                 Object... ids)
      throws CompassException
Description copied from interface: CompassOperations
Returns an object that match the mapping specified for the defined class, and matches the specified ids. Returns null if the object is not found.

Specified by:
get in interface CompassOperations
Specified by:
get in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

get

public Object get(String alias,
                  Object id)
           throws CompassException
Description copied from interface: CompassOperations
Returns an object that match the mapping specified for the defined alias, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Specified by:
get in interface CompassOperations
Specified by:
get in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

get

public Object get(String alias,
                  Object... ids)
           throws CompassException
Description copied from interface: CompassOperations
Returns an object that match the mapping specified for the defined alias, and matches the specified ids. Returns null if the object is not found.

Specified by:
get in interface CompassOperations
Specified by:
get in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

load

public <T> T load(Class<T> clazz,
                  Object id)
       throws CompassException
Description copied from interface: CompassOperations
Loads and returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Specified by:
load in interface CompassOperations
Specified by:
load in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The object
Throws:
CompassException

load

public <T> T load(Class<T> clazz,
                  Object... ids)
       throws CompassException
Description copied from interface: CompassOperations
Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.

Specified by:
load in interface CompassOperations
Specified by:
load in interface CompassSearchSession
Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object
Throws:
CompassException

load

public Object load(String alias,
                   Object id)
            throws CompassException
Description copied from interface: CompassOperations
Loads and returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Specified by:
load in interface CompassOperations
Specified by:
load in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The object
Throws:
CompassException

load

public Object load(String alias,
                   Object... ids)
            throws CompassException
Description copied from interface: CompassOperations
Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.

Specified by:
load in interface CompassOperations
Specified by:
load in interface CompassSearchSession
Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object
Throws:
CompassException

delete

public void delete(CompassQuery query)
            throws CompassException
Description copied from interface: CompassIndexSession
Deletes all entries in the index that match the given query.

Specified by:
delete in interface CompassIndexSession
Specified by:
delete in interface CompassOperations
Parameters:
query - The query to delete by
Throws:
CompassException

find

public CompassHits find(String query)
                 throws CompassException
Description copied from interface: CompassOperations
Finds a list of objects that match the specified query. The query syntax is a search engine format query. For detailed description of the query syntax please visit the site.

Several examples are:

Note that the list may contains several object types (classes) with no relation between them (except for the semantic relation).

Specified by:
find in interface CompassOperations
Specified by:
find in interface CompassSearchSession
Parameters:
query - The query string to search by
Returns:
A hits of objects that matches the query string
Throws:
CompassException

create

public void create(Object obj)
            throws CompassException
Description copied from interface: CompassIndexSession
Creates a NEW object in Compass. All the meta data defined in the Compass mapping files will be indexed and saved for later searching. Note that if the same object (same alias and same id's) already exists in the index, it won't be deleted.

Specified by:
create in interface CompassIndexSession
Specified by:
create in interface CompassOperations
Parameters:
obj - The object to save.
Throws:
CompassException

create

public void create(String alias,
                   Object obj)
            throws CompassException
Description copied from interface: CompassIndexSession
Creates a NEW object in Compass that shares mapping alais with multiple objects. All the meta data defined in Compass mapping files will be indexed and saved for later searching. Note that if the same object (same alias and same id's) already exists in the index, it won't be deleted.

Specified by:
create in interface CompassIndexSession
Specified by:
create in interface CompassOperations
Parameters:
alias - The alias that match the object mappings
obj - The object to save
Throws:
CompassException

save

public void save(Object obj)
          throws CompassException
Description copied from interface: CompassIndexSession
Saves an object in Compass. All the meta data defined in the Compass mapping files will be indexed and saved for later searching.

Specified by:
save in interface CompassIndexSession
Specified by:
save in interface CompassOperations
Parameters:
obj - The object to save.
Throws:
CompassException

save

public void save(String alias,
                 Object obj)
          throws CompassException
Description copied from interface: CompassIndexSession
Saves an object in Compass that shares mapping alais with multiple objects. All the meta data defined in Compass mapping files will be indexed and saved for later searching.

Specified by:
save in interface CompassIndexSession
Specified by:
save in interface CompassOperations
Parameters:
alias - The alias that match the object mappings
obj - The object to save
Throws:
CompassException

evict

public void evict(Object obj)
Description copied from interface: CompassOperations
Evicts the given object from the first level cache (transaction scoped cache).

Specified by:
evict in interface CompassOperations
Parameters:
obj - The objects to evict.

evict

public void evict(String alias,
                  Object id)
Description copied from interface: CompassOperations
Evicts the given object from the first level cache (transaction scoped cache). The object can either be the id (or an array of ids), or the actual data object with it's property ids set.

Specified by:
evict in interface CompassOperations
Parameters:
alias - The alias of the object/entry to evict.
id - The id of the object/entry to evict.

evict

public void evict(Resource resource)
Description copied from interface: CompassOperations
Evicts the given resource from the first level cache (transaction scoped cache).

Specified by:
evict in interface CompassOperations
Parameters:
resource - The resource to evict.

evictAll

public void evictAll()
Description copied from interface: CompassOperations
Evicts all the objects and the resources from the first level cache.

Specified by:
evictAll in interface CompassOperations


Copyright (c) 2004-2009 The Compass Project.