Package oracle.soda.rdbms
Interface OracleRDBMSMetadataBuilder
-
public interface OracleRDBMSMetadataBuilderBuilds custom collection metadata, expressed as a JSONOracleDocument. The resultingOracleDocumentmust be supplied toOracleDatabaseAdmin.createCollection(String, OracleDocument)method to create a collection with the provided metadata. Custom collection metadata is needed when you want to specify, for example, how the collection is stored, or that the collection is read-only, or remove some of the optional (e.g. version, created-on timestamp, last modified timestamp) columns from the underlying table storing the collection. Custom collection metadata can also be used to map a pre-existing SQL table to a new SODA collection.The builder is created as follows:
OracleRDBMSClient client = ... OracleRDBMSMetadataBuilder builder = client.createMetadataBuilder();The resulting builder is initialized with default metadata settings. These settings can be modified using variousOracleRDBMSMetadataBuildermethods. For example, to change the key assignment method to client-assigned, and to change the content column type toVARCHAR2, invokekeyColumnAssignmentMethod(String)andcontentColumnType(String)as follows:
builder.keyColumnAssignmentMethod("CLIENT").contentColumnType("VARCHAR2");Once the desired changes to the default metadata settings are made, theOracleDocumentrepresenting collection metadata in JSON should be created as follows:
OracleDocument metadata = builder.build();This metadata document is supplied to theOracleDatabaseAdmin.createCollection(String, OracleDocument)method to create a collection with the specified custom metadata:
OracleDatabase db = ... OracleCollection collection = db.admin().createCollection("myCollection", metadata);
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description OracleDocumentbuild()Builds a JSON object containing the collection metadata.OracleRDBMSMetadataBuildercontentColumnCache(boolean cache)Sets the SecureFiles LOB cache setting for the content column.OracleRDBMSMetadataBuildercontentColumnCompress(String compress)Sets the SecureFiles LOB compress setting for the content column.OracleRDBMSMetadataBuildercontentColumnEncrypt(String encrypt)Sets the SecureFiles LOB encryption setting for the content column.OracleRDBMSMetadataBuildercontentColumnMaxLength(int maxLength)Sets the maximum length of the content column.OracleRDBMSMetadataBuildercontentColumnName(String name)Sets the name of the content column.OracleRDBMSMetadataBuildercontentColumnType(String sqlType)Sets the SQL type of the content column.OracleRDBMSMetadataBuildercontentColumnValidation(String validation)Sets the validation mode for the content column.OracleRDBMSMetadataBuildercreationTimeColumnName(String name)Sets the optional creation time column name.OracleRDBMSMetadataBuilderdualityViewName(String dualityViewName)OracleRDBMSMetadataBuilderkeyColumnAssignmentMethod(String assignmentMethod)Sets the key column assignment method.OracleRDBMSMetadataBuilderkeyColumnMaxLength(int maxLength)Sets the maximum size of the key column.OracleRDBMSMetadataBuilderkeyColumnName(String name)Sets the name of the key column.OracleRDBMSMetadataBuilderkeyColumnSequenceName(String sequenceName)Sets the sequence name for sequence-based keys.OracleRDBMSMetadataBuilderkeyColumnType(String sqlType)Sets the key column type.OracleRDBMSMetadataBuilderlastModifiedColumnIndex(String index)Sets the last-modified column index name.OracleRDBMSMetadataBuilderlastModifiedColumnName(String name)Sets the optional last-modified timestamp column name.OracleRDBMSMetadataBuildermediaTypeColumnName(String name)Sets the media type column name.OracleRDBMSMetadataBuilderreadOnly(boolean readOnly)Sets the read/write policy.OracleRDBMSMetadataBuilderremoveOptionalColumns()Removes the optional metadata columns.OracleRDBMSMetadataBuilderschemaName(String schemaName)Sets the SQL schema name for the underlying database object.OracleRDBMSMetadataBuildertableName(String tableName)Sets the SQL table name.OracleRDBMSMetadataBuilderversionColumnMethod(String method)Sets version column method.OracleRDBMSMetadataBuilderversionColumnName(String name)Sets the version (ETag) column name.OracleRDBMSMetadataBuilderviewName(String viewName)Sets the SQL view name.
-
-
-
Method Detail
-
build
OracleDocument build() throws OracleException
Builds a JSON object containing the collection metadata. AnOracleExceptionwill be raised if an invalid configuration is detected. The specific validation errors that may occur are documented throughout this interface.- Returns:
- The JSON collection metadata encoded as UTF-8
- Throws:
OracleException- if an invalid combination is detected- See Also:
OracleDatabaseAdmin.createCollection(String, OracleDocument)
-
schemaName
OracleRDBMSMetadataBuilder schemaName(String schemaName)
Sets the SQL schema name for the underlying database object. IfschemaNameisnull, the schema associated with the connection will be used.- Parameters:
schemaName- the name of the schema ornull- Returns:
- a reference to this object
-
tableName
OracleRDBMSMetadataBuilder tableName(String tableName)
Sets the SQL table name. A collection is based off of a table or a view. Calling this method will override the view name if previously set usingviewName(String). IftableNameisnull, the collection will be created using a table name based on the name of the collection name.- Parameters:
tableName- the name of the table. May benull- Returns:
- a reference to this object
- See Also:
viewName(String)
-
viewName
OracleRDBMSMetadataBuilder viewName(String viewName)
Sets the SQL view name. A collection is based off of a table or a view. Calling this method will override the table name if previously set usingtableName(String)IfviewNameisnull, the collection will be created using a table name based on the name of the collection name.- Parameters:
viewName- the name of the view. May benull- Returns:
- a reference to this object
- See Also:
tableName(String)
-
dualityViewName
OracleRDBMSMetadataBuilder dualityViewName(String dualityViewName)
-
contentColumnName
OracleRDBMSMetadataBuilder contentColumnName(String name)
Sets the name of the content column. Ifnameisnull, the default value"JSON_DOCUMENT"is used.- Parameters:
name- the name of the column. May benull- Returns:
- a reference to this object
-
contentColumnType
OracleRDBMSMetadataBuilder contentColumnType(String sqlType) throws OracleException
Sets the SQL type of the content column. The value must be either"VARCHAR2","NVARCHAR2","RAW","BLOB","CLOB", or"NCLOB". IfsqlTypeisnull, the default value"BLOB"is used.Changing the content column type may automatically remove other related settings:
- Setting to LOB type will remove the content column maximum length.
- Setting to a non-LOB type will remove all SecureFile LOB settings.
- Parameters:
sqlType- the type of the content column. May benull- Returns:
- a reference to this object
- Throws:
OracleException- ifsqlTypeis not one of the expected values
-
contentColumnMaxLength
OracleRDBMSMetadataBuilder contentColumnMaxLength(int maxLength) throws OracleException
Sets the maximum length of the content column. IfmaxLengthis 0, then the maximum is unspecified and the default value of 2000 will be used, if applicable. If the content column type is a LOB type and a maximum length is specified, an error will be raised whenbuild()is called.- Parameters:
maxLength- the maximum size- Returns:
- a reference to this object
- Throws:
OracleException- ifmaxLengthis negative- See Also:
contentColumnType(String)
-
contentColumnValidation
OracleRDBMSMetadataBuilder contentColumnValidation(String validation) throws OracleException
Sets the validation mode for the content column. The value ofvalidationmust be one of"STANDARD","STRICT", or"LAX". Ifvalidationisnull, the default"STANDARD"mode is used.- Parameters:
validation- the validation mode. May benull- Returns:
- a reference to this object.
- Throws:
OracleException- ifvalidationis notnull,"STANDARD","STRICT", or"LAX"
-
contentColumnCompress
OracleRDBMSMetadataBuilder contentColumnCompress(String compress) throws OracleException
Sets the SecureFiles LOB compress setting for the content column. The value ofcompressmust be one of"NONE","HIGH","MEDIUM", or"LOW". This setting is not applicable if thecontent column typeis not a LOB type. Ifcompressisnull, the default value"NONE"is used.If the compression is set to something other than
"NONE"and the column is not a LOB type, an error will be raised whenbuild()is called.- Parameters:
compress- the compression mode. May benull- Returns:
- a reference to this object
- Throws:
OracleException- ifcompressis not one of the expected values- See Also:
contentColumnType(String)
-
contentColumnCache
OracleRDBMSMetadataBuilder contentColumnCache(boolean cache)
Sets the SecureFiles LOB cache setting for the content column. This setting is not applicable if thecontent column typeis not a LOB type. The default value istrue.If the
cacheistrueand the column is not a LOB type, an error will be raised whenbuild()is called.- Parameters:
cache- specifies if caching is used- Returns:
- a reference to this object
- See Also:
contentColumnType(String)
-
contentColumnEncrypt
OracleRDBMSMetadataBuilder contentColumnEncrypt(String encrypt) throws OracleException
Sets the SecureFiles LOB encryption setting for the content column. The value ofencryptmust be"NONE","3DES168","AES128","AES192","AES256". Ifencryptis null, the default value"NONE"is used. This setting is not applicable if thecontent column typeis not a LOB type. Ifencryptis anything other than"NONE"and the column is not a LOB type, an error will be raised whenbuild()is called.- Parameters:
encrypt- the encryption type. May benull- Returns:
- a reference to this object
- Throws:
OracleException- ifencryptis not one of the expected values- See Also:
contentColumnType(String)
-
keyColumnName
OracleRDBMSMetadataBuilder keyColumnName(String name)
Sets the name of the key column. Ifnameis null, they default value"ID"is used.- Parameters:
name- the name of the key column. May benull- Returns:
- a reference to this object
-
keyColumnType
OracleRDBMSMetadataBuilder keyColumnType(String sqlType) throws OracleException
Sets the key column type. The value ofsqlTypemust be one of"VARCHAR2","NVARCHAR2","NUMBER", or"RAW". IfsqlTypeisnull, the default value"VARCHAR2"will be used. Setting the key column type to"NUMBER"or"RAW"automatically removes the maximum size of the key column.- Parameters:
sqlType- the key column type. May benull- Returns:
- a reference to this object
- Throws:
OracleException- ifsqlTypeis not one of the expected values.
-
keyColumnMaxLength
OracleRDBMSMetadataBuilder keyColumnMaxLength(int maxLength) throws OracleException
Sets the maximum size of the key column. IfmaxLengthis 0, then the maximum is unspecified and the default value of 255 will be used, if applicable. If the key column type isNUMBERorRAWand a maximum length is specified, an error will be raised whenbuild()is called.- Parameters:
maxLength- the maximum size- Returns:
- a reference to this object
- Throws:
OracleException- ifmaxLengthis negative- See Also:
keyColumnType(String)
-
keyColumnAssignmentMethod
OracleRDBMSMetadataBuilder keyColumnAssignmentMethod(String assignmentMethod) throws OracleException
Sets the key column assignment method. The value ofassignmentMethodmust be one of"SEQUENCE","GUID","UUID", or"CLIENT". IfassignmentMethodisnull, the default value"UUID"will be used. IfassignmentMethodis anything other than"SEQUENCE", the key column sequence name will be automatically removed. If the assignment method is"SEQUENCE"but no key column sequence name is specified, an error will be raised whenbuild()is called.- Parameters:
assignmentMethod- the key column assignment method. May benull- Returns:
- a reference to this object
- Throws:
OracleException- ifassignmentMethodis not one of the expected values- See Also:
keyColumnSequenceName(String)
-
keyColumnSequenceName
OracleRDBMSMetadataBuilder keyColumnSequenceName(String sequenceName)
Sets the sequence name for sequence-based keys. IfsequenceNameisnull, the sequence name is unspecified. Specifying a sequence name automatically changes the key column assignment method to"SEQUENCE".- Parameters:
sequenceName- the name of the sequence. May benull- Returns:
- a reference to this object
- See Also:
keyColumnAssignmentMethod(String)
-
creationTimeColumnName
OracleRDBMSMetadataBuilder creationTimeColumnName(String name)
Sets the optional creation time column name. Ifnameisnull, no creation time column will be used. The default value is"CREATED_ON".- Parameters:
name- the name of the column. May benull- Returns:
- a reference to this object
-
lastModifiedColumnName
OracleRDBMSMetadataBuilder lastModifiedColumnName(String name)
Sets the optional last-modified timestamp column name. Ifnameisnull, no last-modified column will be used and the last-modified column index will automatically be removed. The default value is"LAST_MODIFIED".- Parameters:
name- the name of the column. May benull- Returns:
- a reference to this object
- See Also:
lastModifiedColumnIndex(String)
-
lastModifiedColumnIndex
OracleRDBMSMetadataBuilder lastModifiedColumnIndex(String index)
Sets the last-modified column index name. Ifindexisnull, the index name is unspecified. If the last-modified index name is specified but the last-modified column name is not set, an error will be raised whenbuild()is called.- Parameters:
index- the name of the index. May benull- Returns:
- a reference to this object
- See Also:
lastModifiedColumnName(String)
-
versionColumnName
OracleRDBMSMetadataBuilder versionColumnName(String name)
Sets the version (ETag) column name. Ifnameisnull, the version column will not be used and the version column method will automatically set to"NONE". The default value is"VERSION".- Parameters:
name- the name of the column. May benull- Returns:
- a reference to this object
- See Also:
versionColumnMethod(String)
-
versionColumnMethod
OracleRDBMSMetadataBuilder versionColumnMethod(String method) throws OracleException
Sets version column method. The value ofmethodmust be"SEQUENTIAL","TIMESTAMP","UUID","SHA256","MD5", or"NONE". Ifmethodisnull, the default value"NONE"is used. If the version column method is not"NONE"and the version column name is not specified, an error will be raised whenbuild()is called.- Parameters:
method- the version method. May benull- Returns:
- a reference to this object
- Throws:
OracleException- ifmethodis not one of the expected values
-
mediaTypeColumnName
OracleRDBMSMetadataBuilder mediaTypeColumnName(String name)
Sets the media type column name. Ifnameisnull, the media type column is unspecified and a media type column will not be used. If thecontent column typeis not"BLOB"and the media type column is specified, an error will be raised whenbuild()is called. By default, the media type column is unspecified.- Parameters:
name- the name of the media type column. May benull- Returns:
- a reference to this object
-
readOnly
OracleRDBMSMetadataBuilder readOnly(boolean readOnly)
Sets the read/write policy. The default value isfalse.- Parameters:
readOnly- when true, specifies the collection is read only- Returns:
- a reference to this object
-
removeOptionalColumns
OracleRDBMSMetadataBuilder removeOptionalColumns()
Removes the optional metadata columns. This method is useful when creating a collection over an existing table where these columns may not exist.Calling this method is equivalent to the following:
this .creationTimeColumnName(null) .lastModifiedColumnName(null) .versionColumnName(null) .mediaTypeColumnName(null);- Returns:
- a reference to this object
-
-