org.objectledge.database.persistence
Interface Persistence

All Known Implementing Classes:
DefaultPersistence

public interface Persistence

Provides Object-Relational DB mapping.

Version:
$Id: Persistence.java,v 1.10 2004/02/27 12:23:23 pablo Exp $
Author:
Rafal Krzewski, Pawel Potempski

Method Summary
 int count(String table, String where)
          An utility method for checking the number of matching rows.
 void delete(Persistent object)
          Removes an object from the database.
 void delete(String where, PersistentFactory factory)
          Removes the objects from the database.
 boolean exists(String table, String where)
          An utility method for checking for existence of rows.
 Database getDatabase()
          Get the database component used by persistence.
 Persistent load(long id, PersistentFactory factory)
          Loads an object from the database.
 List load(String where, PersistentFactory factory)
          Loads objects from the database.
 void revert(Persistent object)
          Reverts the object to the saved state.
 void save(Persistent object)
          Saves an object in the database.
 

Method Detail

load

Persistent load(long id,
                PersistentFactory factory)
                throws PersistenceException
Loads an object from the database.

Parameters:
id - the identifier of the object.
factory - the object instance factory.
Returns:
the presistent object.
Throws:
PersistenceException - if any exception occured.

load

List load(String where,
          PersistentFactory factory)
          throws PersistenceException
Loads objects from the database.

Note that joins are not supported. This package provides a means of converting objects to rows in a table and vice versa. If you want more, you need some different tool.

Parameters:
where - the where clause to be used in the query
factory - the object instance factory.
Returns:
the list of presistent objects.
Throws:
PersistenceException - if any exception occured.

save

void save(Persistent object)
          throws PersistenceException
Saves an object in the database.

Parameters:
object - the object to be saved.
Throws:
PersistenceException - if any exception occured.

revert

void revert(Persistent object)
            throws PersistenceException,
                   IllegalStateException
Reverts the object to the saved state.

Parameters:
object - the object to have it's state restored.
Throws:
PersistenceException - if any exception occured.
IllegalStateException - if no state has been saved yet for the object in question.

delete

void delete(Persistent object)
            throws PersistenceException
Removes an object from the database.

Parameters:
object - the object to be removed.
Throws:
PersistenceException - if any exception occured.

delete

void delete(String where,
            PersistentFactory factory)
            throws PersistenceException
Removes the objects from the database.

Parameters:
where - the where clause to be used in the query
factory - the object instance factory.
Throws:
PersistenceException - if any exception occured.

exists

boolean exists(String table,
               String where)
               throws PersistenceException
An utility method for checking for existence of rows.

Parameters:
table - the table to be checked.
where - the condition.
Returns:
true if the condition is true for one or more rows in the table.
Throws:
PersistenceException - if any exception occured.

count

int count(String table,
          String where)
          throws PersistenceException
An utility method for checking the number of matching rows.

Parameters:
table - the table to be chcked.
where - the condition.
Returns:
the number of table matching the condition.
Throws:
PersistenceException - if any exception occured.

getDatabase

Database getDatabase()
Get the database component used by persistence.

Returns:
the database.


Copyright © 2003-2006 objectledge.org. All Rights Reserved.