This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch version-3-generic
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/version-3-generic by this push:
     new a5d6698  EMPIREDB-369 first attempt
a5d6698 is described below

commit a5d66987b7c931cddc2cd5357bb326f98c421490
Author: Rainer Döbele <[email protected]>
AuthorDate: Tue Feb 8 00:45:00 2022 +0100

    EMPIREDB-369 first attempt
---
 .../apache/empire/db/codegen/CodeGenWriter.java    |  6 +-
 .../apache/empire/db/codegen/WriterService.java    |  4 +-
 .../org/apache/empire/samples/db/SampleApp.java    | 42 ++++++------
 .../org/apache/empire/samples/db/SampleDB.java     | 36 +++++-----
 .../apache/empire/samples/db/beans/Department.java |  2 +-
 .../apache/empire/samples/db/beans/Employee.java   | 72 +++++++++++++-------
 .../apache/empire/jsf2/websample/db/SampleDB.java  | 47 +++++++------
 .../empire/jsf2/websample/db/SampleTable.java      |  5 +-
 .../jsf2/websample/db/records/SampleRecord.java    |  2 +-
 .../jsf2/websample/web/SampleApplication.java      |  8 +--
 .../jsf2/websample/web/pages/EmployeeListPage.java |  6 +-
 .../apache/empire/rest/app/SampleServiceApp.java   |  4 +-
 .../empire/rest/service/EmployeeService.java       | 10 +--
 .../org/apache/empire/vue/sample/db/SampleDB.java  | 31 ++++++---
 .../apache/empire/vue/sample/db/SampleTable.java   |  5 +-
 .../vue/sample/db/records/EmployeeRecord.java      |  2 +-
 .../empire/vue/sample/db/records/SampleRecord.java |  2 +-
 .../org/apache/empire/data/bean/BeanResult.java    |  6 +-
 .../main/java/org/apache/empire/db/DBColumn.java   | 13 ++--
 .../java/org/apache/empire/db/DBCommandExpr.java   | 22 +++----
 .../java/org/apache/empire/db/DBDDLGenerator.java  | 60 ++++++++---------
 .../main/java/org/apache/empire/db/DBDatabase.java | 76 +++++++++++-----------
 .../org/apache/empire/db/DBExpressionIndex.java    |  7 +-
 .../main/java/org/apache/empire/db/DBIndex.java    | 12 ++--
 .../main/java/org/apache/empire/db/DBQuery.java    | 13 ++--
 .../java/org/apache/empire/db/DBQueryColumn.java   |  2 +-
 .../main/java/org/apache/empire/db/DBReader.java   | 16 ++---
 .../main/java/org/apache/empire/db/DBRecord.java   | 20 +++---
 .../java/org/apache/empire/db/DBRecordBase.java    | 21 +++---
 .../main/java/org/apache/empire/db/DBRelation.java | 22 ++++---
 .../main/java/org/apache/empire/db/DBRowSet.java   | 25 ++++---
 .../main/java/org/apache/empire/db/DBTable.java    | 22 +++----
 .../main/java/org/apache/empire/db/DBUtils.java    |  7 +-
 .../src/main/java/org/apache/empire/db/DBView.java | 12 ++--
 .../apache/empire/db/expr/column/DBCountExpr.java  |  3 +-
 .../empire/db/expr/join/DBCrossJoinExpr.java       |  3 +-
 .../org/apache/empire/db/expr/set/DBSetExpr.java   |  3 +-
 .../empire/db/validation/DBModelChecker.java       | 58 ++++++++---------
 .../java/org/apache/empire/dbms/DBMSHandler.java   | 12 ++--
 .../org/apache/empire/dbms/DBMSHandlerBase.java    | 16 +++--
 .../apache/empire/dbms/hsql/HSqlDDLGenerator.java  |  8 +--
 .../empire/dbms/mysql/MySQLDDLGenerator.java       |  2 +-
 .../empire/dbms/oracle/OracleDDLGenerator.java     | 16 ++---
 .../empire/dbms/oracle/OracleDataDictionnary.java  |  4 +-
 .../dbms/postgresql/PostgreDDLGenerator.java       |  4 +-
 .../java/org/apache/empire/db/IntegerTest.java     | 16 ++---
 46 files changed, 424 insertions(+), 361 deletions(-)

diff --git 
a/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
 
