datanucleus-rdbms
datanucleus-rdbms copied to clipboard
Oracle : support writing BLOB columns in join tables
Oracle (for storing large amounts of data, offline, in a BLOB column) requires some whacky process of inserting EMPTY_BLOB() on an INSERT and then retrieving and setting the actual value of the BLOB field. This is only implemented for tables of classes currently, and not for join tables.
v6.0 updates means that we have OracleCollectionMapping and the element mapping would be such as OracleBlobColumnMapping (in the join table). The add element of the backing store fires off any INSERT (or UPDATE if it was to do one). This would need to call mapping.performSetPostProcessing(...).
The difficult part of this is tied to OracleBlobColumnMapping.setPostProcessing (and equivalent Clob method). This needs to do
SELECT {blob} FROM join_tbl WHERE ID = ?
but with a join table we don't have an "id", we have the owner, but that only restricts to all elements of the collection. We also (may, with an indexed List) have an index column. We need to restrict to a particular element of the collection (or particular key/value of the map).
Note that we could allow a BLOB to store less than 4k bytes (?) by just putting the value into the INSERT statement, but why use a BLOB in that case?
Sample test that shows a simple field persisted as CLOB (passes), Collection field persisted (serialised) as BLOB (passes), and Collection field persisted into JOIN table with CLOB element (fails). test.zip