JBoss.orgCommunity Documentation

Chapter 7. Handling Large Objects

7.1. Large Objects
7.1.1. Data Types
7.1.2. Why Use Large Object Support?
7.2. Handling Large Objects
7.3. Inserting or Updating Large Objects

This chapter examines how to use facilities provided by the Teiid Connector API to use large objects such as blobs, clobs, and xml in your connector.

The Connector API automatically handles large objects (Blob/Clob/SQLXML) through the creation of special purpose wrapper objects when it retrieves results.

Once the wrapped object is returned, the streaming of LOB is automatically supported. These LOB objects then can for example appear in client results, in user defined functions, or sent to other connectors.

A connector execution is usually closed and the underlying connection is either closed/released as soon as all rows for that execution have been retrieved.  However, LOB objects may need to be read after their initial retrieval of results.  When LOBs are detected the default closing behavior is prevented by setting a flag on the ExecutionContext.

Now the connector execution only when the user Statement object is closed.  Note that connectors may at their discretion have executions delayed in their closure by directly setting the keep alive on the ExecutionContext

      
      executionContext.keepExecutionAlive(true);
    

An important limitation of using the LOB type objects is that streaming is not supported from remote connectors. This is an issue in clustered environments if connectors intended to return LOBs are deployed on only a subset of the hosts or in failover situations. The most appropriate workaround to this limitation is to deploy connectors intended to return LOBs on each host in the cluster.

LOBs will be passed to the Connector in the language objects as an ILiteral containing a java.sql.Blob,  java.sql.Clob, or java.sql.SQLXML.  You can use these interfaces to retrieve the data in the large object and use it for insert or update.