Академический Документы
Профессиональный Документы
Культура Документы
Object relational mapping (ORM) is a way to virtually map Java objects with
relational database to aid in object-oriented programming. Visual Paradigm Eclipse
integrationprovides you with an all-in-one modeling plugin for Eclipse. You can
design database with the ERD tool, and design system with UML diagrams. You
can also generate database and source code. VP-UML uses Hibernate as ORM
framework, providing Java developers with the most popular and easy-to-use
database programming solution. Here are some of the benefits of using VP-UML's
Eclipse integration for ORM:
In this tutorial, we will try out object relational mapping by first drawing an ERD,
then generate a class diagram, generate the database and code, and finally to
program the application. The tutorial is aimed at describing the use of ORM
with VP-UML in brief. Hence, the sample being used will be in minimum scale.
February 2, 2011
User Rating:
Views: 31,938
PDF Link
/ 26
Add comments
4. Select Modeling > ORM > Database Configuration... from the main menu.
5. In the Database Configuration dialog box, select the database software you use
from the list. In this tutorial, MySQL has to be selected.
6. In the Database Setting panel, press on the down arrow button next to Driver
file field. If your database software does not support downloading driver file, try to
look for it from its official website.
Design database
1. Right click on Entity Relationship Diagram in Diagram Navigator and select New
Entity Relationship Diagram from the popup menu.
4. Right click on the entity and select New Column from the popup menu.
5. Enter +id to create a primary key with id as name. Press Enter to confirm and
create one more column. Enter name : varchar(20) as column name. Click on the
diagram background to confirm editing.
6. Move the mouse pointer over the Shop entity. Press on the resource icon One-toMany Relationship -> Entity and drag it out.
7. Release the mouse button to create the entity. Name it as Product. Create two
columns +id and name : varchar(50).
10. Click OK in the Synchronize to Class Diagram dialog box. This produces a class
diagram.
11. Double click on the package header and enter myshop as name
3. Click OK to generate the database. When finished, you can optionally check in
MySQL whether the database has been exported or not.
4. Go back to Eclipse. Select Modeling > ORM > Generate Code... from the main
menu.
5. Change the drop down menu to generate only code.
6. Click OK to generate code. Check the Package Explorer. You can find the
generated code files there.
2. Replace the first TODO with a setName call to the shop object.
3. Replace the second TODO with a setName call to the product object. Besides, set
also the shop of product to be the shop object above.
5. Run this class by selecting Run > Run As > Java Application from the main
menu.
6. Let's list out the data from database. Open the ormsamples.ListMyShopData class.
7. Edit the print statements in listTestData() to print the names of shops and products.
8. Check the console output. You can see the id and name of shop and product are
printed.