How To: Generate JPA JavaBeans
From jVantage
- Note: this tutorial is currently under construction.
This tutorial shows how to visually build a jVantage application, and then automatically generate a JavaBean JAR that can be used to communicate with your application's database using Hibernate or TopLink.
As described elsewhere on this site, one of the unique aspects of jVantage is that it not only allows developers to create applications visually, from a business model perspective, it also provides everything that is necessary to create an application - from the database schema to the user interface. Another important characteristic of jVantage is that it is not a code generator. Instead, when you build applications with jVantage, you are actually creating metadata that describes and captures the behavior of your application. This means that there is no round-trip development cycle that is typical of rapid application development tools that are based on code generation. In the end, we believe that this is the best of both worlds. jVantage applications are maintained from within the visual development environment, and any custom code that is created to implement business specific logic is invoked from within your jVantage applications.
Having said all of this, as we have used jVantage over the years ourselves, we have found that it is often desirable to create business logic that works in concert with jVantage applications, but which utilizes object/relational persistence services such as Hibernate or TopLink. This scenario allows developers to leverage jVantage to handle most of the user interface and presentation aspects of their web applications, but allows business logic to be written and maintained entirely independently of jVantage.
Since the introduction of the EJB3 specification, jVantage has been fully ported from EJB 2.n to EJB3 at a grassroots level. As part of this upgrade, we have implemented a feature that allows jVantage to create all the artifacts needed to utilize hibernate or TopLink very easily; in fact, with only a few mouse clicks.
Overview
The following diagram shows how jVantage works in conjunction with JPA.
An explanation of the diagram.
- Applications built with jVantage are largely stored in the database as metadata.
- Those applications then run by leveraging that metadata and any custom code created externally. The application stores its regular application data in a database like any other application.
- Since application behavior, as well as the object model used by those applications, is embodied in the meta information that jVantage has created, jVantage is able to produce a JAR that contains JPA-annotated JavaBeans that reflect the application's object model, which can then be leveraged for any other Java development.
- Business logic created external to jVantage via traditional Java development (using an IDE such as NetBeans or Eclipse), can then leverage the generated JavaBean library to interact with the database using a JPA implementation such as Hibernate or TopLink.
- The generated JPA-annotated JavaBean JAR contains no references or dependencies on jVantage at all - the JavaBeans are standard POJO's and the JAR is completely independent of jVantage. In fact, it is possible to utilize the jVantage development environment to create an object model from which a JPA JAR is generated, and then completely disregard the jVantage application itself.
- Note: this tutorial is in progress

