|
In normal, attributes are mapped to database column. We support defining Formula for attribute in ORM Persistable class in order to query the database. In the generated mapping file, it will show the formula correspondingly.
Formula is a SQL expression and does not have any column for it. Now, formula can be define. You can take advantage of formula by generating ORM persistable code from the object model. Defining ORM FormulaRight-click on an attribute in an ORM Persistable class and select Open Specification... in the popup menu. 
Open the ORM Attribute Detail tab. 
Enter the Formula for the attribute in the Formula field. 
Confirm editing by pressing OK.
Generating ORM Code from Class DiagramSelect Tools > Object-Relational Mapping (ORM) > Generate Code... from the main menu. 
Select generate Code and Database or Code only. 
Specify the output path of the code. 
When everything is ready, press OK to proceed with code generation.
Here is the generated files, with formula presented:
Hibernate Mapping File (when XML is selected as Mapping Type) 
Java source code (when Annotation is selected as Mapping Type) 
 |
|
Last Updated on Thursday, 05 June 2008 08:44 |