We assume you already have Visual Paradigm Standard installed and integrated with Eclipse. SQL Server is also being setup and ready to use. Suppose we have a simple ORM class, Product, and we want to define extra features for calculate the product price after volume discount:
- Click on the Product class and drag out the resource icon.
- Release the mouse button on the desire location in the diagram.
- Select Create ORM Implementation Class in Resource Catalog..
- Name the created class as ProductImpl.
- Right-click on ProductImpl and select Add > Operation.
- Name the operation as getVolumeDiscountPrice(qty : int) : float
- Now the model is ready and we can proceed to generate ER model and hibernate code. First we define the default database for our project. Select Modeling > ORM > Database Configuration...
- Select SQL Server as our default database. Specify the connection details to the SQL Server. Use the Test Connection button to make sure your configuration detail works. Then press OK to close the Database Configuration dialog.
- Right-click on the blank area of the class diagram and select Synchronize to Entity Relationship Diagram, follow the wizard to perform the synchronization with default settings.
- The ERD for our model is generated. To simplify the testing we can predefine some sample data for our database. Right-click on the blank area of the ERD and select Show Table Record Editor or View Editor.
- Enter the sample record below to the Table Record Editor.
- We are almost there. Select Modeling > ORM > Generate Code...
- In Database Code Generation dialog, select generate Code and Database.
- Select Generate Sample Code so that we can test the implementation with the generated testing program.
- Press the Advanced Settings button.
- In the Advanced Settings dialog, select ORM Implementation as Persistent API return type.
- Switch to Database tab and select Export to database. Select Yes (With Auto Generated PK) in Generate Sample Data. Press OK to proceed code generation.
- Now the Hibernate code are being generated, and we can start define the custom implementation in the getVolumeDiscountPrice method. i.e. we offer 10% off for purchase 5+ copies, and 20% off for purchase 10+ copies.
- Done. Let's modify printout section in the list data sample to test our custom implementation.
- Run the modified list data sample and the custom implementation method was being called.