Accessibility
Maik Schumacher

Maik Schumacher

Adobe Consulting

Table of Contents

Created:
27 October 2008
User Level:
Beginner
Products:
Flex Builder
BlazeDS

Put it all together: Adobe Flex, BlazeDS, and Hibernate JPA on Tomcat and MySQL

This article demonstrates how to create and run a simple Flex application that is connected to a relational database using the Hibernate implementation of the Java Persistence Architecture (JPA). It guides you through all steps required to create and run a sample application including setup of the required software.

The Hibernate website says this about Java Persistence with Hibernate:

The Java Persistence API is the standard object/relational mapping and persistence management interface of the Java EE 5.0 platform. As part of the EJB 3.0 specification effort, it is supported by all major vendors of the Java industry.

Hibernate implements the Java Persistence object/relational mapping and persistence management interfaces with the Hibernate Annotations and Hibernate EntityManager modules, on top of the mature and powerful Hibernate Core.

The Hibernate modules can be stacked and combined as desired. You can use the Hibernate Java Persistence provider in any environment, Java SE 5.0 or Java EE 5.0. The Hibernate Java Persistence provider is fully certified and passes the Sun TCK (Technology Compatibility Kit).

The sample application makes use of the following software and technology:

  • Eclipse 3.4 Ganymede
  • Adobe Flex Builder 3.0.1
  • Adobe Flex SDK 3.1
  • BlazeDS 3.0.1.1755
  • MySQL 5.0.67
  • Hibernate 3.3.1
  • Apache Tomcat 6.0.18
  • Sun Java JRE 1.6.0_07

The application uses a Flex front end to perform the following tasks:

  • Create new data records to a database
  • Read data from a database
  • Update existing data in a database
  • Delete data from a database

The application uses BlazeDS, a server-based Java remoting and Web messaging technology that enables developers to connect to back-end distributed data and push data in real-time to Adobe Flex and Adobe AIR applications. BlazeDS is an open source product. BlazeDS contains configurable channels that transport the data between the client and server. This article uses the Remote Procedure Call (RPC) Services (also called Flash Remoting) and Action Message Format (AMF).

AMF is a binary format for data serialization/deserialization and remote method invocation. It improves performance by dramatically compressing the size of data transferred and parsing binary data into objects in memory far more efficiently than parsing XML data.

This article is written for Java and Flex developers who want to learn more about integrating Flex with Java or vice versa. It follows a very practical approach and guides the reader through all steps needed to create a simple Web application; it includes all the code and configuration settings that are required to deploy and launch the application.

Flex developers will get a better understanding of the back end where the Java code communicates with the database, and Java developers will get a better understanding of the Flex coding in the front end.

Requirements

In order to make the most of this article, you need the following software and files:

Adobe Flex Builder 3 Eclipse Plug-in

Flex 3 SDK

BlazeDS

Eclipse

Hibernate

Apache Tomcat

MySQL

MySQL Connector/J

Java Runtime Environment (JRE)

Sample files:

Prerequisite knowledge

Some working knowledge of Eclipse and the Adobe Flex Builder will be helpful to build the application. Some Java and Flex background will help as well, but even with no any Java or Flex background you can still build the application from the available source code.

About the author

Maik Schumacher is a Senior Consultant at Adobe Consulting in Cologne, Germany. Maik has several years of professional experience in the field of information technology, mainly working on Web based solutions and software architectures using Java and J2EE technologies as well as Adobe Flex.