Blame | Letzte Änderung | Log anzeigen | RSS feed
<com:TContent ID="body"><h1>Mapped Statements</h1><p>Mapped Statements can hold any SQL statement and can use Parameter Maps andResult Maps for input and output. (A stored procedure is a specialized form ofa statement. </p><p>If the case is simple, the Mapped Statement can reference the parameter andresult classes directly. Mapped Statements support caching through referenceto a Cache Model element. The following example shows the syntax for astatement element.</p><com:TTextHighlighter Language="xml" CssClass="source"><statement id="statement.name"[parameterMap="parameterMap.name"][parameterClass="class.name"][resultMap="resultMap.name"][resultClass="class.name"][listClass="class.name"][cacheModel="cache.name"]>select * from Products where Product_Id = [?|#propertyName#]order by [$simpleDynamic$]</statement></com:TTextHighlighter><p>The <tt>[bracketed]</tt> parts are optional, and someoptions are mutually exclusive. It is perfectly legal to have a MappedStatement as simple as shown by the following example.</p><com:TTextHighlighter Language="xml" CssClass="source"><statement id="InsertTestProduct" >insert into Products (Product_Id, Product_Description) values (1, "Shih Tzu")</statement></com:TTextHighlighter><p>The above example is obviously unlikely, unless you are running atest. But it does shows that you can use SQLMap to execute arbitrary SQLstatements. More likely, you will use the object mapping features with<a href="?page=Manual.ParameterMap">Parameter Maps</a> and<a href="?page=Manual.ResultMaps">Result Maps</a> since that's where the magic happens.</p><h2>Statement Types</h2><p>The <tt><statement></tt> element is a general "catch all" element that can beused for any type of SQL statement. Generally it is a good idea to use one ofthe more specific statement-type elements. The more specific elements providedbetter error-checking and even more functionality. (For example, the insertstatement can return a database-generated key.) The following tablesummarizes the statement-type elements and their supported attributes andfeatures. </p><!-- tabular: align=|l|l|l|l|, width=(0.2 0.2 0.2 0.2) --><table class="tabular"><tr><th>Statement Element</th><th>Attribute</th><th>Child Elements</th><th>Methods</th></tr><tr><td><tt><statement></tt></td><td><tt>id</tt><br /><tt>parameterClass</tt><br /><tt>resultClass</tt><br /><tt>listClass</tt><br /><tt>parameterMap</tt><br /><tt>resultMap</tt><br /><tt>cacheModel</tt></td><td>None</td><td><tt>Insert</tt><br /><tt>Update</tt><br /><tt>Delete</tt><br />All query methods</td></tr><tr><td><tt><insert></tt></td><td><tt>id</tt><br /><tt>parameterClass</tt><br /><tt>parameterMap</tt></td><td><tt><selectKey></tt><br /><tt><generate></tt></td><td><tt>Insert</tt><br /><tt>Update</tt><br /><tt>Delete</tt></td></tr><tr><td><tt><update></tt></td><td><tt>id</tt><br /><tt>parameterClass</tt><br /><tt>parameterMap</tt><br /><tt>extends</tt></td><td><tt><generate></tt></td><td><tt>Insert</tt><br /><tt>Update</tt><br /><tt>Delete</tt></td></tr><tr><td><tt><delete></tt></td><td><tt>id</tt><br /><tt>parameterClass</tt><br /><tt>parameterMap</tt><br /><tt>extends</tt></td><td><tt><generate></tt></td><td><tt>Insert</tt><br /><tt>Update</tt><br /><tt>Delete</tt></td></tr><tr><td><tt><select></tt></td><td><tt>id</tt><br /><tt>parameterClass</tt><br /><tt>resultClass</tt><br /><tt>listClass</tt><br /><tt>parameterMap</tt><br /><tt>resultMap</tt><br /><tt>cacheModel</tt><br /><tt>extends</tt></td><td><tt><generate></tt></td><td>All query methods</td></tr><tr><td><tt><procedure></tt></td><td><tt>id</tt><br /><tt>parameterClass</tt><br /><tt>resultClass</tt><br /><tt>listClass</tt><br /><tt>parameterMap</tt><br /><tt>resultMap</tt><br /><tt>cacheModel</tt></td><td>None</td><td><tt>Insert</tt><br /><tt>Update</tt><br /><tt>Delete</tt><br />All query methods</td></tr></table><h2>Stored Procedures</h2><p>TODO</p></com:TContent>