The Groovy support includes the ability to reference attributes of Entity Objects and View Objects. For instance you may create a transient attribute TotalCost in an InvoiceLines Entity Object based on the Groovy expression "Cost * Quantity" referencing the same named Entity Object attributes:
As you become more familiar with the use of Groovy expressions you'll realize you can also call the functions of the underlying attribute type. For instance a String attribute FullName would support the Groovy expression "FullName.toLowerCase()".
However there is a catch. When calling functions of a specific attribute, say calling the oracle.jbo.domain.Number add() function on the Quantity Number attribute, at runtime you might discover a runtime error such as:
(oracle.jbo.JboException) JBO-29000: Unexpected exception caught: groovy.lang.MissingMethodException, msg=No signature of method: java.lang.Long.add() is applicable for argument types: (java.lang.Integer) values: [1]
This comes as a surprise as the Fusion Guide tells us the Number attribute type is backed by the oracle.jbo.domain.Number class supplied by Oracle.
What's happening is that the Groovy expression evaluator is undertaking some implicit datatype conversions/casts on our behalf with the underlying attributes. In order to make this easier to understand I've documented the type conversions for you. The following table gives you the Type Name as selected in the EO/VO attribute editor, the Java Type you'll see in the resulting EntityImpl and ViewRowImpl classes, and then the Groovy Type they'll be cast to during a Groovy expression evaluation.
You'll note with the Groovy Types sometimes they are in fact the oracle.jbo.domain class, but in others they're the parent class. And for some types there is no oracle.jbo.domain equivalent, just a java.lang type. It's all a bit inconsistent but hopefully the table gives you the appropriate type for your attribute:
Type Name | Java Type | Groovy Type |
Array | oracle.jbo.domain.Array | - |
BFileDomain | oracle.jbo.domain.BFileDomain | - |
BigDecimal | java.math.BigDecimal | java.math.BigDecimal |
BlobDomain | oracle.jbo.domain.BlobDomain | oracle.jbo.domain.BlobDomain |
Boolean | java.lang.Boolean | java.lang.Boolean |
Byte | java.lang.Byte | java.lang.Byte |
Char | oracle.jbo.domain.Char | java.lang.String |
Character | java.lang.Character | java.lang.Character |
ClobDomain | oracle.jbo.domain.ClobDomain | oracle.jbo.domain.ClobDomain |
DBSequence | oracle.jbo.domain.DBSequence | java.lang.Long |
Date | oracle.jbo.domain.Date | java.sql.Date |
Double | java.lang.Double | java.lang.Double |
Float | java.lang.Float | java.lang.Float |
Integer | java.lang.Integer | java.lang.Integer |
Long | java.lang.Long | java.lang.Long |
NClobDomain | oracle.jbo.domain.NClobDomain | oracle.jbo.domain.NClobDomain |
Number | oracle.jbo.domain.Number | java.lang.Long |
Object | java.lang.Object | java.lang.Object |
OrdAudioDomain | oracle.ord.im.OrdAudioDomain | oracle.ord.im.OrdAudioDomain |
OrdDocDomain | oracle.ord.im.OrdDomain | oracle.ord.im.OrdDomain |
OrdImageDomain | oracle.ord.im.OrdImageDomain | oracle.ord.im.OrdImageDomain |
OrdImageSignatureDomain | oracle.ord.im.OrdImageSignatureDomain | oracle.ord.im.OrdImageSignatureDomain |
OrdVideoDomain | oracle.ord.im.OrdVideoDomain | oracle.ord.im.OrdVideoDomain |
REF | oracle.sql.REF | - |
Raw | oracle.jbo.domain.Raw | - |
RowID | oracle.jbo.domain.RowID | java.lang.String |
Short | java.lang.Short | java.lang.Short |
String | java.lang.String | java.lang.String |
Timestamp | oracle.jbo.domain.Timestamp | java.sql.Timestamp |
TimestampLTZ | oracle.jbo.domain.TimestampLTZ | java.sql.Timestamp |
TimestampTZ | oracle.jbo.domain.TimestampTZ | java.sql.Timestamp |
You'll note I've missed a few Groovy Types, I simply couldn't determine the equivalent type.
This post was specifically written against JDeveloper 11g 11.1.1.2.0 build 5536. It's quite possibly in the future Oracle will tweak the data types to make it more consistent so be careful to check my facts.
1 comment:
We definitely need a unififed type system in ADF;)
Post a Comment