Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
Enterprise Application Development Using Java Blend
Enterprise Application Development Using Java Blend

Object-oriented software development using Sun Microsystems' Java language has become an industry standard for building scalable enterprise client/server applications. Additionally, most online transaction processing (OLTP) applications developed today by enterprises use relational databases as a standard DataStore, forcing developers to be proficient in the details and intricacies of both relational database design and object-oriented programming. They also must contend with mapping objects to relational schema, object management and caching, object navigation, transaction and concurrency controls. However, until recently developing Java applications with relational databases has been a time consuming process for developers.

To simplify development of application programs that use the Java programming language objects and relational databases, Sun Microsystems is introducing a new software product called Java Blend. The primary goal of Java Blend software is to provide programmers with a tool to easily develop business applications entirely in Java. With Java Blend, developers aren't required to learn the details of relational databases or Structured Query Language (SQL).

Java Blend consists of a development tool and a run-time environment. The development tool provides bidirectional mapping that can be used to map existing relational schema into a set of Java classes or map an application model written in Java to a new database schema to store instances of Java classes. The run-time environment provides transparent and automatic conversion of database records to Java programming language objects and Java programming language objects to database records, object navigation, transactions, concurrency and object caching for high performance.

Java Blend understands a database schema and can automatically generate the default mappings based on the relationship information between the tables, whether it is one-one, one-many, many-many, foreign key or inheritance. Additionally, it features the advanced capability to modify mapping of views on multiple tables, mapping a Java class to multiple tables or multiple Java classes to one table. Features such as using different names and types in Java and the database for the same fields are also supported, of course.

Applications written in Java Blend are highly portable, not only because the code generated is 100% pure Java, but also because it is based on the Object Database Management Group (ODMG) standard for object/relational mappings and object databases. Java Blend uses JDBC to communicate to relational databases so that any database with JDBC support automatically becomes usable by Java Blend; it supports several major databases in its first release, and will support any JDBC or ODBC based database in later releases.

Java Blend supports optimistic concurrency as well as the traditional pessimistic locking. Use of the optimistic concurrency control mechanism allows Java Blend to detect the values that have changed in the program's memory and database since the last transaction began. This results in higher performance and scalability at run time.

Application development using Java Blend can be broken down into four main steps.

1. Object/Relational Mapping
Using the Java Blend tool, map your database schema to Java classes or vice versa. For example, if you had two tables - Customer and Orders - in your database that were defined by the data definition statements in Listing 1, Java Blend would generate the class definitions for Customer and Orders in Listing 2.

Java Blend automatically generates member variables for each column and accessors/mutators for each member variable. Java Blend also understands relations between tables and maps them as one-one, one-many or many-many relationships between Java classes depending on the relationship between the tables. It then generates appropriate accessors/mutators and other helper methods. For example, Java Blend figured out the one-many relationship between Customer and Orders and generated an accessor method getOrdersForCustomer that returns a collection of Orders objects and other helper methods, like addOrdersForCustomer and removeOrdersForCustomer for adding and removing Orders objects for a Customer.

Before products like Java Blend, these mappings had to be done manually by someone who understood both the data model and the object model. As this example shows, such a mapping can now be created automatically, including more complex one-many and many-many relationships.

2. Add Business Logic
Almost every business application will have some business logic. With Java Blend, the business logic can be added into the generated Java classes in the form of new methods or embedded in the accessors and mutators.

For example, the code snippet in Listing 3 shows how the method addOrdersForCustomer in class Customer can be modified to check the customer's credit history before placing the order.

3. Write Queries
Queries are often required in applications to extract data. Java Blend supports industry standard Object Query language (OQL) that has been defined by ODMG. OQL has a rich syntax that allows the writing of simple to complex queries to extract data in the form of Java objects from a relational database. For example, the following query will extract all the Orders objects with a unit price greater than $100:

Select O from Orders O Where O.unitprice > 100;

This query will be compiled using the Java Blend tool and then later instantiated in your program to get a collection of "Orders."

With OQL, queries are written using the object model, not the relational model. This makes it much more intuitive and easy for object-oriented programmers to use.

4. Write the Application
So far we have seen how the mapping works, where to add business logic and how to write an OQL query. Still missing, however, are ways to open and close the database, start and commit transactions and, a method of concurrency control.

Java Blend provides a set of Application Programming Interfaces (API) for database and OQL queries and transactions. The code snippet in Listing 4 demonstrates how some of these APIs can be used in a typical database application.

Notice that the open method takes a database URL, a user name and a password as arguments.

Starting the Transaction is as simple as creating an instance of the Transaction object and invoking the begin method. The begin method takes an argument that specifies the concurrency mode. In this case the transaction mode is optimistic. The value Transaction.PESSIMISTIC will start the transaction in the traditional locking mode.

The new and set methods on objects between the begin and the commit statements will result in changes in the relational database. For example, in this case a Customer object with customerid 1000 will be created as a row in the Customer table in the relational database.

With Java Blend software, even transactions are object-oriented, not relational oriented. This makes application development much easier for developers who are familiar with the object model but not as familiar with relational databases.

Java Blend software allows programmers to easily develop business applications entirely in Java without having to learn the details of relational databases or SQL. With Java Blend, writing Java applications that access relational databases has just become much easier.

If you would like more information on the Java platform or Java Blend software, visit http://java.sun.com, or call 1-888-THE-JAVA.

About Syed Q. Abbas
Syed Q. Abbas is a senior Java developer at Sun Microsystems in Menlo Park, CA. Syed received his master's degree in computer science from AMU Aligarh, India, and has worked in the software industry for eight years.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Latest Cloud Developer Stories
Swisscom, the Swiss telecom, is going into the cloud business. Its subsidiary Swisscom IT Services AG has signed up with Red Hat as a Certified Cloud Provider and launched a public cloud Infrastructure-as-a-Service (IaaS) cloud targeting enterprise-class customers primarily in ...
Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP)....
In a surprise move on Tuesday, January 10, Oracle wheeled out its Big Data Appliance. That’s the one it said in October would be ready sometime in the first half. Only nobody believed it meant early in the first half. Heck, it’s not even clear anybody thought Oracle could make ...
Rackspace Hosting, the service leader in cloud computing, on Thursday announced its acquisition of SharePoint911, an industry leader in SharePoint consulting, training, and "JumpStart" services within SharePoint. The unification of both companies provides capabilities to deliver ...
CloudLinux, Inc., on Thursday released CafeFS 3, a virtualized file system for shared hosters that cages each customer within its own virtualized file system. CageFS becomes part of CloudLinux OS at no additional charge. CloudLinux OS, the only commercially-supported Linux OS m...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE

Breaking Cloud Computing News

Aruba Networks, Inc. (NASDAQ:ARUN), a global leader in distributed enterprise netwo...