Coordonnées

A proposActualitésProductsPresseEvaluation/Download Recherche

   

JDX,

THE POWERFUL JAVA OBJECT-RELATIONAL MAPPING TECHNOLOGY

     
PRESENTATION
  Overview
  System requirements
  Customers
  Features
WHAT'S NEW?

PRODUCTS

LICENSE AGREEMENT
DOWNLOAD
HOW TO BUY?
SUPPORT
 
______________________________________________________________________

Presentation: Features

JDX provides a natural object-oriented interface to relational data. JDX uses a clean, non-intrusive programming model.

By using JDX, you...

  • Accelerate development lifecycle by avoiding tedious, time-consuming and error-prone tasks of low-level JDBC/SQL programming for persistence of business objects.

  • Accelerate data movement by using JDXs fine-tuned object-relational mapping engine.

  • Accelerate your Java/Servlets/JSP/EJB projects by concentrating on business logic instead of wasting time on infrastructure details.

 

 

Issues

Object-oriented programming (OOP) has become the dominant programming paradigm these days. In OOP languages(e.g. Java, C++), a class encapsulates the structure and behavior of objects of a certain type. Business objects are easier to represent as instances of classes. Examples of business objects are Quotations, Purchase orders, Customer information, Invoices, Patient records, Drug information, Configuration information, Product information, Pricing information, Sales transactions, etc. However, the applications that create and manipulate these objects can come and go. One common need for virtually all business applications is the persistence (stable storage) of business objects. The options for persistent storage are file systems, object-oriented databases and relational SQL databases (RDBMS). For simple, non-mission critical applications requiring low data volume, a file system solution may be sufficient. However, for high-performance, scaleable, transactional and, robust applications, a database management system is required for storing business objects. In spite of recent advancements in object-oriented databases, a recent study has shown that only a small fraction of the corporate data resides in these kinds of databases. The rest resides in the trusted relational databases. Corporations feel comfortable with the maturity of the RDBMS technology and the availability of numerous third-party tools for analyzing and managing the data in RDBMS. It is only natural that application and tools developers would like to represent the business objects in object-oriented languages like Java and at the same time use relational databases for the persistence of those objects.

Since there is already a lot of data residing in relational databases, it is also very important that the existing data may be used in new object-oriented applications.

Data is stored in rows of tables in a relational database. All rows of a table have a fixed number of typed columns. In other words, a table is a collection of the same kind of rows. There is a uniformity to the way data is stored in relational databases. However, data in class objects may not be represented in a flat structured way. In general, an object may have complex structure such that an attribute of an object may reference an object (or a collection of11 objects) of another kind. Further, a referenced object may reference another set of objects. Now some of these referenced objects may really be integral part of the containing object (for example, a purchase order may contain multiple line items). When a complex object needs to be made persistent in a relational database, different components of the object may need to be put in different tables because each table can store only one kind of row (object). It is also possible to independently store a component of an object but later on that component should be retrievable as part of the containing object. There is an inherent paradigm-mismatch between an object-oriented model and relational model. However, there is a genuine need to use relational databases to store business objects. How to bridge this gap ?

  1. First need is to easily define the mapping between the object model and the relational model.

  2. The second need is to store this mapping information such that it can be used most naturally and conveniently.

  3. Thirdly, there is need for a product to understand this mapping and do appropriate translation between the object and relational data. That also includes the functionality of generating the relational schema definition given the class definitions and the mapping information.

  4. And finally, there is need for defining an intuitive application programming interface (API) which will make the task of a programmer easier by relieving him of the burden of generating low-level SQL statements to store/get the object data into/from the relational database.


With JDX, Software Tree proposes an innovative way to define the mapping between an object model and a relational model. They also describe an API that can effectively be used by application programmers to meet their object persistence needs using an RDBMS.

The following discussion assumes Java as the OOP language.

 

Why JDX? Why can't we use JDBC to store Java objects in RDBMS?

JDBC is a Java application programming interface to SQL databases defined by JavaSoft. Although a useful technology, use of JDBC forces the application developers to generate SQL statements explicitly. This requires a lot of hand-coding of SQL statements and processing the results. It is a very mundane and time-consuming job.

Just to give an idea of how JDX can simplify the program development task of retrieving Java objects from the database, here is an example of appropriate code segments - one using JDBC and the other using JDX. For this example, we assume 2 classes - Title and RoySched (Java class definitions). Each Title object has an array of RoySched objects. Primitive attributes of Title objects come from titles table and that of RoySched objects come from roysched table. We are trying to retrieve Title object(s) corresponding to a title_id stored in a String variable 'tid'.

JDBC Code

// Assuming a Connection object 'con' has been obtained to the database

// Retrieve the Title object


