Ce contenu n'est pas disponible dans la langue sélectionnée.

13.22. Object Translator


13.22.1. Object Translator

The Object translator is a bridge for reading Java objects from external sources, such as JBoss Data Grid (infinispan-cache) or Map Cache, and delivering them to the engine for processing. To assist in providing that bridge, the OBJECTTABLE function ( Section 3.6.10, “Nested Tables: OBJECTTABLE”) must be used to transform the Java object into rows and columns.
The following are Object translator types:
  • map-cache - supports a local cache that is of type Map and using Key searching. This translator is implemented by the org.teiid.translator.object.ObjectExecutionFactory class.
  • infinispan-cache - supports JBoss Data Grid using either Key searching (for objects that are not annotated) or Hibernate/Lucene searching. This translator is implemented by the org.teiid.translator.object.infinispan.InfinispanExecutionFactory class which extends the org.teiid.translator.object.ObjectExecutionFactory class.

Note

See the JBoss Data Grid resource adapter for this translator. It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName or RemoteServerList). Also see the Red Hat JBoss Data Virtualization Administration and Configuration Guide for more configuration information.

13.22.2. Object Translator: Execution Properties

The following execution properties are relevant to translating from JBoss Data Grid.
Expand
Table 13.15. Execution Properties
Name
Description
Required
Default
SupportsLuceneSearching
Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache
N
false

13.22.3. Object Translator: Supported Capabilities

The following are the connector capabilities when Key Searching is used:
  • SELECT command
  • CompareCriteria - only EQ
  • InCriteria
The following are the connector capabilities when Hibernate/Lucene Searching is enabled:
  • SELECT command
  • CompareCriteria - EQ, NE, LT, GT, etc.
  • InCriteria
  • OrCriteria
  • And/Or Criteria
  • Like Criteria
  • INSERT, UPDATE, DELETE

13.22.4. Object Translator: Usage

Retrieve objects from a cache and transform into rows and columns.
  • The primary object returned by the cache should have a name in source of 'this'. All other columns will have their name in source (which defaults to the column name) interpreted as the path to the column value from the primary object.
  • All columns that are not the primary key nor covered by a lucene index should be marked as SEARCHABLE 'Unsearchable'.

13.22.5. Object Translator Example

The following is an example of a key search. It uses a dynamic vdb to define the physical source and views using DDL. It uses a TeamObject class, shown below, with a teamName field that is used as its cache key and a String list of players.
public class TeamObject {

   private String teamName;
   private List<String> players = new ArrayList<String>();

   public String getTeamName() {
      return teamName;
   }

   public void setTeamName(String teamName) {
           this.teamName = teamName;
   }

   public List<String> getPlayers() {
           return players;
   }

}
Copy to Clipboard Toggle word wrap
Notice the use of the [OBJECTABLE|TEIID:OBJECTABLE] function to parse the object from Team and transform into rows and column. This metadata could also be defined by using Teiid Designer.
<vdb name="team" version="1">
    <property name="UseConnectorMetadata" value="cached" />
    <model name="Team" visible="false">
        <source name="objsource" translator-name="infinispan1" connection-jndi-name="java:infinispan-jndi"/>
        <metadata type="DDL"><![CDATA[

            CREATE FOREIGN TABLE Team (
                TeamObject Object OPTIONS (NAMEINSOURCE 'this', SEARCHABLE 'Unsearchable'),
                teamName varchar(255) PRIMARY KEY)
              OPTIONS (NAMEINSOURCE 'teams');

         ]]> </metadata>
    </model>
    <model name="TeamView" type="VIRTUAL">
         <metadata type="DDL"><![CDATA[
             CREATE VIEW Players (
                  TeamName varchar(255) PRIMARY KEY,
                  PlayerName varchar(255)
             )
             AS
             SELECT t.TeamName, y.Name FROM Team as T,
                   OBJECTTABLE('m.players' PASSING T.TeamObject as m COLUMNS Name string 'teiid_row') as y;

        ]]> </metadata>
    </model>

    <translator name="infinispan1" type="infinispan-cache">
        <property name="SupportsLuceneSearching" value="true"/>
    </translator>
</vdb>
Copy to Clipboard Toggle word wrap
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat