3 Replies Latest reply on Jul 17, 2008 1:58 PM by rcherchi

    Problem with Native Queries

    rcherchi

      Hi guys,

      I'm trying to execute a simple native query using JBoss 4.0.5GA and EJB 3.0.

      Here is my entity bean with the SqlResultSetMapping annotation:

      @SqlResultSetMapping(name="poiResultsMapping",
       entities=@EntityResult(entityClass=POI.class,
       fields=@FieldResult(name="name", column="POI_NAME")))
      @Entity
      public class POI implements java.io.Serializable { ... }


      Here is the native query which fails in the session bean.

      q = em.createNativeQuery("select p.POI_NAME from poi as p limit 8", "poiResultsMapping");
      
      this.poiResults = q.getResultList();
      


      This is the cause of the error :

      2007-09-17 13:36:53,608 INFO [org.hibernate.type.LongType] could not read column value from result set: POI2_12_0_;


      Do you see what could be wrong with this code ? Did I forget something ?

      Regards.

        • 1. Re: Problem with Native Queries
          rcherchi

          Here is the exception generated by postgresql :

          org.postgresql.util.PSQLException: The column name x was not found in this ResultSet.
          


          Would you need any other information to solve the problem ?

          Thanks

          • 2. Re: Problem with Native Queries
            mapoitras

            Have you found a solution to this problem? I'm having the exact same issue and I can't seem to figure it out. In my case I get

            [IntegerType] could not read column value from result set: FINC1_18_0_;

            In my SQL statement, all the columns have alias so I have no idea where FINC1_18_0_ comes from.

            the only integer is the key so I suspect its related to that but I'm not sure. Any help would be appreciated.

            @Id @GeneratedValue
            @Column(name="FINC_TRN_ID")
            public Integer getId() {
            return id;
            }

            • 3. Re: Problem with Native Queries
              rcherchi

              No sorry,

              I just replaced all my native queries by standard EJB/QL queries :)

              Cheers