Mapped Statements

Mapped Statements can hold any SQL statement and can use Parameter Maps and Result Maps for input and output. (A stored procedure is a specialized form of a statement.

If the case is simple, the Mapped Statement can reference the parameter and result classes directly. Mapped Statements support caching through reference to a Cache Model element. The following example shows the syntax for a statement element.

select * from Products where Product_Id = [?|#propertyName#] order by [$simpleDynamic$]

The [bracketed] parts are optional, and some options are mutually exclusive. It is perfectly legal to have a Mapped Statement as simple as shown by the following example.

insert into Products (Product_Id, Product_Description) values (1, "Shih Tzu")

The above example is obviously unlikely, unless you are running a test. But it does shows that you can use SQLMap to execute arbitrary SQL statements. More likely, you will use the object mapping features with Parameter Maps and Result Maps since that's where the magic happens.

Statement Types

The <statement> element is a general "catch all" element that can be used for any type of SQL statement. Generally it is a good idea to use one of the more specific statement-type elements. The more specific elements provided better error-checking and even more functionality. (For example, the insert statement can return a database-generated key.) The following table summarizes the statement-type elements and their supported attributes and features.

Statement Element Attribute Child Elements Methods
<statement> id
parameterClass
resultClass
listClass
parameterMap
resultMap
cacheModel
None Insert
Update
Delete
All query methods
<insert> id
parameterClass
parameterMap
<selectKey>
<generate>
Insert
Update
Delete
<update> id
parameterClass
parameterMap
extends
<generate> Insert
Update
Delete
<delete> id
parameterClass
parameterMap
extends
<generate> Insert
Update
Delete
<select> id
parameterClass
resultClass
listClass
parameterMap
resultMap
cacheModel
extends
<generate> All query methods
<procedure> id
parameterClass
resultClass
listClass
parameterMap
resultMap
cacheModel
None Insert
Update
Delete
All query methods

Stored Procedures

TODO