Homepage

org.tinymarbles
Interface Repository

All Known Subinterfaces:
RepositoryImplementor
All Known Implementing Classes:
RepositoryImpl

public interface Repository

The Repository is the entry point to Tiny Marbles

Author:
duke

Method Summary
 void close()
          Closes the repository, rolling back any pending transaction.
 void commit()
          Commits the transaction.
 void commitAndClose()
          Commits the transaction and Closes the repository.
 Filter createFilter(PType type)
          Creates a filter for objects with the given type
 Filter createFilter(String typeName)
          Creates a filter for objects with the type identified by the typeName argument
 HQLFilter createHQLFilter(String queryString)
          Creates a filter for objects with the given queryString
 HQLFilter createHQLFilter(String queryString, Map<String,Object> values)
          Creates a filter for objects with the given queryString
 SQLFilter createSQLFilter(String queryString)
          Creates a filter for objects with the given queryString
 SQLFilter createSQLFilter(String queryString, Map<String,Object> values)
          Creates a filter for objects with the given queryString
 PType createType(String name)
          Creates a new persistent type with the given name.
 void delete()
          Clears the contents of the repository.
 void delete(Persistent object)
          Deletes this instance from the repository.
 PObject get(Long persistentId)
          Returns an instance of the object with the given persistent ID, or null if such object doesn't exist
 PObject get(String systemId)
          Returns an instance of the object with the given system ID, or null if such object doesn't exist
 PType getType(String name)
          Returns the persistent type with the given name, or null if there is no such type.
 List<PObject> list(PType type)
          Fetches all objects of a given type.
 List<PType> listTypes()
          Lists all types in the system
 PObject load(Long persistentId)
          Loads an object using its persistent id
 PObject load(String systemId)
          Loads an object using its system ID
 PType loadType(String name)
          Loads an existing persistent type given its unique name.
 PType requireType(String name)
          Try to get an existing persistent type, if doesn't exist create a new type with the given name.
 void save(Persistent object)
          Saves this object to the repository.
 

Method Detail

createType

PType createType(String name)
Creates a new persistent type with the given name. The returned instance is not persisted. Typical usage is this:

 PType myType = repository.createType("MyType");
 //add attributes to the type
 myType.save();
 

Parameters:
name - the type's unique name
Returns:
a new, transient instance
See Also:
PType, loadType(String)

getType

PType getType(String name)
Returns the persistent type with the given name, or null if there is no such type.

Parameters:
name - the type's unique name
Returns:
the PType instance or null if no persistent instance with the given name exists.

loadType

PType loadType(String name)
               throws ObjectNotFoundException
Loads an existing persistent type given its unique name.

Parameters:
name - the type's unique name
Returns:
the PType instance
Throws:
ObjectNotFoundException
See Also:
createType(String)

get

PObject get(String systemId)
Returns an instance of the object with the given system ID, or null if such object doesn't exist

Parameters:
systemId - a string that uniquely identifies this object in the repository
Returns:
the persistent object, or null if the object doesn't exist

requireType

PType requireType(String name)
Try to get an existing persistent type, if doesn't exist create a new type with the given name.

Parameters:
name - a string that uniquely identifies this type in the repository
Returns:
the PType instance or a new, transient PType if it didn't exist

load

PObject load(String systemId)
             throws ObjectNotFoundException
Loads an object using its system ID

Parameters:
systemId - a string that uniquely identifies this object in the repository
Returns:
the persistent object
Throws:
ObjectNotFoundException

get

PObject get(Long persistentId)
Returns an instance of the object with the given persistent ID, or null if such object doesn't exist

Parameters:
persistentId - the object's persistent id
Returns:
the persistent object, or null if the object doesn't exist

load

PObject load(Long persistentId)
             throws ObjectNotFoundException
Loads an object using its persistent id

Parameters:
persistentId - the object's persistent id
Returns:
the persistent object
Throws:
ObjectNotFoundException

list

List<PObject> list(PType type)
Fetches all objects of a given type.

Parameters:
type - a persistent type
Returns:
a list of persistent objects.

createFilter

Filter createFilter(PType type)
Creates a filter for objects with the given type

Parameters:
type - a persistent type
Returns:
a new filter
See Also:
createFilter(String)

createHQLFilter

HQLFilter createHQLFilter(String queryString,
                          Map<String,Object> values)
Creates a filter for objects with the given queryString

Parameters:
queryString - a HQL query
values - named values to replace in the queryString
Returns:
a new HQLFilter

createHQLFilter

HQLFilter createHQLFilter(String queryString)
Creates a filter for objects with the given queryString

Parameters:
queryString - a HQL query
Returns:
a new HQLFilter

createSQLFilter

SQLFilter createSQLFilter(String queryString,
                          Map<String,Object> values)
Creates a filter for objects with the given queryString

Parameters:
queryString - a sql query
values - named values to replace in the queryString
Returns:
a new SQLFilter

createSQLFilter

SQLFilter createSQLFilter(String queryString)
Creates a filter for objects with the given queryString

Parameters:
queryString - a sql query
Returns:
a new SQLFilter

createFilter

Filter createFilter(String typeName)
Creates a filter for objects with the type identified by the typeName argument

Parameters:
typeName - the name of a type
Returns:
a new filter
See Also:
createFilter(PType)

delete

void delete()
Clears the contents of the repository. All persistent types are deleted, as well as all persistent instances.


commit

void commit()
            throws StorageException
Commits the transaction. If there is an error, rolls back the outermost transaction.

Throws:
StorageException - if the storage cannot commit or rollback a transaction

close

void close()
Closes the repository, rolling back any pending transaction. This method is silent and will not throw an exception.


commitAndClose

void commitAndClose()
                    throws StorageException
Commits the transaction and Closes the repository. If there is an error, rolls back the outermost transaction.

Throws:
StorageException - if the storage cannot commit or rollback a transaction

listTypes

List<PType> listTypes()
                      throws StorageException
Lists all types in the system

Returns:
a list of types
Throws:
StorageException - if the access to the repository fails.

delete

void delete(Persistent object)
            throws StorageException
Deletes this instance from the repository.

Parameters:
object - a Persistent object to delete(PType or PObject)
Throws:
StorageException - if the operation cannot be completed

save

void save(Persistent object)
          throws StorageException
Saves this object to the repository. Since release 1.0rc1, this method is optional, but you might want to call it if you need its persistent identifier.

Parameters:
object - a Persistent object to save(PType or PObject)
Throws:
StorageException - if the operation cannot be completed

Homepage