com.jenkov.mrpersister.itf.mapping
Interface IDbPrimaryKeyDeterminer

All Known Implementing Classes:
DbPrimaryKeyDeterminer, HsqldbPrimaryKeyDeterminer

public interface IDbPrimaryKeyDeterminer

This interface represents the functions of the database primary key determiners used in Mr. Persister. The responsibility of the database primary key determiner is to determine what column in the table is the primary key. This information is stored in the coresponding object method along with the table name, and is used by both the object reader and object writer for functions like read-by-primary-key, insert, updateBatch, delete and delete-by-primary-key.

As of now the database primary key determiner can only determine single column primary keys, and not primary keys consisting of several columns.

The database primary key determiner is used internally in the object mapper.

Author:
Jakob Jenkov, Jenkov Development

Method Summary
 java.lang.String getPrimaryKeyColumnName(java.lang.String table, java.lang.String databaseName, java.sql.Connection connection)
          Deprecated. Use the getPrimaryKeyColumnsinstead
 IKey getPrimaryKeyMapping(java.lang.String table, java.lang.String databaseName, java.sql.Connection connection)
          Returns a list of the columns that are part of the
 

Method Detail

getPrimaryKeyColumnName

java.lang.String getPrimaryKeyColumnName(java.lang.String table,
                                         java.lang.String databaseName,
                                         java.sql.Connection connection)
                                         throws PersistenceException
Deprecated. Use the getPrimaryKeyColumnsinstead

Returns the primary key column name for the given table and database. The database name is optional as this name is usually implicitly referenced in the database connection. You can leave it to null in most cases (in fact you should only need to set this if referencing a database other than the one connected to. A different database on the same server that is, not a different database server).

Parameters:
table - The name of the table to determine the primary key column name of.
databaseName - The name of the database. Set this to null in most cases. See above description.
connection - The connection to the database in which the table exists to determine primary key column for.
Returns:
The name of the primary key column of the given table. Null if the table has no primary key.
Throws:
PersistenceException - If anything goes wrong during primary key column name determining.

getPrimaryKeyMapping

IKey getPrimaryKeyMapping(java.lang.String table,
                          java.lang.String databaseName,
                          java.sql.Connection connection)
                          throws PersistenceException
Returns a list of the columns that are part of the

Parameters:
table -
databaseName -
connection -
Returns:
Throws:
PersistenceException