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 --- .../rdb-das-cpp-workingwithnamemapping.html | 145 +++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 site/trunk/site-publish/rdb-das-cpp-workingwithnamemapping.html (limited to 'site/trunk/site-publish/rdb-das-cpp-workingwithnamemapping.html') diff --git a/site/trunk/site-publish/rdb-das-cpp-workingwithnamemapping.html b/site/trunk/site-publish/rdb-das-cpp-workingwithnamemapping.html new file mode 100644 index 0000000000..f9565dfdbc --- /dev/null +++ b/site/trunk/site-publish/rdb-das-cpp-workingwithnamemapping.html @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + Apache Tuscany : RDB DAS CPP - WorkingWithNameMapping + + + + + + + + + + + + + + + +
+ + + + +   + +
+ + +
+
+ + + + + + + + + +
+  Apache Tuscany > Home > DAS Overview > DAS C++ > DAS C++ Documentation Menu > RDB DAS C++ - User Guide > RDB DAS CPP - WorkingWithNameMapping + + User List | Dev List | Issue Tracker   +
+ + + + + + + +
+ + +
+ +
+
+

WorkingWithNameMapping

+ +

The default behavior for the RDB DAS is to map database names to SDO names. So, if a CUTSOMER table is read from the database then each row will be represented as a CUSTOMER DataObject. Likewise, if the CUSTOMER tabel has columns (ID, LASTNAME, ADDRESS) then CUSTOMER DataObject instances will have properties (ID, LASTNAME, ADDRESS). Database Table names map to DataObject Type names and database column names map to DataObject property names.

+ +

This implicit mapping of database and SDO names woks well but some developers will want explicit name mapping that allows the database and SDO names to vary. One typical example is that the database table and column names will be automatically converted to uppercase when DAS generates the SDO Types, but a developer might want to work with SDO Types and properties that are camelcased. So, database names CUSTOMER and LASTNAME might map to SDO names Customer and lastName.

+ +

The RDB DAS allows this type of explicit mapping via configuration (usually in the form of a XML config file). The following example illstrates the use of this feature:

+
+
DAS* das = DASImpl::getFactory().createDAS(Config("BooksConfigWithAlias.xml"), getConnection());
+
+   CommandPtr select = das->getCommand("get book by ID equal 1");
+
+   DataObjectPtr root = select->executeQuery();
+   wstring author = root->getCString("Book[1]/Writer"));    delete das; 
+
+
+

Here is the associated configuration file:

+
+
<Config xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd">
+
+       <Command name="get all books" SQL="SELECT * FROM BOOK"/>
+
+       <Command name="get Cat in the Hat" SQL="SELECT * FROM BOOK WHERE NAME = 'Cat in the Hat'"/>
+
+       <Command name="get book by ID equal 1" SQL="SELECT * FROM BOOK WHERE BOOK.BOOK_ID = 1"/>
+
+       <Table tableName="BOOK" typeName="Book">
+           <Column columnName="BOOK_ID" primaryKey="true"/>
+           <Column columnName="AUTHOR" propertyName="Writer"/>
+           <Column columnName="OCC" collision="true"/>
+       </Table
+   </Config>
+
+
+
+
+
+ + +
+ + + + + + website stats + + + + + + -- cgit v1.2.3