com.caucho.amber
Interface AmberConnection


public interface AmberConnection

Main user interface to Amber.


Method Summary
 void beginTransaction()
          Starts a transaction.
 void close()
          Closes the connection.
 void commit()
          Commits a transaction.
 boolean contains(java.lang.Object entity)
          Returns true if the entitiy is managed.
 void create(java.lang.Object obj)
          Creates a new entity given the values in the object.
 void delete(java.lang.Object obj)
          Deletes the specified entry.
 java.util.List find(java.lang.String query)
          Queries the database, returning a result set
 void flush()
          Flushes data from the connection.
 java.lang.Object load(java.lang.Class cl, long key)
          Loads the entity specified by its class and primary key.
 java.lang.Object load(java.lang.Class cl, java.lang.Object key)
          Loads the entity specified by its class and primary key.
 java.lang.Object makePersistent(java.lang.Object entity)
          Loads the entity, returning the active entity
 AmberQuery prepareQuery(java.lang.String queryString)
          Creates a query object from a query string.
 java.sql.ResultSet query(java.lang.String query)
          Queries the database, returning a result set
 void rollback()
          Rolls a transaction back.
 int update(java.lang.String query)
          Queries the database, returning a result set
 

Method Detail

load

java.lang.Object load(java.lang.Class cl,
                      java.lang.Object key)
                      throws AmberException
Loads the entity specified by its class and primary key.

Throws:
AmberException

load

java.lang.Object load(java.lang.Class cl,
                      long key)
                      throws AmberException
Loads the entity specified by its class and primary key.

Throws:
AmberException

makePersistent

java.lang.Object makePersistent(java.lang.Object entity)
                                throws java.sql.SQLException
Loads the entity, returning the active entity

Throws:
java.sql.SQLException

create

void create(java.lang.Object obj)
            throws java.sql.SQLException
Creates a new entity given the values in the object.

Throws:
java.sql.SQLException

contains

boolean contains(java.lang.Object entity)
Returns true if the entitiy is managed.


delete

void delete(java.lang.Object obj)
            throws java.sql.SQLException
Deletes the specified entry.

Throws:
java.sql.SQLException

query

java.sql.ResultSet query(java.lang.String query)
                         throws java.sql.SQLException
Queries the database, returning a result set

Parameters:
query - the query
Returns:
the query result set.
Throws:
java.sql.SQLException

update

int update(java.lang.String query)
           throws java.sql.SQLException
Queries the database, returning a result set

Parameters:
query - the query
Returns:
the query result set.
Throws:
java.sql.SQLException

prepareQuery

AmberQuery prepareQuery(java.lang.String queryString)
                        throws AmberException
Creates a query object from a query string. The query will load the default group values for any selected entitites.

Parameters:
queryString - a query
Throws:
AmberException

beginTransaction

void beginTransaction()
                      throws java.sql.SQLException
Starts a transaction.

Throws:
java.sql.SQLException

commit

void commit()
            throws java.sql.SQLException
Commits a transaction.

Throws:
java.sql.SQLException

rollback

void rollback()
              throws java.sql.SQLException
Rolls a transaction back.

Throws:
java.sql.SQLException

flush

void flush()
           throws java.sql.SQLException
Flushes data from the connection.

Throws:
java.sql.SQLException

close

void close()
Closes the connection. Unlike JDBC, this will never throw an exception (although it may log a warning.)


find

java.util.List find(java.lang.String query)
                    throws java.sql.SQLException
Queries the database, returning a result set

Parameters:
query - the query
Returns:
the query result set.
Throws:
java.sql.SQLException