1 Reply Latest reply on Oct 5, 2009 6:49 AM by Arbi Sookazian

    createNativeQuery

    Tommaso Cereghetti Newbie
      Hello,

      In a session bean (method with @Create) I have the query:
      `

                      List<Object[]> results = em
                                      .createNativeQuery(
                                                      "select il.id, th.id, il.description, il.long_description, th.comment "
                                                      + "from Ilist il inner join Test_header th on il.id = th.list_id "
                                                      + "where th.user_id = :user_id")
                                      .setParameter("user_id", user.getId()).getResultList();                
                      inteListItems.clear();
                      int count = 0;
                      for (Object[] result : results) {
                              count++;
                              inteListItems.add(new InteListItem(
                                              count,
                                              (Long)result[0],
                                              (Long)result[1],
                                              (String)result[2],
                                              (String)result[3],
                                              (String)result[4]
                                              ));
                      }

      `
      inteListItems is a List of a simple class without any annotation.

      I get the error:
      `
      18:08:55,343 INFO  [STDOUT] Hibernate:
          select
              il.id,
              th.id,
              il.description,
              il.long_description,
              th.comment
          from
              Ilist il
          inner join
              Test_header th
                  on il.id = th.list_id
          where
              th.user_id = ?
      18:08:55,375 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: 42P01
      18:08:55,375 ERROR [JDBCExceptionReporter] FEHLER: Relation +ilist½ existiert nicht
        Position: 75
      18:08:55,375 ERROR [TxPolicy] javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.SQLGrammarException: could not execute query
      18:08:55,375 SEVERE [viewhandler] Error Rendering View[/inteList.xhtml]
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: inteList
              at org.jboss.seam.Component.newInstance(Component.java:2144)
              at org.jboss.seam.Component.getInstance(Component.java:2021)
              at org.jboss.seam.Component.getInstance(Component.java:1983)
      `


      What is wrong with my query?

      Thank you and regards,
      Tommaso