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 da90f3c EMPIREDB-362 minor DBCommand set() bugfix and SampleAdv
improvement
da90f3c is described below
commit da90f3ca8185c665b38160e3ac4700f8256361be
Author: Rainer Döbele <[email protected]>
AuthorDate: Wed Feb 16 12:43:58 2022 +0100
EMPIREDB-362 minor DBCommand set() bugfix and SampleAdv improvement
---
.../empire/samples/db/advanced/CarSalesDB.java | 169 ++++++++++++++++-----
.../empire/samples/db/advanced/SampleAdvApp.java | 137 +++++++++++++++--
.../samples/db/advanced/SampleAdvContext.java | 41 +++++
.../samples/db/advanced/records/BrandRecord.java | 43 ++++++
.../org/apache/empire/samples/db/SampleApp.java | 112 --------------
.../main/java/org/apache/empire/db/DBCommand.java | 25 +--
.../main/java/org/apache/empire/db/DBTable.java | 41 +++++
.../empire/db/expr/compare/DBCompareAndOrExpr.java | 4 +-
.../empire/db/expr/compare/DBCompareColExpr.java | 4 +-
.../empire/db/expr/compare/DBCompareExpr.java | 4 +-
.../empire/db/expr/compare/DBCompareNotExpr.java | 4 +-
.../empire/db/expr/compare/DBExistsExpr.java | 4 +-
.../empire/db/expr/compare/DBParenthesisExpr.java | 4 +-
.../org/apache/empire/db/expr/set/DBSetExpr.java | 4 +-
14 files changed, 412 insertions(+), 184 deletions(-)
diff --git
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/CarSalesDB.java
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/CarSalesDB.java
index 2c02576..fcf05ac 100644
---
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/CarSalesDB.java
+++
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/CarSalesDB.java
@@ -37,6 +37,7 @@ import org.apache.empire.db.generic.TTable;
import org.apache.empire.db.validation.DBModelChecker;
import org.apache.empire.db.validation.DBModelErrorLogger;
import org.apache.empire.dbms.postgresql.DBMSHandlerPostgreSQL;
+import org.apache.empire.samples.db.advanced.records.BrandRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -83,11 +84,34 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
}
/**
- * This class represents the Departments table.
+ * EngineType enum
+ */
+ public enum DealershipType
+ {
+ B("Brand"),
+ I("Independent"),
+ F("Franchise"),
+ U("Used cars"),
+ G("Small garage");
+
+ private final String title;
+ private DealershipType(String title)
+ {
+ this.title = title;
+ }
+ @Override
+ public String toString()
+ {
+ return title;
+ }
+ }
+
+ /**
+ * This class represents the Brand table.
*/
public static class Brand extends TTable<CarSalesDB>
{
- public final DBTableColumn ID;
+ public final DBTableColumn WMI;
public final DBTableColumn NAME;
public final DBTableColumn COUNTRY;
public final DBTableColumn UPDATE_TIMESTAMP;
@@ -96,25 +120,25 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
{
super("BRAND", db);
// ID
- ID = addColumn("ID", DataType.AUTOINC,
0, true, "BRAND_ID_SEQUENCE"); // Optional Sequence for some DBMS (e.g.
Oracle)
+ WMI = addColumn("WMI", DataType.VARCHAR,
3, true); // World Manufacturer code
NAME = addColumn("NAME", DataType.VARCHAR,
80, true);
COUNTRY = addColumn("COUNTRY", DataType.VARCHAR,
80, false);
UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP",
DataType.TIMESTAMP, 0, true);
// Primary Key (automatically set due to AUTOINC column)
- // setPrimaryKey(ID);
+ setPrimaryKey(WMI);
}
}
/**
- * This class represents the Employees table.
+ * This class represents the Model table.
*/
public static class Model extends TTable<CarSalesDB>
{
public final DBTableColumn ID;
public final DBTableColumn NAME;
public final DBTableColumn CONFIG_NAME;
- public final DBTableColumn BRAND_ID;
+ public final DBTableColumn WMI;
public final DBTableColumn TRIM;
public final DBTableColumn ENGINE_TYPE;
public final DBTableColumn ENGINE_POWER;
@@ -129,7 +153,7 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
ID = addColumn("ID", DataType.AUTOINC,
0, true, "MODEL_ID_SEQUENCE"); // Optional Sequence name for some DBMS
(e.g. Oracle)
NAME = addColumn("NAME", DataType.VARCHAR,
20, true);
CONFIG_NAME = addColumn("CONFIGURATION", DataType.VARCHAR,
40, true);
- BRAND_ID = addColumn("BRAND_ID", DataType.INTEGER,
0, true);
+ WMI = addColumn("WMI", DataType.VARCHAR,
3, true);
TRIM = addColumn("TRIM", DataType.VARCHAR,
20, true);
ENGINE_TYPE = addColumn("ENGINE_TYPE", DataType.CHAR,
1, true, EngineType.class);
ENGINE_POWER = addColumn("ENGINE_POWER", DataType.DECIMAL,
4.0, true);
@@ -142,7 +166,58 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
}
/**
- * This class represents the Payments table.
+ * This class represents the Dealer table.
+ */
+ public static class Dealer extends TTable<CarSalesDB>
+ {
+ public final DBTableColumn ID;
+ public final DBTableColumn COMPANY_NAME;
+ public final DBTableColumn STREET;
+ public final DBTableColumn CITY;
+ public final DBTableColumn YEAR_FOUNDED;
+ public final DBTableColumn UPDATE_TIMESTAMP;
+
+ public Dealer(CarSalesDB db)
+ {
+ super("DEALER", db);
+
+ // ID
+ ID = addColumn("ID", DataType.AUTOINC,
0, true, "DEALER_ID_SEQUENCE"); // Optional Sequence name for some DBMS
(e.g. Oracle)
+ COMPANY_NAME = addColumn("COMPANY_NAME", DataType.VARCHAR,
40, true);
+ STREET = addColumn("ADDRESS", DataType.VARCHAR,
40, false);
+ CITY = addColumn("CITY", DataType.VARCHAR,
20, true);
+ YEAR_FOUNDED = addColumn("YEAR_FOUNDED", DataType.DECIMAL,
4.0, false);
+ UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP",
DataType.TIMESTAMP, 0, true);
+
+ // Primary Key (automatically set due to AUTOINC column)
+ // setPrimaryKey(ID);
+ }
+ }
+
+ /**
+ * This class represents the Dealer table.
+ */
+ public static class DealerBrands extends TTable<CarSalesDB>
+ {
+ public final DBTableColumn DEALER_ID;
+ public final DBTableColumn BRAND_WMI;
+ public final DBTableColumn TYPE;
+
+ public DealerBrands(CarSalesDB db)
+ {
+ super("DEALER_BRANDS", db);
+
+ // ID
+ DEALER_ID = addForgeinKey(db.DEALER, "DEALER_ID", true);
+ BRAND_WMI = addForgeinKey(db.BRAND, "BRAND_WMI", true);
+ TYPE = addColumn("TYPE", DataType.CHAR, 1,
true, DealershipType.class);
+ // Primary Key (automatically set due to AUTOINC column)
+ // setPrimaryKey(ID);
+ }
+ }
+
+ /**
+ * This class represents the Sales table.
*/
public static class Sales extends TTable<CarSalesDB>
{
@@ -168,9 +243,14 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
}
// Declare all Tables and Views here
- public final Brand BRAND = new Brand(this);
- public final Model MODEL = new Model(this);
- public final Sales SALES = new Sales(this);
+ public final Brand BRAND = new Brand(this);
+ public final Model MODEL = new Model(this);
+ public final Dealer DEALER = new Dealer(this);
+ public final DealerBrands DEALER_BRANDS = new DealerBrands(this);
+ public final Sales SALES = new Sales(this);
+
+ private boolean wasCreated;
+
/**
* Constructor of the SampleDB data model
@@ -180,10 +260,15 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
public CarSalesDB()
{
// Define Foreign-Key Relations
- addRelation( MODEL.BRAND_ID.referenceOn( BRAND.ID ));
+ addRelation( MODEL.WMI.referenceOn( BRAND.WMI ));
addRelation( SALES.MODEL_ID.referenceOn( MODEL.ID ));
}
+ public boolean wasCreated()
+ {
+ return wasCreated;
+ }
+
@Override
public void open(DBContext context)
{
@@ -193,6 +278,8 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
if (checkExists(context))
{ // attach to driver
super.open(context);
+ // remember
+ wasCreated = false;
// yes, it exists, then check the model
checkDataModel(context);
}
@@ -207,8 +294,8 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
setAutoCommit(context, false);
// attach to driver
super.open(context);
- // populate
- populate(context);
+ // populate
+ wasCreated = true;
// Commit
context.commit();
}
@@ -248,33 +335,32 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
}
}
- private void populate(DBContext context)
+ public void populate(SampleAdvContext context)
{
- DBRecord brand = new DBRecord(context, BRAND);
- brand.create().set(BRAND.NAME, "VW").set(BRAND.COUNTRY,
"Germany").update(); long idVW = brand.getId();
- brand.create().set(BRAND.NAME, "Ford").set(BRAND.COUNTRY,
"USA").update(); long idFord = brand.getId();
- brand.create().set(BRAND.NAME, "Tesla").set(BRAND.COUNTRY,
"USA").update(); long idTesla = brand.getId();
- brand.create().set(BRAND.NAME, "Toyota").set(BRAND.COUNTRY,
"Japan").update();long idToy = brand.getId();
+ BrandRecord brandVW = new BrandRecord(context); brandVW
.insert("WVW", "VW", "Germany");
+ BrandRecord brandFord = new BrandRecord(context); brandFord
.insert("1F", "Ford", "USA");
+ BrandRecord brandTesla = new BrandRecord(context);
brandTesla.insert("5YJ", "Tesla", "USA");
+ BrandRecord brandToy = new BrandRecord(context); brandToy
.insert("JT", "Toyota", "Japan");
DBRecord model = new DBRecord(context, MODEL);
// VW
- model.create().set(MODEL.BRAND_ID, idVW).set(MODEL.NAME,
"Golf").set(MODEL.CONFIG_NAME, "Golf Style 1,5 l TSI").set(MODEL.TRIM,
"Style").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
130).set(MODEL.BASE_PRICE,30970).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idVW).set(MODEL.NAME,
"Golf").set(MODEL.CONFIG_NAME, "Golf R-Line 2,0 l TSI 4MOTION").set(MODEL.TRIM,
"R-Line").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
190).set(MODEL.BASE_PRICE,38650).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idVW).set(MODEL.NAME,
"Tiguan").set(MODEL.CONFIG_NAME, "Tiguan Life 1,5 l TSI").set(MODEL.TRIM,
"Life").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
150).set(MODEL.BASE_PRICE,32545).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idVW).set(MODEL.NAME,
"Tiguan").set(MODEL.CONFIG_NAME, "Tiguan Elegance 2,0 l TDI
SCR").set(MODEL.TRIM, "Elegance").set(MODEL.ENGINE_TYPE,
EngineType.D).set(MODEL.ENGINE_POWER,
150).set(MODEL.BASE_PRICE,40845).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idVW).set(MODEL.NAME,
"Tiguan").set(MODEL.CONFIG_NAME, "Tiguan R-Line 1,4 l eHybrid").set(MODEL.TRIM,
"R-Line").set(MODEL.ENGINE_TYPE, EngineType.H).set(MODEL.ENGINE_POWER,
150).set(MODEL.BASE_PRICE,48090).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandVW).set(MODEL.NAME,
"Golf").set(MODEL.CONFIG_NAME, "Golf Style 1,5 l TSI").set(MODEL.TRIM,
"Style").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
130).set(MODEL.BASE_PRICE,30970).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandVW).set(MODEL.NAME,
"Golf").set(MODEL.CONFIG_NAME, "Golf R-Line 2,0 l TSI 4MOTION").set(MODEL.TRIM,
"R-Line").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
190).set(MODEL.BASE_PRICE,38650).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandVW).set(MODEL.NAME,
"Tiguan").set(MODEL.CONFIG_NAME, "Tiguan Life 1,5 l TSI").set(MODEL.TRIM,
"Life").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
150).set(MODEL.BASE_PRICE,32545).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandVW).set(MODEL.NAME,
"Tiguan").set(MODEL.CONFIG_NAME, "Tiguan Elegance 2,0 l TDI
SCR").set(MODEL.TRIM, "Elegance").set(MODEL.ENGINE_TYPE,
EngineType.D).set(MODEL.ENGINE_POWER,
150).set(MODEL.BASE_PRICE,40845).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandVW).set(MODEL.NAME,
"Tiguan").set(MODEL.CONFIG_NAME, "Tiguan R-Line 1,4 l eHybrid").set(MODEL.TRIM,
"R-Line").set(MODEL.ENGINE_TYPE, EngineType.H).set(MODEL.ENGINE_POWER,
150).set(MODEL.BASE_PRICE,48090).update();generateRandomSales(model);
// Tesla
- model.create().set(MODEL.BRAND_ID, idTesla).set(MODEL.NAME, "Model
3").set(MODEL.CONFIG_NAME, "Model 3 LR").set(MODEL.TRIM, "Long
Range").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
261).set(MODEL.BASE_PRICE,45940).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idTesla).set(MODEL.NAME, "Model
3").set(MODEL.CONFIG_NAME, "Model 3 Performance").set(MODEL.TRIM,
"Performance").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
487).set(MODEL.BASE_PRICE,53940).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idTesla).set(MODEL.NAME, "Model
Y").set(MODEL.CONFIG_NAME, "Model Y LR").set(MODEL.TRIM, "Long
Range").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
345).set(MODEL.BASE_PRICE,53940).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idTesla).set(MODEL.NAME, "Model
Y").set(MODEL.CONFIG_NAME, "Model Y Performance").set(MODEL.TRIM,
"Performance").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
450).set(MODEL.BASE_PRICE,58940).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idTesla).set(MODEL.NAME, "Model
S").set(MODEL.CONFIG_NAME, "Model S Plaid").set(MODEL.TRIM,
"Plaid").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
1020).set(MODEL.BASE_PRICE,126990).update(); // no sales
+ model.create().set(MODEL.WMI, brandTesla).set(MODEL.NAME, "Model
3").set(MODEL.CONFIG_NAME, "Model 3 LR").set(MODEL.TRIM, "Long
Range").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
261).set(MODEL.BASE_PRICE,45940).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandTesla).set(MODEL.NAME, "Model
3").set(MODEL.CONFIG_NAME, "Model 3 Performance").set(MODEL.TRIM,
"Performance").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
487).set(MODEL.BASE_PRICE,53940).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandTesla).set(MODEL.NAME, "Model
Y").set(MODEL.CONFIG_NAME, "Model Y LR").set(MODEL.TRIM, "Long
Range").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
345).set(MODEL.BASE_PRICE,53940).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandTesla).set(MODEL.NAME, "Model
Y").set(MODEL.CONFIG_NAME, "Model Y Performance").set(MODEL.TRIM,
"Performance").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
450).set(MODEL.BASE_PRICE,58940).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandTesla).set(MODEL.NAME, "Model
S").set(MODEL.CONFIG_NAME, "Model S Plaid").set(MODEL.TRIM,
"Plaid").set(MODEL.ENGINE_TYPE, EngineType.E).set(MODEL.ENGINE_POWER,
1020).set(MODEL.BASE_PRICE,126990).update(); // no sales
// Ford
- model.create().set(MODEL.BRAND_ID, idFord).set(MODEL.NAME,
"Mustang").set(MODEL.CONFIG_NAME, "Mustang GT 5,0 l Ti-VCT V8").set(MODEL.TRIM,
"GT").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
449).set(MODEL.BASE_PRICE,54300).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idFord).set(MODEL.NAME,
"Mustang").set(MODEL.CONFIG_NAME, "Mustang Mach1 5,0 l Ti-VCT
V8").set(MODEL.TRIM, "Mach1").set(MODEL.ENGINE_TYPE,
EngineType.P).set(MODEL.ENGINE_POWER,
460).set(MODEL.BASE_PRICE,62800).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandFord).set(MODEL.NAME,
"Mustang").set(MODEL.CONFIG_NAME, "Mustang GT 5,0 l Ti-VCT V8").set(MODEL.TRIM,
"GT").set(MODEL.ENGINE_TYPE, EngineType.P).set(MODEL.ENGINE_POWER,
449).set(MODEL.BASE_PRICE,54300).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandFord).set(MODEL.NAME,
"Mustang").set(MODEL.CONFIG_NAME, "Mustang Mach1 5,0 l Ti-VCT
V8").set(MODEL.TRIM, "Mach1").set(MODEL.ENGINE_TYPE,
EngineType.P).set(MODEL.ENGINE_POWER,
460).set(MODEL.BASE_PRICE,62800).update();generateRandomSales(model);
// Toyota
- model.create().set(MODEL.BRAND_ID, idToy).set(MODEL.NAME,
"Prius").set(MODEL.CONFIG_NAME, "Prius Hybrid 1,8-l-VVT-i").set(MODEL.TRIM,
"Basis").set(MODEL.ENGINE_TYPE, EngineType.H).set(MODEL.ENGINE_POWER,
122).set(MODEL.BASE_PRICE,38000).update();generateRandomSales(model);
- model.create().set(MODEL.BRAND_ID, idToy).set(MODEL.NAME,
"Supra").set(MODEL.CONFIG_NAME, "GR Supra Pure 2,0 l Twin-Scroll
Turbo").set(MODEL.TRIM, "Pure").set(MODEL.ENGINE_TYPE,
EngineType.P).set(MODEL.ENGINE_POWER,
258).set(MODEL.BASE_PRICE,49290).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandToy).set(MODEL.NAME,
"Prius").set(MODEL.CONFIG_NAME, "Prius Hybrid 1,8-l-VVT-i").set(MODEL.TRIM,
"Basis").set(MODEL.ENGINE_TYPE, EngineType.H).set(MODEL.ENGINE_POWER,
122).set(MODEL.BASE_PRICE,38000).update();generateRandomSales(model);
+ model.create().set(MODEL.WMI, brandToy).set(MODEL.NAME,
"Supra").set(MODEL.CONFIG_NAME, "GR Supra Pure 2,0 l Twin-Scroll
Turbo").set(MODEL.TRIM, "Pure").set(MODEL.ENGINE_TYPE,
EngineType.P).set(MODEL.ENGINE_POWER,
258).set(MODEL.BASE_PRICE,49290).update();generateRandomSales(model);
}
private void generateRandomSales(DBRecord model)
@@ -326,7 +412,7 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
DBCommand cmd = this.createCommand()
.select(BRAND.NAME.as("BRAND"), MODEL.NAME.as("MODEL"),
MODEL.BASE_PRICE.avg(), SALES.MODEL_ID.count(), SALES.PRICE.avg())
.select(SALES.PRICE.avg().minus(MODEL.BASE_PRICE.avg()).round(2).as("DIFFERENCE"))
- .join(MODEL.BRAND_ID, BRAND.ID)
+ .join(MODEL.WMI, BRAND.ID)
.joinLeft(MODEL.ID, SALES.MODEL_ID, SALES.YEAR.is(2021))
.where(MODEL.ENGINE_TYPE.in(EngineType.H, EngineType.E)) // Hybrid
and Electric
.where(MODEL.BASE_PRICE.isGreaterThan(30000))
@@ -339,7 +425,7 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
.select (MODEL.BASE_PRICE)
.select (SALES.MODEL_ID.count(), SALES.PRICE.avg())
.select (SALES.PRICE.avg().minus(MODEL.BASE_PRICE.avg()).round(2))
- .join (MODEL.BRAND_ID, BRAND.ID)
+ .join (MODEL.WMI, BRAND.WMI)
.joinLeft(MODEL.ID, SALES.MODEL_ID, SALES.YEAR.is(2021)) // only
year 2021
.where (MODEL.ENGINE_TYPE.in(EngineType.P, EngineType.H,
EngineType.E)) // Petrol, Hybrid, Electric
.where (MODEL.BASE_PRICE.isGreaterThan(30000))
@@ -368,10 +454,19 @@ public class CarSalesDB extends TDatabase<CarSalesDB>
DBCommand cmd = context.createCommand()
.set (MODEL.BASE_PRICE.to(55000)) // set the price-tag
- .join (MODEL.BRAND_ID, BRAND.ID)
+ .join (MODEL.WMI, BRAND.WMI)
.where(BRAND.NAME.is("Tesla"))
.where(MODEL.NAME.is("Model 3").and(MODEL.TRIM.is("Performance")));
+ /*
+ * Clone test
+ DBCommand cl1 = cmd.clone();
+ cl1.set(MODEL.BASE_PRICE.to(66000)); // set the price-tag
+ cl1.where(BRAND.NAME.is("Foo"));
+ log.info("cmd= {} params={}", cmd.getUpdate(), cmd.getParamValues());
+ log.info("cmd= {} params={}", cl1.getUpdate(), cl1.getParamValues());
+ */
+
// and off you go...
context.executeUpdate(cmd);
}
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 f9ed354..3b94ac8 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
@@ -30,14 +30,12 @@ import org.apache.empire.data.DataType;
import org.apache.empire.db.DBCmdParam;
import org.apache.empire.db.DBColumnExpr;
import org.apache.empire.db.DBCommand;
-import org.apache.empire.db.DBContext;
import org.apache.empire.db.DBDDLGenerator.DDLActionType;
import org.apache.empire.db.DBQuery;
import org.apache.empire.db.DBReader;
import org.apache.empire.db.DBRecord;
import org.apache.empire.db.DBSQLScript;
import org.apache.empire.db.DBTableColumn;
-import org.apache.empire.db.context.DBContextStatic;
import org.apache.empire.db.exceptions.ConstraintViolationException;
import org.apache.empire.db.exceptions.StatementFailedException;
import org.apache.empire.dbms.DBMSHandler;
@@ -57,7 +55,7 @@ public class SampleAdvApp
private final CarSalesDB carSales = new CarSalesDB();
- private DBContext context;
+ private SampleAdvContext context;
// Shortcuts
private SampleAdvDB.Employees T_EMP = db.T_EMPLOYEES;
@@ -108,15 +106,19 @@ public class SampleAdvApp
DBMSHandler dbms = getDBMSHandler(config.getDatabaseProvider());
// STEP 2.2: Create a Context
- context = new DBContextStatic(dbms, conn)
- // set optional context features
- .setPreparedStatementsEnabled(true)
- .setRollbackHandlingEnabled(true);
+ context = new SampleAdvContext(carSales, dbms, conn);
+ // set optional context features
+ context.setPreparedStatementsEnabled(false);
+ context.setRollbackHandlingEnabled(true);
// STEP 3: Open Database (and create if not existing)
System.out.println("*** Step 3: openDatabase() ***");
db.open(context);
carSales.open(context);
+ if (carSales.wasCreated())
+ { // newly created
+ carSales.populate(context);
+ }
carSales.queryDemo(context);
carSales.updateDemo(context);
@@ -583,15 +585,128 @@ public class SampleAdvApp
// Define an updateable query
DBQuery Q_EMP_DEP = new DBQuery(cmd, T_EMP.C_EMPLOYEE_ID);
DBRecord rec = new DBRecord(context, Q_EMP_DEP);
- rec.read(employeeId);
// Modify and Update fields from both Employee and Department
- rec.set(T_EMP.C_PHONE_NUMBER, "0815-4711");
- rec.set(T_DEP.C_BUSINESS_UNIT, "AUTO");
- rec.update();
+ rec.read(employeeId)
+ .set(T_EMP.C_PHONE_NUMBER, "0815-4711")
+ .set(T_DEP.C_BUSINESS_UNIT, "AUTO")
+ .update();
// Successfully updated
System.out.println("The employee has been sucessfully updated");
}
+
+ /**
+ * testTransactionCreate
+ * @param context
+ * @param idDep
+ *
+ private int testTransactionCreate(long idDep)
+ {
+ // Shortcut for convenience
+ SampleDB.Employees EMP = db.EMPLOYEES;
+
+ DBRecord rec = new DBRecord(context, EMP);
+ rec.create();
+ rec.set(EMP.FIRSTNAME, "Foo");
+ rec.set(EMP.LASTNAME, "Manchoo");
+ rec.set(EMP.GENDER, Gender.M);
+ rec.set(EMP.DEPARTMENT_ID, idDep);
+ rec.update();
+ log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
+
+ rec.set(EMP.FIRSTNAME, "Foo 2");
+ rec.set(EMP.LASTNAME, "Manchu");
+ rec.set(EMP.PHONE_NUMBER, "0815/4711");
+ rec.update();
+ log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
+
+ context.rollback();
+
+ rec.set(EMP.FIRSTNAME, "Dr. Foo");
+ rec.update();
+ log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
+
+ rec.delete();
+
+ context.rollback();
+
+ // insert final
+ rec.update();
+ log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
+
+ log.info("testTransactionCreate performed OK");
+ context.commit();
+
+ return rec.getInt(EMP.ID);
+ }
+ */
+
+ /**
+ * @param context
+ * @param idDep
+ *
+ private void testTransactionUpdate(long idEmp)
+ {
+ // Shortcut for convenience
+ SampleDB.Employees EMP = db.EMPLOYEES;
+
+ DBRecord rec = new DBRecord(context, EMP);
+ rec.read(idEmp);
+ rec.set(EMP.PHONE_NUMBER, null);
+ rec.set(EMP.SALARY, "100.000");
+ rec.update();
+
+ log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
+
+ context.rollback();
+
+ rec.set(EMP.PHONE_NUMBER, "07531-45716-0");
+ rec.update();
+
+ log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
+
+ context.rollback();
+
+ rec.update();
+
+ log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
+ log.info("testTransactionUpdate performed OK");
+ context.commit();
+ }
+ */
+
+ /**
+ * @param context
+ * @param idDep
+ *
+ private void testTransactionDelete(long idEmp)
+ {
+ // Shortcut for convenience
+ SampleDB.Employees T = db.EMPLOYEES;
+
+ DBRecord rec = new DBRecord(context, T);
+ rec.read(idEmp);
+
+ // log.info("Timestamp {}", rec.getString(T.UPDATE_TIMESTAMP));
+ // rec.set(T.SALARY, "100.001");
+ // rec.update();
+ // log.info("Timestamp {}", rec.getString(T.UPDATE_TIMESTAMP));
+
+ rec.delete();
+
+ context.rollback();
+
+ // DBCommand cmd = context.createCommand();
+ // cmd.select(T.UPDATE_TIMESTAMP);
+ // cmd.where (T.EMPLOYEE_ID.is(idEmp));
+ // log.info("Timestamp {}", db.querySingleString(cmd,
context.getConnection()));
+
+ rec.update();
+
+ log.info("Transaction performed OK");
+ }
+ */
+
/**
* This function demonstrates cascaded deletes.
* See DBRelation.setOnDeleteAction()
diff --git
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvContext.java
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvContext.java
new file mode 100644
index 0000000..b970d40
--- /dev/null
+++
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvContext.java
@@ -0,0 +1,41 @@
+/*
+ * 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.samples.db.advanced;
+
+import java.sql.Connection;
+
+import org.apache.empire.db.context.DBContextStatic;
+import org.apache.empire.dbms.DBMSHandler;
+
+public class SampleAdvContext extends DBContextStatic
+{
+ private final CarSalesDB database;
+
+ public SampleAdvContext(CarSalesDB db, DBMSHandler dbmsHandler, Connection
conn)
+ {
+ super(dbmsHandler, conn);
+ // set database
+ this.database = db;
+ }
+
+ public CarSalesDB getDatabase()
+ {
+ return database;
+ }
+}
diff --git
a/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/records/BrandRecord.java
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/records/BrandRecord.java
new file mode 100644
index 0000000..baa88e2
--- /dev/null
+++
b/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/records/BrandRecord.java
@@ -0,0 +1,43 @@
+/*
+ * 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.samples.db.advanced.records;
+
+import org.apache.empire.db.generic.TRecord;
+import org.apache.empire.samples.db.advanced.CarSalesDB;
+import org.apache.empire.samples.db.advanced.SampleAdvContext;
+
+public class BrandRecord extends TRecord<CarSalesDB.Brand>
+{
+ private static final long serialVersionUID = 1L;
+
+ public BrandRecord(SampleAdvContext context)
+ {
+ super(context, context.getDatabase().BRAND);
+ }
+
+ public void insert(String wmi, String name, String country)
+ {
+ create();
+ set(RS.WMI, wmi);
+ set(RS.NAME, name);
+ set(RS.COUNTRY, country);
+ update();
+ }
+
+}
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 60e93b9..cfe6560 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
@@ -415,118 +415,6 @@ public class SampleApp
}
/**
- * testTransactionCreate
- * @param context
- * @param idDep
- *
- private int testTransactionCreate(long idDep)
- {
- // Shortcut for convenience
- SampleDB.Employees EMP = db.EMPLOYEES;
-
- DBRecord rec = new DBRecord(context, EMP);
- rec.create();
- rec.set(EMP.FIRSTNAME, "Foo");
- rec.set(EMP.LASTNAME, "Manchoo");
- rec.set(EMP.GENDER, Gender.M);
- rec.set(EMP.DEPARTMENT_ID, idDep);
- rec.update();
- log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
-
- rec.set(EMP.FIRSTNAME, "Foo 2");
- rec.set(EMP.LASTNAME, "Manchu");
- rec.set(EMP.PHONE_NUMBER, "0815/4711");
- rec.update();
- log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
-
- context.rollback();
-
- rec.set(EMP.FIRSTNAME, "Dr. Foo");
- rec.update();
- log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
-
- rec.delete();
-
- context.rollback();
-
- // insert final
- rec.update();
- log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
-
- log.info("testTransactionCreate performed OK");
- context.commit();
-
- return rec.getInt(EMP.ID);
- }
- */
-
- /**
- * @param context
- * @param idDep
- *
- private void testTransactionUpdate(long idEmp)
- {
- // Shortcut for convenience
- SampleDB.Employees EMP = db.EMPLOYEES;
-
- DBRecord rec = new DBRecord(context, EMP);
- rec.read(idEmp);
- rec.set(EMP.PHONE_NUMBER, null);
- rec.set(EMP.SALARY, "100.000");
- rec.update();
-
- log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
-
- context.rollback();
-
- rec.set(EMP.PHONE_NUMBER, "07531-45716-0");
- rec.update();
-
- log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
-
- context.rollback();
-
- rec.update();
-
- log.info("Timestamp {}", rec.getString(EMP.UPDATE_TIMESTAMP));
- log.info("testTransactionUpdate performed OK");
- context.commit();
- }
- */
-
- /**
- * @param context
- * @param idDep
- *
- private void testTransactionDelete(long idEmp)
- {
- // Shortcut for convenience
- SampleDB.Employees T = db.EMPLOYEES;
-
- DBRecord rec = new DBRecord(context, T);
- rec.read(idEmp);
-
- // log.info("Timestamp {}", rec.getString(T.UPDATE_TIMESTAMP));
- // rec.set(T.SALARY, "100.001");
- // rec.update();
- // log.info("Timestamp {}", rec.getString(T.UPDATE_TIMESTAMP));
-
- rec.delete();
-
- context.rollback();
-
- // DBCommand cmd = context.createCommand();
- // cmd.select(T.UPDATE_TIMESTAMP);
- // cmd.where (T.EMPLOYEE_ID.is(idEmp));
- // log.info("Timestamp {}", db.querySingleString(cmd,
context.getConnection()));
-
- rec.update();
-
- log.info("Transaction performed OK");
- }
- */
-
- /**
* <PRE>
* Performs an SQL-Query and prints the result to System.out
*
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
index b2811d3..c959656 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
@@ -212,12 +212,12 @@ public abstract class DBCommand extends DBCommandExpr
clone.cmdParams = new ArrayList<DBCmdParam>(cmdParams.size());
// clone set
for (int i=0; (clone.set!=null && i<clone.set.size()); i++)
- clone.set.set(i, clone.set.get(i).copyCommand(clone));
+ clone.set.set(i, clone.set.get(i).copy(clone));
// clone where and having
for (int i=0; (clone.where!=null && i<clone.where.size()); i++)
- clone.where.set(i, clone.where.get(i).copyCommand(clone));
+ clone.where.set(i, clone.where.get(i).copy(clone));
for (int i=0; (clone.having!=null && i<clone.having.size());
i++)
- clone.having.set(i,
clone.having.get(i).copyCommand(clone));
+ clone.having.set(i, clone.having.get(i).copy(clone));
}
// done
return clone;
@@ -457,6 +457,7 @@ public abstract class DBCommand extends DBCommandExpr
*/
public DBCommand set(DBSetExpr expr)
{
+ // add to list
if (set == null)
set = new ArrayList<DBSetExpr>();
for (int i = 0; i < set.size(); i++)
@@ -465,21 +466,25 @@ public abstract class DBCommand extends DBCommandExpr
if (chk.column.equals(expr.column))
{ // Overwrite existing value
if (useCmdParam(expr.column, expr.value))
- { // replace parameter value
- // int index = ((DBCommandParam) chk.value).index;
- // this.setCmdParam(index, getCmdParamValue(expr.column,
expr.value));
+ { // Use parameter value
if (chk.value instanceof DBCmdParam)
+ { // reuse the old paramter
((DBCmdParam)chk.value).setValue(expr.value);
+ expr.value = chk.value;
+ chk.value = null;
+ }
else
- chk.value = addParam(expr.column.getDataType(),
expr.value);
+ { // create new one
+ expr.value = addParam(expr.column.getDataType(),
expr.value);
+ }
}
else
{ // remove from parameter list (if necessary)
- if (cmdParams!=null && chk.value instanceof DBCmdParam)
+ if (cmdParams!=null && (chk.value instanceof DBCmdParam))
cmdParams.remove(chk.value);
- // replace value
- chk.value = expr.value;
}
+ // replace now
+ set.set(i, expr);
return this;
}
}
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 d464f21..593a1f9 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
@@ -411,6 +411,47 @@ public class DBTable extends DBRowSet implements Cloneable
col.setEnumOptions(enumValue.getClass());
return col;
}
+
+ /**
+ * Adds a new ForgeinKey table column the column list
+ * The foreign table must have a single column foreign key
+ * @param target the table on which to reference
+ * @param name the name of the new column
+ * @param required true if the value is required
+ * @param options (optional) a set of allowed values for this column
+ * @return the new column
+ */
+ public DBTableColumn addForgeinKey(DBTable target, String name, boolean
required, Options options)
+ {
+ DBColumn[] keyCols = target.getKeyColumns();
+ if (keyCols==null || keyCols.length!=1)
+ throw new InvalidArgumentException("target", target);
+ // add column
+ DBTableColumn keyCol = (DBTableColumn)keyCols[0];
+ DataType keyDataType = keyCol.getDataType();
+ if (keyDataType==DataType.AUTOINC)
+ keyDataType =DataType.INTEGER;
+ DBTableColumn referenceColumn = addColumn(name, keyDataType,
keyCol.getSize(), required, options);
+ // Adapter foreign key
+ String fkName = getName() + "_" + name.replace("_ID", "_FK");
+ db.addRelation(fkName, referenceColumn.referenceOn(keyCol));
+ return referenceColumn;
+ }
+
+ /**
+ * Adds a new ForgeinKey table column the column list
+ * The foreign table must have a single column foreign key
+ * @param target the table on which to reference
+ * @param name the name of the new column
+ * @param required true if the value is required
+ * @param options (optional) a set of allowed values for this column
+ * @return the new column
+ */
+ public final DBTableColumn addForgeinKey(DBTable target, String name,
boolean required)
+ {
+ return addForgeinKey(target, name, required, null);
+ }
+
/**
* Returns the primary key.
diff --git
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
index 98ae024..06084af 100644
---
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
+++
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
@@ -98,9 +98,9 @@ public class DBCompareAndOrExpr extends DBCompareExpr
* @param cmd
*/
@Override
- public DBCompareExpr copyCommand(DBCommand cmd)
+ public DBCompareExpr copy(DBCommand newCmd)
{
- return new DBCompareAndOrExpr(left.copyCommand(cmd),
right.copyCommand(cmd), or);
+ return new DBCompareAndOrExpr(left.copy(newCmd), right.copy(newCmd),
or);
}
/**
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 f9da3f7..fdb5f10 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
@@ -149,11 +149,11 @@ public class DBCompareColExpr extends DBCompareExpr
* @param cmd
*/
@Override
- public DBCompareExpr copyCommand(DBCommand cmd)
+ public DBCompareExpr copy(DBCommand newCmd)
{
Object valueCopy = value;
if (value instanceof DBCmdParam)
- valueCopy = cmd.addParam(DataType.UNKNOWN,
((DBCmdParam)value).getValue());
+ valueCopy = newCmd.addParam(DataType.UNKNOWN,
((DBCmdParam)value).getValue());
return new DBCompareColExpr(expr, cmpop, valueCopy);
}
diff --git
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java
index 20c47a0..40a3395 100644
---
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java
+++
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java
@@ -72,9 +72,9 @@ public abstract class DBCompareExpr extends DBExpr
public abstract void prepareCommand(DBCommand cmd);
/**
- * internally used for parameter cloning
+ * internally used for command cloning
* @param cmd
*/
- public abstract DBCompareExpr copyCommand(DBCommand cmd);
+ public abstract DBCompareExpr copy(DBCommand newCmd);
}
diff --git
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
index 5ffd495..c506152 100644
---
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
+++
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
@@ -76,9 +76,9 @@ public class DBCompareNotExpr extends DBCompareExpr
* @param cmd
*/
@Override
- public DBCompareExpr copyCommand(DBCommand cmd)
+ public DBCompareExpr copy(DBCommand newCmd)
{
- return new DBCompareNotExpr(expr.copyCommand(cmd));
+ return new DBCompareNotExpr(expr.copy(newCmd));
}
/**
diff --git
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java
index 63d12d4..d9f56b9 100644
---
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java
+++
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java
@@ -92,11 +92,11 @@ public class DBExistsExpr extends DBCompareExpr
* @param cmd
*/
@Override
- public DBCompareExpr copyCommand(DBCommand newCmd)
+ public DBCompareExpr copy(DBCommand newCmd)
{
if (compareExpr==null)
return this;
- return new DBExistsExpr(cmd, compareExpr.copyCommand(newCmd));
+ return new DBExistsExpr(cmd, compareExpr.copy(newCmd));
}
/**
diff --git
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
index d5ad8ed..a201d85 100644
---
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
+++
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
@@ -71,9 +71,9 @@ public class DBParenthesisExpr extends DBCompareExpr
implements Unwrappable<DBCo
}
@Override
- public DBCompareExpr copyCommand(DBCommand cmd)
+ public DBCompareExpr copy(DBCommand newCmd)
{
- return new DBParenthesisExpr(wrapped.copyCommand(cmd));
+ return new DBParenthesisExpr(wrapped.copy(newCmd));
}
@Override
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 8d258b5..317ef0d 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
@@ -117,11 +117,11 @@ public class DBSetExpr extends DBExpr
* Copy Command
* @param cmd
*/
- public DBSetExpr copyCommand(DBCommand cmd)
+ public DBSetExpr copy(DBCommand newCmd)
{
Object valueCopy = value;
if (value instanceof DBCmdParam)
- valueCopy = cmd.addParam(DataType.UNKNOWN,
((DBCmdParam)value).getValue());
+ valueCopy = newCmd.addParam(DataType.UNKNOWN,
((DBCmdParam)value).getValue());
return new DBSetExpr(column, valueCopy);
}