Free your ARTS Domain Model from aging technology
Complex enterprise applications can become trapped on outdated technology due to the cost and complexity of porting to more advanced technology. Breaking free of aging technology isn’t easy, but for retailers this problem has been made a lot easier to solve. This article shows how to quickly build the persistence layer for an application from an ARTS (Association of Retail Technology Standards) compliant database schema.
This article is based on an actual project that Starmount Sytems undertook to develop a Mobile Point of Sale solution. The task of creating the persistence layer from the ARTS schema seemed daunting. It was originally estimated to be at least 700 hours of work and the time to complete it was very short. This was one of the biggest risks to the success of the project. Using the techniques described here, the actual work was completed in 150 hours over 9 days.
In addition to new projects, an ideal application of this solution would be for a project with the goal of retooling an existing Enterprise Java Beans (EJBs) architecture. In many EJB applications the line between business logic and persistence layer is blurred across session beans and entity beans, making it difficult to isolate those parts of the application architecture. The application server also tends to become an integral part of the application rather then an enabling technology making if difficult to port the application to another technology or even update to a newer version of the application server. This solution clearly isolates the persistence layer of the application, eliminating the need for entity beans and allows business logic to be encapsulated in Spring based services or traditional session beans.
The enabling technologies for this solution are JPA (Java Persistence API) and Hibernate. JPA and Hibernate handle the bulk of the work by generating a set of model classes (or Data Transfer Objects DTOs) and a set of DAO’s (Data Access Objects). The classes generated by the JPA/Hibernate tools form a working persistence layer, however the names of the classes and variables are based on the database table and column names. Anyone familiar with the ARTS schema will know that those names are not easily readable. The labor intensive part of this process is to rename all the classes and variables as well as references to them. One very beneficial characteristic of the ARTS schema is that the meta data for the tables and columns contains a value in the Remarks column that contains an ideal name that can be used to rename the classes and variables from their ARTS names. The renaming process is handled by a set of Starmount Systems custom Java classes.
The entire process is described in detail here.
- Use HibernateToolTask to generate the base classes from the schema.
- Download http://downloads.jboss.org/hibernate/caveatemptor/jpwh-gettingstarted-070401.zip.
- The README.txt in the helloworld-reverse directory will show general instructions on using the utility.
- Customize the build scripts and configuration files to work with the target database.
- After the ant script completes a set of model and DAO java classes will exist.
- Run the Starmount Systems Domain cleanup scripts to convert the ARTS class names and variables into readable names. The scripts are too lengthy to post here but they are available by request. Contact the author, Greg Bondy at gbondy@starmountsystems.com. This is what the scripts will do:
- The model class and all of the attributes are renamed from the ARTs name to a proper variable name.
- A DAO interface is generated.
- The DAOJpa classes are renamed from the ARTs name to a proper class name.
- A DAO TestNG testcase is generated.
Following this process, there is some manual cleanup work that has to be done. Most of the manual work is within the TestNG testcases and there is an additional script that automates most of that work.
The end result is a complete Spring enabled JPA/Hibernate persistence layer with a complete set of Model/DTO classes and a set of functional test cases to verify the implementation. The entire implementation can be completed by just a few developers in a matter of days. For anyone with a new or existing ARTS database schema this can be a great way to lay the foundation for an enterprise application that utilizes state of the art persistence technology and provides a well defined boundary between the server side business logic and the persistence layer.
Posted in: Development, Main



