.NET
  Home arrow .NET arrow Page 3 - Providing a Complete Data Persistence Solu...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Providing a Complete Data Persistence Solution
By: Dwight Peltzer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2005-04-27

    Table of Contents:
  • Providing a Complete Data Persistence Solution
  • A Mapping Architectural Overview
  • Mapping Tool Types
  • Writing XML, Reading from Java

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Providing a Complete Data Persistence Solution - Mapping Tool Types


    (Page 3 of 4 )

    Mapping tools fall into two distinct categories: (1) developmental tools and (2) plug-and-play tools. JNBridge LLC provides a developmental tool called JNBridge Pro. It provides bi-directional connectivity to and from Java and .NET. Another tool, called JSQLMapper from JNetDirect, offers plug-and-play connectivity to SQL Server 2000 from Java and vice versa. JSQLMapper is the tool we will now focus on.

    Currently, three approaches exist for calling Java code from .NET and vice versa: (1) socket communication, (2) XML and SOAP, and (3) bridging technologies. SOAP is an XML-oriented approach that supports schemas such as XSD and Relax NG schemas. Schemas validate XML document instances by providing document structure, enforcing business model rules, and facilitating the creation of user-defined data types when needed. Additionally, JSQLMapper achieves bi-directional mappings through support for Remote Method Invocation calls.

    JNetDirect provides a well-written tutorial that leads users through the steps of mapping data to a relational database such as SQL Server 2000. Let’s walk through the tutorial. Be sure to start the JSQLMapper GUI in tutorial mode by issuing the following command:

    JSQLMapper_Tutorial

    JSQLMapper’s wizard allows you to create a new mapping or load a pre-existing mapping. The second wizard page connects to a database provided especially for the tutorial. The drop-down list provides a list of drivers from which you choose the driver appropriate for your object-to-relational database mapping:

               • JNetDirect             • DB2
               • PostgreSQL             • MySQL (Connector/J) 
               • Oracle                 • Custom 
               • Microsoft SQL Server   • Tutorial

    Once you have made your choice, the connection to the tutorial database is established. After providing a user ID and password (sa), a list of tables residing within the database is displayed so you can select and add tables via a user-friendly GUI. Typically, because the tables exist in hierarchical format, the first table added is referred to as the Root table. Subsequently, all tables added after the root table are considered child tables of the root, thereby setting up a parent/child relationship. This makes it easy to set up your primary key/foreign relationships.

    The tutorial lists four tables for your convenience: Customer, Invoice, Item, Product.

    JSQLMapper requires each database row to contain a globally unique ID (GUID). The wizard allows you to select columns that comprise the table’s primary key. The wizard screen is divided in two panes. The left pane displays all fields residing in a table, whereas the right pane represents key fields selected by the user.

    The next wizard allows you to select a key generator. For example, when JSQLMapper inserts new rows into the table, it utilizes the key generator to generate a key value for the new row. JSQLMapper provides a list of key generators that represent the type of identity key associated with a specific relational database. For example, DB2’s identity key generator differs from Microsoft’s identity key generator.

    Once the key is generated, you need to define how the table is related to its parent. You accomplish this by identifying the primary key/foreign key relationship. In the event JSQLMapper is unable to determine the key relationship, you can do it manually. It is also possible to define a compound key as mandated by dataset rules.

    Once you finish adding tables and establishing relational key mappings, JSQLMapper allows you to test the mapping without writing any code. If everything is properly defined, a new wizard window allows you to restrict your test dataset using a standard SQL WHERE clause. Enter where id = 0 to restrict your dataset to the first table, in this case Invoice. Finally, select the "read" button to have your dataset printed in XML format. This verifies that JNetDirect provides support for the Relax NG Schema as a core component of their technology.

    More .NET Articles
    More By Dwight Peltzer


     

    .NET ARTICLES

    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek