Table of Contents
Introduction#
Makumba supports mainly two query languages: the native Makumba Query Language (MQL) and the Hibernate Query Language (HQL) .MQL#
MQL was developed as a sum of the most useful aspects of OQL and HQL. As such is it based on HQL in many regards (see the reference documentation), except following:
- it accepts boolean projections: SELECT a=1 AS col1 ... etc
- selecting an object will lead in selecting the external form of its Makumba pointer
- it works with Makumba DataDefinitions instead of Hibernate mappings
- like HQL, it supports subqueries in the style of e.g. MySQL
- since Makumba only has set (equivalent of Hibernate bag), some of the HQL constructs like indices() don't make sense.
- some of the HQL functions are not yet implemented (e.g. current_date())
MQL Functions#
MQL provides support for functions that will translate into SQL functions. Currently, the following functions are supported:
String functions#
name | argument(s) | result type | description |
---|---|---|---|
lower | (str) | string | Converts the string argument to lower case |
upper | (str) | string | Converts the string argument to upper case |
trim | (str) | string | Remove leading trailing spaces. |
ltrim | (str) | string | Remove leading spaces. |
rtrim | (str) | string | Remove trailing spaces. |
concat | (str1, str2, ...) | string | Concatenates two or more strings |
concat_ws | (separator, str1, str2, ...) | string | Concatenates two or more string with the given separator |
substring | (str, position [, length]) | string | Takes a substring of the given string |
replace | (str, fromStr, toStr) | string | Replace occurrences of a specified string |
reverse | (str) | string | Returns the string str with the order of the characters reversed. |
ascii | (str) | int | Return numeric value of left-most character. |
character_length | (str) | int | Return number of characters in the string argument. |
format | (int) | string | Return a number formatted to specified number of decimal places |
Date functions#
name | argument(s) | result type | description |
---|---|---|---|
dayOfMonth | (date) | int | Return the day of the month (0-31). |
dayOfWeek (alternatively: weekday) | (date) | int | Return the weekday index of the argument. |
week | (date) | int | Return the week number. |
dayOfYear | (date) | int | Return the day of the year (1-366). |
year | (date) | int | Return the year from the date argument. |
month | (date) | int | Return the month from the date argument. |
hour | (date) | int | Return the hour from the date argument. |
minute | (date) | int | Return the minute from the date argument. |
second | (date) | int | Return the second from the date argument. |
extract | (unit FROM date) | int | Extracts parts from the date. For example: SELECT EXTRACT(YEAR_MONTH FROM '2009-07-02 01:02:03'); -> 200907. See the MySQL Documentation ![]() |
monthName | (date) | string | Return the name of the month. |
dayName | (date) | string | Return the name of the day. |
last_day | (date) | string | Return the name of the day. |
current_date | date | Return the current date. | |
current_time | date | Return the current time. | |
current_timestamp (alternatively: now) | date | Return the current date and time. | |
dateAdd | (date, int, INTERVAL unit) | date | Adds the amount of the second argument to the date. Example: dateAdd(now(), 2, 'hours'). Available from Makumba >= 0.9, works only for MySQL; see the MySQL Documentation ![]() |
dateSub | (date, int, INTERVAL unit) | date | Substracts the amount f the second argument from the date. See dateAdd. |
Note
Support for new functions is normally easy to add, so if you miss specific functions, please just mail the makumba developers!
HQL#
Makumba supports HQL as a query language. Please check its reference documentation.
In order to use HQL in Makumba JSPs pages, the following TLD declaration should be used:
<%@taglib uri="http://www.makumba.org/view-hql" prefix="mak" %>