b/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
index 220b06d..7cfd0ea 100644
--- 
a/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
+++ 
b/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
@@ -128,7 +128,7 @@ public class CodeGenWriter {
         * @param db
         *            the DBDatabase to generate files for
         */
-       public List<File> generateCodeFiles(DBDatabase db) {
+       public List<File> generateCodeFiles(DBDatabase<?> db) {
                List<File> generatedFiles = new ArrayList<File>();
 
                // Prepare directories for generated source files
@@ -153,7 +153,7 @@ public class CodeGenWriter {
         }
         
                // Create table classes, record interfaces and record classes
-               for (DBTable table : db.getTables()) {
+               for (DBTable<?> table : db.getTables()) {
                        if (!config.isNestTables()) {
                                // if table nesting is disabled, create 
separate table classes 
                                generatedFiles.add(this.createTableClass(db, 
table));
@@ -165,7 +165,7 @@ public class CodeGenWriter {
                }
                
                // Create view classes
-               for (DBView view : db.getViews()) {
+               for (DBView<?> view : db.getViews()) {
                        if (config.isGenerateViews() && !config.isNestViews()) {
                                // if table nesting is disabled, create 
separate table classes 
                                generatedFiles.add(this.createViewClass(db, 
view));
diff --git 
a/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
 
b/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
index d95cf19..54bc5f6 100644
--- 
a/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
+++ 
b/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
@@ -163,7 +163,7 @@ public class WriterService {
         * 
         * @param table the table to inspect
         */
-       public boolean hasBigDecimalField(DBTable table)
+       public boolean hasBigDecimalField(DBTable<?> table)
        {       
                for (DBColumn column : table.getColumns())
                {
@@ -181,7 +181,7 @@ public class WriterService {
         * 
         * @param table the table to inspect
         */
-       public boolean hasDateField(DBTable table)
+       public boolean hasDateField(DBTable<?> table)
        {
                for (DBColumn column : table.getColumns())
                {
diff --git 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
index 778a0fc..f607710 100644
--- 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
+++ 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
@@ -353,7 +353,7 @@ public class SampleApp
     {
         SampleDB.Departments DEP = db.DEPARTMENTS;
                // Insert a Department
-               DBRecord rec = new DBRecord(context, DEP);
+               DBRecord<SampleDB.Departments> rec = new 
DBRecord<SampleDB.Departments>(context, DEP);
                rec.create();
                rec.setValue(DEP.NAME, departmentName);
                rec.setValue(DEP.BUSINESS_UNIT, businessUnit);
@@ -371,10 +371,10 @@ public class SampleApp
     {
         SampleDB.Employees EMP = db.EMPLOYEES;
                // Insert an Employee
-               DBRecord rec = new DBRecord(context, EMP);
+               DBRecord<SampleDB.Employees> rec = new 
DBRecord<SampleDB.Employees>(context, EMP);
                rec.create(null);
-               rec.setValue(EMP.FIRSTNAME, firstName);
-               rec.setValue(EMP.LASTNAME, lastName);
+               rec.setValue(EMP.FIRST_NAME, firstName);
+               rec.setValue(EMP.LAST_NAME, lastName);
                rec.setValue(EMP.GENDER, gender);
                rec.setValue(EMP.DEPARTMENT_ID, departmentId);
                rec.update();
@@ -394,7 +394,7 @@ public class SampleApp
         LocalDate date = LocalDate.now();
         date = date.minusDays(date.getDayOfMonth()-1); // first day of this 
month
         // Add Payment for each month
-        DBRecord rec = new DBRecord(context, PAY);
+        DBRecord<SampleDB.Payments> rec = new 
DBRecord<SampleDB.Payments>(context, PAY);
         for (LocalDate month=date.minusMonths(20); !month.isAfter(date); 
month=month.plusMonths(1))
         {
             BigDecimal variation = new BigDecimal((Math.random()*200) - 100.0);
@@ -414,7 +414,7 @@ public class SampleApp
        private static void updateEmployee(long idEmp, String phoneNumber)
     {
                // Update an Employee
-               DBRecord rec = new DBRecord(context, db.EMPLOYEES);
+               DBRecord<SampleDB.Employees> rec = new 
DBRecord<SampleDB.Employees>(context, db.EMPLOYEES);
                rec.read(idEmp);
                // Set
                rec.setValue(db.EMPLOYEES.PHONE_NUMBER, phoneNumber);
@@ -432,7 +432,7 @@ public class SampleApp
         SampleDB.Employees EMP = db.EMPLOYEES;
         // Update an Employee with partial record
         // this will only load the EMPLOYEE ID and the PHONE_NUMBER
-        DBRecord rec = new DBRecord(context, EMP);
+        DBRecord<SampleDB.Employees> rec = new 
DBRecord<SampleDB.Employees>(context, EMP);
         rec.read(DBRecord.key(idEmp), PartialMode.INCLUDE, EMP.PHONE_NUMBER);
         // Set
         rec.setValue(db.EMPLOYEES.PHONE_NUMBER, phoneNumber);
@@ -455,13 +455,13 @@ public class SampleApp
         cmd.select(EMP.getColumns());
         cmd.select(DEP.getColumns());
         cmd.join(EMP.DEPARTMENT_ID, DEP.ID);
-        DBQuery query = new DBQuery(cmd, EMP.ID);
+        DBQuery<SampleDB> query = new DBQuery<SampleDB>(cmd, EMP.ID);
 
         // Make employee Head of Department and update salary
-        DBRecord rec = new DBRecord(context, query);
+        DBRecord<DBQuery<SampleDB>> rec = new 
DBRecord<DBQuery<SampleDB>>(context, query);
         rec.read(idEmp);
         rec.setValue(EMP.SALARY, salary);
-        rec.setValue(DEP.HEAD, rec.getString(EMP.LASTNAME));
+        rec.setValue(DEP.HEAD, rec.getString(EMP.LAST_NAME));
         rec.update();
     }
 
@@ -618,7 +618,7 @@ public class SampleApp
 
            // The following expression concats lastname + ', ' + firstname
         // DBColumnExpr EMPLOYEE_FULLNAME = EMP.LASTNAME.append(", 
").append(EMP.FIRSTNAME).as("FULL_NAME");
-        DBColumnExpr EMPLOYEE_FULLNAME = EMP.LASTNAME.concat(", ", 
EMP.FIRSTNAME).as("FULL_NAME");
+        DBColumnExpr EMPLOYEE_FULLNAME = EMP.LAST_NAME.concat(", ", 
EMP.FIRST_NAME).as("FULL_NAME");
         DBColumnExpr PAYMENTS_LAST_YEAR = 
PAY.AMOUNT.sum().as("PAYMENTS_LAST_YEAR");
         
         // The following expression extracts the extension number from the 
phone field
@@ -646,7 +646,7 @@ public class SampleApp
         cmd.join(EMP.DEPARTMENT_ID, DEP.ID);
         cmd.joinLeft(EMP.ID, PAY.EMPLOYEE_ID).where(PAY.YEAR.is(lastYear));
         // Where constraints
-        cmd.where(EMP.LASTNAME.length().isGreaterThan(0));
+        cmd.where(EMP.LAST_NAME.length().isGreaterThan(0));
         cmd.where(EMP.GENDER.in(Gender.M, Gender.F));
         cmd.where(EMP.RETIRED.is(false));
         // Order by
@@ -718,7 +718,7 @@ public class SampleApp
            
            DBCommand cmd = db.createCommand();
            cmd.where(EMP.GENDER.is(Gender.M));
-           cmd.orderBy(EMP.LASTNAME.desc());
+           cmd.orderBy(EMP.LAST_NAME.desc());
            List<Employee> list = context.getUtils().queryBeanList(cmd, 
Employee.class, null);
            for (Employee emp : list)
            {
@@ -761,7 +761,7 @@ public class SampleApp
         cmdEmpTotal.select(PAY.EMPLOYEE_ID, EMP_TOTAL);
         cmdEmpTotal.where (PAY.YEAR.is(lastYear));
         cmdEmpTotal.groupBy(PAY.EMPLOYEE_ID);
-        DBQuery qryEmpTotal = new DBQuery(cmdEmpTotal, "qet");
+        DBQuery<SampleDB> qryEmpTotal = new DBQuery<SampleDB>(cmdEmpTotal, 
"qet");
         
         // Department total query
         DBColumnExpr DEP_TOTAL = PAY.AMOUNT.sum().as("DEP_TOTAL");
@@ -770,12 +770,12 @@ public class SampleApp
         cmdDepTotal.join  (PAY.EMPLOYEE_ID, EMP.ID);
         cmdDepTotal.where (PAY.YEAR.is(lastYear));
         cmdDepTotal.groupBy(EMP.DEPARTMENT_ID);
-        DBQuery qryDepTotal = new DBQuery(cmdDepTotal, "qdt");
+        DBQuery<SampleDB> qryDepTotal = new DBQuery<SampleDB>(cmdDepTotal, 
"qdt");
 
         DBColumnExpr PCT_OF_DEPARTMENT_COST = 
qryEmpTotal.column(EMP_TOTAL).multiplyWith(100).divideBy(qryDepTotal.column(DEP_TOTAL));
         // Create the employee query
         DBCommand cmd = db.createCommand();
-        cmd.select(EMP.ID, EMP.FIRSTNAME, EMP.LASTNAME, 
DEP.NAME.as("DEPARTMENT"));
+        cmd.select(EMP.ID, EMP.FIRST_NAME, EMP.LAST_NAME, 
DEP.NAME.as("DEPARTMENT"));
         cmd.select(qryEmpTotal.column(EMP_TOTAL));
         cmd.select(PCT_OF_DEPARTMENT_COST.as("PCT_OF_DEPARTMENT_COST"));
         // join Employee with Department
@@ -785,7 +785,7 @@ public class SampleApp
         cmd.joinLeft(DEP.ID, qryDepTotal.column(EMP.DEPARTMENT_ID));
         // Order by
         cmd.orderBy(DEP.NAME.desc());
-        cmd.orderBy(EMP.LASTNAME);
+        cmd.orderBy(EMP.LAST_NAME);
            
         List<DataListEntry> list = context.getUtils().queryDataList(cmd);
         /* uncomment this to print full list
@@ -796,7 +796,7 @@ public class SampleApp
         {
             long empId = dle.getRecordId(EMP);
             // int depId = dle.getId(DEP);
-            String empName = StringUtils.concat(", ", 
dle.getString(EMP.LASTNAME), dle.getString(EMP.FIRSTNAME));
+            String empName = StringUtils.concat(", ", 
dle.getString(EMP.LAST_NAME), dle.getString(EMP.FIRST_NAME));
             String depName = dle.getString(DEP.NAME);
             boolean hasPayments =!dle.isNull(qryEmpTotal.column(EMP_TOTAL));
             if (hasPayments)
@@ -831,13 +831,13 @@ public class SampleApp
         cmd.join(EMP.DEPARTMENT_ID, DEP.ID);
         cmd.where(DEP.NAME.is("Development"));
         // query now
-        List<DBRecord> list = context.getUtils().queryRecordList(cmd, EMP);
+        List<DBRecord<SampleDB.Employees>> list = 
context.getUtils().queryRecordList(cmd, EMP);
         log.info("RecordList query found {} employees in Development 
department", list.size());
-        for (DBRecord record : list)
+        for (DBRecord<SampleDB.Employees> record : list)
         {
             Object[] key = record.getKey();
             // print info
-            String empName = StringUtils.concat(", ", 
record.getString(EMP.LASTNAME), record.getString(EMP.FIRSTNAME));
+            String empName = StringUtils.concat(", ", 
record.getString(EMP.LAST_NAME), record.getString(EMP.FIRST_NAME));
             String phone   = record.getString(EMP.PHONE_NUMBER);
             BigDecimal salary = record.getDecimal(EMP.SALARY);
             log.info("Eployee[{}]: {}\tPhone: {}\tSalary: {}", 
StringUtils.toString(key), empName, phone, salary);
diff --git 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java
 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java
index b0fe93b..877ba96 100644
--- 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java
+++ 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java
@@ -42,7 +42,7 @@ import org.apache.empire.samples.db.beans.Payment;
  * You may declare other database tables or views in the same way.
  * </PRE>
  */
-public class SampleDB extends DBDatabase
+public class SampleDB extends DBDatabase<SampleDB>
 {
     /**
      * Gender enum
@@ -68,7 +68,7 @@ public class SampleDB extends DBDatabase
     /**
      * This class represents the Departments table.
      */
-    public static class Departments extends DBTable
+    public static class Departments extends DBTable<SampleDB>
     {
         public final DBTableColumn ID;
         public final DBTableColumn NAME;
@@ -76,11 +76,11 @@ public class SampleDB extends DBDatabase
         public final DBTableColumn BUSINESS_UNIT;
         public final DBTableColumn UPDATE_TIMESTAMP;
 
-        public Departments(DBDatabase db)
+        public Departments(SampleDB db)
         {
             super("DEPARTMENTS", db);
             // ID
-            ID              = addColumn("ID",               DataType.AUTOINC,  
     0, true); // Optional Sequence name ("DEP_ID_SEQUENCE") for some DBMS 
(e.g. Oracle)
+            ID              = addColumn("ID",               DataType.AUTOINC,  
     0, true, "DEP_ID_SEQUENCE"); // Optional Sequence for some DBMS (e.g. 
Oracle)
             NAME            = addColumn("NAME",             DataType.VARCHAR,  
    80, true);
             HEAD            = addColumn("HEAD",             DataType.VARCHAR,  
    80, false);
             BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.VARCHAR,  
     4, true, "ITTK");
@@ -99,39 +99,43 @@ public class SampleDB extends DBDatabase
     /**
      * This class represents the Employees table.
      */
-    public static class Employees extends DBTable
+    public static class Employees extends DBTable<SampleDB>
     {
         public final DBTableColumn ID;
-        public final DBTableColumn FIRSTNAME;
-        public final DBTableColumn LASTNAME;
+        public final DBTableColumn SALUTATION;
+        public final DBTableColumn FIRST_NAME;
+        public final DBTableColumn LAST_NAME;
         public final DBTableColumn DATE_OF_BIRTH;
         public final DBTableColumn DEPARTMENT_ID;
         public final DBTableColumn GENDER;
         public final DBTableColumn PHONE_NUMBER;
+        public final DBTableColumn EMAIL;
         public final DBTableColumn SALARY;
         public final DBTableColumn RETIRED;
         public final DBTableColumn UPDATE_TIMESTAMP;
 
-        public Employees(DBDatabase db)
+        public Employees(SampleDB db)
         {
             super("EMPLOYEES", db);
             
             // ID
-            ID              = addColumn("ID",               DataType.AUTOINC,  
    0, true);  // Optional Sequence name ("EMPLOYEE_ID_SEQUENCE") for some DBMS 
(e.g. Oracle)
-            FIRSTNAME       = addColumn("FIRSTNAME",        DataType.VARCHAR,  
   40, true);
-            LASTNAME        = addColumn("LASTNAME",         DataType.VARCHAR,  
   40, true);
+            ID              = addColumn("ID",               DataType.AUTOINC,  
    0, true, "EMPLOYEE_ID_SEQUENCE");  // Optional Sequence name for some DBMS 
(e.g. Oracle)
+            SALUTATION      = addColumn("SALUTATION",       DataType.VARCHAR,  
    5, false);
+            FIRST_NAME      = addColumn("FIRST_NAME",       DataType.VARCHAR,  
   40, true);
+            LAST_NAME       = addColumn("LAST_NAME",        DataType.VARCHAR,  
   40, true);
             DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,     
    0, false);
             DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.INTEGER,  
    0, true);
-            GENDER          = addColumn("GENDER",           DataType.VARCHAR,  
    1, false, Gender.class);
+            GENDER          = addColumn("GENDER",           DataType.VARCHAR,  
    1, true, Gender.class);
             PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.VARCHAR,  
   40, false);
+            EMAIL           = addColumn("EMAIL",            DataType.VARCHAR,  
   80, false);
             SALARY          = addColumn("SALARY",           DataType.DECIMAL,  
 10.2, false);
             RETIRED         = addColumn("RETIRED",          DataType.BOOL,     
    0, true, false);
             UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", 
DataType.TIMESTAMP,    0, true);
-
+            
             // Primary Key (automatically set due to AUTOINC column)
             // setPrimaryKey(EMPLOYEE_ID);
             // Set other Indexes
-            addIndex("EMPLOYEE_NAME_IDX", true, new DBColumn[] { FIRSTNAME, 
LASTNAME, DATE_OF_BIRTH });
+            addIndex("EMPLOYEE_NAME_IDX", true, new DBColumn[] { FIRST_NAME, 
LAST_NAME, DATE_OF_BIRTH });
 
             // Set beanType (optional)
             setBeanType(Employee.class);
@@ -141,14 +145,14 @@ public class SampleDB extends DBDatabase
     /**
      * This class represents the Payments table.
      */
-    public static class Payments extends DBTable
+    public static class Payments extends DBTable<SampleDB>
     {
         public final DBTableColumn EMPLOYEE_ID;
         public final DBTableColumn YEAR;
         public final DBTableColumn MONTH;
         public final DBTableColumn AMOUNT;
 
-        public Payments(DBDatabase db)
+        public Payments(SampleDB db)
         {
             super("PAYMENTS", db);
             
diff --git 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Department.java
 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Department.java
index 5d25c2f..6713b03 100644
--- 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Department.java
+++ 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Department.java
@@ -68,7 +68,7 @@ public class Department implements DataBean<SampleDB>
     {
         DBCommand cmd = db.createCommand();
         cmd.where(db.EMPLOYEES.DEPARTMENT_ID.is(this.id));
-        cmd.orderBy(db.EMPLOYEES.FIRSTNAME, db.EMPLOYEES.LASTNAME);
+        cmd.orderBy(db.EMPLOYEES.FIRST_NAME, db.EMPLOYEES.LAST_NAME);
         employees = context.getUtils().queryBeanList(cmd, Employee.class, 
db.EMPLOYEES, this);
     }
     
diff --git 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Employee.java
 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Employee.java
index b8083de..818808c 100644
--- 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Employee.java
+++ 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/beans/Employee.java
@@ -41,12 +41,14 @@ public class Employee implements DataBean<SampleDB>
     private static final Logger log = LoggerFactory.getLogger(Employee.class);
     
     private long   id;          // "ID" 
-    private String firstname;   // "FIRSTNAME"
-    private String lastname;    // "LASTNAME"
+    private String salutation;  // "SALUTATION"
+    private String firstName;   // "FIRST_NAME"
+    private String lastName;    // "LAST_NAME"
     private Date   dateOfBirth; // "DATE_OF_BIRTH"
     private long   departmentId;// "DEPARTMENT_ID"
     private String gender;      // "GENDER"
     private String phoneNumber; // "PHONE_NUMBER"
+    private String email;       // "EMAIL"
     private BigDecimal salary;  // "SALARY"
     private boolean retired;    // "RETIRED" 
     
@@ -83,19 +85,23 @@ public class Employee implements DataBean<SampleDB>
     }
      */
 
+    
     /**
      * Constructor using fields but without timestamp 
      */
-    public Employee(int id, String firstname, String lastname, Date 
dateOfBirth, int departmentId, String gender, String phoneNumber,
-                    BigDecimal salary, boolean retired)
+    public Employee(long id, String salutation, String firstName, String 
lastName, Date dateOfBirth, long departmentId, String gender,
+                    String phoneNumber, String email, BigDecimal salary, 
boolean retired)
     {
+        super();
         this.id = id;
-        this.firstname = firstname;
-        this.lastname = lastname;
+        this.salutation = salutation;
+        this.firstName = firstName;
+        this.lastName = lastName;
         this.dateOfBirth = dateOfBirth;
         this.departmentId = departmentId;
         this.gender = gender;
         this.phoneNumber = phoneNumber;
+        this.email = email;
         this.salary = salary;
         this.retired = retired;
 
@@ -105,7 +111,7 @@ public class Employee implements DataBean<SampleDB>
     /**
      * Constructor using primary key fields 
      */
-    public Employee(int id)
+    public Employee(long id)
     {
         this.id = id;
         log.info("Employee bean created using primary key constructor");
@@ -120,34 +126,36 @@ public class Employee implements DataBean<SampleDB>
         log.info("Employee bean created using standard constructor");
     }
 
-    public long getId()
+    
+    
+    public String getSalutation()
     {
-        return id;
+        return salutation;
     }
 
-    public void setId(long id)
+    public void setSalutation(String salutation)
     {
-        this.id = id;
+        this.salutation = salutation;
     }
- 
-    public String getFirstname()
+
+    public String getFirstName()
     {
-        return firstname;
+        return firstName;
     }
 
-    public void setFirstname(String firstname)
+    public void setFirstName(String firstName)
     {
-        this.firstname = firstname;
+        this.firstName = firstName;
     }
 
-    public String getLastname()
+    public String getLastName()
     {
-        return lastname;
+        return lastName;
     }
 
-    public void setLastname(String lastname)
+    public void setLastName(String lastName)
     {
-        this.lastname = lastname;
+        this.lastName = lastName;
     }
 
     public Date getDateOfBirth()
@@ -190,6 +198,16 @@ public class Employee implements DataBean<SampleDB>
         this.phoneNumber = phoneNumber;
     }
 
+    public String getEmail()
+    {
+        return email;
+    }
+
+    public void setEmail(String email)
+    {
+        this.email = email;
+    }
+
     public BigDecimal getSalary()
     {
         return salary;
@@ -210,6 +228,16 @@ public class Employee implements DataBean<SampleDB>
         this.retired = retired;
     }
 
+    public long getId()
+    {
+        return id;
+    }
+
+    public int getRownum()
+    {
+        return rownum;
+    }
+
     public Department getDepartment()
     {
         return department;
@@ -228,9 +256,9 @@ public class Employee implements DataBean<SampleDB>
         buf.append("\t");
         buf.append(id);
         buf.append("\t");
-        buf.append(firstname);
+        buf.append(firstName);
         buf.append("\t");
-        buf.append(lastname);
+        buf.append(lastName);
         buf.append("\t");
         buf.append(DateUtils.formatDate(dateOfBirth, Locale.US));
         buf.append("\t");
diff --git 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
index f0588b0..e4e27d5 100644
--- 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
+++ 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
@@ -24,7 +24,7 @@ import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTableColumn;
 
-public class SampleDB extends DBDatabase
+public class SampleDB extends DBDatabase<SampleDB>
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
 
@@ -61,7 +61,11 @@ public class SampleDB extends DBDatabase
         public final DBTableColumn BUSINESS_UNIT;
         public final DBTableColumn UPDATE_TIMESTAMP;
 
-        public TDepartments(DBDatabase db)
+        /**
+         * Departments table constructor
+         * @param db
+         */
+        public TDepartments(SampleDB db)
         {
             super("DEPARTMENTS", db);
             // ID
@@ -78,8 +82,6 @@ public class SampleDB extends DBDatabase
         }
     }
 
-  
-
     /**
      * This class represents the definition of the Employees table.
      */
@@ -87,7 +89,7 @@ public class SampleDB extends DBDatabase
     {
         // *Deprecated* private static final long serialVersionUID = 1L;
 
-        public final DBTableColumn EMPLOYEE_ID;
+        public final DBTableColumn ID;
         public final DBTableColumn SALUTATION;
 //      public final DBTableColumn PICTURE;
         public final DBTableColumn FIRST_NAME;
@@ -97,27 +99,34 @@ public class SampleDB extends DBDatabase
         public final DBTableColumn GENDER;
         public final DBTableColumn PHONE_NUMBER;
         public final DBTableColumn EMAIL;
+        public final DBTableColumn SALARY;
         public final DBTableColumn RETIRED;
         public final DBTableColumn UPDATE_TIMESTAMP;
-        public TEmployees(DBDatabase db)
+
+        /**
+         * Employees table constructor
+         * @param db
+         */
+        public TEmployees(SampleDB db)
         {
             super("EMPLOYEES", db);
             // ID
-            EMPLOYEE_ID        = addColumn("EMPLOYEE_ID",              
DataType.AUTOINC,        0, true, "EMPLOYEE_ID_SEQUENCE");
-            SALUTATION                 = addColumn("SALUTATION",               
DataType.VARCHAR,        5, false);
-            FIRST_NAME                 = addColumn("FIRST_NAME",               
DataType.VARCHAR,       40, true);
-            LAST_NAME          = addColumn("LAST_NAME",                
DataType.VARCHAR,       40, true);
-            DATE_OF_BIRTH      = addColumn("DATE_OF_BIRTH",    DataType.DATE,  
         0, false);
-            DEPARTMENT_ID      = addColumn("DEPARTMENT_ID",    
DataType.INTEGER,        0, true);
-            GENDER                     = addColumn("GENDER",                   
DataType.VARCHAR,        1, false);
-            PHONE_NUMBER       = addColumn("PHONE_NUMBER",     
DataType.VARCHAR,       40, false);
-            EMAIL                      = addColumn("EMAIL",                    
DataType.VARCHAR,       80, false);
-            RETIRED                    = addColumn("RETIRED",                  
DataType.BOOL,           0, true, false);
-            // PICTURE                 = addColumn("PICTURE",                  
DataType.BLOB,           0, false);
-            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", 
DataType.TIMESTAMP,         0, true);
+            ID              = addColumn("ID",               DataType.AUTOINC,  
  0, true, "EMPLOYEE_ID_SEQUENCE");
+            SALUTATION      = addColumn("SALUTATION",       DataType.VARCHAR,  
  5, false);
+            FIRST_NAME      = addColumn("FIRST_NAME",       DataType.VARCHAR,  
 40, true);
+            LAST_NAME       = addColumn("LAST_NAME",        DataType.VARCHAR,  
 40, true);
+            DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,     
  0, false);
+            DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.INTEGER,  
  0, true);
+            GENDER          = addColumn("GENDER",           DataType.VARCHAR,  
  1, false);
+            PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.VARCHAR,  
 40, false);
+            EMAIL           = addColumn("EMAIL",            DataType.VARCHAR,  
 80, false);
+            SALARY          = addColumn("SALARY",           DataType.DECIMAL, 
10.2, false);
+            RETIRED         = addColumn("RETIRED",          DataType.BOOL,     
  0, true, false);
+            // PICTURE      = addColumn("PICTURE",          DataType.BLOB,     
  0, false);
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", 
DataType.TIMESTAMP,  0, true);
 
             // Primary Key
-            setPrimaryKey(EMPLOYEE_ID);
+            setPrimaryKey(ID);
             // Set other Indexes
             addIndex("PERSON_NAME_IDX", true, new DBColumn[] { FIRST_NAME, 
LAST_NAME, DATE_OF_BIRTH });
 
diff --git 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleTable.java
 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleTable.java
index 46aaf7d..9fb5ce3 100644
--- 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleTable.java
+++ 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleTable.java
@@ -21,7 +21,6 @@ package org.apache.empire.jsf2.websample.db;
 import java.util.Locale;
 
 import org.apache.empire.data.DataType;
-import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 
@@ -29,13 +28,13 @@ import org.apache.empire.db.DBTableColumn;
  * Base class definition for all database tables Automatically generates a 
message-key for the field title e.g. for the column
  * EMPLOYEES.DATE_OF_BIRTH it generates the key 
"!field.title.employees.dateOfBirth";
  */
-public class SampleTable extends DBTable
+public class SampleTable extends DBTable<SampleDB>
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
     
     public final String       MESSAGE_KEY_PREFIX = "!field.title.";
 
-    public SampleTable(String name, DBDatabase db)
+    public SampleTable(String name, SampleDB db)
     {
         super(name, db);
     }
diff --git 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/SampleRecord.java
 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/SampleRecord.java
index 9f25a08..c974486 100644
--- 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/SampleRecord.java
+++ 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/SampleRecord.java
@@ -31,7 +31,7 @@ import org.apache.empire.jsf2.app.FacesUtils;
 import org.apache.empire.jsf2.websample.db.SampleTable;
 import org.apache.empire.jsf2.websample.web.pages.SamplePage;
 
-public abstract class SampleRecord<T extends SampleTable> extends DBRecord
+public abstract class SampleRecord<T extends SampleTable> extends DBRecord<T>
 {
     private static final long   serialVersionUID = 1L;
 
diff --git 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
index b9d2b80..5289207 100644
--- 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
+++ 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
@@ -235,7 +235,7 @@ public class SampleApplication extends WebApplication {
         */
        private int insertDepartmentSampleRecord(DBContext context, String 
department_name, String businessUnit) {
                // Insert a Department
-               DBRecord rec = new DBRecord(context, sampleDB.T_DEPARTMENTS);
+               DBRecord<SampleDB.TDepartments> rec = new 
DBRecord<SampleDB.TDepartments>(context, sampleDB.T_DEPARTMENTS);
                rec.create();
                rec.setValue(sampleDB.T_DEPARTMENTS.NAME, department_name);
                rec.setValue(sampleDB.T_DEPARTMENTS.BUSINESS_UNIT, 
businessUnit);
@@ -254,7 +254,7 @@ public class SampleApplication extends WebApplication {
         */
        private int insertEmployeeSampleRecord(DBContext context, String 
salutation, String firstName, String lastName, String gender, int depID) {
                // Insert an Employee
-               DBRecord rec = new DBRecord(context, sampleDB.T_EMPLOYEES);
+               DBRecord<SampleDB.TEmployees> rec = new 
DBRecord<SampleDB.TEmployees>(context, sampleDB.T_EMPLOYEES);
                rec.create();
                rec.setValue(sampleDB.T_EMPLOYEES.SALUTATION, salutation);
                rec.setValue(sampleDB.T_EMPLOYEES.FIRST_NAME, firstName);
@@ -268,13 +268,13 @@ public class SampleApplication extends WebApplication {
                        return 0;
                }
                // Return Employee ID
-               return rec.getInt(sampleDB.T_EMPLOYEES.EMPLOYEE_ID);
+               return rec.getInt(sampleDB.T_EMPLOYEES.ID);
        }
 
-       @Override
        /**
         * returns null as connection pooling is not used
         */
+    @Override
        protected DataSource getAppDataSource(DBDatabase db) {
                return null;
        }
diff --git 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
index 8e1ea9f..0a55747 100644
--- 
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
+++ 
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
@@ -146,7 +146,7 @@ public class EmployeeListPage extends SamplePage
         TEmployees EMP = getDatabase().T_EMPLOYEES;
 
         // create the Employees List page element
-        employees = new BeanListPageElement<EmployeeListEntry>(this, 
EmployeeListEntry.class, EMP.EMPLOYEE_ID);
+        employees = new BeanListPageElement<EmployeeListEntry>(this, 
EmployeeListEntry.class, EMP.ID);
     }
 
     
@@ -184,7 +184,7 @@ public class EmployeeListPage extends SamplePage
 
         DBCommand queryCmd = createQueryCommand();
 
-        queryCmd.select(EMP.EMPLOYEE_ID, FULL_NAME);
+        queryCmd.select(EMP.ID, FULL_NAME);
         queryCmd.select(EMP.GENDER, EMP.DATE_OF_BIRTH, EMP.RETIRED);
         // queryCmd.select(EMP.RETIRED.decode(true, "X", "-"));
         queryCmd.select(DEPARTMENT);
@@ -214,7 +214,7 @@ public class EmployeeListPage extends SamplePage
         TEmployees EMP = getDatabase().T_EMPLOYEES;
         EmployeeSearchFilter filter = getSearchFilter();
         
-        addSearchConstraint(queryCmd, EMP.EMPLOYEE_ID, filter);
+        addSearchConstraint(queryCmd, EMP.ID, filter);
         addSearchConstraint(queryCmd, EMP.FIRST_NAME, filter);
         addSearchConstraint(queryCmd, EMP.LAST_NAME, filter);
         addSearchConstraint(queryCmd, EMP.GENDER, filter);
diff --git 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/app/SampleServiceApp.java
 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/app/SampleServiceApp.java
index 2b154c2..3104d82 100644
--- 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/app/SampleServiceApp.java
+++ 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/app/SampleServiceApp.java
@@ -240,7 +240,7 @@ public class SampleServiceApp
             return 0;
         }
         // Return Department ID
-        return rec.getInt(db.T_DEPARTMENTS.DEPARTMENT_ID);
+        return rec.getInt(db.T_DEPARTMENTS.ID);
     }
 
     /*
@@ -262,7 +262,7 @@ public class SampleServiceApp
             return 0;
         }
         // Return Employee ID
-        return rec.getInt(db.T_EMPLOYEES.EMPLOYEE_ID);
+        return rec.getInt(db.T_EMPLOYEES.ID);
     }
 
     private void initLogging() {
diff --git 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/service/EmployeeService.java
 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/service/EmployeeService.java
index c784050..b1accdb 100644
--- 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/service/EmployeeService.java
+++ 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/rest/service/EmployeeService.java
@@ -67,8 +67,8 @@ public class EmployeeService extends Service {
         // Query Department options
         SampleDB db = getDatabase();
         DBCommand cmd = db.createCommand();
-        cmd.select(db.T_DEPARTMENTS.DEPARTMENT_ID, db.T_DEPARTMENTS.NAME);
-        cmd.join  (db.T_DEPARTMENTS.DEPARTMENT_ID, 
db.T_EMPLOYEES.DEPARTMENT_ID);
+        cmd.select(db.T_DEPARTMENTS.ID, db.T_DEPARTMENTS.NAME);
+        cmd.join  (db.T_DEPARTMENTS.ID, db.T_EMPLOYEES.DEPARTMENT_ID);
         cmd.groupBy(cmd.getSelectExpressions());
         cmd.orderBy(db.T_DEPARTMENTS.NAME);
         Options departmentOptions = ctx.getUtils().queryOptionList(cmd);
@@ -76,7 +76,7 @@ public class EmployeeService extends Service {
         // Create Metadata
         TEmployees TE = db.T_EMPLOYEES;
         JsoColumnMeta[] meta = new JsoColumnMeta[] { 
-          new JsoColumnMeta(TE.EMPLOYEE_ID, textResolver),
+          new JsoColumnMeta(TE.ID, textResolver),
           new JsoColumnMeta(TE.FIRST_NAME, textResolver),
           new JsoColumnMeta(TE.LAST_NAME, textResolver),
           new JsoColumnMeta(TE.DEPARTMENT_ID, textResolver, departmentOptions, 
false, false, false),
@@ -104,8 +104,8 @@ public class EmployeeService extends Service {
         log.info("Providing employee list...");
 
         DBCommand cmd = db.createCommand();
-        cmd.select(TE.EMPLOYEE_ID, FULL_NAME, DEPARTMENT, TE.GENDER, 
TE.DATE_OF_BIRTH, TE.RETIRED);
-        cmd.join  (TE.DEPARTMENT_ID, TD.DEPARTMENT_ID, DBJoinType.LEFT);
+        cmd.select(TE.ID, FULL_NAME, DEPARTMENT, TE.GENDER, TE.DATE_OF_BIRTH, 
TE.RETIRED);
+        cmd.join  (TE.DEPARTMENT_ID, TD.ID, DBJoinType.LEFT);
 
         // apply all filters
         if (filter.hasNonNullValue(TE.FIRST_NAME))
diff --git 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleDB.java
 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleDB.java
index 2e5d173..a17dfaa 100644
--- 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleDB.java
+++ 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleDB.java
@@ -24,7 +24,7 @@ import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTableColumn;
 
-public class SampleDB extends DBDatabase
+public class SampleDB extends DBDatabase<SampleDB>
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
 
@@ -38,7 +38,7 @@ public class SampleDB extends DBDatabase
     public SampleDB()
     {
         // Define Foreign-Key Relations
-        
addRelation(T_EMPLOYEES.DEPARTMENT_ID.referenceOn(T_DEPARTMENTS.DEPARTMENT_ID));
+        addRelation(T_EMPLOYEES.DEPARTMENT_ID.referenceOn(T_DEPARTMENTS.ID));
     }
 
     // Needed for the DBELResolver
@@ -55,24 +55,28 @@ public class SampleDB extends DBDatabase
     {
         // *Deprecated* private static final long serialVersionUID = 1L;
 
-        public final DBTableColumn DEPARTMENT_ID;
+        public final DBTableColumn ID;
         public final DBTableColumn NAME;
         public final DBTableColumn HEAD;
         public final DBTableColumn BUSINESS_UNIT;
         public final DBTableColumn UPDATE_TIMESTAMP;
 
-        public TDepartments(DBDatabase db)
+        /**
+         * Departments table constructor
+         * @param db
+         */
+        public TDepartments(SampleDB db)
         {
             super("DEPARTMENTS", db);
             // ID
-            DEPARTMENT_ID      = addColumn("DEPARTMENT_ID",    
DataType.AUTOINC,        0, true, "DEP_ID_SEQUENCE");
+            ID                     = addColumn("ID",               
DataType.AUTOINC,    0, true, "DEP_ID_SEQUENCE");
             NAME                       = addColumn("NAME",                     
DataType.VARCHAR,       80, true);
             HEAD                       = addColumn("HEAD",                     
DataType.VARCHAR,       80, false);
             BUSINESS_UNIT      = addColumn("BUSINESS_UNIT",    
DataType.VARCHAR,    4, true, "ITTK");
             UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", 
DataType.TIMESTAMP,  0, true);
 
             // Primary Key
-            setPrimaryKey(DEPARTMENT_ID);
+            setPrimaryKey(ID);
             // Set other Indexes
             addIndex("DEARTMENT_NAME_IDX", true, new DBColumn[] { NAME });
 
@@ -88,7 +92,7 @@ public class SampleDB extends DBDatabase
     {
         // *Deprecated* private static final long serialVersionUID = 1L;
 
-        public final DBTableColumn EMPLOYEE_ID;
+        public final DBTableColumn ID;
         public final DBTableColumn SALUTATION;
 //      public final DBTableColumn PICTURE;
         public final DBTableColumn FIRST_NAME;
@@ -98,13 +102,19 @@ public class SampleDB extends DBDatabase
         public final DBTableColumn GENDER;
         public final DBTableColumn PHONE_NUMBER;
         public final DBTableColumn EMAIL;
+        public final DBTableColumn SALARY;
         public final DBTableColumn RETIRED;
         public final DBTableColumn UPDATE_TIMESTAMP;
-        public TEmployees(DBDatabase db)
+
+        /**
+         * Employees table constructor
+         * @param db
+         */
+        public TEmployees(SampleDB db)
         {
             super("EMPLOYEES", db);
             // ID
-            EMPLOYEE_ID        = addColumn("EMPLOYEE_ID",              
DataType.AUTOINC,        0, true, "EMPLOYEE_ID_SEQUENCE");
+            ID                     = addColumn("ID",               
DataType.AUTOINC,    0, true, "EMPLOYEE_ID_SEQUENCE");
             SALUTATION                 = addColumn("SALUTATION",               
DataType.VARCHAR,        5, false);
             FIRST_NAME                 = addColumn("FIRST_NAME",               
DataType.VARCHAR,       40, true);
             LAST_NAME          = addColumn("LAST_NAME",                
DataType.VARCHAR,       40, true);
@@ -113,12 +123,13 @@ public class SampleDB extends DBDatabase
             GENDER                     = addColumn("GENDER",                   
DataType.VARCHAR,        1, false);
             PHONE_NUMBER       = addColumn("PHONE_NUMBER",     
DataType.VARCHAR,       40, false);
             EMAIL                      = addColumn("EMAIL",                    
DataType.VARCHAR,       80, false);
+            SALARY          = addColumn("SALARY",           DataType.DECIMAL, 
10.2, false);
             RETIRED                    = addColumn("RETIRED",                  
DataType.BOOL,           0, true, false);
             // PICTURE                 = addColumn("PICTURE",                  
DataType.BLOB,           0, false);
             UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", 
DataType.TIMESTAMP,  0, true);
 
             // Primary Key
-            setPrimaryKey(EMPLOYEE_ID);
+            setPrimaryKey(ID);
             // Set other Indexes
             addIndex("PERSON_NAME_IDX", true, new DBColumn[] { FIRST_NAME, 
LAST_NAME, DATE_OF_BIRTH });
 
diff --git 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleTable.java
 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleTable.java
index 3f1c64f..462dd94 100644
--- 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleTable.java
+++ 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/SampleTable.java
@@ -21,7 +21,6 @@ package org.apache.empire.vue.sample.db;
 import java.util.Locale;
 
 import org.apache.empire.data.DataType;
-import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 
@@ -29,13 +28,13 @@ import org.apache.empire.db.DBTableColumn;
  * Base class definition for all database tables Automatically generates a 
message-key for the field title e.g. for the column
  * EMPLOYEES.DATE_OF_BIRTH it generates the key 
"!field.title.employees.dateOfBirth";
  */
-public class SampleTable extends DBTable
+public class SampleTable extends DBTable<SampleDB>
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
     
     public final String       MESSAGE_KEY_PREFIX = "!field.title.";
 
-    public SampleTable(String name, DBDatabase db)
+    public SampleTable(String name, SampleDB db)
     {
         super(name, db);
     }
diff --git 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/EmployeeRecord.java
 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/EmployeeRecord.java
index 25c3fc1..5cbca22 100644
--- 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/EmployeeRecord.java
+++ 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/EmployeeRecord.java
@@ -56,7 +56,7 @@ public class EmployeeRecord extends SampleRecord<TEmployees>
         {
             SampleDB db = (SampleDB) getDatabase();
             DBCommand cmd = db.createCommand();
-            cmd.select(db.T_DEPARTMENTS.DEPARTMENT_ID);
+            cmd.select(db.T_DEPARTMENTS.ID);
             cmd.select(db.T_DEPARTMENTS.NAME);
             cmd.orderBy(db.T_DEPARTMENTS.NAME);
             return recordContext.getUtils().queryOptionList(cmd);
diff --git 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/SampleRecord.java
 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/SampleRecord.java
index a949588..af029f8 100644
--- 
a/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/SampleRecord.java
+++ 
b/empire-db-examples/empire-db-example-vue/src/main/java/org/apache/empire/vue/sample/db/records/SampleRecord.java
@@ -35,7 +35,7 @@ import org.apache.empire.vue.sample.db.RecordContext;
 import org.apache.empire.vue.sample.db.SampleTable;
 
 
-public abstract class SampleRecord<T extends SampleTable> extends DBRecord 
+public abstract class SampleRecord<T extends SampleTable> extends DBRecord<T> 
 {
        private static final long serialVersionUID = 1L;
        
diff --git 
a/empire-db/src/main/java/org/apache/empire/data/bean/BeanResult.java 
b/empire-db/src/main/java/org/apache/empire/data/bean/BeanResult.java
index 46d2743..8ab5c59 100644
--- a/empire-db/src/main/java/org/apache/empire/data/bean/BeanResult.java
+++ b/empire-db/src/main/java/org/apache/empire/data/bean/BeanResult.java
@@ -73,13 +73,13 @@ public class BeanResult<T> extends ArrayList<T>
      * @param beanType the of T
      * @param rowset the rowset 
      */
-    public BeanResult(Class<T> beanType, DBRowSet rowset)
+    public BeanResult(Class<T> beanType, DBRowSet<?> rowset)
     {
         DBObject.checkParamNull("beanType", beanType);
         DBObject.checkParamNull("rowset", rowset);
         this.beanType = beanType;
         // Create the command
-        DBDatabase db = rowset.getDatabase();
+        DBDatabase<?> db = rowset.getDatabase();
         cmd = db.createCommand();
         autoSelectColumns(rowset);
     }
@@ -147,7 +147,7 @@ public class BeanResult<T> extends ArrayList<T>
      * Selects all columns for a given rowset
      * @param rowset
      */
-    protected void autoSelectColumns(DBRowSet rowset)
+    protected void autoSelectColumns(DBRowSet<?> rowset)
     {
         // Select all accessible columns
         int count = 0;
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBColumn.java 
b/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
index 53bb88d..05925ab 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
@@ -62,9 +62,9 @@ public abstract class DBColumn extends DBColumnExpr
     public static final String DBCOLATTR_SINGLEBYTECHARS  = "singleByteChars";
 
     // basic data
-    protected final DBRowSet  rowset; /* transient */
-    protected final String    name;
-    protected String          comment;
+    protected final DBRowSet<?> rowset; /* transient */
+    protected final String      name;
+    protected String            comment;
 
     private Boolean quoteName = null;
     
@@ -74,7 +74,7 @@ public abstract class DBColumn extends DBColumnExpr
      * @param rowset the rowset (i.e. Table or View) that this column belongs 
to
      * @param name the column name
      */
-    protected DBColumn(DBRowSet rowset, String name)
+    protected DBColumn(DBRowSet<?> rowset, String name)
     {
         this.rowset = rowset;
         this.name = name;
@@ -216,8 +216,9 @@ public abstract class DBColumn extends DBColumnExpr
     /**
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public final <T extends DBDatabase> T getDatabase()
+    public final DBDatabase<?> getDatabase()
     {
         return (rowset!=null ? rowset.getDatabase() : null);
     }
@@ -289,7 +290,7 @@ public abstract class DBColumn extends DBColumnExpr
      *
      * @return the DBTable, DBQuery or DBView object
      */
-    public DBRowSet getRowSet()
+    public DBRowSet<?> getRowSet()
     {
         return rowset;
     }
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
index f78ea46..cbbabaa 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
@@ -44,7 +44,7 @@ public abstract class DBCommandExpr extends DBExpr
     private static final Logger log = 
LoggerFactory.getLogger(DBCommandExpr.class);
 
     // Internal Classes
-    protected static class DBCmdQuery extends DBRowSet
+    protected static class DBCmdQuery<DB extends DBDatabase<DB>> extends 
DBRowSet<DB>
     {
         // *Deprecated* private static final long serialVersionUID = 1L;
         private DBCommandExpr cmd;
@@ -134,7 +134,7 @@ public abstract class DBCommandExpr extends DBExpr
 
         /** throws ERR_NOTSUPPORTED */
         @Override
-        public void updateRecord(DBRecordBase rec)
+        public void updateRecord(DBRecordBase record)
         {
             throw new NotSupportedException(this, "updateRecord");
         }
@@ -161,7 +161,7 @@ public abstract class DBCommandExpr extends DBExpr
          * @param query the row set
          * @param expr the column
          */
-        public DBCmdColumn(DBRowSet query, DBColumnExpr expr)
+        public DBCmdColumn(DBRowSet<?> query, DBColumnExpr expr)
         { // call base
             super(query, expr.getName());
             // set Expression
@@ -280,7 +280,7 @@ public abstract class DBCommandExpr extends DBExpr
     }
 
     // Members
-    protected DBCmdQuery          cmdQuery = null;
+    protected DBCmdQuery<?>       cmdQuery = null;
     protected List<DBOrderByExpr> orderBy  = null;
 
     /** Constructs an empty DBCommandExpr object */
@@ -362,8 +362,8 @@ public abstract class DBCommandExpr extends DBExpr
      */
     public DBCommandExpr union(DBCommandExpr other)
     {   // give dbms a chance to subclass DBCombinedCmd
-       DBMSHandler dbms = getDatabase().getDbms();
-       return dbms.createCombinedCommand(this, "UNION", other);
+        DBMSHandler dbms = getDatabase().getDbms();
+        return dbms.createCombinedCommand(this, "UNION", other);
     }
 
     /**
@@ -389,8 +389,8 @@ public abstract class DBCommandExpr extends DBExpr
      */
     public DBCommandExpr intersect(DBCommandExpr other)
     {   // give dbms a chance to subclass DBCombinedCmd
-       DBMSHandler dbms = getDatabase().getDbms();
-       return dbms.createCombinedCommand(this, "INTERSECT", other);
+        DBMSHandler dbms = getDatabase().getDbms();
+        return dbms.createCombinedCommand(this, "INTERSECT", other);
     }
     
     /**
@@ -510,7 +510,7 @@ public abstract class DBCommandExpr extends DBExpr
      * 
      * @return the insert into SQL-Command
      */
-    public final String getInsertInto(DBTable table, List<DBColumnExpr> 
columns)
+    public final String getInsertInto(DBTable<?> table, List<DBColumnExpr> 
columns)
     {
         return getInsertInto(table, getSelectExprList(), columns);
     }
@@ -523,7 +523,7 @@ public abstract class DBCommandExpr extends DBExpr
      * 
      * @return the insert into SQL-Command
      */
-    public final String getInsertInto(DBTable table)
+    public final String getInsertInto(DBTable<?> table)
     {
         DBColumnExpr[] select = getSelectExprList();
         if (select == null || select.length < 1)
@@ -588,7 +588,7 @@ public abstract class DBCommandExpr extends DBExpr
      * 
      * @return the insert into SQL-Command
      */
-    protected String getInsertInto(DBTable table, DBColumnExpr[] select, 
List<DBColumnExpr> columns)
+    protected String getInsertInto(DBTable<?> table, DBColumnExpr[] select, 
List<DBColumnExpr> columns)
     {
         if (select == null)
             throw new ObjectNotValidException(this);
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBDDLGenerator.java 
b/empire-db/src/main/java/org/apache/empire/db/DBDDLGenerator.java
index c1347a9..3293654 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBDDLGenerator.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBDDLGenerator.java
@@ -93,22 +93,22 @@ public abstract class DBDDLGenerator<T extends DBMSHandler>
     }
 
     // Add statements
-    protected void addCreateTableStmt(DBTable table, StringBuilder sql, 
DBSQLScript script)
+    protected void addCreateTableStmt(DBTable<?> table, StringBuilder sql, 
DBSQLScript script)
     {
         log.info("Adding create statmement for table {}.", table.getName());
         script.addStmt(sql);
     }
-    protected void addCreateIndexStmt(DBIndex index, StringBuilder sql, 
DBSQLScript script)
+    protected void addCreateIndexStmt(DBIndex<?> index, StringBuilder sql, 
DBSQLScript script)
     {
         log.info("Adding create statmement for index {}.", index.getName());
         script.addStmt(sql);
     }
-    protected void addCreateRelationStmt(DBRelation rel, StringBuilder sql, 
DBSQLScript script)
+    protected void addCreateRelationStmt(DBRelation<?> rel, StringBuilder sql, 
DBSQLScript script)
     {
         log.info("Adding create statmement for relation {}.", rel.getName());
         script.addStmt(sql);
     }
-    protected void addCreateViewStmt(DBView v, StringBuilder sql, DBSQLScript 
script)
+    protected void addCreateViewStmt(DBView<?> v, StringBuilder sql, 
DBSQLScript script)
     {
         log.info("Adding create statmement for view {}.", v.getName());
         script.addStmt(sql);
@@ -253,7 +253,7 @@ public abstract class DBDDLGenerator<T extends DBMSHandler>
             switch (type)
             {
                 case CREATE:
-                    createDatabase((DBDatabase) dbo, script);
+                    createDatabase((DBDatabase<?>) dbo, script);
                     return;
                 case DROP:
                     dropObject(null, schema, databaseObjectName, script);
@@ -267,10 +267,10 @@ public abstract class DBDDLGenerator<T extends 
DBMSHandler>
             switch (type)
             {
                 case CREATE:
-                    createTable((DBTable) dbo, script);
+                    createTable((DBTable<?>) dbo, script);
                     return;
                 case DROP:
-                    dropObject(schema, ((DBTable) dbo).getName(), "TABLE", 
script);
+                    dropObject(schema, ((DBTable<?>) dbo).getName(), "TABLE", 
script);
                     return;
                 default:
                     throw new NotImplementedException(this, "getDDLScript." + 
dbo.getClass().getName() + "." + type);
@@ -281,28 +281,28 @@ public abstract class DBDDLGenerator<T extends 
DBMSHandler>
             switch (type)
             {
                 case CREATE:
-                    createView((DBView) dbo, script);
+                    createView((DBView<?>) dbo, script);
                     return;
                 case DROP:
-                    dropObject(schema, ((DBView) dbo).getName(), "VIEW", 
script);
+                    dropObject(schema, ((DBView<?>) dbo).getName(), "VIEW", 
script);
                     return;
                 case ALTER:
-                    dropObject(schema, ((DBView) dbo).getName(), "VIEW", 
script);
-                    createView((DBView) dbo, script);
+                    dropObject(schema, ((DBView<?>) dbo).getName(), "VIEW", 
script);
+                    createView((DBView<?>) dbo, script);
                     return;
                 default:
                     throw new NotImplementedException(this, "getDDLScript." + 
dbo.getClass().getName() + "." + type);
             }
         } 
-        else if (dbo instanceof DBRelation)
+        else if (dbo instanceof DBRelation<?>)
         { // Relation
             switch (type)
             {
                 case CREATE:
-                    createRelation((DBRelation) dbo, script);
+                    createRelation((DBRelation<?>) dbo, script);
                     return;
                 case DROP:
-                    dropObject(schema, ((DBRelation) dbo).getName(), 
"CONSTRAINT", script);
+                    dropObject(schema, ((DBRelation<?>) dbo).getName(), 
"CONSTRAINT", script);
                     return;
                 default:
                     throw new NotImplementedException(this, "getDDLScript." + 
dbo.getClass().getName() + "." + type);
@@ -313,10 +313,10 @@ public abstract class DBDDLGenerator<T extends 
DBMSHandler>
             switch (type)
             {
                 case CREATE:
-                    createIndex(((DBIndex) dbo).getTable(), (DBIndex) dbo, 
script);
+                    createIndex(((DBIndex<?>) dbo).getTable(), (DBIndex<?>) 
dbo, script);
                     return;
                 case DROP:
-                    dropObject(schema, ((DBIndex) dbo).getName(), "INDEX", 
script);
+                    dropObject(schema, ((DBIndex<?>) dbo).getName(), "INDEX", 
script);
                     return;
                 default:
                     throw new NotImplementedException(this, "getDDLScript." + 
dbo.getClass().getName() + "." + type);
@@ -338,20 +338,20 @@ public abstract class DBDDLGenerator<T extends 
DBMSHandler>
      * @param db the database to create
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void createDatabase(DBDatabase db, DBSQLScript script)
+    protected void createDatabase(DBDatabase<?> db, DBSQLScript script)
     {
         // Create all Tables
-        for (DBTable dbTable : db.getTables())
+        for (DBTable<?> dbTable : db.getTables())
         {
             createTable(dbTable, script);
         }
         // Create Relations
-        for (DBRelation dbRelation : db.getRelations())
+        for (DBRelation<?> dbRelation : db.getRelations())
         {
             createRelation(dbRelation, script);
         }
         // Create Views
-        for (DBView v : db.getViews())
+        for (DBView<?> v : db.getViews())
         {
             try {
                 createView(v, script);
@@ -367,7 +367,7 @@ public abstract class DBDDLGenerator<T extends DBMSHandler>
      * @param db the database to drop
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void dropDatabase(DBDatabase db, DBSQLScript script)
+    protected void dropDatabase(DBDatabase<?> db, DBSQLScript script)
     {
         dropObject(null, db.getSchema(), "DATABASE", script);
     }
@@ -377,7 +377,7 @@ public abstract class DBDDLGenerator<T extends DBMSHandler>
      * @param t the table to create
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void createTable(DBTable t, DBSQLScript script)
+    protected void createTable(DBTable<?> t, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("-- creating table ");
@@ -397,7 +397,7 @@ public abstract class DBDDLGenerator<T extends DBMSHandler>
             addSeparator = true;
         }
         // Primary Key
-        DBIndex pk = t.getPrimaryKey();
+        DBIndex<?> pk = t.getPrimaryKey();
         if (pk != null)
         { // add the primary key
             sql.append(",\r\n");
@@ -429,10 +429,10 @@ public abstract class DBDDLGenerator<T extends 
DBMSHandler>
      * @param pk the primary key index to ignore
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void createTableIndexes(DBTable t, DBIndex pk, DBSQLScript 
script)
+    protected void createTableIndexes(DBTable<?> t, DBIndex<?> pk, DBSQLScript 
script)
     {
         // Create other Indexes (except primary key)
-        for (DBIndex idx : t.getIndexes())
+        for (DBIndex<?> idx : t.getIndexes())
         {
             if (idx == pk || idx.getType() == DBIndexType.PRIMARY_KEY)
                 continue;
@@ -448,7 +448,7 @@ public abstract class DBDDLGenerator<T extends DBMSHandler>
      * @param idx the index to create
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void createIndex(DBTable t, DBIndex idx, DBSQLScript script)
+    protected void createIndex(DBTable<?> t, DBIndex<?> idx, DBSQLScript 
script)
     {
         StringBuilder sql = new StringBuilder();
 
@@ -479,10 +479,10 @@ public abstract class DBDDLGenerator<T extends 
DBMSHandler>
      * @param r the relation to create
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void createRelation(DBRelation r, DBSQLScript script)
+    protected void createRelation(DBRelation<?> r, DBSQLScript script)
     {
-        DBTable sourceTable = (DBTable) 
r.getReferences()[0].getSourceColumn().getRowSet();
-        DBTable targetTable = (DBTable) 
r.getReferences()[0].getTargetColumn().getRowSet();
+        DBTable<?> sourceTable = (DBTable<?>) 
r.getReferences()[0].getSourceColumn().getRowSet();
+        DBTable<?> targetTable = (DBTable<?>) 
r.getReferences()[0].getTargetColumn().getRowSet();
 
         StringBuilder sql = new StringBuilder();
         sql.append("-- creating foreign key constraint ");
@@ -564,7 +564,7 @@ public abstract class DBDDLGenerator<T extends DBMSHandler>
      * @param v the view to create
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void createView(DBView v, DBSQLScript script)
+    protected void createView(DBView<?> v, DBSQLScript script)
     {
         // Create the Command
         DBCommandExpr cmd = v.createCommand();
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java 
b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
index 24b6c2f..4031a95 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
@@ -68,7 +68,7 @@ import org.slf4j.LoggerFactory;
  * <P>
  *
  */
-public abstract class DBDatabase extends DBObject
+public abstract class DBDatabase<DB extends DBDatabase<DB>> extends DBObject
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
     
@@ -103,17 +103,17 @@ public abstract class DBDatabase extends DBObject
     /** 
      * global map of all database instances that have been allocated
      */
-    private static Map<String, WeakReference<DBDatabase>> databaseMap = new 
LinkedHashMap<String, WeakReference<DBDatabase>>();
+    private static Map<String, WeakReference<DBDatabase<?>>> databaseMap = new 
LinkedHashMap<String, WeakReference<DBDatabase<?>>>();
     
     /** 
      * find a database by id
      */
-    public static DBDatabase findByIdentifier(String dbIdent)
+    public static DBDatabase<?> findByIdentifier(String dbIdent)
     {
-        WeakReference<DBDatabase> ref = databaseMap.get(dbIdent);
+        WeakReference<DBDatabase<?>> ref = databaseMap.get(dbIdent);
         if (ref==null)
             return null; // not found
-        DBDatabase db = ref.get();
+        DBDatabase<?> db = ref.get();
         if (db==null) 
         {   // object reference not valid
             log.warn("Database width id='{}' habe been destroyed!", dbIdent);
@@ -125,11 +125,11 @@ public abstract class DBDatabase extends DBObject
     /** 
      * find a database by id
      */
-    public static DBDatabase findByClass(Class<? extends DBDatabase> cls)
+    public static DBDatabase<?> findByClass(Class<? extends DBDatabase<?>> cls)
     {
-        for (WeakReference<DBDatabase> ref : databaseMap.values())
+        for (WeakReference<DBDatabase<?>> ref : databaseMap.values())
         {   // find database by class
-            DBDatabase db = ref.get();
+            DBDatabase<?> db = ref.get();
             if (db!=null && cls.isInstance(db))
                 return db;
         }
@@ -143,9 +143,9 @@ public abstract class DBDatabase extends DBObject
     private String instanceId;      // internal instance id
     
     // Collections
-    protected final List<DBTable>    tables    = new ArrayList<DBTable>();
-    protected final List<DBRelation> relations = new ArrayList<DBRelation>();
-    protected final List<DBView>     views     = new ArrayList<DBView>();
+    protected final List<DBTable<DB>>    tables    = new 
ArrayList<DBTable<DB>>();
+    protected final List<DBRelation<DB>> relations = new 
ArrayList<DBRelation<DB>>();
+    protected final List<DBView<DB>>     views     = new 
ArrayList<DBView<DB>>();
     
     protected DBMSHandler dbms    = null;
     
@@ -214,9 +214,9 @@ public abstract class DBDatabase extends DBObject
     {
         // Check if it exists
         Set<String> invalidKeys = new HashSet<String>();
-        for (Map.Entry<String, WeakReference<DBDatabase>> e : 
databaseMap.entrySet())
+        for (Map.Entry<String, WeakReference<DBDatabase<?>>> e : 
databaseMap.entrySet())
         {   
-            DBDatabase dbInst = e.getValue().get(); 
+            DBDatabase<?> dbInst = e.getValue().get(); 
             if (dbInst==this)
             {   // Remove from set
                 log.error("Instance of database "+getClass().getName()+" 
already registered. Not registering same instance twice!");
@@ -260,7 +260,7 @@ public abstract class DBDatabase extends DBObject
         }
         // register database in global map
         log.info("Instance of database {} registered with instanceid={}", 
getClass().getName(), this.instanceId);
-        databaseMap.put(this.instanceId, new WeakReference<DBDatabase>(this));
+        databaseMap.put(this.instanceId, new 
WeakReference<DBDatabase<?>>(this));
     }
 
     /**
@@ -416,9 +416,9 @@ public abstract class DBDatabase extends DBObject
      */
     @SuppressWarnings("unchecked")
     @Override
-    public final <T extends DBDatabase> T getDatabase()
+    public final DB getDatabase()
     {
-        return (T)(this);
+        return (DB)this;
     }
 
     /**
@@ -644,14 +644,14 @@ public abstract class DBDatabase extends DBObject
      * <P> 
      * @param table the DBTable object
      */
-    protected void addTable(DBTable table)
+    protected void addTable(DBTable<DB> table)
     { // find column by name
         if (table == null || table.getDatabase() != this)
             throw new InvalidArgumentException("table", table);
         if (tables.contains(table)==true)
             throw new ItemExistsException(table.getName());
         // Check for second instances
-        DBTable existing = getTable(table.getName()); 
+        DBTable<DB> existing = getTable(table.getName()); 
         if (existing!=null)
         {   // Check classes
             if (existing.getClass().equals(table.getClass()))
@@ -668,7 +668,7 @@ public abstract class DBDatabase extends DBObject
      * 
      * @return db tables.
      */
-    public List<DBTable> getTables()
+    public List<DBTable<DB>> getTables()
     {
         return Collections.unmodifiableList(this.tables);        
     }
@@ -679,9 +679,9 @@ public abstract class DBDatabase extends DBObject
      * @param name the name of the table
      * @return the located DBTable object
      */
-    public DBRowSet getRowSet(String name)
+    public DBRowSet<DB> getRowSet(String name)
     { // find table by name
-        DBRowSet rset = getTable(name);
+        DBRowSet<DB> rset = getTable(name);
         if (rset==null)
             rset = getView(name);
         return rset;
@@ -693,11 +693,11 @@ public abstract class DBDatabase extends DBObject
      * @param name the name of the table
      * @return the located DBTable object
      */
-    public DBTable getTable(String name)
+    public DBTable<DB> getTable(String name)
     { // find table by name
         for (int i = 0; i < tables.size(); i++)
         { // search for the table
-            DBTable tab = tables.get(i);
+            DBTable<DB> tab = tables.get(i);
             if (tab.getName().equalsIgnoreCase(name))
                 return tab;
         }
@@ -709,7 +709,7 @@ public abstract class DBDatabase extends DBObject
      * <P>
      * @param reference a reference for a source and target column pair
      */
-    public final DBRelation addRelation(DBRelation.DBReference reference)
+    public final DBRelation<DB> addRelation(DBRelation.DBReference reference)
     {
         String table = reference.getSourceColumn().getRowSet().getName();
         String col1 = reference.getSourceColumn().getName();
@@ -726,7 +726,7 @@ public abstract class DBDatabase extends DBObject
      * @param ref1 a reference for a source and target column pair
      * @param ref2 a reference for a source and target column pair
      */
-    public final DBRelation addRelation(DBRelation.DBReference ref1, 
DBRelation.DBReference ref2)
+    public final DBRelation<DB> addRelation(DBRelation.DBReference ref1, 
DBRelation.DBReference ref2)
     {
         String table = ref1.getSourceColumn().getRowSet().getName();
         String col1 = ref1.getSourceColumn().getName();
@@ -745,22 +745,24 @@ public abstract class DBDatabase extends DBObject
      * @param name the relation name
      * @param references a list of source and target column pairs
      */
-    public DBRelation addRelation(String name, DBRelation.DBReference... 
references)
+    public DBRelation<DB> addRelation(String name, DBRelation.DBReference... 
references)
     {
        // Check
        if (getRelation(name)!=null)
             throw new ItemExistsException(name); // Relation already exists
        // Get default cascade action
-       DBTable targetTable = 
(DBTable)references[0].getTargetColumn().getRowSet();
+       @SuppressWarnings("unchecked")
+        DBTable<DB> targetTable = 
(DBTable<DB>)references[0].getTargetColumn().getRowSet();
        DBCascadeAction deleteAction = 
targetTable.getDefaultCascadeDeleteAction(); 
         // Add a Relation
-        DBRelation relation = new DBRelation(this, name, references, 
deleteAction);
+        DBRelation<DB> relation = new DBRelation<DB>(getDatabase(), name, 
references, deleteAction);
         if (relations.contains(relation))
             throw new ItemExistsException(name); // Relation already exists
         // Add Reference column to table
         for (DBRelation.DBReference ref : references)
         {   // add the reference column
-            DBRowSet rset = ref.getSourceColumn().getRowSet();
+            @SuppressWarnings("unchecked")
+            DBRowSet<DB> rset = 
(DBRowSet<DB>)ref.getSourceColumn().getRowSet();
             rset.addColumnReference(ref.getSourceColumn(), 
ref.getTargetColumn());
         }
         // OK
@@ -772,7 +774,7 @@ public abstract class DBDatabase extends DBObject
      * removes a relation from the list of relations
      * @param name
      */
-    public void removeRelation(DBRelation relation)
+    public void removeRelation(DBRelation<DB> relation)
     {
         if (relation==null || relation.getDatabase()!=this)
             throw new InvalidArgumentException("relation", relation);
@@ -785,7 +787,7 @@ public abstract class DBDatabase extends DBObject
      * 
      * @return db relations.
      */
-    public List<DBRelation> getRelations()
+    public List<DBRelation<DB>> getRelations()
     {
         return Collections.unmodifiableList(this.relations);        
     }
@@ -795,9 +797,9 @@ public abstract class DBDatabase extends DBObject
      * 
      * @return db the relation of the given name
      */
-    public DBRelation getRelation(String relationName)
+    public DBRelation<DB> getRelation(String relationName)
     {
-        for (DBRelation r : relations)
+        for (DBRelation<DB> r : relations)
         {
                String name = r.getName();
                if (relationName.compareToIgnoreCase(name)==0)
@@ -812,7 +814,7 @@ public abstract class DBDatabase extends DBObject
      * <P> 
      * @param view the DBView object
      */
-    protected void addView(DBView view)
+    protected void addView(DBView<DB> view)
     { // find column by name
         if (view == null || view.getDatabase() != this)
             throw new InvalidArgumentException("view", view);
@@ -827,7 +829,7 @@ public abstract class DBDatabase extends DBObject
      * 
      * @return db views.
      */
-    public List<DBView> getViews()
+    public List<DBView<DB>> getViews()
     {
         return Collections.unmodifiableList(this.views);        
     }
@@ -838,11 +840,11 @@ public abstract class DBDatabase extends DBObject
      * @param name the name of the view
      * @return the located DBTable object
      */
-    public DBView getView(String name)
+    public DBView<DB> getView(String name)
     { // find table by name
         for (int i = 0; i < views.size(); i++)
         { // search for the table
-            DBView view = views.get(i);
+            DBView<DB> view = views.get(i);
             if (view.getName().equalsIgnoreCase(name))
                 return view;
         }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java 
b/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java
index f3b0955..1653606 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java
@@ -25,7 +25,7 @@ import org.apache.empire.exceptions.InvalidArgumentException;
  * The primary key contains one or more columns.
  *
  */
-public class DBExpressionIndex extends DBIndex
+public class DBExpressionIndex<DB extends DBDatabase<DB>> extends DBIndex<DB>
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
     
@@ -57,11 +57,10 @@ public class DBExpressionIndex extends DBIndex
         this(name, (unique ? DBIndexType.UNIQUE : DBIndexType.STANDARD), 
columnExpressions);
     }
     
-    @SuppressWarnings("unchecked")
     @Override
-    public <T extends DBDatabase> T getDatabase()
+    public DB getDatabase()
     {
-        return (T)(columnExpressions[0].getDatabase());
+        return (columnExpressions[0].getDatabase());
     }
 
     /**
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 5331922..2a31cec 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
@@ -25,7 +25,7 @@ package org.apache.empire.db;
  * 
  *
  */
-public class DBIndex extends DBObject
+public class DBIndex<DB extends DBDatabase<DB>> extends DBObject
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
   
@@ -52,7 +52,7 @@ public class DBIndex extends DBObject
     private String          name;
     private DBIndexType     type;
     private DBColumn[]      columns;
-    private DBTable         table;
+    private DBTable<DB>     table;
 
     /**
      * Constructs a DBIndex object set the specified parameters to this object.
@@ -73,7 +73,7 @@ public class DBIndex extends DBObject
      * Valid only if the index has been added to a table (DBTable.addIndex)
      * @return the corresponding table
      */
-    public DBTable getTable()
+    public DBTable<DB> getTable()
     {
         return table;
     }
@@ -83,16 +83,16 @@ public class DBIndex extends DBObject
      * The table must be added to the table's index list beforehand 
      * @param table
      */
-    void setTable(DBTable table)
+    void setTable(DBTable<DB> table)
     {
         this.table = table;
     }
     
     @SuppressWarnings("unchecked")
     @Override
-    public <T extends DBDatabase> T getDatabase()
+    public DB getDatabase()
     {
-        return (table!=null) ? (T)table.getDatabase() : null;
+        return (table!=null) ? table.getDatabase() : null;
     }
 
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBQuery.java 
b/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
index 166634b..4c4db14 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
@@ -54,7 +54,7 @@ import org.apache.empire.exceptions.NotSupportedException;
  * </UL>
  *
  */
-public class DBQuery extends DBRowSet
+public class DBQuery<DB extends DBDatabase<DB>> extends DBRowSet<DB>
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
 
@@ -68,7 +68,7 @@ public class DBQuery extends DBRowSet
     {
         // *Deprecated* private static final long serialVersionUID = 1L;
         
-        protected DBQueryExprColumn(DBQuery q, String name, DBColumnExpr expr)
+        protected DBQueryExprColumn(DBQuery<?> q, String name, DBColumnExpr 
expr)
         {
             super(q, name, expr);
         }
@@ -429,13 +429,14 @@ public class DBQuery extends DBRowSet
         // Get the fields and the flags
         Object[] fields = record.getFields();
         // Get all Update Commands
-        Map<DBRowSet, DBCommand> updCmds = new HashMap<DBRowSet, DBCommand>(3);
+        Map<DBRowSet<DB>, DBCommand> updCmds = new HashMap<DBRowSet<DB>, 
DBCommand>(3);
         for (int i = 0; i < columns.size(); i++)
         { // get the table
             DBColumn col = columns.get(i);
             if (col == null)
                 continue;
-            DBRowSet table = col.getRowSet();
+            @SuppressWarnings("unchecked")
+            DBRowSet<DB> table = (DBRowSet<DB>)col.getRowSet();
             DBCommand updCmd = updCmds.get(table);
             if (updCmd == null)
             { // Add a new Command
@@ -463,9 +464,9 @@ public class DBQuery extends DBRowSet
         // the commands
         DBCommand cmd = getCommandFromExpression();
         Object[] key  = getRecordKey(record);
-        DBRowSet table= null;
+        DBRowSet<DB> table= null;
         DBCommand upd = null;
-        for(Entry<DBRowSet,DBCommand> entry:updCmds.entrySet())
+        for(Entry<DBRowSet<DB>,DBCommand> entry:updCmds.entrySet())
         {
             int i = 0;
             // Iterate through options
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBQueryColumn.java 
b/empire-db/src/main/java/org/apache/empire/db/DBQueryColumn.java
index 43d4772..63fda4f 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBQueryColumn.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBQueryColumn.java
@@ -35,7 +35,7 @@ public class DBQueryColumn extends DBColumn
      * @param query the DBQuery object
      * @param expr the concrete DBColumnExpr object
      */
-    public DBQueryColumn(DBQuery query, String name, DBColumnExpr expr)
+    public DBQueryColumn(DBQuery<?> query, String name, DBColumnExpr expr)
     { // call base
         super(query, name);
         // set Expression
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBReader.java 
b/empire-db/src/main/java/org/apache/empire/db/DBReader.java
index 15e506c..45e0aa4 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBReader.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBReader.java
@@ -248,7 +248,7 @@ public class DBReader extends DBRecordData implements 
Closeable
     protected final DBContext context;
     
     // Object references
-    private DBDatabase     db      = null;
+    private DBDatabase<?>  db      = null;
     private DBColumnExpr[] columns = null;
     private ResultSet      rset    = null;
     // the field index map
@@ -655,7 +655,7 @@ public class DBReader extends DBRecordData implements 
Closeable
     public void initRecord(DBRecordBase rec)
     {
         // init Record
-        DBRowSet rowset = rec.getRowSet();
+        DBRowSet<?> rowset = rec.getRowSet();
        rowset.initRecord(rec, this);
     }
     
@@ -859,7 +859,7 @@ public class DBReader extends DBRecordData implements 
Closeable
      * @param columns the query column expressions
      * @param rset the JDBC-ResultSet
      */
-    protected void init(DBDatabase db, DBColumnExpr[] columns, ResultSet rset)
+    protected void init(DBDatabase<?> db, DBColumnExpr[] columns, ResultSet 
rset)
     {
         this.db = db;
         this.columns = columns;
@@ -936,15 +936,15 @@ public class DBReader extends DBRecordData implements 
Closeable
         // check the joins
         for (DBJoinExpr j : joins)
         {
-            DBRowSet rsl = j.getLeftTable();
-            DBRowSet rsr = j.getRightTable();
+            DBRowSet<?> rsl = j.getLeftTable();
+            DBRowSet<?> rsr = j.getRightTable();
             if (rsl instanceof DBQuery)
             {   // the left join is a query
-                subQueryParams = addSubQueryParams((DBQuery)rsl, 
subQueryParams);
+                subQueryParams = addSubQueryParams((DBQuery<?>)rsl, 
subQueryParams);
             }
             if (rsr instanceof DBQuery)
             {   // the right join is a query
-                subQueryParams = addSubQueryParams((DBQuery)rsr, 
subQueryParams);
+                subQueryParams = addSubQueryParams((DBQuery<?>)rsr, 
subQueryParams);
             }
         }
         return subQueryParams; 
@@ -956,7 +956,7 @@ public class DBReader extends DBRecordData implements 
Closeable
      * @param list the current list of parameters
      * @return the new list of parameters
      */
-    private List<Object> addSubQueryParams(DBQuery query, List<Object> list)
+    private List<Object> addSubQueryParams(DBQuery<?> query, List<Object> list)
     {
         DBCommandExpr sqcmd = query.getCommandExpr();
         Object[] params = query.getCommandExpr().getParamValues();
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 abebaac..34589c4 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
@@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory;
  * 
  * The record is Serializable either if the provided DBContext is 
serializable, or if the Context is provided on deserialization in a derived 
class.
  */
-public class DBRecord extends DBRecordBase
+public class DBRecord<RS extends DBRowSet<?>> extends DBRecordBase
 {
     private static final long serialVersionUID = 1L;
     
@@ -69,7 +69,7 @@ public class DBRecord extends DBRecordBase
 
     // Context and RowSet
     protected final transient DBContext context;  /* transient for 
serialization */
-    protected final transient DBRowSet  rowset;   /* transient for 
serialization */
+    protected final transient RS        rowset;   /* transient for 
serialization */
 
     // options
     protected boolean       enableRollbackHandling;
@@ -108,7 +108,7 @@ public class DBRecord extends DBRecordBase
         DBContext ctx = readContext(strm);
         ClassUtils.setPrivateFieldValue(DBRecord.class, this, "context", ctx);
         // set final field
-        DBRowSet rowset = readRowSet(strm);
+        DBRowSet<?> rowset = readRowSet(strm);
         ClassUtils.setPrivateFieldValue(DBRecord.class, this, "rowset", 
rowset);
         // read the rest
         strm.defaultReadObject();
@@ -119,16 +119,16 @@ public class DBRecord extends DBRecordBase
         return (DBContext)strm.readObject();
     }
     
-    protected DBRowSet readRowSet(ObjectInputStream strm)  throws IOException, 
ClassNotFoundException
+    protected DBRowSet<?> readRowSet(ObjectInputStream strm)  throws 
IOException, ClassNotFoundException
     {   // Rowset
         String dbid = String.valueOf(strm.readObject());
         String rsid = String.valueOf(strm.readObject());
         // find database
-        DBDatabase dbo = DBDatabase.findByIdentifier(dbid);
+        DBDatabase<?> dbo = DBDatabase.findByIdentifier(dbid);
         if (dbo==null)
             throw new ItemNotFoundException(dbid);
         // find rowset
-        DBRowSet rso = dbo.getRowSet(rsid);
+        DBRowSet<?> rso = dbo.getRowSet(rsid);
         if (rso==null)
             throw new ItemNotFoundException(dbid);
         // done
@@ -139,7 +139,7 @@ public class DBRecord extends DBRecordBase
      * Internal constructor for DBRecord
      * May be used by derived classes to provide special behaviour
      */
-    protected DBRecord(DBContext context, DBRowSet rowset, boolean 
enableRollbackHandling)
+    protected DBRecord(DBContext context, RS rowset, boolean 
enableRollbackHandling)
     {   // init
         this.context = context;
         this.rowset = rowset;
@@ -153,7 +153,7 @@ public class DBRecord extends DBRecordBase
      * @param context the DBContext for this record
      * @param rowset the corresponding RowSet(Table, View, Query, etc.)
      */
-    public DBRecord(DBContext context, DBRowSet rowset)
+    public DBRecord(DBContext context, RS rowset)
     {
         this(checkParamNull("context", context),
              checkParamNull("rowset", rowset),
@@ -180,11 +180,11 @@ public class DBRecord extends DBRecordBase
      */
     @Override
     @SuppressWarnings("unchecked")
-    public <T extends DBRowSet> T getRowSet()
+    public RS getRowSet()
     {
         if (this.rowset==null)
             throw new ObjectNotValidException(this);
-        return (T)this.rowset;
+        return this.rowset;
     }
 
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRecordBase.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRecordBase.java
index ed3d09f..e0dba67 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRecordBase.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRecordBase.java
@@ -269,7 +269,7 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
      * Returns the DBRowSet object.
      * @return the DBRowSet object
      */
-    public abstract <T extends DBRowSet> T getRowSet();
+    public abstract <T extends DBRowSet<?>> T getRowSet();
     
     /**
      * Returns whether or not RollbackHandling is enabled for this record
@@ -288,11 +288,11 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
 
     /**
      * Returns the current DBDatabase object.
-     * 
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public <T extends DBDatabase> T getDatabase()
+    public DBDatabase<?> getDatabase()
     {
         return getRowSet().getDatabase();
     }
@@ -328,7 +328,7 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
     {
         if (!isValid())
             return true;
-        DBRowSet rowset = getRowSet();
+        DBRowSet<?> rowset = getRowSet();
         return (rowset==null || !rowset.isUpdateable());
     }
 
@@ -730,7 +730,7 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
     @Override
     public boolean isFieldReadOnly(Column column)
     {
-        DBRowSet rowset = getRowSet();
+        DBRowSet<?> rowset = getRowSet();
        if (getFieldIndex(column)<0)
             throw new InvalidArgumentException("column", column);
        // Check key column 
@@ -819,7 +819,9 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
         if (!isValid() || !other.isValid())
             return false;
         // compare table
-        if (!getRowSet().isSame(other.getRowSet()))
+        DBRowSet<?> rs1 = getRowSet();
+        DBRowSet<?> rs2 = other.getRowSet();
+        if (!rs1.isSame(rs2))
             return false;
         // compare key
         Object[] key1 = getKey();
@@ -839,7 +841,8 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
             throw new ObjectNotValidException(this);
         // Add Field Description
         int count = 0;
-        List<DBColumn> columns = getRowSet().getColumns();
+        DBRowSet<?> rowset = getRowSet();
+        List<DBColumn> columns = rowset.getColumns();
         for (int i = 0; i < columns.size(); i++)
         { // Add Field
             DBColumn column = columns.get(i);
@@ -916,7 +919,7 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
         // Create Document
         DBXmlDictionary xmlDic = getXmlDictionary();
         Element root = XMLUtil.createDocument(xmlDic.getRowSetElementName());
-        DBRowSet rowset = getRowSet();
+        DBRowSet<?> rowset = getRowSet();
         if (rowset.getName() != null)
             root.setAttribute("name", rowset.getName());
         // Add Field Description
@@ -965,7 +968,7 @@ public abstract class DBRecordBase extends DBRecordData 
implements Record, Clone
     protected void initData(boolean newRecord)
     {
         // Init rowset
-        DBRowSet rowset = getRowSet();
+        DBRowSet<?> rowset = getRowSet();
         int colCount = rowset.getColumns().size();
         if (fields==null || fields.length!=colCount)
             fields = new Object[colCount];
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRelation.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRelation.java
index 818676f..5308fd5 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRelation.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRelation.java
@@ -27,7 +27,7 @@ import 
org.apache.empire.exceptions.UnexpectedReturnValueException;
  * 
  *
  */
-public class DBRelation extends DBObject
+public class DBRelation<DB extends DBDatabase<DB>> extends DBObject
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
     
@@ -79,7 +79,7 @@ public class DBRelation extends DBObject
        }
 
        // Members
-    private DBDatabase    db;
+    private DB            db;
     private String        name;
     private DBReference[] references;
     private DBCascadeAction onDeleteAction;
@@ -92,7 +92,7 @@ public class DBRelation extends DBObject
      * @param references the references for this relation
      * @param onDeleteAction specifies the action performed when deleting 
affected records.
      */
-       public DBRelation(DBDatabase db, String name, DBReference[] references, 
DBCascadeAction onDeleteAction)
+       public DBRelation(DB db, String name, DBReference[] references, 
DBCascadeAction onDeleteAction)
        {
           this.db         = db;
           this.name       = name;
@@ -107,7 +107,7 @@ public class DBRelation extends DBObject
      * @param name the name
      * @param references the references for this relation
      */
-    public DBRelation(DBDatabase db, String name, DBReference[] references)
+    public DBRelation(DB db, String name, DBReference[] references)
     {
        this(db, name, references, DBCascadeAction.NONE);
     }
@@ -147,25 +147,27 @@ public class DBRelation extends DBObject
      * Returns the table that is containing the foreign key (source table) 
      * @return true if the relation's source table is the given table 
      */
-    public DBTable getForeignKeyTable()
+    @SuppressWarnings("unchecked")
+    public DBTable<DB> getForeignKeyTable()
     {
-        return (DBTable)references[0].getSourceColumn().getRowSet();
+        return (DBTable<DB>)references[0].getSourceColumn().getRowSet();
     }
 
     /**
      * Returns the table that is referenced by this foreign key relation 
(target table)
      * @return true if the relation's target table 
      */
-    public DBTable getReferencedTable()
+    @SuppressWarnings("unchecked")
+    public DBTable<DB> getReferencedTable()
     {
-        return (DBTable)references[0].getTargetColumn().getRowSet();
+        return (DBTable<DB>)references[0].getTargetColumn().getRowSet();
     }
     
     @SuppressWarnings("unchecked")
     @Override
-    public final <T extends DBDatabase> T getDatabase()
+    public final DB getDatabase()
     {
-        return (T)db;
+        return db;
     }
     
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
index 2d58e1c..e97a280 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
@@ -67,10 +67,8 @@ import org.slf4j.LoggerFactory;
  * DBView and DBQuery classes this class contains all the columns of the
  * tables, views or queries
  * <P>
- * 
- *
  */
-public abstract class DBRowSet extends DBExpr implements Entity
+public abstract class DBRowSet<DB extends DBDatabase<DB>> extends DBExpr 
implements Entity
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
 
@@ -139,7 +137,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      */
     
     // Members
-    protected final DBDatabase         db;     /* transient ? */
+    protected final DB                 db;     /* transient ? */
     protected String                   comment          = null;
     protected DBColumn                 timestampColumn  = null;
     protected Map<DBColumn, DBColumn>  columnReferences = null;
@@ -176,7 +174,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * Constructs a DBRecord object set the current database object.
      * @param db the database object
      */
-    public DBRowSet(DBDatabase db)
+    public DBRowSet(DB db)
     {
         this.db = db;
     }
@@ -254,7 +252,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
             return super.equals(other);
         if (other instanceof DBRowSet)
         {   // Database and name must match
-            DBRowSet r = (DBRowSet) other; 
+            DBRowSet<?> r = (DBRowSet<?>) other; 
             if (db.equals(r.getDatabase())==false)
                 return false;
             // Check Alias
@@ -271,7 +269,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * @param otherObject
      * @return true if it is the same rowset (but maybe a different instance)
      */
-    public boolean isSame(DBRowSet other)
+    public boolean isSame(DBRowSet<?> other)
     {
         // record
         if (!getDatabase().equals(other.getDatabase()))
@@ -355,9 +353,9 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      */
     @SuppressWarnings("unchecked")
     @Override
-    public final <T extends DBDatabase> T getDatabase()
+    public final DB getDatabase()
     {
-        return (T)db;
+        return db;
     }
 
     /**
@@ -1089,12 +1087,12 @@ public abstract class DBRowSet extends DBExpr 
implements Entity
     protected final void deleteAllReferences(Object[] key, DBContext context)
     {
         // Merge Sub-Records
-        List<DBRelation> relations = db.getRelations();
+        List<DBRelation<DB>> relations = db.getRelations();
         DBColumn[] keyColumns =(DBColumn[])getKeyColumns();
         if (keyColumns==null)
             return; // No primary key - no references!
         // Find all relations
-        for (DBRelation rel : relations)
+        for (DBRelation<DB> rel : relations)
         {   // Check cascade
             if (rel.getOnDeleteAction()!=DBCascadeAction.CASCADE_RECORDS)
                 continue;
@@ -1104,7 +1102,8 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
             {
                 if (refs[i].getTargetColumn().equals(keyColumns[0]))
                 {   // Found a reference on RowSet
-                    DBRowSet rs = refs[0].getSourceColumn().getRowSet(); 
+                    @SuppressWarnings("unchecked")
+                    DBRowSet<DB> rs = 
(DBRowSet<DB>)refs[0].getSourceColumn().getRowSet(); 
                     rs.deleteReferenceRecords(refs, key, context);
                 }
             }
@@ -1130,7 +1129,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
             DBCommand cmd = db.createCommand();
             for (int i=0; i<parentKey.length; i++)
                 cmd.where(refs[i].getSourceColumn().is(parentKey[i]));
-            if (context.executeDelete((DBTable)this, cmd)<0)
+            if (context.executeDelete((DBTable<DB>)this, cmd)<0)
                 throw new UnexpectedReturnValueException(-1, 
"db.executeSQL()");
         }
         else
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 1dc70f2..514aa64 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
@@ -43,9 +43,8 @@ import 
org.apache.empire.exceptions.UnexpectedReturnValueException;
 /**
  * This class represent one table of the database.
  * It contains methods to get, add, update and delete records from the 
database.
- *
  */
-public class DBTable extends DBRowSet implements Cloneable
+public class DBTable<DB extends DBDatabase<DB>> extends DBRowSet<DB> 
implements Cloneable
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
     
@@ -71,7 +70,7 @@ public class DBTable extends DBRowSet implements Cloneable
      * @param name the table name
      * @param db the valid database object
      */
-    public DBTable(String name, DBDatabase db, String alias)
+    public DBTable(String name, DB db, String alias)
     { 
         super(db);
         // generate alias
@@ -92,7 +91,7 @@ public class DBTable extends DBRowSet implements Cloneable
      * @param name the table name
      * @param db the valid database object
      */
-    public DBTable(String name, DBDatabase db)
+    public DBTable(String name, DB db)
     { 
         this(name, db, null);
     }
@@ -169,7 +168,8 @@ public class DBTable extends DBRowSet implements Cloneable
     @Override
     public Object clone() throws CloneNotSupportedException 
     {
-        DBTable clone = (DBTable) super.clone();
+        @SuppressWarnings("unchecked")
+        DBTable<DB> clone = (DBTable<DB>) super.clone();
         initClonedFields(clone);
         // set new alias
         clone.alias = "t" + String.valueOf(tableCount.incrementAndGet());
@@ -179,10 +179,10 @@ public class DBTable extends DBRowSet implements Cloneable
     }
     
     @SuppressWarnings("unchecked")
-    public <T extends DBTable> T clone(String newAlias) 
+    public <T extends DBTable<DB>> T clone(String newAlias) 
     {
         try {
-            DBTable clone = (DBTable) super.clone();
+            DBTable<DB> clone = (DBTable<DB>) super.clone();
             initClonedFields(clone);
             // set new alias
             if (StringUtils.isEmpty(newAlias))
@@ -199,7 +199,7 @@ public class DBTable extends DBRowSet implements Cloneable
         }
     }
     
-    protected <T extends DBTable> void initClonedFields(T clone) throws 
CloneNotSupportedException
+    protected <T extends DBTable<DB>> void initClonedFields(T clone) throws 
CloneNotSupportedException
     {
         // clone all columns
         Class<?> colClass = columns.get(0).getClass();
@@ -694,10 +694,10 @@ public class DBTable extends DBRowSet implements Cloneable
      * Returns a list of all foreign key relations for this table
      * @return the list of foreign key relations
      */
-    public List<DBRelation> getForeignKeyRelations()
+    public List<DBRelation<DB>> getForeignKeyRelations()
     {
-        List<DBRelation> relations = new ArrayList<DBRelation>();
-        for (DBRelation r : getDatabase().getRelations())
+        List<DBRelation<DB>> relations = new ArrayList<DBRelation<DB>>();
+        for (DBRelation<DB> r : getDatabase().getRelations())
         {   // check relation
             if (this.equals(r.getForeignKeyTable()))
                 relations.add(r);
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBUtils.java 
b/empire-db/src/main/java/org/apache/empire/db/DBUtils.java
index cd61d7a..02d36d6 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBUtils.java
@@ -816,7 +816,7 @@ public class DBUtils implements DBContextAware
      * @param recordClass the recordClass for which to create the list head 
      * @return
      */
-    protected <R extends DBRecordBase> DBRecordListFactory<R> 
createDefaultRecordListFactory(Class<R> recordClass, DBRowSet rowset) 
+    protected <RS extends DBRowSet<?>, R extends DBRecordBase> 
DBRecordListFactory<R> createDefaultRecordListFactory(Class<R> recordClass, RS 
rowset) 
     {
         return new DBRecordListFactoryImpl<R>(recordClass, context.getClass(), 
rowset);
     }
@@ -902,7 +902,7 @@ public class DBUtils implements DBContextAware
      * @param rowset the rowset for which to query the records
      * @return the list of DBRecord items
      */
-    public final <R extends DBRecordBase> List<R> queryRecordList(DBCommand 
cmd, DBRowSet rowset, Class<R> recordType)
+    public final <RS extends DBRowSet<?>, R extends DBRecord<RS>> List<R> 
queryRecordList(DBCommand cmd, RS rowset, Class<R> recordType)
     {
         @SuppressWarnings("cast")
         DBRecordListFactory<R> factory = 
(DBRecordListFactory<R>)createDefaultRecordListFactory(recordType, rowset);
@@ -915,7 +915,8 @@ public class DBUtils implements DBContextAware
      * @param rowset the rowset for which to query the records
      * @return the list of DBRecord items
      */
-    public final List<DBRecord> queryRecordList(DBCommand cmd, DBRowSet rowset)
+    @SuppressWarnings("unchecked")
+    public final <RS extends DBRowSet<?>> List<DBRecord<RS>> 
queryRecordList(DBCommand cmd, RS rowset)
     {
         return queryRecordList(cmd, rowset, DBRecord.class);
     }
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBView.java 
b/empire-db/src/main/java/org/apache/empire/db/DBView.java
index 9d5acd3..5a117e3 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBView.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBView.java
@@ -34,7 +34,7 @@ import org.w3c.dom.Element;
  * This class represents a database view.
  * It contains methods to get and update records from the database
  */
-public abstract class DBView extends DBRowSet
+public abstract class DBView<DB extends DBDatabase<DB>> extends DBRowSet<DB>
 {
     // *Deprecated* private static final long serialVersionUID = 1L;
 
@@ -57,7 +57,7 @@ public abstract class DBView extends DBRowSet
          * @param view the DBView object
          * @param expr the DBColumnExpr of the source table
          */
-        protected DBViewColumn(DBView view, String name, DBColumnExpr expr, 
double size)
+        protected DBViewColumn(DBView<?> view, String name, DBColumnExpr expr, 
double size)
         { // call base
             super(view, name);
             // set Expression
@@ -81,9 +81,9 @@ public abstract class DBView extends DBRowSet
             return expr;
         }
         
-        public DBView getView()
+        public DBView<?> getView()
         {
-            return (DBView)getRowSet();
+            return (DBView<?>)getRowSet();
         }
 
         @Override
@@ -199,7 +199,7 @@ public abstract class DBView extends DBRowSet
      * @param db the database this view belongs to.
      * @param isUpdateable true if the records of this view can be updated 
      */
-    public DBView(String name, DBDatabase db, boolean isUpdateable)
+    public DBView(String name, DB db, boolean isUpdateable)
     { // Set the column expressions
         super(db);
         // Set Name and Alias
@@ -217,7 +217,7 @@ public abstract class DBView extends DBRowSet
      * @param name the name of the view
      * @param db the database this view belongs to.
      */
-    public DBView(String name, DBDatabase db)
+    public DBView(String name, DB db)
     { // Set the column expressions
         this(name, db, false);
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java
index d9998ab..68e9097 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java
@@ -77,8 +77,9 @@ public class DBCountExpr extends DBColumnExpr
      * 
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public final <T extends DBDatabase> T getDatabase()
+    public final DBDatabase<?> getDatabase()
     {
         if (column!=null)
             return column.getDatabase();
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java
index ab5c879..2243ee3 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java
@@ -62,8 +62,9 @@ public class DBCrossJoinExpr extends DBJoinExpr
      * 
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public final <T extends DBDatabase> T getDatabase()
+    public final DBDatabase<?> getDatabase()
     {
         return left.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java
index 615f460..62d2aef 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java
@@ -62,8 +62,9 @@ public class DBSetExpr extends DBExpr
      * 
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public final <T extends DBDatabase> T getDatabase()
+    public final DBDatabase<?> getDatabase()
     {
         return column.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java 
b/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java
index ad09038..46b67d5 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java
@@ -55,16 +55,16 @@ public class DBModelChecker
      * The remote Database
      * This will be populated by the ModelChecker
      */
-    private static class RemoteDatabase extends DBDatabase
+    private static class RemoteDatabase extends DBDatabase<RemoteDatabase>
     {
         /*
          * Will be dynamically populated
          */
     }
     
-    private static class RemoteView extends DBView
+    private static class RemoteView extends DBView<RemoteDatabase>
     {
-        public RemoteView(String name, DBDatabase db)
+        public RemoteView(String name, RemoteDatabase db)
         {
             super(name, db);
         }
@@ -81,13 +81,13 @@ public class DBModelChecker
         }
     }
 
-    protected final String catalog;
-    protected final String schemaPattern;
+    protected final String  catalog;
+    protected final String  schemaPattern;
 
-    protected final String remoteName;
-    protected DBDatabase remoteDb = null;  /* will be recreated on every call 
to checkModel */
+    protected final String  remoteName;
+    protected DBDatabase<?> remoteDb = null;  /* will be recreated on every 
call to checkModel */
 
-    protected final Map<String, DBRowSet> tableMap = new HashMap<String, 
DBRowSet>();
+    protected final Map<String, DBRowSet<?>> tableMap = new HashMap<String, 
DBRowSet<?>>();
     
     /**
      * Creates a new Model Checker
@@ -117,7 +117,7 @@ public class DBModelChecker
      * Only available after parseModel() is called 
      * @return the remote Database
      */
-    public DBDatabase getRemoteDatabase()
+    public DBDatabase<?> getRemoteDatabase()
     {
         return remoteDb;
     }
@@ -128,7 +128,7 @@ public class DBModelChecker
      * @param conn the connection for retrieving the remote database metadata
      * @param handler the handler that is called to handle inconsistencies
      */
-    public void checkModel(DBDatabase db, Connection conn, DBModelErrorHandler 
handler)
+    public void checkModel(DBDatabase<?> db, Connection conn, 
DBModelErrorHandler handler)
     {
         // parse first
         parseModel(conn);
@@ -387,7 +387,7 @@ public class DBModelChecker
      * @param db the database to check the remote against
      * @param handler
      */
-    public void checkRemoteAgainst(DBDatabase db, DBModelErrorHandler handler)
+    public void checkRemoteAgainst(DBDatabase<?> db, DBModelErrorHandler 
handler)
     {
         if (this.remoteDb==null)
         {   // parseModel has not been called
@@ -395,21 +395,21 @@ public class DBModelChecker
         }
         
         // check Tables
-        for (DBTable table : db.getTables())
+        for (DBTable<?> table : db.getTables())
         {
             checkTable(table, handler);
         }
 
         // check Views
-        for (DBView view : db.getViews())
+        for (DBView<?> view : db.getViews())
         {
             checkView(view, handler);
         }
     }
 
-    protected void checkTable(DBTable table, DBModelErrorHandler handler)
+    protected void checkTable(DBTable<?> table, DBModelErrorHandler handler)
     {
-        DBTable remoteTable = remoteDb.getTable(table.getName()); // 
getTable(table.getName());
+        DBTable<?> remoteTable = remoteDb.getTable(table.getName()); // 
getTable(table.getName());
         if (remoteTable == null)
         {   // Check if it is a view instead
             if (remoteDb.getView(table.getName())!=null)
@@ -435,9 +435,9 @@ public class DBModelChecker
         }
     }
 
-    protected void checkView(DBView view, DBModelErrorHandler handler)
+    protected void checkView(DBView<?> view, DBModelErrorHandler handler)
     {
-        DBView remoteView = remoteDb.getView(view.getName());
+        DBView<?> remoteView = remoteDb.getView(view.getName());
         if (remoteView == null)
         {   // Check if it is a table instead
             if (remoteDb.getTable(view.getName())!=null)
@@ -459,7 +459,7 @@ public class DBModelChecker
         }
     }
 
-    protected void checkPrimaryKey(DBTable table, DBTable remoteTable, 
DBModelErrorHandler handler)
+    protected void checkPrimaryKey(DBTable<?> table, DBTable<?> remoteTable, 
DBModelErrorHandler handler)
     {
         if (table.getPrimaryKey() == null)
         {
@@ -500,16 +500,16 @@ public class DBModelChecker
             return;
         }
 
-        List<DBRelation> relations = table.getForeignKeyRelations();
-        List<DBRelation> remoteRelations = 
remoteTable.getForeignKeyRelations();
+        List<DBRelation<?>> relations = table.getForeignKeyRelations();
+        List<DBRelation<?>> remoteRelations = 
remoteTable.getForeignKeyRelations();
 
-        for (DBRelation relation : relations)
+        for (DBRelation<?> relation : relations)
         {
             referenceLoop: for (DBReference reference : 
relation.getReferences())
             {
                 if (reference.getTargetColumn().getRowSet() instanceof DBTable)
                 {
-                    DBTable targetTable = (DBTable) 
reference.getTargetColumn().getRowSet();
+                    DBTable<?> targetTable = (DBTable<?>) 
reference.getTargetColumn().getRowSet();
                     DBTableColumn targetColumn = reference.getTargetColumn();
                     if (!targetTable.getPrimaryKey().contains(targetColumn))
                     {
@@ -521,7 +521,7 @@ public class DBModelChecker
                     }
                 }
 
-                for (DBRelation remoteRelation : remoteRelations)
+                for (DBRelation<?> remoteRelation : remoteRelations)
                 {
                     for (DBReference remoteReference : 
remoteRelation.getReferences())
                     {
@@ -718,17 +718,17 @@ public class DBModelChecker
     /*
      * internal methods
      */
-    protected final Collection<DBRowSet> getTables()
+    protected final Collection<DBRowSet<?>> getTables()
     {
         return this.tableMap.values();
     }
     
-    protected final DBRowSet getTable(String tableName)
+    protected final DBRowSet<?> getTable(String tableName)
     {
         return this.tableMap.get(tableName.toUpperCase());
     }
 
-    protected DBDatabase createRemoteDatabase()
+    protected DBDatabase<?> createRemoteDatabase()
     {
         return new RemoteDatabase();
     }
@@ -740,7 +740,7 @@ public class DBModelChecker
     
     protected void addView(String viewName)
     {
-        this.tableMap.put(viewName.toUpperCase(), new RemoteView(viewName, 
this.remoteDb));
+        this.tableMap.put(viewName.toUpperCase(), new RemoteView(viewName, 
(RemoteDatabase)this.remoteDb));
     }
     
     protected void addRelation(String relName, DBReference... references)
@@ -748,7 +748,7 @@ public class DBModelChecker
         this.remoteDb.addRelation(relName, references);
     }
     
-    protected DBColumn addColumn(DBRowSet t, ResultSet rs)
+    protected DBColumn addColumn(DBRowSet<?> t, ResultSet rs)
         throws SQLException
     {
         String name = rs.getString("COLUMN_NAME");
@@ -824,7 +824,7 @@ public class DBModelChecker
         DBColumn col;
         if (t instanceof DBTable)
         {
-            col = ((DBTable)t).addColumn(name, empireType, colSize, required, 
defaultValue);
+            col = ((DBTable<?>)t).addColumn(name, empireType, colSize, 
required, defaultValue);
             // We still need to know the base data type for this AUTOINC
             // because the Record g/setters need to know this, right?
             // So, let's add it as meta data every time the column is AUTOINC
diff --git a/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandler.java 
b/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandler.java
index 3fbbaf3..59ff788 100644
--- a/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandler.java
+++ b/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandler.java
@@ -44,19 +44,19 @@ public interface DBMSHandler
     /**
      * Called when a database is opened
      */
-    void attachDatabase(DBDatabase db, Connection conn);
+    void attachDatabase(DBDatabase<?> db, Connection conn);
 
     /**
      * Called when a database is closed
      */
-    void detachDatabase(DBDatabase db, Connection conn);
+    void detachDatabase(DBDatabase<?> db, Connection conn);
     
     /**
      * This function creates a DBCommand derived object this database
      * @param db the database for which to create a command object for
      * @return a DBCommand object
      */
-    DBCommand createCommand(DBDatabase db);
+    DBCommand createCommand(DBDatabase<?> db);
 
     /**
      * This function gives the dbms a chance to provide a custom 
implementation 
@@ -131,7 +131,7 @@ public interface DBMSHandler
      * @param conn a valid database connection
      * @return the auto-generated value
      */
-    Object getColumnAutoValue(DBDatabase db, DBTableColumn column, Connection 
conn);
+    Object getColumnAutoValue(DBDatabase<?> db, DBTableColumn column, 
Connection conn);
     
     /**
      * Executes an select SQL-command that returns only one scalar value
@@ -235,13 +235,13 @@ public interface DBMSHandler
      * @param enable true to enable the relation or false to disable
      * @param script the script to which to add the DDL command(s)
      */
-    void appendEnableRelationStmt(DBRelation r, boolean enable, DBSQLScript 
script);
+    void appendEnableRelationStmt(DBRelation<?> r, boolean enable, DBSQLScript 
script);
  
     /**
      * Creates a DataModelChecker instance of this DBMSHandler
      * @return
      */
-    DBModelChecker createModelChecker(DBDatabase db);
+    DBModelChecker createModelChecker(DBDatabase<?> db);
     
     /**
      * Extracts native error message of an sqlExeption.
diff --git 
a/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandlerBase.java 
b/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandlerBase.java
index eb94e4c..fd1107c 100644
--- a/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandlerBase.java
+++ b/empire-db/src/main/java/org/apache/empire/dbms/DBMSHandlerBase.java
@@ -83,6 +83,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * This class is used to emulate sequences by using a sequence table.
      * It is used with the executeSQL function and only required for insert 
statements
      */
+    @SuppressWarnings("rawtypes")
     public static class DBSeqTable extends DBTable
     {
         // *Deprecated* private static final long serialVersionUID = 1L;
@@ -97,6 +98,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
          * @param tableName the table name
          * @param db the database object
          */
+        @SuppressWarnings("unchecked")
         public DBSeqTable(String tableName, DBDatabase db)
         {
             super(tableName, db);
@@ -215,7 +217,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * Called when a database is opened
      */
     @Override
-    public void attachDatabase(DBDatabase db, Connection conn)
+    public void attachDatabase(DBDatabase<?> db, Connection conn)
     {
         /* Nothing here */
     }
@@ -224,7 +226,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * Called when a database is closed
      */
     @Override
-    public void detachDatabase(DBDatabase db, Connection conn)
+    public void detachDatabase(DBDatabase<?> db, Connection conn)
     {
         /* Nothing here */
     }
@@ -235,7 +237,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * @return a DBCommand object
      */
     @Override
-    public abstract DBCommand createCommand(DBDatabase db);
+    public abstract DBCommand createCommand(DBDatabase<?> db);
 
     /**
      * This function gives the dbms a chance to provide a custom 
implementation 
@@ -331,7 +333,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * @param conn a valid database connection
      * @return a new unique sequence value or null if an error occurred
      */
-    public abstract Object getNextSequenceValue(DBDatabase db, String SeqName, 
int minValue, Connection conn);
+    public abstract Object getNextSequenceValue(DBDatabase<?> db, String 
SeqName, int minValue, Connection conn);
     
     /**
      * Returns an expression for creating a sequence value.
@@ -374,7 +376,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * @return the auto-generated value
      */
     @Override
-    public Object getColumnAutoValue(DBDatabase db, DBTableColumn column, 
Connection conn)
+    public Object getColumnAutoValue(DBDatabase<?> db, DBTableColumn column, 
Connection conn)
     {
         // Supports sequences?
         DataType type = column.getDataType();
@@ -717,7 +719,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * @param script the script to which to add the DDL command(s)
      */
     @Override
-    public void appendEnableRelationStmt(DBRelation r, boolean enable, 
DBSQLScript script)
+    public void appendEnableRelationStmt(DBRelation<?> r, boolean enable, 
DBSQLScript script)
     {
         if (enable)
             getDDLScript(DDLActionType.CREATE, r, script);
@@ -730,7 +732,7 @@ public abstract class DBMSHandlerBase implements DBMSHandler
      * @return
      */
     @Override
-    public DBModelChecker createModelChecker(DBDatabase db)
+    public DBModelChecker createModelChecker(DBDatabase<?> db)
     {
         log.warn("A general and possibly untested DBModelChecker is used for 
DBMSHandler {}. Please override to inklude DBMS specific features.", 
getClass().getSimpleName());
         // the default model checker
diff --git 
a/empire-db/src/main/java/org/apache/empire/dbms/hsql/HSqlDDLGenerator.java 
b/empire-db/src/main/java/org/apache/empire/dbms/hsql/HSqlDDLGenerator.java
index a87387e..c2fa671 100644
--- a/empire-db/src/main/java/org/apache/empire/dbms/hsql/HSqlDDLGenerator.java
+++ b/empire-db/src/main/java/org/apache/empire/dbms/hsql/HSqlDDLGenerator.java
@@ -62,10 +62,10 @@ public class HSqlDDLGenerator extends 
DBDDLGenerator<DBMSHandlerHSql>
     */
  
     @Override
-    protected void createDatabase(DBDatabase db, DBSQLScript script)
+    protected void createDatabase(DBDatabase<?> db, DBSQLScript script)
     {
         // Create all Sequences
-        for (DBTable table : db.getTables())
+        for (DBTable<?> table : db.getTables())
         {
             for (DBColumn dbColumn : table.getColumns())
             {
@@ -86,7 +86,7 @@ public class HSqlDDLGenerator extends 
DBDDLGenerator<DBMSHandlerHSql>
         // Additional tasks
         if ((type==DDLActionType.DROP) && (dbo instanceof DBTable))
         {   // Drop Sequences
-            for (DBColumn c : ((DBTable) dbo).getColumns())
+            for (DBColumn c : ((DBTable<?>) dbo).getColumns())
             {
                 if (c.getDataType() == DataType.AUTOINC && (c instanceof 
DBTableColumn))
                 {   // SEQUENCE column
@@ -104,7 +104,7 @@ public class HSqlDDLGenerator extends 
DBDDLGenerator<DBMSHandlerHSql>
      * @param column the column for which to create the sequence
      * @param script the sql script to which to append the dll command(s)
      */
-    protected void createSequence(DBDatabase db, DBTableColumn column, 
DBSQLScript script)
+    protected void createSequence(DBDatabase<?> db, DBTableColumn column, 
DBSQLScript script)
     {
         String seqName = dbms.getColumnSequenceName(column);
         // createSQL
diff --git 
a/empire-db/src/main/java/org/apache/empire/dbms/mysql/MySQLDDLGenerator.java 
b/empire-db/src/main/java/org/apache/empire/dbms/mysql/MySQLDDLGenerator.java
index 65b23d7..d9e9fb0 100644
--- 
a/empire-db/src/main/java/org/apache/empire/dbms/mysql/MySQLDDLGenerator.java
+++ 
b/empire-db/src/main/java/org/apache/empire/dbms/mysql/MySQLDDLGenerator.java
@@ -203,7 +203,7 @@ public class MySQLDDLGenerator extends 
DBDDLGenerator<DBMSHandlerMySQL>
      * @param script the sql script to which to append the dll command(s)
      */
     @Override
-    protected void createView(DBView v, DBSQLScript script)
+    protected void createView(DBView<?> v, DBSQLScript script)
     {
         // Create the Command
         DBCommandExpr cmd = v.createCommand();
diff --git 
a/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDDLGenerator.java 
b/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDDLGenerator.java
index dd85bb6..515a384 100644
--- 
a/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDDLGenerator.java
+++ 
b/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDDLGenerator.java
@@ -91,10 +91,10 @@ public class OracleDDLGenerator extends 
DBDDLGenerator<DBMSHandlerOracle>
     }
  
     @Override
-    protected void createDatabase(DBDatabase db, DBSQLScript script)
+    protected void createDatabase(DBDatabase<?> db, DBSQLScript script)
     {
         // Create all Sequences
-        for (DBTable table : db.getTables())
+        for (DBTable<?> table : db.getTables())
         {
             for (DBColumn dbColumn : table.getColumns())
             {
@@ -109,7 +109,7 @@ public class OracleDDLGenerator extends 
DBDDLGenerator<DBMSHandlerOracle>
     }
 
     @Override
-    protected void dropDatabase(DBDatabase db, DBSQLScript script)
+    protected void dropDatabase(DBDatabase<?> db, DBSQLScript script)
     {
         dropObject(null, db.getSchema(), "USER", script);
     }
@@ -121,7 +121,7 @@ public class OracleDDLGenerator extends 
DBDDLGenerator<DBMSHandlerOracle>
         // Additional tasks
         if ((type==DDLActionType.DROP) && (dbo instanceof DBTable))
         {   // Drop Sequences
-            for (DBColumn c : ((DBTable) dbo).getColumns())
+            for (DBColumn c : ((DBTable<?>) dbo).getColumns())
             {
                 if (c.getDataType() == DataType.AUTOINC && (c instanceof 
DBTableColumn))
                 {   // SEQUENCE column
@@ -136,7 +136,7 @@ public class OracleDDLGenerator extends 
DBDDLGenerator<DBMSHandlerOracle>
     /**
      * Returns true if the sequence has been created successfully.
      */
-    protected void createSequence(DBDatabase db, DBTableColumn column, 
DBSQLScript script)
+    protected void createSequence(DBDatabase<?> db, DBTableColumn column, 
DBSQLScript script)
     {
         String seqName = dbms.getColumnSequenceName(column);
         // createSQL
@@ -152,11 +152,11 @@ public class OracleDDLGenerator extends 
DBDDLGenerator<DBMSHandlerOracle>
     }
 
     @Override
-    protected void createTable(DBTable t, DBSQLScript script)
+    protected void createTable(DBTable<?> t, DBSQLScript script)
     {
         super.createTable(t, script);
         // Add Column comments (if any)
-        DBDatabase db = t.getDatabase();
+        DBDatabase<?> db = t.getDatabase();
         createComment(db, "TABLE", t, t.getComment(), script);
         for (DBColumn c : t.getColumns())
         {
@@ -166,7 +166,7 @@ public class OracleDDLGenerator extends 
DBDDLGenerator<DBMSHandlerOracle>
         }
     }
 
-    protected void createComment(DBDatabase db, String type, DBExpr expr, 
String comment, DBSQLScript script)
+    protected void createComment(DBDatabase<?> db, String type, DBExpr expr, 
String comment, DBSQLScript script)
     {
         if (comment==null || comment.length()==0)
             return; // Nothing to do
diff --git 
a/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDataDictionnary.java
 
b/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDataDictionnary.java
index 8ab8453..83ae2c3 100644
--- 
a/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDataDictionnary.java
+++ 
b/empire-db/src/main/java/org/apache/empire/dbms/oracle/OracleDataDictionnary.java
@@ -218,7 +218,7 @@ public class OracleDataDictionnary {
     
     public void checkDBTableDefinition(List<DBTable> dbTables) {
         // go through all tables defined in the Java code
-        for(DBTable currentTable: dbTables) {
+        for(DBTable<?> currentTable: dbTables) {
             String dbTableName = currentTable.getName();
             // check if the table name is in the data dictionnary
             if(this.dictionnary.containsKey(dbTableName)) {
@@ -249,7 +249,7 @@ public class OracleDataDictionnary {
     
     public void checkDBViewDefinition(List<DBView> dbViews) {
 //      go through all views defined in the Java code
-        for(DBView currentView: dbViews) {
+        for(DBView<?> currentView: dbViews) {
             String dbviewName = currentView.getName();
             // check if the view name is in the data dictionnary
             if(this.dictionnary.containsKey(dbviewName)) {
diff --git 
a/empire-db/src/main/java/org/apache/empire/dbms/postgresql/PostgreDDLGenerator.java
 
b/empire-db/src/main/java/org/apache/empire/dbms/postgresql/PostgreDDLGenerator.java
index 9fce87a..2e4d49b 100644
--- 
a/empire-db/src/main/java/org/apache/empire/dbms/postgresql/PostgreDDLGenerator.java
+++ 
b/empire-db/src/main/java/org/apache/empire/dbms/postgresql/PostgreDDLGenerator.java
@@ -79,10 +79,10 @@ public class PostgreDDLGenerator extends 
DBDDLGenerator<DBMSHandlerPostgreSQL>
     }
     
     @Override
-    protected void createDatabase(DBDatabase db, DBSQLScript script)
+    protected void createDatabase(DBDatabase<?> db, DBSQLScript script)
     {
         // Create all Sequences
-        for (DBTable table : db.getTables())
+        for (DBTable<?> table : db.getTables())
         {
             for (DBColumn dbColumn : table.getColumns()) {
                 DBTableColumn c = (DBTableColumn) dbColumn;
diff --git a/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java 
b/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
index da6d72f..b18dd9c 100644
--- a/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
+++ b/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
@@ -113,14 +113,14 @@ public class IntegerTest {
         database.open(context);
         createDatabase(database, context);
 
-        DBRecord maxRec = new DBRecord(context, database.SAMPLE);
+        DBRecord<SampleDB.SampleTable> maxRec = new 
DBRecord<SampleDB.SampleTable>(context, database.SAMPLE);
         maxRec.create();
         maxRec.setValue(database.SAMPLE.MY_INTEGER, Integer.MAX_VALUE);
         maxRec.setValue(database.SAMPLE.MY_LONG, Long.MAX_VALUE);
         maxRec.setValue(database.SAMPLE.MY_SHORT, Short.MAX_VALUE);
         maxRec.update();
         
-        DBRecord minRec = new DBRecord(context, database.SAMPLE);
+        DBRecord<SampleDB.SampleTable> minRec = new 
DBRecord<SampleDB.SampleTable>(context, database.SAMPLE);
         minRec.create();
         minRec.setValue(database.SAMPLE.MY_INTEGER, Integer.MIN_VALUE);
         minRec.setValue(database.SAMPLE.MY_LONG, Long.MIN_VALUE);
@@ -189,11 +189,11 @@ public class IntegerTest {
         throw new RuntimeException("Unknown Database Provider " + 
config.databaseProvider);
     }
 
-    private void createDatabase(DBDatabase db, DBContext context) {
+    private void createDatabase(DBDatabase<?> db, DBContext context) {
         // try to remove previously existing tables
         List<String> tables = getTableNames(db, context.getConnection());
         DBSQLScript script2 = new DBSQLScript(context);
-        for(DBTable table:db.getTables()){
+        for(DBTable<?> table:db.getTables()){
             if(tables.contains(table.getName())){
                 db.getDbms().getDDLScript(DDLActionType.DROP, table, script2);
             }
@@ -214,7 +214,7 @@ public class IntegerTest {
         context.commit();
     }
 
-    private List<String> getTableNames(DBDatabase db, Connection conn)
+    private List<String> getTableNames(DBDatabase<?> db, Connection conn)
     {
         List<String> tables = new ArrayList<String>();
         ResultSet result = null;
@@ -244,19 +244,19 @@ public class IntegerTest {
         return tables;
     }
 
-    public static class SampleDB extends DBDatabase {
+    public static class SampleDB extends DBDatabase<SampleDB> {
 
         // *Deprecated* private static final long serialVersionUID = 1L;
         public final SampleTable SAMPLE = new SampleTable(this);
 
-        public class SampleTable extends DBTable {
+        public class SampleTable extends DBTable<SampleDB> {
 
             // *Deprecated* private static final long serialVersionUID = 1L;
             public final DBTableColumn MY_INTEGER;
             public final DBTableColumn MY_LONG;
             public final DBTableColumn MY_SHORT;
 
-            public SampleTable(DBDatabase db) {
+            public SampleTable(SampleDB db) {
                 super("SAMPLE", db);
                 MY_INTEGER = addColumn("MY_INTEGER", DataType.INTEGER, 0, 
true);
                 MY_LONG    = addColumn("MY_LONG",    DataType.INTEGER, 8, 
true);

Reply via email to