com.jenkov.mrpersister.itf.mapping
Interface ICustomObjectMapper

All Known Implementing Classes:
AutoGeneratedColumnsMapper, CustomObjectMapperBase

public interface ICustomObjectMapper

A custom object mapper can assist the IGenericDao instances with the mapping of classes to database tables. A custom object mapper has 3 options:

  1. Create a complete mapping manually, programmatically.
    Useful when the objects to map do not match any tables in the database. Either because the names are too different, or for instance if you are mapping a class to an SQL query (select sum(...) from...) where the columns in the query do not exist in any table.
  2. Only provide the table name which the given class is to be mapped to.
    Useful when the getters / setters match the column names, but the class and table names don't match. For instance mapping Employee.class to table "persons".
  3. Modify the mapping generated by the object mapper, after it was generated, but before it is used.
    This is very useful if you need to add extra information to an auto-generated object mapping, for instance a getter / setter that needs to be mapped to a column that has a name that cannot be guessed. Or, for instance to mark on the primary key getter mapping of the object mapping, that the primary key is autogenerated by the database. The object mapper is not yet capable of auto-detecting auto-generated columns. This is because it is missing in JDBC.

If a custom mapper does nothing (returns null for all three assisting methods) the object mapping will be fully auto-generated.

Author:
Jakob Jenkov, Copyright 2004 Jenkov Development

Method Summary
 IObjectMapping getObjectMapping(java.lang.Object objectMappingKey)
          Creates an object mapping for the given object mapping key.
 java.lang.String getTableName(java.lang.Object objectMappingKey)
           
 void modify(java.lang.Object objectMappingKey, IObjectMapping mapping)
           
 

Method Detail

getObjectMapping

IObjectMapping getObjectMapping(java.lang.Object objectMappingKey)
                                throws PersistenceException
Creates an object mapping for the given object mapping key.

Parameters:
objectMappingKey -
Returns:
Throws:
PersistenceException

getTableName

java.lang.String getTableName(java.lang.Object objectMappingKey)
                              throws PersistenceException
Parameters:
objectMappingKey -
Returns:
Throws:
PersistenceException

modify

void modify(java.lang.Object objectMappingKey,
            IObjectMapping mapping)
            throws PersistenceException
Throws:
PersistenceException