9 Replies Latest reply on Jan 13, 2019 4:02 PM by rareddy

    Teiid does not present view as EntityType

    tamarm

      Hi,

       

      I am using Teiid in order to expose Postgres view inside Salesforce.

      Beside this view I have created few tables.

      When accessing the $metadata endpoint I can see all the tables as entity types but I can't see any view.

      After debugging the code I noticed that the problem is that my view doesn't define primary key/unique constraint,

      but as far as I know it is not possible to define primary key or unique constraint on Postgres views..

       

      Does anybody know how to handle it? I saw that Teiid supports both views and Postgres data source...

        • 1. Re: Teiid does not present view as EntityType
          shawkins

          > Does anybody know how to handle it? I saw that Teiid supports both views and Postgres data source...

           

          If you cannot add it directly in the database the workaround is to add a teiid view selecting from the postgresql view and define a primary key there.

          • 2. Re: Teiid does not present view as EntityType
            tamarm

            I am trying to expose data from multiple Postgres data models into Salesforce using Odata.

            For this I am using Teiid spring boot starter.

            I defined multiple data sources(one for each postgres db that contains relevant data for my OData consumer) - inside application.properties and also defined matching spring bean.

            Now I want to define virtual view and expose only this virtual view as OData endpoint.

             

             

             

             

             

            1. Is it possible to define virtual view in the old way using -vdb.xml with the spring boot starter? I want to keep my code very simple and not interested in adding extra java classes?

            (saw the following in the Teiid spring boot documentation:

            With Teiid Spring Boot, there is no need to use the any tooling, your application layer and View definition layer become one. The virtual View construction happens with Annotations in your Java code. It is exactly same steps as to defining Entity using JPA framework with couple extra annotations that are specific to Teiid.)

             

             

            2. If it is possible, is this xml valid? assuming I have "principal" table in my data source

             

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <vdb name="users" version="1">

              <description>My virtual view above Postgres DBs</description>
                <model name="Users" visible="false">
                  <source name="authenticationDataSource" translator-name="postgresql" connection-jndi-name="authenticationDataSource" />
                </model>
                <model name="UserView" type="VIRTUAL">
                  <metadata type="DDL"><![CDATA[

                    CREATE VIEW UsersView (

                    id string,

                    email string

                    )

                    AS SELECT U.id, U.email FROM principal AS U;

                    ]]> </metadata>
                  </model>
              </vdb>

             

             

            Running my app and accessing localhost:8080/$metadata shows all the data sources as EntityTypes and many more entities(with the prefix "pg_catalog") but my virtual view isn't showed.

             

             

             

             

            • 3. Re: Teiid does not present view as EntityType
              rareddy

              Tamar,

               

              Directly adding the Dynamic VDB without need for the Java Classes to define a View is new feature I added couple weeks back to the code that is not released yet. You can see an example here [1]. I hope to release this version of the code in next week or two, until then you fork and build locally and use it.

               

              Ramesh..

               

              [1] teiid-spring-boot/samples/vdb at master · teiid/teiid-spring-boot · GitHub

              • 4. Re: Teiid does not present view as EntityType
                shawkins

                A primary key / unique constraint is still missing, you may want something like:

                 

                CREATE VIEW UsersView (

                        id string PRIMARY KEY,

                        email string

                        ) ...

                • 5. Re: Teiid does not present view as EntityType
                  tamarm

                  Hi Ramesh,

                   

                  I am using version 1.0.2-SNAPSHOT... isn't your code there?

                  • 6. Re: Teiid does not present view as EntityType
                    tamarm

                    Thanks Steven, I added this but I still can't see the view..

                     

                    by the way, Is it possible to get read permissions to the gitbook documentation?

                    • 7. Re: Teiid does not present view as EntityType
                      shawkins

                      > Thanks Steven, I added this but I still can't see the view..

                       

                      Any table / view with a primary key will be visible.  Make sure you are looking under the right namespace / schema.

                       

                      > by the way, Is it possible to get read permissions to the gitbook documentation?

                       

                      Are you saying that you can't see the git project: GitHub - teiid/teiid-documents: Community documents for Teiid Engine and Teiid Server

                      Or you can't see the generated docs : teiid-documents | Community documents for Teiid Engine and Teiid Server - or links from the site Teiid Wildfly Documents | Teiid 

                      • 8. Re: Teiid does not present view as EntityType
                        tamarm

                        Do you have estimation for version 1.0.2 release date?

                        • 9. Re: Teiid does not present view as EntityType
                          rareddy

                          We will be releasing Teiid 12 this week, the Spring Boot version will be released soon after that.