Add Value To Your Data

Let the database do the processing for you

Column Expressions Create Information

Expressions can also be used to create new values from the database values automagically, allowing you to change the data type of column, retrieve dynamic values, or transform the data before it reaches your java code

For instance we had a database that used integers to store dates in a non-standard way. To get the correct dates automatically we created the field normally then used an expression column to get the value as a date. To simplify the process of transforming dozens of dates, we placed the expression in a custom QDT

Here's what it looked like in the DBRow:

public DBInteger dateReconciled = new DBInteger();

public DBDateOnlyKappa dateReconciledAsDate =
new DBDateOnlyKappa(this.column(this.dateReconciled));

And the custom QDT was:

public class DBDateOnlyKappa extends DBDateOnly{

public DBDateOnlyKappa(NumberExpression originalColumn) {
super(DateExpression.value(new Date(-1, 11, 31)).addDays(originalColumn.minus(693901)));

This is a real example of the power provided by QueryableDatatype's expression column functionality

Expression columns create a column from the expression when the DBQuery is run. since it is a DBExpression everything that is available to an expression is available as a data column

A particularly good example of this is accessing dynamic values from the database like current user, database system time, or the next value in a sequence

public DBDate systemDate = new DBDate(DateExpression.currentDate());

public DBString systemUser = new DBString(StringExpression.currentUser());

public DBNumber nextValue = new DBNumber(NumberExpression.getNextSequenceValue("MySequence"));

This is also highly valuable to provide Map/Reduce-like functionality where the query examples provide the Reduce behaviour and the expression columns provide the Mapping

When you want DB to be easier and faster...

Get DBvolution from GitHub or Maven

DBvolution is the gateway to your database and high-speed querying
  Contact us now for details
  +64 27 444 5201
Support us on Patreon
  • Gregory Graham
  • DBvolution