ERROR org.hibernate.util.JDBCExceptionReporter - Le nom de colonne dt_ajout n'a pas été trouvé dans ce ResultSet.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ERROR org.hibernate.util.JDBCExceptionReporter - Le nom de colonne dt_ajout n'a pas été trouvé dans ce ResultSet.

sporta
This post has NOT been accepted by the mailing list yet.
Hi there !

Well, i'm trying to do a spatial query but... the query don't work...
When i try the query in pgAdmin, there is some results but not using thejava code.
I'm using those libraries :
         o asm:asm:3.1
         o javax.ws.rs:jsr311-api:1.1.1
         o org.hibernate:hibernate-entitymanager:3.6.3.Final
         o org.hibernate:hibernate-core:3.6.3.Final
         o antlr:antlr:2.7.6
         o commons-collections:commons-collections:3.1
         o org.hibernate:hibernate-commons-annotations:3.2.0.Final
         o org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.0.Final
         o javax.transaction:jta:1.1
         o javassist:javassist:3.12.0.GA
         o org.hibernatespatial:hibernate-spatial-postgis:1.1.1
         o org.hibernatespatial:hibernate-spatial:1.1.1
         o com.vividsolutions:jts:1.12
         o org.postgis:postgis-jdbc:1.3.3
         o org.postgis:postgis-stubs:1.3.3
         o postgresql:postgresql:9.1-901.jdbc3
         o org.slf4j:slf4j-simple:1.6.1

The java code :
   Session session = HibernateUtil.currentSession();
        session.beginTransaction();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1");
        EntityManager em = emf.createEntityManager(); // Retrieve an application managed entity manager

        String queryString = "select long,lat, id from signalisation where ST_DWithin(position, SetSRID(ST_GeomFromEWKT('POINT(2.38222166666667 48.8566133333333)'),4326), 2000.0)";
        Query query = (Query) em.createNativeQuery(queryString, Signalisation.class);
        Object result = query.getSingleResult(); //from a resultset

The persistence.xml :
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
        <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
       
     <properties>
         <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
         <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/myDB"/>
         <property name="hibernate.connection.username" value="xxxx"/>
         <property name="hibernate.connection.password" value="xxxx"/>
         <property name="hibernate.connection.pool_size" value="5"/>
         <property name="hibernate.dialect" value="org.hibernatespatial.postgis.PostgisDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="update"/>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.format_sql" value="true"/>
     </properties>             
        </persistence-unit>
</persistence>


The log :
2859 [main] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - schema update complete
Hibernate:
    select
        position,
        long,
        lat,
        id
    from
        signalisation
    where
        ST_DWithin(position, SetSRID(ST_GeomFromEWKT('POINT(2.38222166666667 48.8566133333333)'),4326), 2000.0)
3125 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42703
3125 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Le nom de colonne dt_ajout n'a pas été trouvé dans ce ResultSet.
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
        at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:307)
        at fr.sporta.samusocial.SignalisationManager.testSpatialQuery(SignalisationManager.java:74)
        at fr.sporta.samusocial.SignalisationManager.main(SignalisationManager.java:42)

And i'm wondering what's happening.... anyone have an idea ?

Thx in advanve ! and thx to hibernate spatial to exists :D
Sebastien