Using transient Attribute with “Derived from SQL Expression” in JDeveloper 11g

Transient attribute can be used to calculate a value based on SQL expression. This may be very helpful, for example, you can use a transient attribute in “SCOTT.EMP” Entity object definition to get name of the department for all employees.To implement this, do following steps.

1- Create an Entity object definition for Table “SCOTT.EMP”.

2- Now open EMP Entity Object definition in the editor and click its Attribute tab.

3- Add an attribute by clicking on green plus sign.

4- Set name as “Dname”, deselect Persistent check box, select “Derived from SQL Expression” and enter following query in Expression box, as shown in figure below.

(Select Dname from dept where deptno=Emp.Deptno)

Do not forget to put parenthesis around SQL query. Otherwise you will get following exception at run-time while trying to update,

(oracle.jbo.DMLException) JBO-26080: Error while selecting entity for Emp.

5- Now create a default View Object for EMP Entity object and add it to an Application Module. Run Application module and double click View object. Department name will be visible as shown in figure below.

Leave a Reply

Your email address will not be published. Required fields are marked *