3.3. Creating Entities
Let us create the Customer
entity class.
-
Go to the DATA MODEL tab in the navigation section and click New → Entity. The New entity dialog window will appear.
-
Enter the name of the entity class –
Customer
– in the Class name field. -
Click OK. The entity designer page will be displayed in the workspace.
-
The entity name and the database table name will be automatically generated in the Name and the Table fields respectively.
-
Leave the existing value –
StandardEntity
- in the Parent class field. -
Leave the Inheritance strategy field blank.
-
Click button next to the Name to open the Localized message window. Specify localization for the entity name for the available languages in it.
Next, let us create entity attributes. To do this, click the New button below the Attributes table.
-
Create attribute window will appear. Enter the name of the entity attribute −
name
, in the Name field. SelectDATATYPE
value in the Attribute type list, specifyString
attribute type in the Type field and then set the length of the text attribute to 100 characters in the Length field. Check the Mandatory box. The name of the database table column will be automatically generated in the Column field.Now click button next to the attribute name to open the Localized message window. Localize the attribute name in the available languages.
Click Add to add the attribute.
-
email
attribute is created in the same way but the value in Length field should be set to50
.
After creating the attributes, go to the Instance name tab in the entity designer to specify Name pattern. Select the name attribute in the Available attributes list and move it to the Name pattern attributes list by clicking the button with the right arrow on it.
Customer entity creation is now complete. Click OK in the top panel to save the changes and close the page.
Let us create the Order
entity. Click New entity option on the Entities tab. Enter the Class name − Order
. The entity should have the following attributes:
-
Name −
customer
, Attribute type −ASSOCIATION
, Type −Customer
, Cardinality −MANY_TO_ONE
. -
Name −
date
, Attribute type −DATATYPE
, Type −Date
. Check Mandatory box fordate
attribute. -
Name −
amount
, Attribute type −DATATYPE
, Type −BigDecimal
.
Specify localized caption for each of the attributes by clicking the button next to the attribute name.