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 f07247a EMPIREDB-373 just Beauty changes
f07247a is described below
commit f07247a130e7ab0d9d8e0638627e7ecbae99011d
Author: Rainer Döbele <[email protected]>
AuthorDate: Tue Feb 15 16:34:24 2022 +0100
EMPIREDB-373 just Beauty changes
---
.../empire/samples/db/advanced/SampleAdvApp.java | 19 ++++++++-------
.../org/apache/empire/samples/db/SampleApp.java | 28 ++++++++++------------
.../main/java/org/apache/empire/db/DBReader.java | 5 ++--
.../empire/db/expr/compare/DBCompareColExpr.java | 2 +-
4 files changed, 27 insertions(+), 27 deletions(-)
diff --git
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
index 298af0e..f9ed354 100644
---
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
+++
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
@@ -108,7 +108,10 @@ public class SampleAdvApp
DBMSHandler dbms = getDBMSHandler(config.getDatabaseProvider());
// STEP 2.2: Create a Context
- context = new DBContextStatic(dbms, conn);
+ context = new DBContextStatic(dbms, conn)
+ // set optional context features
+ .setPreparedStatementsEnabled(true)
+ .setRollbackHandlingEnabled(true);
// STEP 3: Open Database (and create if not existing)
System.out.println("*** Step 3: openDatabase() ***");
@@ -153,7 +156,7 @@ public class SampleAdvApp
// STEP 7: read from Employee_Info_View
System.out.println("--------------------------------------------------------");
System.out.println("*** read from EMPLOYEE_INFO_VIEW ***");
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
cmd.select (db.V_EMPLOYEE_INFO.getColumns());
cmd.orderBy(db.V_EMPLOYEE_INFO.C_NAME_AND_DEP);
printQueryResults(cmd);
@@ -339,7 +342,7 @@ public class SampleAdvApp
rec.setValue(T_EDH.C_DATE_FROM, dateFrom);
rec.update();
*/
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
cmd.set(T_EDH.C_EMPLOYEE_ID.to(employeeId));
cmd.set(T_EDH.C_DEPARTMENT_ID.to(departmentId));
cmd.set(T_EDH.C_DATE_FROM.to(dateFrom));
@@ -351,7 +354,7 @@ public class SampleAdvApp
private void commandParamsSample(int idProdDep, int idDevDep)
{
// create a command
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
// Create cmd parameters
DBCmdParam curDepParam = cmd.addParam(); // Current Department
DBCmdParam genderParam = cmd.addParam(); // Gender ('M' or 'F')
@@ -407,7 +410,7 @@ public class SampleAdvApp
private void bulkProcessRecords()
{
// Define the query
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
// Define shortcuts for tables used - not necessary but convenient
SampleAdvDB.Employees EMP = T_EMP;
// Select required columns
@@ -464,7 +467,7 @@ public class SampleAdvApp
private HashMap<Integer, DBRecord> bulkReadRecords(Connection conn)
{
// Define the query
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
// Select required columns
cmd.select(T_EMP.getColumns());
// Set Constraints
@@ -550,14 +553,14 @@ public class SampleAdvApp
private void querySample(int employeeId)
{
// Define the sub query
- DBCommand subCmd = db.createCommand();
+ DBCommand subCmd = context.createCommand();
DBColumnExpr MAX_DATE_FROM =
T_EDH.C_DATE_FROM.max().as(T_EDH.C_DATE_FROM);
subCmd.select(T_EDH.C_EMPLOYEE_ID, MAX_DATE_FROM);
subCmd.groupBy(T_EDH.C_EMPLOYEE_ID);
DBQuery Q_MAX_DATE = new DBQuery(subCmd);
// Define the query
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
// Select required columns
cmd.select(T_EMP.C_EMPLOYEE_ID, T_EMP.C_FULLNAME);
cmd.select(T_EMP.C_GENDER, T_EMP.C_PHONE_NUMBER);
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 b3221be..b70cd47 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
@@ -107,27 +107,25 @@ public class SampleApp
// SECTION 1: Get a JDBC Connection
log.info("Step 1: getJDBCConnection()");
- db.setPreparedStatementsEnabled(true);
-
Connection conn = getJDBCConnection();
// SECTION 2: Choose a DBMSHandler
log.info("Step 2: getDatabaseProvider()");
DBMSHandler dbms = getDBMSHandler(config.getDatabaseProvider(), conn);
-
- // SECTION 2.2: Create a Context
+
+ // SECTION 3: Create a Context
context = new DBContextStatic(dbms, conn, true)
// set optional context features
- .setPreparedStatementsEnabled(db.isPreparedStatementsEnabled())
+ .setPreparedStatementsEnabled(false)
.setRollbackHandlingEnabled(false);
- // SECTION 3: Open Database
+ // SECTION 4: Open Database
log.info("Step 3: Open database (and create if not existing)");
// Open the database (and create if not existing)
db.open(context);
// SECTION 5 AND 6: Populate Database and modify Data
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
cmd.select(db.EMPLOYEES.count());
if (context.getUtils().querySingleInt(cmd)==0)
{ // Employess table is empty. Populate now
@@ -400,7 +398,7 @@ public class SampleApp
SampleDB.Departments DEP = db.DEPARTMENTS;
// Create DBQuery from command
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
cmd.select(EMP.getColumns());
cmd.select(DEP.getColumns());
cmd.join(EMP.DEPARTMENT_ID, DEP.ID);
@@ -515,7 +513,7 @@ public class SampleApp
context.rollback();
- // DBCommand cmd = db.createCommand();
+ // DBCommand cmd = context.createCommand();
// cmd.select(T.UPDATE_TIMESTAMP);
// cmd.where (T.EMPLOYEE_ID.is(idEmp));
// log.info("Timestamp {}", db.querySingleString(cmd,
context.getConnection()));
@@ -586,7 +584,7 @@ public class SampleApp
*/
// Select Employee and Department columns
- DBCommand cmd = db.createCommand()
+ DBCommand cmd = context.createCommand()
.selectQualified(EMP.ID) // select "EMPLOYEE_ID"
.select(EMPLOYEE_NAME, EMP.GENDER, EMP.PHONE_NUMBER, EMP.SALARY)
.selectQualified(DEP.NAME) // "DEPARMENT_NAME"
@@ -669,7 +667,7 @@ public class SampleApp
{
SampleDB.Employees EMP = db.EMPLOYEES;
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
cmd.where(EMP.GENDER.is(Gender.M));
cmd.orderBy(EMP.LAST_NAME.desc());
List<Employee> list = context.getUtils().queryBeanList(cmd,
Employee.class, null);
@@ -708,7 +706,7 @@ public class SampleApp
// Employee total query
DBColumnExpr EMP_TOTAL = PAY.AMOUNT.sum().as("EMP_TOTAL");
- DBCommand cmdEmpTotal = db.createCommand()
+ DBCommand cmdEmpTotal = context.createCommand()
.select(PAY.EMPLOYEE_ID, EMP_TOTAL)
.where (PAY.YEAR.is(lastYear))
.groupBy(PAY.EMPLOYEE_ID);
@@ -716,7 +714,7 @@ public class SampleApp
// Department total query
DBColumnExpr DEP_TOTAL = PAY.AMOUNT.sum().as("DEP_TOTAL");
- DBCommand cmdDepTotal = db.createCommand()
+ DBCommand cmdDepTotal = context.createCommand()
.select(EMP.DEPARTMENT_ID, DEP_TOTAL)
.join (PAY.EMPLOYEE_ID, EMP.ID)
.where (PAY.YEAR.is(lastYear))
@@ -726,7 +724,7 @@ public class SampleApp
// Percentage of department
DBColumnExpr PCT_OF_DEP_COST =
Q_EMP_TOTAL.column(EMP_TOTAL).multiplyWith(100).divideBy(Q_DEP_TOTAL.column(DEP_TOTAL));
// Create the employee query
- DBCommand cmd = db.createCommand()
+ DBCommand cmd = context.createCommand()
.select(EMP.ID, EMP.FIRST_NAME, EMP.LAST_NAME,
DEP.NAME.as("DEPARTMENT"))
.select(Q_EMP_TOTAL.column(EMP_TOTAL))
.select(PCT_OF_DEP_COST.as("PCT_OF_DEPARTMENT_COST"))
@@ -779,7 +777,7 @@ public class SampleApp
/*
* Test RecordList
*/
- DBCommand cmd = db.createCommand();
+ DBCommand cmd = context.createCommand();
cmd.join(EMP.DEPARTMENT_ID, DEP.ID);
cmd.where(DEP.NAME.is("Development"));
// query now
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 d4da336..e3edb2a 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
@@ -39,7 +39,6 @@ import org.apache.empire.data.EntityType;
import org.apache.empire.db.exceptions.EmpireSQLException;
import org.apache.empire.db.exceptions.NoPrimaryKeyException;
import org.apache.empire.db.exceptions.QueryNoResultException;
-import org.apache.empire.db.expr.join.DBJoinExpr;
import org.apache.empire.db.list.DataBean;
import org.apache.empire.exceptions.BeanInstantiationException;
import org.apache.empire.exceptions.InvalidArgumentException;
@@ -962,7 +961,6 @@ public class DBReader extends DBRecordData implements
Closeable
* internal helper function to find parameterized subqueries
* @param cmd the command
* @return a list of parameter arrays, one for each subquery
- */
protected List<Object> findSubQueryParams(DBCommand cmd)
{
List<Object> subQueryParams = null;
@@ -985,13 +983,13 @@ public class DBReader extends DBRecordData implements
Closeable
}
return subQueryParams;
}
+ */
/**
* Adds any subquery params to the supplied list
* @param query the subquery
* @param list the current list of parameters
* @return the new list of parameters
- */
private List<Object> addSubQueryParams(DBQuery query, List<Object> list)
{
DBCommandExpr sqcmd = query.getCommandExpr();
@@ -1017,6 +1015,7 @@ public class DBReader extends DBRecordData implements
Closeable
}
return list;
}
+ */
/**
* Returns a constructor for a bean class for the set of parameters or
null if no suitable constructor is found
diff --git
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
index 72fb654..e31acf0 100644
---
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
+++
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
@@ -120,7 +120,7 @@ public class DBCompareColExpr extends DBCompareExpr
@Override
public void prepareCommand(DBCommand cmd)
{
- // Cannot user DBExpr or DBSystemDate as parameter
+ // Cannot use DBExpr or DBSystemDate as parameter
if (value==null || value instanceof DBCmdParam || value instanceof
DBExpr || value instanceof DBDatabase.DBSystemDate)
return;
// check operator