-
Notifications
You must be signed in to change notification settings - Fork 2
Arrays
SQL Arrays are supported both as input and output parameters.
If a method parameter is either either Collection subtype or primitive or reference array (not java.sql.Array) we automatically map it to a SQL array.
In order to create the array we need to know the name of the element type (see Connection#createArrayOf). We use a default mapping of Java types to SQL standard types. For cases where this does not work for you you can either use the @TypeName annotation or implement the TypeNameResolver interface and register it using the #withNamespaceNamingStrategy method. For Collection subtype we recommend annotation the type parameter but annotating the parameter works as well.
@ReturnValue
String sampleArrayArgumentTypeParameter(List<@TypeName("name-of-array-element-type") Integer> ids);
@ReturnValue
String sampleArrayArgumentArray(@TypeName("name-of-array-element-type") Integer[] ids);We will call Array#free before the method returns.
Returning SQL arrays through out parameter or return values works much the same way, simply make your interface method return a Java primitive or reference array (not java.sql.Array). As the driver creates the array there is no need to pass in the name of the element type.
We will call Array#free before the method returns.
Arrays in Oracle are special because Oracle does not support anonymous arrays, Oracle only supports arrays as user defined types with a name.
-
Usage
-
Integration