|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsf.qof.parser.SqlParser
public class SqlParser
A parser to extract parameter and result definitions.
The SqlParser
is used to extract parameter and result defintions embedded
in the SQL statement.
Parameter definitions have the following form:
{%#}
or {type %#}
or {%#.field}
or {type %#.field}
#
is the index of the Java parameter (1..n)
field
is the name of the field in the mapped Java Bean object
type
is the optional name of mapper (int
, string
, etc)
Result definitions have the following form:
{%%}
or {type %%}
or {%%.field}
or {type %%.field}
or {%%*}
field
is the name of the field in the mapped Java Bean object
type
is the optional name of mapper (int
, string
, etc)
{%%*}
denotes the map key if the return result type is Map
In/out definitions for stored procedure calls have the following form:
{result definition,parameter definition}
or {parameter definition,result definition}
i.e. {%%,%1}
, {int %%.id,int %2}
For partial definitions add @#
at the end of the definition where #
is the part number.
Partial definitions are used for custom mapping adapters when more than one column or parameter maps to the
same Java object. If more than one definition with the same type are in the same SQL statement then a group
name in brackets is required at the end of the definition [group]
.
Examples:
select id {int %%.id,%%*}, name {string %%.name} from person where id = {int %1} insert into person (id, name) values ({%1}, {%2}) update person set name = {%2} where id = {%1} delete from person where id = {%1} { %% = call numberOfPersons({%1}) } { call inout({%1,%%}) } insert into person (id, first_name, last_name) values ({%1}, {name%2@1}, {name%2@2}) select width {measurement%%.width@1[width]}, unit_of_measurement_width {measurement%%.width@2[width]}, height {measurement%%.height@1[height]}, unit_of_measurement_height {measurement%%.height@2[height]}, length {measurement%%.length@1[length]}, unit_of_measurement_length {measurement%%.length@2[length]} from product
Constructor Summary | |
---|---|
SqlParser(String sql,
boolean isCallableStatement)
Instantiate and parse a SQL statement. |
Method Summary | |
---|---|
ParameterDefinition[] |
getParameterDefinitions()
Returns the extracted parameter definitions. |
ResultDefinition[] |
getResultDefinitions()
Returns the extracted result definitions. |
String |
getSql()
Returns the parsed SQL statement without parameter and result definitions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SqlParser(String sql, boolean isCallableStatement)
sql
- a SQL statementisCallableStatement
- true if the SQL statement is a store procedure call
SqlParserException
Method Detail |
---|
public ParameterDefinition[] getParameterDefinitions()
public ResultDefinition[] getResultDefinitions()
public String getSql()
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |