org.compass.core
Interface CompassIndexSession

All Known Subinterfaces:
CompassSession, InternalCompassSession
All Known Implementing Classes:
DefaultCompassSession, ExistingCompassSession

public interface CompassIndexSession

A specialized interface that provides only index capabilities.

Using the session depends on how transaction managemnet should be done (also see Compass.openSession(). The simplest form looks like this:

 CompassIndexSession session = compass.openIndexSession();
 try {
      // do operations with the session
      session.commit(); // same as session.close()
 } catch (Exception e) {
      session.rollback();
 } finally {
      session.close();
 }
 

Author:
kimchy

Method Summary
 void close()
          Closes the CompassSession.
 void commit()
          Same as CompassSession.close().
 void create(Object obj)
          Creates a NEW object in Compass.
 void create(String alias, Object obj)
          Creates a NEW object in Compass that shares mapping alais with multiple objects.
 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(CompassQuery query)
          Deletes all entries in the index that match the given query.
 void delete(Object obj)
          Deletes an object from Compass.
 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 flush()
          Flush the current transaction.
 void flushCommit(String... aliases)
          Flush commit all the provided aliases (or all of them, if none is provided).
 CompassSettings getSettings()
          Runtimes settings that apply on the session level.
 boolean isClosed()
          Returns true if the session is closed.
 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(String alias, Object obj)
          Saves an object in Compass that shares mapping alais with multiple objects.
 

Method Detail

getSettings

CompassSettings getSettings()
Runtimes settings that apply on the session level.

Returns:
Runtime settings applies on the session level

resourceFactory

ResourceFactory resourceFactory()
Returns a resource factory allowing to create resources and properties.


flush

void flush()
           throws CompassException
Flush the current transaction.

Throws:
CompassException

flushCommit

void flushCommit(String... aliases)
                 throws CompassException
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.

Throws:
CompassException

delete

void delete(Resource resource)
            throws CompassException
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.

Parameters:
resource - The resource to be deleted.
Throws:
CompassException

delete

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

Parameters:
obj - The object to delete
Throws:
CompassException

delete

void delete(String alias,
            Object obj)
            throws CompassException
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.

Parameters:
alias - The alias that the objects maps under
obj - The object to delete
Throws:
CompassException

delete

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

Parameters:
alias - The alias that the objects maps under
ids - The ids of the object to delete
Throws:
CompassException

delete

void delete(Class clazz,
            Object obj)
            throws CompassException
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.

Parameters:
clazz - The class that represtents the required mapping
obj - The object to delete
Throws:
CompassException

delete

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

Parameters:
clazz - The class that represtents the required mapping
ids - The object ids to delete
Throws:
CompassException

delete

void delete(CompassQuery query)
            throws CompassException
Deletes all entries in the index that match the given query.

Parameters:
query - The query to delete by
Throws:
CompassException

create

void create(Object obj)
            throws CompassException
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.

Parameters:
obj - The object to save.
Throws:
CompassException

create

void create(String alias,
            Object obj)
            throws CompassException
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.

Parameters:
alias - The alias that match the object mappings
obj - The object to save
Throws:
CompassException

save

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

Parameters:
obj - The object to save.
Throws:
CompassException

save

void save(String alias,
          Object obj)
          throws CompassException
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.

Parameters:
alias - The alias that match the object mappings
obj - The object to save
Throws:
CompassException

rollback

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

Throws:
CompassException

commit

void commit()
            throws CompassException
Same as CompassSession.close().

Throws:
CompassException

close

void close()
           throws CompassException
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.

Throws:
CompassException
See Also:
Compass.openSession()

isClosed

boolean isClosed()
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.



Copyright (c) 2004-2009 The Compass Project.