How to find the max string length for a BDM class field?

1
0
-1

If I have BDM class "com.company.model.MyBDM" with a string field "field1", declared to have a max size of 80 in the business data definition of the studio, how can I determine this max size in groovy connector scripts (or other script types).

In particular: I'd like to be able to add contract constraints to police the max lengths allowed without having to hard-code the length in the BDM definition and all related scripts, constraints and expressions.

I'm pretty sure it has something to do with annotations, but I cant work out the correct syntax.

Many thanks

Chris

1 answer

1
+1
-1

Hmm .. sorry, I should have left it another few mins before posting. Found it (I think). This seems to work (with minimal testing)....

import com.company.model.*
import javax.persistence.Column.*
MyBDM.getDeclaredField("field1").getAnnotation(Column.class).length()
Notifications