Menu

0.9.10 Fixes a SQL Server Issue and Adds Expressions To DBRows

Toaomalkster managed to find a funny little bug caused by MS SQL Server's interpretation of "get the date". All fixed now tho.

More importantly, or not if you use SQL Server, I've added the ability to add an expression to a QueryableDatatype during the initialisation of a DBRow class.

This is similar to adding a column expression to a query but it's permanently attached to the DBRow class like any other field. This makes it easy to perform calculations, do transformations, or just trim strings.

You can add criteria and access values on the expression just like a normal QDT. In fact is a normal QDT!

Here's the test class:

@DBTableName("marque")
public static class ExpressionRow extends DBRow {

    public static final long serialVersionUID = 1L;
    public static final String STRING_VALUE = "THis ValuE";

    @DBColumn
    DBDate sysDateColumnOnClass = new DBDate(DateExpression.currentDate());

    @DBColumn
    DBString stringColumnOnClass = new DBString(StringExpression.value(STRING_VALUE).uppercase());

    @DBColumn
    DBNumber numberColumnOnClass = new DBNumber(NumberExpression.value(5).times(3));

    @DBColumn("uid_marque")
    @DBPrimaryKey
    public DBInteger uidMarque = new DBInteger();

    @DBColumn
    public DBString name = new DBString();

    @DBColumn
    DBNumber marqueUIDTimes10 = new DBNumber(this.column(this.uidMarque).times(10));

}

The fields sysDateColumnOnClass, stringColumnOnClass, and numberColumnOnClass show expressions being set on DBDate, DBString, and DBNumber QDTs at initialisation. This means the QDTs will automatically generate the expressions' value for the SELECT and WHERE clauses.

Note the expression for marqueUIDTimes10: it shows how to change the columns of the row easily. This is really going to stress the expressions that are available so expect to see lots of improvements and extensions there.

This is an important step toward version 1.0 and I hope you like it.

Posted by Gregory Graham 2014-02-25

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.