net.sourceforge.floggy.persistence
Class PersistableManager

java.lang.Object
  extended by net.sourceforge.floggy.persistence.PersistableManager

public abstract class PersistableManager
extends Object

This is the main class of the framework. All persistence operations methods (such as loading, saving, deleting and searching for objects) are declared in this class.

Since:
1.0

Constructor Summary
PersistableManager()
           
 
Method Summary
abstract  void delete(Persistable persistable)
          Removes an object from the repository.
abstract  void deleteAll()
          Removes all objects from the repository.
abstract  void deleteAll(Class persistableClass)
          Removes all objects that belongs to the class passed as parameter from the repository.
abstract  ObjectSet find(Class persistableClass, Filter filter, Comparator comparator)
          Searches objects of an especific persistable class from the repository.
abstract  ObjectSet find(Class persistableClass, Filter filter, Comparator comparator, boolean lazy)
          Searches objects of an especific persistable class from the repository.
abstract  int getId(Persistable persistable)
          Gets the id under the persistable is stored.
static PersistableManager getInstance()
          Returns the current instance of PersistableManager.
abstract  boolean isPersisted(Persistable persistable)
          Check if the object is already persisted.
abstract  void load(Persistable persistable, int id)
          Load an previously stored object from the repository using the object ID.
The object ID is the result of a save operation or you can obtain it executing a search.
abstract  void load(Persistable persistable, int id, boolean lazy)
          Load an previously stored object from the repository using the object ID.
The object ID is the result of a save operation or you can obtain it executing a search.
abstract  int save(Persistable persistable)
          Store an object in the repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistableManager

public PersistableManager()
Method Detail

getInstance

public static PersistableManager getInstance()
Returns the current instance of PersistableManager.

Returns:
The current instance of PersistableManager.
Throws:
RuntimeException - DOCUMENT ME!

load

public abstract void load(Persistable persistable,
                          int id)
                   throws FloggyException
Load an previously stored object from the repository using the object ID.
The object ID is the result of a save operation or you can obtain it executing a search.

Parameters:
persistable - An instance where the object data will be loaded into. Cannot be null.
id - The ID of the object to be loaded from the repository.
Throws:
FloggyException - Exception thrown if an error occurs while loading the object.
See Also:
save(Persistable)

load

public abstract void load(Persistable persistable,
                          int id,
                          boolean lazy)
                   throws FloggyException
Load an previously stored object from the repository using the object ID.
The object ID is the result of a save operation or you can obtain it executing a search.

Parameters:
persistable - An instance where the object data will be loaded into. Cannot be null.
id - The ID of the object to be loaded from the repository.
lazy - A flag indicating to load or not all composite relationships.
Throws:
FloggyException - Exception thrown if an error occurs while loading the object.
See Also:
save(Persistable)

save

public abstract int save(Persistable persistable)
                  throws FloggyException
Store an object in the repository. If the object is already in the repository, the object data will be overwritten.
The object ID obtained from this operation can be used in the load operations.

Parameters:
persistable - Object to be stored.
Returns:
The ID of the object.
Throws:
FloggyException - Exception thrown if an error occurs while storing the object.
See Also:
load(Persistable, int)

delete

public abstract void delete(Persistable persistable)
                     throws FloggyException
Removes an object from the repository. If the object is not stored in the repository then a FloggyException will be thrown.

Parameters:
persistable - Object to be removed.
Throws:
FloggyException - Exception thrown if an error occurs while removing the object.

deleteAll

public abstract void deleteAll()
                        throws FloggyException
Removes all objects from the repository.

Throws:
FloggyException - Exception thrown if an error occurs while removing the objects.

deleteAll

public abstract void deleteAll(Class persistableClass)
                        throws FloggyException
Removes all objects that belongs to the class passed as parameter from the repository.

Parameters:
persistableClass - The persistable class to search the objects.
Throws:
FloggyException - Exception thrown if an error occurs while removing the objects.

find

public abstract ObjectSet find(Class persistableClass,
                               Filter filter,
                               Comparator comparator)
                        throws FloggyException
Searches objects of an especific persistable class from the repository.

An optional application-defined search criteria can be defined using a Filter.

An optional application-defined sort order can be defined using a Comparator.

Parameters:
persistableClass - The persistable class to search the objects.
filter - An optional application-defined criteria for searching objects.
comparator - An optional application-defined criteria for sorting objects.
Returns:
List of objects that matches the defined criteria.
Throws:
FloggyException - DOCUMENT ME!

find

public abstract ObjectSet find(Class persistableClass,
                               Filter filter,
                               Comparator comparator,
                               boolean lazy)
                        throws FloggyException
Searches objects of an especific persistable class from the repository.

An optional application-defined search criteria can be defined using a Filter.

An optional application-defined sort order can be defined using a Comparator.

Parameters:
persistableClass - The persistable class to search the objects.
filter - An optional application-defined criteria for searching objects.
comparator - An optional application-defined criteria for sorting objects.
lazy - A flag indicating to load or not all composite relationships.
Returns:
List of objects that matches the defined criteria.
Throws:
FloggyException - DOCUMENT ME!

getId

public abstract int getId(Persistable persistable)
Gets the id under the persistable is stored.

Parameters:
persistable - Object to be retrieved the id.
Returns:
the id under the persistable is stored

isPersisted

public abstract boolean isPersisted(Persistable persistable)
Check if the object is already persisted.
WARNING The method only checks if the underline system has an entry for the given persistable object. The method doesn't checks if the fields have changed.

Parameters:
persistable - Object to be checked the persistable state.
Returns:
true if the object is already persisted in the underline system, false otherwise.


Copyright © 2006-2009 Floggy Open Source Group. All Rights Reserved.