ADF Database sequence using Groovy
We may have a database sequence that generate a primary key for the table. During the manual SQL insert query, we refer <SEQUENCE_NAME>.nextval to generate the next unique key for the primary key column. We could apply the same solution in ADF Entity object declarative using groovy expression.
To do this, open the entity object, Select Attribute that requires sequence value, Enable ‘Expression’, Select the expression icon and add the following expression as shown in the below image.
(new oracle.jbo.server.SequenceImpl(“<YOUR SEQUENCE NAME>”,adf.object.getDBTransaction())).getSequenceNumber()
In the above statement, replace <YOUR SEQUENCE NAME> with the database sequence name . For example if the sequence name is ‘SAMPLE_SEQ’ then following expression is valid.
Once it has been applied, Go the Source tab and change trustMode=”trusted” in TransientExpression for the attribute we enabled sequence just before. Default the value is unTrusted.
Note: You might get the following error if you not changed to Trusted mode.
([Static type checking] - [ADF Seurity Error] - Calling the constructor for class.jbo.server.sequenceImpl is not permitted)
The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.
Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
Latest posts by Govind
- P6 Progress Reporter completely integrated into P6 Team Member - August 15, 2017
- Primavera P6 Professional for EPPM Popup 16.2 : The appropriate industry for your organization has not yet been select in admin preferences - August 15, 2017
- Primavera P6 Background Job Error:Creating job Symon Failed to add Database Job, Check the settings table for valid interval values for dbms_scheduler - August 14, 2017