7 Replies Latest reply on Nov 7, 2012 2:53 PM by rareddy

    Using Hibernate (JPA) with Teiid

    ssamaresh

      Is there a tutorial that shows how to configure hibernate JPA with Teiid ?

        • 1. Re: Using Hibernate (JPA) with Teiid
          ssamaresh

          I have created a dynamic vdb having connection to two rdbms. My vdb has been deployed successfully on Jboss too. I am using netbeans to create the hibernate mapping. Is there any tutorial that help me configure the mapping for teiid ?

          • 2. Re: Using Hibernate (JPA) with Teiid
            rareddy

            It is no different from any other RDBMS, once you have your VDB deployed then use Teiid Hibernate Dialect and Teiid JDBC driver to configure the hibernate mapping. That is all it takes.

             

            See https://docs.jboss.org/author/display/TEIID/Using+Teiid+with+Hibernate

             

            Ramesh..

            • 3. Re: Using Hibernate (JPA) with Teiid
              ssamaresh

              Hi..Sorry for the late reply...

               

              I have imported

              in my project

               

              I have these files in my project :

               

              hibernate.cgf.xml

              HibernatweUtil.java

               

              The hibernate.cfg.xml has the following properties...

               

              <property name="hibernate.connection.driver_class">org.teiid.jdbc.TeiidDriver</property>

                  <property name="hibernate.connection.url">jdbc:teiid:Multidb@mm://localhost:31000</property>

                  <property name="hibernate.connection.username">user2</property>

                  <property name="hibernate.connection.password">user2</property>

                  <property name="hibernate.dialect">org.teiid.dialect.TeiidDialect</property>

                  <property name="hibernate.show_sql">true</property>

                  <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>

              and a few mapping resource elements

               

              The virtual database 'Multidb' has been deployed successfully.

               

              I have a Java swing client that just needs to access a table :

               

              I have the following methods in it:

               

               

              private static String query = "from autoChartingInfo";

               

              private  void runQuery(){

                      executeHQLQuery(query);

                  }

               

              private void executeHQLQuery(String hql){

                     

                   try {

                      Session session = HibernateUtil.getSessionFactory().openSession();

                      session.beginTransaction();

                      Query q = session.createQuery(hql);

                      List resultList = q.list();

                      int length = resultList.size(); 

                      displayResult(resultList);

                      session.getTransaction().commit();

                   }

                   catch (HibernateException he) {

                      he.printStackTrace();

                  }

                }

                 

                  private void displayResult(List resultList) {

                  Vector<String> tableHeaders = new Vector<String>();

                  Vector tableData = new Vector();

                  tableHeaders.add("userId");

                  tableHeaders.add("passwd");

                  tableHeaders.add("clientid");

                 

              for(Object o : resultList) {

                      jbmUserId jbm = (jbmUserId)o;

                      jbmUser j = (jbmUser)o;

                      Vector<Object> oneRow = new Vector<Object>();

                      System.out.println(oneRow.add(jbm.getUserId()));

                      System.out.println(oneRow.add(jbm.getPasswd()));

                      System.out.println(oneRow.add(jbm.getClientid()));

                   

                      tableData.add(oneRow);

                  }

                 

                 

                 

                 

                  jTable1.setModel(new DefaultTableModel(tableData, tableHeaders));

                

                  }

               

              I am able to retrieve the number of rows of the table but all data being retrieved is 'null'

               

              Do I need to deploy the hibernate.jar in jboss after building it ?

               

              I don't know what I'm doing wrong

              • 4. Re: Using Hibernate (JPA) with Teiid
                rareddy

                Try using more latest 8.2 Teiid, 7.0 is way old to think about.

                • 5. Re: Using Hibernate (JPA) with Teiid
                  ssamaresh

                  I tried using teiid 8.1... I am not able to get the tables for mapping

                  • 6. Re: Using Hibernate (JPA) with Teiid
                    ssamaresh

                    where do i put the teiid-hibernate-dialect.jar ?

                    • 7. Re: Using Hibernate (JPA) with Teiid
                      rareddy

                      In your applications's classpath.