Tuesday, November 10, 2009

Creating Java Entity Beans Dynamically from Database

What to create your entity beans dynamically?

After you've created a new EJB Project in Eclipse and you have a database with tables, sequences, and relationships defined, it is quite easy to create your entity beans dynamically in Eclipse.
  1. Ensure that the JPS Tools are enabled.
    1. Right click the EJB Project folder and select properties
    2. On the left hand side of the properties window, select Project Facits
    3. Check the Java Persistence checkbox
  2. Build the beans from the database.
    1. Right click the EJB Project folder and select JPA Tools > Generate Entities from Tables...
    2. Ensure you are connected with the correct server and schema
    3. Select the entity beans you want in your project.
    4. Don't for get to tell it which package you want the beans in.
    5. Click next until it asks you for the sequences for each bean and enter in the appropriate sequence generators.
  3. Click finish and it will build all the entity beans for you.
The project will then build the beans for you assuming you have all the appropriate relationships etc.

Resources: Kent Jackson (BYU-Idaho Professor)
(Configuration: Eclipse Galileo for Java EE 6 using JBoss Server on Mac OS X 10.6 connecting to a VMware virtual machine with Windows running an academic licence version of Oracle)

0 comments:

Post a Comment

Have a question, comment, suggestion, or interesting bit of information you'd like to share? Please feel free to speak your mind.

(Blog comments that are spam, crude, have vulgar language (even mildly vulgar), are offensive, or otherwise inappropriate will summarily be deleted.)