com.jenkov.mrpersister.itf
Interface ISqlGenerator

All Known Implementing Classes:
SqlGenerator

public interface ISqlGenerator

This interface represents all functions made available by the SQL generator in Mr. Persister. The SQL generator generates very simple SQL so it should be compatible with most database servers.

Author:
Jakob Jenkov, Jenkov Development

Method Summary
 java.lang.String generateDeleteStatement(IObjectMapping mapping)
          Generates a delete SQL string based on the given object mapping.
 java.lang.String generateInsertStatement(IObjectMapping mapping)
          Generates an insert SQL string based on the given object mapping.
 java.lang.String generateReadByPrimaryKeyStatement(IObjectMapping mapping)
          Generates a read-by-primary-key SQL string based on the given object mapping.
 java.lang.String generateReadListByPrimaryKeysStatement(IObjectMapping mapping, int primaryKeyCount)
          Generates a read-by-primary-keys SQL string based on the given object mapping.
 java.lang.String generateUpdateOptimisticStatement(IObjectMapping mapping)
          Generates an update SQL string based on the given object mapping with optimistic locking.
 java.lang.String generateUpdateStatement(IObjectMapping mapping)
          Generates an updateBatch SQL string based on the given object mapping.
 

Method Detail

generateReadByPrimaryKeyStatement

java.lang.String generateReadByPrimaryKeyStatement(IObjectMapping mapping)
                                                   throws PersistenceException
Generates a read-by-primary-key SQL string based on the given object mapping. The SQL string generated is for use with a PreparedStatement and thus does not contain the value for the primary key itself, but a "?" character instead.

Parameters:
mapping - The object mapping to generate the read-by-primary-key SQL string for.
Returns:
The String instance containing the generated SQL.
Throws:
PersistenceException - If anything goes wrong during the SQL string generation.

generateReadListByPrimaryKeysStatement

java.lang.String generateReadListByPrimaryKeysStatement(IObjectMapping mapping,
                                                        int primaryKeyCount)
                                                        throws PersistenceException
Generates a read-by-primary-keys SQL string based on the given object mapping. The SQL string generated is for use with a PreparedStatement and thus does not contain the value for the primary key itself, but a "?" character instead.

Parameters:
mapping - The object mapping to generate the read-by-primary-key SQL string for.
Returns:
The String instance containing the generated SQL.
Throws:
PersistenceException - If anything goes wrong during the SQL string generation.

generateInsertStatement

java.lang.String generateInsertStatement(IObjectMapping mapping)
                                         throws PersistenceException
Generates an insert SQL string based on the given object mapping. The SQL string generated is for use with a PreparedStatement and thus does not contain the values to be inserted, but a series of "?" characters instead (comma separated).

Parameters:
mapping - The object mapping to generate the insert SQL string for.
Returns:
The String instance containing the generated SQL.
Throws:
PersistenceException - If anything goes wrong during the SQL string generation.

generateUpdateStatement

java.lang.String generateUpdateStatement(IObjectMapping mapping)
                                         throws PersistenceException
Generates an updateBatch SQL string based on the given object mapping. The SQL string generated is for use with a PreparedStatement and thus does not contain the values to be updateBatch, but a series of "?" characters instead (comma separated).

Parameters:
mapping - The object mapping to generate the updateBatch SQL string for.
Returns:
The String instance containing the generated SQL.
Throws:
PersistenceException - If anything goes wrong during the SQL string generation.

generateUpdateOptimisticStatement

java.lang.String generateUpdateOptimisticStatement(IObjectMapping mapping)
                                                   throws PersistenceException
Generates an update SQL string based on the given object mapping with optimistic locking. The SQL string generated is for use with a PreparedStatement and thus does not contain the values to be updateBatch, but a series of "?" characters instead (comma separated).

Parameters:
mapping - The object mapping to generate the updateBatch SQL string for.
Returns:
The String instance containing the generated SQL.
Throws:
PersistenceException - If anything goes wrong during the SQL string generation.

generateDeleteStatement

java.lang.String generateDeleteStatement(IObjectMapping mapping)
                                         throws PersistenceException
Generates a delete SQL string based on the given object mapping. The SQL string generated is for use with a PreparedStatement and thus does not contain the value for the primary key of the record to delete itself, but a "?" character instead.

Parameters:
mapping - The object mapping to generate the delete SQL string for.
Returns:
The String instance containing the generated SQL.
Throws:
PersistenceException - If anything goes wrong during the SQL string generation.