EMPIREDB-282
Added key generation function on DBTable for convenience
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBIndex.java b/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
index de8b910..e1beb1f 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
@@ -115,6 +115,16 @@
     }
     
     /**
+     * Returns the number of columns belonging to this index.
+     * 
+     * @return the number of columns belonging to this index
+     */
+    public int getColumnCount()
+    {
+        return columns.length;
+    }
+    
+    /**
      * checks whether the columns of this index match the supplied columns
      * @param columns
      * @return true if columns match or false otherwise
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
index c499c60..8a1f1cc 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
@@ -70,7 +70,7 @@
     		return this.ordinal()>=other.ordinal();
     	}
     }
-
+    
     protected static final Logger log    = LoggerFactory.getLogger(DBRecord.class);
 
     // This is the record data
@@ -793,7 +793,6 @@
      * @param keyValues a Object array, the primary key(s)
      * @param insert if true change the state of this object to REC_NEW
      */
-     
     public void init(DBRowSet table, Object[] keyValues, boolean insert)
     { 	// Init with keys
         if (table!=null)
@@ -842,12 +841,12 @@
      * @param keys an array of the primary key values
      * @param conn a valid connection to the database.
      */
-    public void read(DBRowSet table, Object[] keys, Connection conn)
+    public void read(DBRowSet table, Object[] key, Connection conn)
     {
         if (table==null)
             throw new InvalidArgumentException("table", table);
         // read
-        table.readRecord(this, keys, conn);
+        table.readRecord(this, key, conn);
     }
 
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBTable.java b/empire-db/src/main/java/org/apache/empire/db/DBTable.java
index 45f5962..a0fa3a3 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBTable.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBTable.java
@@ -634,6 +634,22 @@
     {
         this.cascadeDeleteAction = cascadeDeleteAction;
     }
+    
+    /**
+     * Creates a record key from a list of key values.
+     * The supplied values must be in the correct order. 
+     * @param keyValues
+     * @return the record key
+     */
+    public Object[] key(Object... keyValues)
+    {   // Check size
+        if (keyValues==null || keyValues.length==0)
+            throw new InvalidArgumentException("keyValues", keyValues);
+        if (this.primaryKey!=null && keyValues.length!=this.primaryKey.getColumnCount())
+            throw new InvalidArgumentException("keyValues:length", keyValues.length);
+        // Return the key
+        return keyValues;
+    }
 
     /**
      * Creates a delete SQL-Command by using the DBCommand getDelete method