The only commercial product in my toolbox is Visual Paradigm, a professional UML and modeling tool that integrates with the Netbeans IDE. If you are sincere about ERD, Use-Case and class models you should look at it. The available Netbeans plugins for UML could not convince me yet, too simple (but free). Visual Paradigm seems to operate at the other end, looks rather overloaded with functionality, but once you know what you want and where the function is located, you can create a nice workflow.
In this tutorial (created for internal purpose) I share the steps to create an EJB and the ERD model and let VP (Visual Paradigm) create the class source code for me.
Requirements:
- Netbeans 7.x
- Visual Paradigm (Professional Version)
You can download the 30 days trial, the free community edition is not sufficient.
Tutorial Part 1:
- Create EJB module ‘demoejb’
- Create the VP project file
If you have properly integrated NB and VP you should see this additional buttonsSelect the file view, select the project and click the VP icon
(It makes a difference ! If you select the project in the projects explorer and click the VP icon the file gets created under /src/vpproject and the code creation fails later on, not sure if this is a feature or a bug as of VP version 5.2) - Create a ERD diagram with our DB table layout
For this sample we will use the simple name-address sample
customer_name and customer_address (the tables are not complete, rather a base for the demo walk-through)
We use a UUID in all tables as primary key.customer_name
primary key: pk_customer_namecustomer_address
primary key: pl_customer_addressCreate a one-to-many relationship
Click the ‘one-to-many’ tool, then drag from customer_name to customer_address, and enter:
fk_customername_customeraddress as new column for the relationshipResulting ERD
- Create classdiagramm
Change the stereotype to entity bean for both classes
Final Class Diagram
- Synchronize with Netbeans (code creation)
Created package and classes
There is a bug in the code creation, the imports dont get properly created (as in current version 5.2)
Fix the problem manually by importing
import java.sql.Date;
import java.sql.Timestamp;You can check the Netbeans Settings in VP
- Add Eclipse library to project
(we need for JPA queries at a later stage) - Create Meta Model
Just clean and build will result in meta class created. - Create Persistence Unit ‘demoejbPU’
For now we use the default sample DB - Create Session Bean for Entity Class
in package facade - Final project structure
- Deploy the EJB
The tables get created (depending on your PU strategy)
Remarks:
- Even VP supports round-trips, means changes in the EJB class can be sync’d back to your VP project, I prefer to maintain all DB changes in VP and recreate class diagram and classes, you better dont touch the class asit gets overwritten.
- Be careful with deletions and name changes of columns, they are not ‘forwarded’ to your already existing classes (source code).
In Part 2 we will create a ZK client web application and tinker with different DB’s (Oracle and PostgreSQL). Stay tuned.



























[...] In part 1 of this tutorial we walk through the modeling and code creation of an EJB using Netbeans and Visual Paradigm. In part 2 we will create a simple sample ZK web application that reads data using the EJB. [...]
Pingback by Netbeans + Visual Paradigm = EJB Tutorial (Part 2) « The JavaDude Weblog — October 31, 2011 @ 4:00 pm |
[...] The JavaDude (Opens in new window) Share this on: Mixx Delicious Digg Facebook Twitter BlogsManual [...]
Pingback by Netbeans + Visual Paradigm = EJB Tutorial — November 7, 2011 @ 9:00 pm |
[...] In part 1 of this tutorial we created an EJB using Netbeans and Visual Paradigm, in part 2 a little ZK application to read data using the EJB. In part 3 we will move away from the Derby DB to PostgreSQL and Oracle DB and challenge ourselves with identifier more than 30 characters, which is an issue for Oracle (yes, it is 2011). We will add columns with more than 30 characters and play with a few different column types (the ones showing up in a normal DB layout). [...]
Pingback by Netbeans + Visual Paradigm = EJB Tutorial (Part 3) « The JavaDude Weblog — November 10, 2011 @ 10:21 am |