Statement stmt = con.createStatement();

// First fetch the titles table row

String query = "SELECT title_id, type, price, title, ytd_sales, pub_id," +

" pubdate, royalty, advance, notes FROM titles" +

" WHERE title_id = '" + tid + "'";


ResultSet rs = stmt.executeQuery(query);

Title title = new Title();

while (rs.next()) {

title.title_id = rs.getString("title_id");
title.type = rs.getString("type");
title.price = rs.getBigDecimal("price", 2);
title.title = rs.getString("title");
title.ytd_sales = rs.getInt("ytd_sales");
title.pub_id = rs.getString("pub_id");
title.pubdate = rs.getTimestamp("pubdate");
title.royalty = rs.getInt("royalty");
title.advance = rs.getBigDecimal("advance",2);
title.notes = rs.getString("notes");
break; // Simplifying assumption - only one row is returned.

}


// Now fetch all the corresponding roysched table rows

Vector royScheds = new Vector();

RoySched roySched;


query = "SELECT title_id, lorange, hirange, royalty FROM roysched" +

" WHERE title_id='" + title.title_id + "'" +

" ORDER BY royalty";


rs = stmt.executeQuery(query);

while (rs.next()) {

roySched = new RoySched();
roySched.title_id = rs.getString("title_id");
roySched.lorange = rs.getInt("lorange");
roySched.hirange = rs.getInt("hirange");
roySched.royalty = rs.getInt("royalty");
royScheds.addElement(roySched);

}

stmt.close();


// Initialize title's royscheds attribute with the collection of roysched objects

title.royscheds = new RoySched[royScheds.size()];

royScheds.copyInto(title.royscheds);


JDX Code


// Assuming a handle 'jdx' to the JDX service object has been obtained.

// Retrieve the Title object(s). In general, many qualifying

// objects may be returned.


Vector queryResults = jdx.query("Title", "title_id = '" + tid + "'", -1, 0, null);

Title title = (Title) queryResults.firstElement();

That's it! Similar efficiencies are also gained for inserting, updating or deleting objects. JDX improves program development process by eliminating the need for hand-coding of SQL statements. The resulting code is very intuitive, simple and, easy to maintain.

 

Issues to consider while using raw JDBC

  • Generation of SQL statements (SELECT, INSERT, UPDATE and DELETE) for each class
    Do you have to write these statements manually?
    What if you have hundreds of classes for your application?

  • Hard coding of database column names Aaargh!

  • What if a new attribute is added to a class?
    All corresponding statements have to be updated.

  • What if an attribute name changes?
    All corresponding statements have to be updated.
  • What if an attribute type changes?
    The getXXX call has to be changed appropriately. May involve database changes also.

  • What if a class hierarchy is involved (e.g., a class PoliticalTitle may inherit from Title and its objects may come from a different table)?
    We have to potentially collect objects from multiple tables. Lots of changes at many levels.

  • What if the class structure is more complex (more references, more levels)?
    The code becomes exponentially complex!

  • What if we want to do directed queries for a complex object (i.e., follow some references and ignore a few of them etc.)?
    How to specify such a query?
    Do we repeat the hard-coded SQL statements in different parts of the code?

  • How about directed insert, update, and delete operations?
    Same issues as above.

  • Can you easily define a notion of an object contained by value or by reference?

  • How scaleable is such an implementation?
    Each application has to get its own connection to the database.
    The application process is directly talking to the database server which may be many networking hops away.

  • How easy is the code to share between multiple applications?

  • Does each programmer in the team have to know where different components of an object are stored and how they are connected (primary keys, foreign keys)?

  • What if you want to use a new JDBC driver?
    Do all JDBC drivers behave the same? Do they map uniformly?

  • Do you have tools to generate schema definition given your class definitions?

  • Can you define Java classes based on existing relational data?

  • What if you want to move your application to a different backend database?
    Schema generation tool. Use of different JDBC drivers.

  • Do you like mixing SQL with Java?
    Paradigm mismatch between object and relational views.

  • How easily can this code be maintained/enhanced?
    How much time is spent developing, debugging and enhancing this type of code?
    Would you rather be devoting more time to business logic?

  • How thick you want your application/applet to be?
    All object-relational mapping code and the JDBC driver code may be attached to your application/applet.

 

JDX Solution

JDX provides a natural object-oriented interface to relational data. JDX uses a clean, non-intrusive programming model - it does not change your Java code by pre-processing or post-processing it!

Essentially, there are 3 simple steps to use JDX :

  1. Define business objects (Java classes)

  2. Define object-relational mapping

  3. Develop your applications using intuitive and powerful JDX APIs

 


  JDX and J-Database Exchange are registered trademarks of Software Tree, Inc.
   
Last update: 02/04/2002