This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch version3
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/version3 by this push:
new 8d93807 EMPIREDB-369 small solution with additional generic types
TDatabase, TTable, TView and TRecord
8d93807 is described below
commit 8d93807c0992f431eb06361acf73c516a0ebf22c
Author: Rainer Döbele <[email protected]>
AuthorDate: Tue Feb 8 16:44:41 2022 +0100
EMPIREDB-369 small solution with additional generic types TDatabase,
TTable, TView and TRecord
---
.../empire/samples/db/advanced/SampleAdvDB.java | 63 ++++++++++---------
.../org/apache/empire/samples/db/SampleApp.java | 28 ++++-----
.../org/apache/empire/samples/db/SampleDB.java | 28 +++++----
.../apache/empire/samples/db/beans/Department.java | 2 +-
.../apache/empire/samples/db/beans/Employee.java | 71 +++++++++++++++-------
.../apache/empire/jsf2/websample/db/SampleDB.java | 18 +++---
.../jsf2/websample/db/records/EmployeeRecord.java | 2 +-
.../jsf2/websample/web/SampleApplication.java | 4 +-
.../jsf2/websample/web/pages/EmployeeListPage.java | 10 +--
.../src/main/webapp/pages/employeeListPage.xhtml | 4 +-
.../apache/empire/rest/app/SampleServiceApp.java | 4 +-
.../empire/rest/service/EmployeeService.java | 10 +--
.../org/apache/empire/vue/sample/db/SampleDB.java | 18 +++---
.../vue/sample/db/records/EmployeeRecord.java | 2 +-
.../main/java/org/apache/empire/db/DBDatabase.java | 2 +-
.../main/java/org/apache/empire/db/DBRowSet.java | 2 +-
.../org/apache/empire/db/generic/TDatabase.java | 64 +++++++++++++++++++
.../java/org/apache/empire/db/generic/TRecord.java | 64 +++++++++++++++++++
.../java/org/apache/empire/db/generic/TTable.java | 51 ++++++++++++++++
.../java/org/apache/empire/db/generic/TView.java | 51 ++++++++++++++++
20 files changed, 379 insertions(+), 119 deletions(-)
diff --git
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java
index aff98c8..81a15a4 100644
---
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java
+++
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java
@@ -25,9 +25,10 @@ import org.apache.empire.db.DBColumnExpr;
import org.apache.empire.db.DBCommand;
import org.apache.empire.db.DBCommandExpr;
import org.apache.empire.db.DBDatabase;
-import org.apache.empire.db.DBTable;
import org.apache.empire.db.DBTableColumn;
-import org.apache.empire.db.DBView;
+import org.apache.empire.db.generic.TDatabase;
+import org.apache.empire.db.generic.TTable;
+import org.apache.empire.db.generic.TView;
/**
* <PRE>
@@ -44,14 +45,14 @@ import org.apache.empire.db.DBView;
* You may declare other database tables or views in the same way.
* </PRE>
*/
-public class SampleAdvDB extends DBDatabase
+public class SampleAdvDB extends TDatabase<SampleAdvDB>
{
// *Deprecated* private static final long serialVersionUID = 1L;
/**
* This class represents the definition of the Departments table.
*/
- public static class Departments extends DBTable
+ public static class Departments extends TTable<SampleAdvDB>
{
// *Deprecated* private static final long serialVersionUID = 1L;
@@ -61,7 +62,7 @@ public class SampleAdvDB extends DBDatabase
public final DBTableColumn C_BUSINESS_UNIT;
public final DBTableColumn C_UPDATE_TIMESTAMP;
- public Departments(DBDatabase db)
+ public Departments(SampleAdvDB db)
{
super("DEPARTMENTS", db);
// ID
@@ -81,7 +82,7 @@ public class SampleAdvDB extends DBDatabase
/**
* This class represents the definition of the Employees table.
*/
- public static class Employees extends DBTable
+ public static class Employees extends TTable<SampleAdvDB>
{
// *Deprecated* private static final long serialVersionUID = 1L;
@@ -100,7 +101,7 @@ public class SampleAdvDB extends DBDatabase
// Useful column expressions
public final DBColumnExpr C_FULLNAME;
- public Employees(DBDatabase db)
+ public Employees(SampleAdvDB db)
{
super("EMPLOYEES", db);
// ID
@@ -136,7 +137,7 @@ public class SampleAdvDB extends DBDatabase
/**
* This class represents the definition of the Departments table.
*/
- public static class EmployeeDepartmentHistory extends DBTable
+ public static class EmployeeDepartmentHistory extends TTable<SampleAdvDB>
{
// *Deprecated* private static final long serialVersionUID = 1L;
@@ -144,7 +145,7 @@ public class SampleAdvDB extends DBDatabase
public final DBTableColumn C_DEPARTMENT_ID;
public final DBTableColumn C_DATE_FROM;
- public EmployeeDepartmentHistory(DBDatabase db)
+ public EmployeeDepartmentHistory(SampleAdvDB db)
{
super("EMPLOYEE_DEPARTMENT_HIST", db);
// ID
@@ -160,14 +161,14 @@ public class SampleAdvDB extends DBDatabase
/**
* This class represents the definition of the EmployeeDepSinceView table.
*/
- public static class EmployeeDepSinceView extends DBView
+ public static class EmployeeDepSinceView extends TView<SampleAdvDB>
{
// *Deprecated* private static final long serialVersionUID = 1L;
public final DBViewColumn C_EMPLOYEE_ID;
public final DBViewColumn C_MAX_DATE_FROM;
- public EmployeeDepSinceView(DBDatabase db, EmployeeDepartmentHistory
T_EDH)
+ public EmployeeDepSinceView(SampleAdvDB db, EmployeeDepartmentHistory
T_EDH)
{
super("EMPLOYEE_DEP_SINCE_VIEW", db);
// ID
@@ -187,14 +188,13 @@ public class SampleAdvDB extends DBDatabase
FROM EMPLOYEE_DEPARTMENT_HIST t3
GROUP BY t3.EMPLOYEE_ID);
*/
-
- SampleAdvDB db = (SampleAdvDB)getDatabase();
- SampleAdvDB.EmployeeDepartmentHistory T_EDH = db.T_EMP_DEP_HIST;
+
+ SampleAdvDB.EmployeeDepartmentHistory EDH = DB.T_EMP_DEP_HIST;
// Define the sub query
DBCommand cmd = db.createCommand();
- cmd.select (T_EDH.C_EMPLOYEE_ID, T_EDH.C_DATE_FROM.max());
- cmd.groupBy(T_EDH.C_EMPLOYEE_ID);
+ cmd.select (EDH.C_EMPLOYEE_ID, EDH.C_DATE_FROM.max());
+ cmd.groupBy(EDH.C_EMPLOYEE_ID);
return cmd;
}
}
@@ -202,7 +202,7 @@ public class SampleAdvDB extends DBDatabase
/**
* This class represents the definition of the EmployeeInfoView table.
*/
- public static class EmployeeInfoView extends DBView
+ public static class EmployeeInfoView extends TView<SampleAdvDB>
{
// *Deprecated* private static final long serialVersionUID = 1L;
@@ -210,7 +210,7 @@ public class SampleAdvDB extends DBDatabase
public final DBViewColumn C_CURRENT_DEP_ID;
public final DBViewColumn C_NAME_AND_DEP;
- public EmployeeInfoView(DBDatabase db, Employees T_EMP, Departments
T_DEP)
+ public EmployeeInfoView(SampleAdvDB db, Employees T_EMP, Departments
T_DEP)
{
super("EMPLOYEE_INFO_VIEW", db);
// ID
@@ -234,25 +234,24 @@ public class SampleAdvDB extends DBDatabase
INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID =
t3.DEPARTMENT_ID);
*/
- SampleAdvDB db = (SampleAdvDB)getDatabase();
- SampleAdvDB.Employees T_EMP = db.T_EMPLOYEES;
- SampleAdvDB.EmployeeDepartmentHistory T_EDH = db.T_EMP_DEP_HIST;
- SampleAdvDB.EmployeeDepSinceView V_EDS = db.V_EMP_DEP_SINCE_VIEW;
- SampleAdvDB.Departments T_DEP = db.T_DEPARTMENTS;
+ SampleAdvDB.Employees EMP = DB.T_EMPLOYEES;
+ SampleAdvDB.EmployeeDepartmentHistory EDH = DB.T_EMP_DEP_HIST;
+ SampleAdvDB.EmployeeDepSinceView EDS = DB.V_EMP_DEP_SINCE_VIEW;
+ SampleAdvDB.Departments DEP = DB.T_DEPARTMENTS;
// Define the query
DBCommand cmd = db.createCommand();
// Select required columns
- cmd.select(T_EMP.C_EMPLOYEE_ID);
- cmd.select(T_DEP.C_DEPARTMENT_ID);
- cmd.select(T_EMP.C_LASTNAME.append(", ")
-
.append(T_EMP.C_FIRSTNAME.coalesce(DBDatabase.EMPTY_STRING))
- .append(" (").append(T_DEP.C_NAME).append(")"));
+ cmd.select(EMP.C_EMPLOYEE_ID);
+ cmd.select(DEP.C_DEPARTMENT_ID);
+ cmd.select(EMP.C_LASTNAME.append(", ")
+
.append(EMP.C_FIRSTNAME.coalesce(DBDatabase.EMPTY_STRING))
+ .append(" (").append(DEP.C_NAME).append(")"));
// Set Joins
- cmd.join(T_EDH.C_EMPLOYEE_ID, V_EDS.C_EMPLOYEE_ID)
- .where(T_EDH.C_DATE_FROM.is(V_EDS.C_MAX_DATE_FROM));
- cmd.join(T_EMP.C_EMPLOYEE_ID, T_EDH.C_EMPLOYEE_ID);
- cmd.join(T_DEP.C_DEPARTMENT_ID, T_EDH.C_DEPARTMENT_ID);
+ cmd.join(EDH.C_EMPLOYEE_ID, EDS.C_EMPLOYEE_ID)
+ .where(EDH.C_DATE_FROM.is(EDS.C_MAX_DATE_FROM));
+ cmd.join(EMP.C_EMPLOYEE_ID, EDH.C_EMPLOYEE_ID);
+ cmd.join(DEP.C_DEPARTMENT_ID, EDH.C_DEPARTMENT_ID);
// done
return cmd;
}
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 52bc2ae..10075a3 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
@@ -26,6 +26,7 @@ import java.time.LocalDate;
import java.util.List;
import org.apache.empire.commons.StringUtils;
+import org.apache.empire.data.bean.BeanResult;
import org.apache.empire.data.list.DataListEntry;
import org.apache.empire.db.DBColumnExpr;
import org.apache.empire.db.DBCommand;
@@ -37,6 +38,7 @@ import org.apache.empire.db.DBRecordBean;
import org.apache.empire.db.DBRowSet.PartialMode;
import org.apache.empire.db.DBSQLScript;
import org.apache.empire.db.context.DBContextStatic;
+import org.apache.empire.db.generic.TRecord;
import org.apache.empire.db.validation.DBModelChecker;
import org.apache.empire.db.validation.DBModelErrorLogger;
import org.apache.empire.dbms.DBMSHandler;
@@ -354,7 +356,7 @@ public class SampleApp
{
SampleDB.Departments DEP = db.DEPARTMENTS;
// Insert a Department
- DBRecord rec = new DBRecord(context, DEP);
+ TRecord<SampleDB.Departments> rec = new
TRecord<SampleDB.Departments>(context, DEP);
rec.create();
rec.setValue(DEP.NAME, departmentName);
rec.setValue(DEP.BUSINESS_UNIT, businessUnit);
@@ -374,8 +376,8 @@ public class SampleApp
// Insert an Employee
DBRecord rec = new DBRecord(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();
@@ -471,7 +473,7 @@ public class SampleApp
DBRecord rec = new DBRecord(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();
}
@@ -628,7 +630,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
@@ -656,7 +658,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
@@ -728,7 +730,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)
{
@@ -740,9 +742,8 @@ public class SampleApp
Payment first =
department.getEmployees().get(0).getPayments().get(0);
log.info("First payment amount is {}", first.getAmount());
- /*
// Query all males
- BeanResult<Employee> result = new
BeanResult<Employee>(Employee.class);
+ BeanResult<Employee> result = new
BeanResult<Employee>(Employee.class, EMP);
result.getCommand().where(EMP.GENDER.is(Gender.M));
result.fetch(context);
@@ -753,7 +754,6 @@ public class SampleApp
result.fetch(context);
log.info("Number of female employees is: "+result.size());
- */
}
private static void queryDataList()
@@ -785,7 +785,7 @@ public class SampleApp
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
@@ -795,7 +795,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
@@ -806,7 +806,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)
@@ -847,7 +847,7 @@ public class SampleApp
{
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..1d325e2 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
@@ -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");
@@ -102,36 +102,40 @@ public class SampleDB extends DBDatabase
public static class Employees extends DBTable
{
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);
@@ -148,7 +152,7 @@ public class SampleDB extends DBDatabase
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..59f3af2 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,22 @@ 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)
{
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 +110,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 +125,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 +197,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 +227,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 +255,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..098ab66 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
@@ -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,7 +55,7 @@ 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;
@@ -65,14 +65,14 @@ public class SampleDB extends DBDatabase
{
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"); // 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");
UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP",
DataType.TIMESTAMP, 0, true);
- // Primary Key
- setPrimaryKey(DEPARTMENT_ID);
+ // Primary Key (automatically set due to AUTOINC column)
+ // setPrimaryKey(DEPARTMENT_ID);
// Set other Indexes
addIndex("DEARTMENT_NAME_IDX", true, new DBColumn[] { NAME });
}
@@ -87,7 +87,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;
@@ -103,7 +103,7 @@ public class SampleDB extends DBDatabase
{
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"); // 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);
@@ -116,8 +116,8 @@ public class SampleDB extends DBDatabase
// PICTURE = addColumn("PICTURE",
DataType.BLOB, 0, false);
UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP",
DataType.TIMESTAMP, 0, true);
- // Primary Key
- setPrimaryKey(EMPLOYEE_ID);
+ // Primary Key (automatically set due to AUTOINC column)
+ // setPrimaryKey(EMPLOYEE_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/records/EmployeeRecord.java
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/EmployeeRecord.java
index 04d11fa..e7839a6 100644
---
a/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/EmployeeRecord.java
+++
b/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/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 context.getUtils().queryOptionList(cmd);
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..6784155 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
@@ -246,7 +246,7 @@ public class SampleApplication extends WebApplication {
return 0;
}
// Return Department ID
- return rec.getInt(sampleDB.T_DEPARTMENTS.DEPARTMENT_ID);
+ return rec.getInt(sampleDB.T_DEPARTMENTS.ID);
}
/*
@@ -268,7 +268,7 @@ 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
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..fa14c58 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,12 +184,12 @@ 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);
- queryCmd.join(DEP.DEPARTMENT_ID, EMP.DEPARTMENT_ID);
+ queryCmd.join(DEP.ID, EMP.DEPARTMENT_ID);
queryCmd.orderBy(EMP.FIRST_NAME);
addAllConstraints(queryCmd);
@@ -203,7 +203,7 @@ public class EmployeeListPage extends SamplePage
TDepartments DEP = getDatabase().T_DEPARTMENTS;
DBCommand queryCmd = createQueryCommand();
- queryCmd.select(DEP.DEPARTMENT_ID,DEP.NAME);
+ queryCmd.select(DEP.ID, DEP.NAME);
return getSampleContext().getUtils().queryOptionList(queryCmd);
}
@@ -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-jsf2/src/main/webapp/pages/employeeListPage.xhtml
b/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml
index 22a6b61..04cf9ba 100644
---
a/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml
+++
b/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml
@@ -61,9 +61,9 @@
<h:dataTable id="employeeTable"
value="#{page.employees.items}" var="item" rowClasses="odd,even">
<h:column>
<f:facet name="header">
- <e:title
column="#{db.EMPLOYEES.EMPLOYEE_ID}" value="ID" />
+ <e:title
column="#{db.EMPLOYEES.ID}" value="ID" />
</f:facet>
- <e:value record="#{item}"
column="#{db.EMPLOYEES.EMPLOYEE_ID}"/>
+ <e:value record="#{item}"
column="#{db.EMPLOYEES.ID}"/>
</h:column>
<h:column styleClass="item">
<f:facet name="header">
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..fabf12c 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
@@ -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,7 +55,7 @@ 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;
@@ -65,14 +65,14 @@ public class SampleDB extends DBDatabase
{
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"); // 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");
UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP",
DataType.TIMESTAMP, 0, true);
- // Primary Key
- setPrimaryKey(DEPARTMENT_ID);
+ // Primary Key (automatically set due to AUTOINC column)
+ // setPrimaryKey(DEPARTMENT_ID);
// Set other Indexes
addIndex("DEARTMENT_NAME_IDX", true, new DBColumn[] { NAME });
@@ -88,7 +88,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;
@@ -104,7 +104,7 @@ public class SampleDB extends DBDatabase
{
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"); // 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);
@@ -117,8 +117,8 @@ public class SampleDB extends DBDatabase
// PICTURE = addColumn("PICTURE",
DataType.BLOB, 0, false);
UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP",
DataType.TIMESTAMP, 0, true);
- // Primary Key
- setPrimaryKey(EMPLOYEE_ID);
+ // Primary Key (automatically set due to AUTOINC column)
+ // setPrimaryKey(EMPLOYEE_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/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/src/main/java/org/apache/empire/db/DBDatabase.java
b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
index 24b6c2f..9428007 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
@@ -416,7 +416,7 @@ public abstract class DBDatabase extends DBObject
*/
@SuppressWarnings("unchecked")
@Override
- public final <T extends DBDatabase> T getDatabase()
+ public <T extends DBDatabase> T getDatabase()
{
return (T)(this);
}
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 3d7af28..e9caf45 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
@@ -362,7 +362,7 @@ public abstract class DBRowSet extends DBExpr implements
Entity
*/
@SuppressWarnings("unchecked")
@Override
- public final <T extends DBDatabase> T getDatabase()
+ public <T extends DBDatabase> T getDatabase()
{
return (T)db;
}
diff --git
a/empire-db/src/main/java/org/apache/empire/db/generic/TDatabase.java
b/empire-db/src/main/java/org/apache/empire/db/generic/TDatabase.java
new file mode 100644
index 0000000..9df6dca
--- /dev/null
+++ b/empire-db/src/main/java/org/apache/empire/db/generic/TDatabase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.generic;
+
+import org.apache.empire.db.DBDatabase;
+
+public class TDatabase<DB extends TDatabase<DB>> extends DBDatabase
+{
+ /**
+ * Constructs a new DBDatabase object and sets the specified schema object.
+ *
+ * @param schema the database schema
+ * @param linkName the database link name
+ */
+ public TDatabase(String schema, String linkName)
+ {
+ super(schema, linkName);
+ }
+
+ /**
+ * Constructs a new DBDatabase object and sets the specified schema object.
+ *
+ * @param schema the database schema
+ */
+ public TDatabase(String schema)
+ {
+ super(schema);
+ }
+
+ /**
+ * Constructs a new DBDatabase object set the variable 'schema' = null.
+ */
+ public TDatabase()
+ {
+ super();
+ }
+
+ /**
+ * finally we know the database type
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public final DB getDatabase()
+ {
+ return (DB)this;
+ }
+
+}
diff --git a/empire-db/src/main/java/org/apache/empire/db/generic/TRecord.java
b/empire-db/src/main/java/org/apache/empire/db/generic/TRecord.java
new file mode 100644
index 0000000..62d7e80
--- /dev/null
+++ b/empire-db/src/main/java/org/apache/empire/db/generic/TRecord.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.generic;
+
+import org.apache.empire.db.DBContext;
+import org.apache.empire.db.DBRecord;
+import org.apache.empire.db.DBRowSet;
+
+public class TRecord<RS extends DBRowSet> extends DBRecord
+{
+ private static final long serialVersionUID = 1L;
+
+ public final RS RS;
+
+ /**
+ * Internal constructor for DBRecord
+ * May be used by derived classes to provide special behaviour
+ */
+ protected TRecord(DBContext context, RS rowset, boolean
enableRollbackHandling)
+ {
+ super(context, rowset, enableRollbackHandling);
+ // set the rowset for quick access
+ this.RS = rowset;
+ }
+
+ /**
+ * Constructs a new DBRecord.<BR>
+ * @param context the DBContext for this record
+ * @param rowset the corresponding RowSet(Table, View, Query, etc.)
+ */
+ public TRecord(DBContext context, RS rowset)
+ {
+ super(context, rowset);
+ // set the rowset for quick access
+ this.RS = rowset;
+ }
+
+ /**
+ * finally we know the rowset
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public RS getRowSet()
+ {
+ return this.RS;
+ }
+
+}
diff --git a/empire-db/src/main/java/org/apache/empire/db/generic/TTable.java
b/empire-db/src/main/java/org/apache/empire/db/generic/TTable.java
new file mode 100644
index 0000000..ca447b1
--- /dev/null
+++ b/empire-db/src/main/java/org/apache/empire/db/generic/TTable.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.generic;
+
+import org.apache.empire.db.DBTable;
+
+public class TTable<DB extends TDatabase<DB>> extends DBTable
+{
+ public final DB DB;
+
+ public TTable(String name, DB db, String alias)
+ {
+ super(name, db, alias);
+ // set type
+ this.DB = db;
+ }
+
+ public TTable(String name, DB db)
+ {
+ super(name, db);
+ // set type
+ this.DB = db;
+ }
+
+ /**
+ * finally we know the database type
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public final DB getDatabase()
+ {
+ return this.DB;
+ }
+
+}
diff --git a/empire-db/src/main/java/org/apache/empire/db/generic/TView.java
b/empire-db/src/main/java/org/apache/empire/db/generic/TView.java
new file mode 100644
index 0000000..303ebef
--- /dev/null
+++ b/empire-db/src/main/java/org/apache/empire/db/generic/TView.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.generic;
+
+import org.apache.empire.db.DBView;
+
+public abstract class TView<DB extends TDatabase<DB>> extends DBView
+{
+ public final DB DB;
+
+ public TView(String name, DB db, boolean isUpdateable)
+ {
+ super(name, db, isUpdateable);
+ // set type
+ this.DB = db;
+ }
+
+ public TView(String name, DB db)
+ {
+ super(name, db);
+ // set type
+ this.DB = db;
+ }
+
+ /**
+ * finally we know the database type
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public final DB getDatabase()
+ {
+ return (DB)super.getDatabase();
+ }
+
+}