From 200a40b332420f94992eb39a6d0ea1cf1490ffc4 Mon Sep 17 00:00:00 2001 From: coreyg Date: Fri, 21 Nov 2014 09:30:19 +0000 Subject: Adding tuscany's website to their svn repo for svnpubsub git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1640879 13f79535-47bb-0310-9956-ffa450edef68 --- .../site-publish/named-parameters-support.html | 195 +++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 site/trunk/site-publish/named-parameters-support.html (limited to 'site/trunk/site-publish/named-parameters-support.html') diff --git a/site/trunk/site-publish/named-parameters-support.html b/site/trunk/site-publish/named-parameters-support.html new file mode 100644 index 0000000000..5c6601450a --- /dev/null +++ b/site/trunk/site-publish/named-parameters-support.html @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + Apache Tuscany : Named parameters support + + + + + + + + + + + + + + + +
+ + + + +   + +
+ + +
+
+ + + + + + + + + +
+  Apache Tuscany > Home > DAS Overview > DAS Java > DAS Java Documentation Menu > DAS Java Developer Guide > RDB DAS Java > RDB DAS - User Guide > Named parameters support + + User List | Dev List | Issue Tracker   +
+ + + + + + + +
+ + +
+ +
+
+

Named parameters support

+ +

JDB API requires indexed parameter setting. i.e. statement.setXXX(int, value). But in the DAS client
+it may be helpful to provide named parameters setting on the command. This is particularly convenient
+when the table involves many columns during insert/update.

+ +

Below are config schema portion supporting this.

+
+
<xsd:complexType name="Parameter">
+  <xsd:attribute name="name" type="xsd:string"/>
+  <xsd:attribute name="columnType" type="xsd:string"/>
+  <xsd:attribute name="direction" type="xsd:string" default="IN"/>
+  <xsd:attribute name="index" type="xsd:int"/>
+</xsd:complexType>
+<xsd:complexType name="Parameters">
+  <xsd:sequence>
+	<xsd:element maxOccurs="unbounded" minOccurs="0" name="Parameter" type="config:Parameter"/>
+  </xsd:sequence>
+</xsd:complexType>
+<xsd:complexType name="Create">
+  <xsd:sequence>
+    <xsd:element maxOccurs="1" minOccurs="0" name="Parameters" type="config:Parameters"/>
+  </xsd:sequence>
+  <xsd:attribute name="sql" type="xsd:string"/>
+</xsd:complexType>
+<xsd:complexType name="Update">
+  <xsd:sequence>
+    <xsd:element maxOccurs="1" minOccurs="0" name="Parameters" type="config:Parameters"/>
+  </xsd:sequence>
+  <xsd:attribute name="sql" type="xsd:string"/>
+</xsd:complexType>
+<xsd:complexType name="Delete">
+  <xsd:sequence>
+    <xsd:element maxOccurs="1" minOccurs="0" name="Parameters" type="config:Parameters"/>
+  </xsd:sequence>
+  <xsd:attribute name="sql" type="xsd:string"/>
+</xsd:complexType>
+<xsd:complexType name="Command">
+  <xsd:sequence>
+     <xsd:element maxOccurs="unbounded" minOccurs="0" name="Parameter" type="config:Parameter"/>
+     <xsd:element maxOccurs="unbounded" minOccurs="0" name="ResultDescriptor" type="config:ResultDescriptor"/>
+  </xsd:sequence>
+  <xsd:attribute name="name" type="xsd:string"/>
+  <xsd:attribute name="SQL" type="xsd:string"/>
+  <xsd:attribute name="kind" type="xsd:string"/>
+</xsd:complexType>
+
+
+ +

User can do Command.setParameter(String name, Object value), getParameter(String name). Indexed set/getParameter() is available as before. Also <create>, <update>, <delete> from Config support named parameters.

+ +

example config:

+
+
<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> 
+<Table tableName="CUSTOMER">  		 
+  <create sql="insert into customer values (?, ?, ?)" >
+    <Parameters>
+      <Parameter name="ID" index="1"/>
+      <Parameter name="LASTNAME" index="1"/>
+      <Parameter name="ADDRESS" index="3"/>
+    </Parameters>
+  </create>
+</Table>
+<Command name="createCustomer" SQL="insert into CUSTOMER values ( ?, ?, ?)" kind="Insert">
+   <Parameter name="ID" index="1"/>
+   <Parameter name="LASTNAME" index="2"/>
+   <Parameter name="ADDRESS" index="3"/>
+</Command>
+
+
+ +

if +ve index is specified in Parameter, it is used, else auto-increment is used. As List is an ordered collection, the sequence(index value) appearing in the cofig file will be maintained. Partially specifying indexes is not supported (i.e. give index for 2 out of 3 params and leave one without it, is not supported)
+Also, if indexes are specified, the ordering in config is flexible, i.e. below is valid.

+
+
<Command name="createCustomer" SQL="insert into CUSTOMER values ( ?, ?, ?)" kind="Insert">   
+   <Parameter name="LASTNAME" index="2"/>
+   <Parameter name="ID" index="1"/>
+   <Parameter name="ADDRESS" index="3"/>
+</Command>
+
+
+ +

Note Convention over config is followed, if Parameters are not defined in config, the sequence
+should match the table columns convention,else user should specify params on command in config and specify index attributes in them config

+
+
+
+ + +
+ + + + + + website stats + + + + + + -- cgit v1.2.3