Md5
Definition
The md5
method allows you to add the MD5
function to the query. The MD5
function is used to calculate the MD5 hash of a string and returns the result in hexadecimal.
There are 2 ways to call this method:
1. Calling from a KColumn
or a KTableColumn
The only one method available to use this functionality calling from a KColumn
or a KTableColumn
is:
md5()
: It does not receive any parameters. TheKColumn
orKTableColumn
that invokes the method will be the one supplied to theMD5
function.
Example
Java code:
k
.select(
APP_USER.EMAIL.md5()
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
MD5(au.email)
FROM app_user au
Parameters:
- None
2. Calling from the KFunction
class
The methods available to use this functionality calling from the KFunction
class are:
md5(KColumn kColumn)
: Receives aKColumn
or aKTableColumn
which will be supplied to theMD5
function.md5(KValTextField kValTextField)
: Receives aKValTextField
which will be supplied to theMD5
function.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example: (KColumn)
Java code:
k
.select(
md5(APP_USER.EMAIL)
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
MD5(au.email)
FROM app_user au
Parameters:
- None
Example: (KValTextField)
Java code:
k
.select(
md5(val("A short text"))
)
.single();
SQL generated:
SELECT MD5(?1)
Parameters:
- ?1: "A short text"