Every Database Function

Use the power of your database in your code

Use Functions From Every Database

Expressions give you the ability to make complex comparisons and transformations easily and reliably


QueryableDatatypes, like the DBString marq.name above, provide excellent methods for normal queries, but sometimes you need more than a simple comparison with known values. DBExpressions like StringExpression, NumberExpression, and DateExpression add all the functions you expect from a database and many more

Starting an expression is easy: either use the column() method of the DBRow class shown above, or use the static value() method of the appropriate expression class — for instance, StringExpression.value("a string")


The column() method uses a fairly common DBvolution pattern: supplying a DBRow instance and a field of that instance. A good example would be "this.column(this.aField)". With the column() method it produces an expression that encapsulates the concept of the particular column and references it in the query


When you need to start your expression with a non-database variable use the value() method. Value() is available for all the common expression types: BooleanExpression, DateExpression, NumberExpression, and StringExpression. The returned object is an expression of the correct type from which you can build your full expression. You won't need the value() method often as expression methods automatically handle common java types


Expressions use a fluent API to allow readable expressions and to maintain type safety. As you extend the expression it automatically switches to the the correct type and presents you with the operations that are allowed for that type. For instance, you can't accidentally compare a String and a Date as there is no StringExpression.is(Date) or DateExpression.is(String), and your IDE or compiler will identify the problem long before anything is sent to the database

To use an expression within a DBQuery or DBTable you need the addCondition() method and a BooleanExpression


A BooleanExpression is created by the many comparison methods within the other expression types: is(), isBetween(), isIn(), isNot(), isLessThan(), isLike(). Most of the methods start with "is" so they are easy to spot

You can also combine BooleanExpressions using the anyOf() and allOf() methods. Or invert them using the not() method. There are also the static trueExpression() and falseExpression() methods when you already know the answer


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