Netbeans + Visual Paradigm = EJB Tutorial

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.


  • 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’

    New EJB module

    New EJB module

    New EJB module

  • Create the VP project file
    If you have properly integrated NB and VP you should see this additional buttons


    Select 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)

    Starting VP

  • 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.


    primary key: pk_customer_name


    primary key: pl_customer_address


    Create 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 relationship

    Relationship Mapping

    Create column

    Resulting ERD


  • Create classdiagramm


    Class Diagram (default)

    Change the stereotype to entity bean for both classes


    Final Class Diagram

    Class Diagram


  • Synchronize with Netbeans (code creation)

    Sync with NB

    Created package and classes

    Code Creation

    There is a bug in the code creation, the imports dont get properly created (as in current version 5.2)

    Import Problem

    Fix the problem manually by importing
    import java.sql.Date;
    import java.sql.Timestamp;

    You can check the Netbeans Settings in VP

    NB settings in VP

  • Add Eclipse library to project
    (we need for JPA queries at a later stage)

    Eclipse Libraries

  • Create Meta Model
    Just clean and build will result in meta class created.

    Meta class

  • Create Persistence Unit ‘demoejbPU’
    For now we use the default sample DB

    Create PU

    Create PU


  • Create Session Bean for Entity Class
    in package facade

    Session Bean

    Session Bean


  • Final project structure
    demoejb project

    Project Structure


  • Deploy the EJB
    The tables get created (depending on your PU strategy)



  • 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.

4 thoughts on “Netbeans + Visual Paradigm = EJB Tutorial

  1. Pingback: Netbeans + Visual Paradigm = EJB Tutorial (Part 2) « The JavaDude Weblog

  2. Pingback: Netbeans + Visual Paradigm = EJB Tutorial

  3. Pingback: Netbeans + Visual Paradigm = EJB Tutorial (Part 3) « The JavaDude Weblog

  4. Pingback: Netbeans + Visual Paradigm = EJB Tutorial (Part 4) « The JavaDude Weblog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s