register
other register

Thursday, April 29, 2010

Convert GroovyRowResult into Domain Class

There are chances that you might want to convert a GroovyRowResult into a domain class. For example, in the clustered environment, certain class needs to "implments Serializable" but if there is GroovyRowResult is in the class, then it will throw  java.io.NotSerializableException as GroovyRowResult can not be serialized.

The workaround is simply create a dummy domain class with properties match the result set fields. It is case sensitive.

If it is oracle database, then it is case sensitive.

GroovyRowResult row = connection.firstRow("select user.firstname as \"firstname\"......")
def person = new Peson (row)

No comments: