com.jenkov.mrpersister.util
Class MappingUtil

java.lang.Object
  extended by com.jenkov.mrpersister.util.MappingUtil

public class MappingUtil
extends java.lang.Object

This class contains utility methods shared by the components of Mr Persister.

Author:
Jakob Jenkov - Copyright 2005 Jenkov Development

Constructor Summary
MappingUtil()
           
 
Method Summary
static int insertPrimaryKey(IObjectMapping mapping, IKeyValue keyValue, java.sql.PreparedStatement statement, int index)
          This method can insert the given key value object into a prepared statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappingUtil

public MappingUtil()
Method Detail

insertPrimaryKey

public static int insertPrimaryKey(IObjectMapping mapping,
                                   IKeyValue keyValue,
                                   java.sql.PreparedStatement statement,
                                   int index)
                            throws PersistenceException
This method can insert the given key value object into a prepared statement. This is a utility method used by the object reader and object writer.

Parameters:
keyValue - The key value to insert into the prepared statement.
statement - The prepared statement to insert the key value into.
index - The index of the prepared statement parameter to insert the first value of the key value into.
Returns:
The index of the last inserted value + 1. Equal to the next index a prepared statement parameter should be inserted into, if there are more parameters in the prepared statement.
Throws:
PersistenceException - If the given key value does not match the primary key of this object mapping, or if the insert fails.