Groovy expression for assigning DB Sequence value to a String type attribute

You can use Groovy expression to default value for  Key attribute from a database sequence while you create new instance of an entity object. If you have access to my book Oracle ADF Real World Developer’s Guide, see page 76 for details or see the following blog from Timo Hahn

This post is just meant for sharing a simple tip that I learned today(Thanks to Steve Muench) for assigning database sequence value to a String type attribute. In case if you need to assign the sequence value to an attribute of type String in an entity object(yes, there are such use cases as well), you can add "as String" to the end of the Groovy expression and set it as default value for the entity attribute.

(new oracle.jbo.server.SequenceImpl("DEPARTMENTS_SEQ", adf.object.getDBTransaction())).getSequenceNumber() as String


  1. I am happy to find this post Very useful for me, as it contains lot of information


  2. A good blog for the people who really needs information about this. Good work keep it up.

    Article submission sites


Post a Comment


The views expressed on this blog are my own and do not necessarily reflect the views of my employer.