cache lookup failed for type 1185046

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

cache lookup failed for type 1185046

Daniel Michulke

Dear all,


I want to persist an entity with a Geometry field using HibernateSpatial/Hibernate on JBoss. The thing is: it doesnt work because of 'org.postgresql.util.PSQLException - false - true - ERROR: cache lookup failed for type 1185046' (the type id changes with every request and is not contained in pg_type or pg_class). 


However, what I can do is 

- persist an entity where the Geometry field is NULL

- SQL INSERT the entity including the geometry field manually

- the hibernate-spatial tutorial v4.x works. 


I was trying to find the problem using postgresql and/or hibernate logs but I only found that:

- With a loglevel = ALL on org.hibernate there is TRACE message showing a data binding for all parameters except the Geometry parameter.

- Via the postgresql log I am not able to get the values inserted so I cannot reproduce the exact query manually cause I cannot see the values.


So I am stuck and don't know where to continue my search.

The field definition is:
@JsonDeserialize(using=PolygonDeserializer.class)
@Column(columnDefinition="Geometry")
@Type(type="org.hibernate.spatial.GeometryType")
private Geometry geom;

I also tried type Polygon (always the com.vividsolutions.jts... classes)

I use 
- hibernate 4.3.5
- hibernate-spatial 4.3 with all dependencies excluded in the pom
- postgresql-9.3-1102-jdbc41
- postgis-jdbc-2.1.7
all running on wildfly 8.1 (and the above JARs are all somewhere in the modules directory of wildfly)

In the DB the field is declared as geometry.

So, anyone has an idea what's going on?

Thank your and best regards, Daniel



_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: cache lookup failed for type 1185046

Karel Maesen
Administrator
Hi Daniel,

Can you post the stacktrace?

You can simulate the query by replacing the geometry value by st_GeometryFromText(wkt) where wkt is the WKT representation for the geometry. See the postgis documentation: http://postgis.net/docs/manual-2.0/ST_GeometryFromText.html.

It might have something to do with where you place the postgis-jdbc-2.1.7. See for example: https://gist.github.com/bjornharrtell/3054462

Regards,

Karel



> On 20 Apr 2015, at 10:00, Daniel Michulke <[hidden email]> wrote:
>
> Dear all,
>
> I want to persist an entity with a Geometry field using HibernateSpatial/Hibernate on JBoss. The thing is: it doesnt work because of 'org.postgresql.util.PSQLException - false - true - ERROR: cache lookup failed for type 1185046' (the type id changes with every request and is not contained in pg_type or pg_class).
>
> However, what I can do is
> - persist an entity where the Geometry field is NULL
> - SQL INSERT the entity including the geometry field manually
> - the hibernate-spatial tutorial v4.x works.
>
> I was trying to find the problem using postgresql and/or hibernate logs but I only found that:
> - With a loglevel = ALL on org.hibernate there is TRACE message showing a data binding for all parameters except the Geometry parameter.
> - Via the postgresql log I am not able to get the values inserted so I cannot reproduce the exact query manually cause I cannot see the values.
>
> So I am stuck and don't know where to continue my search.
>
> The field definition is:
> @JsonDeserialize(using=PolygonDeserializer.class)
> @Column(columnDefinition="Geometry")
> @Type(type="org.hibernate.spatial.GeometryType")
> private Geometry geom;
>
> I also tried type Polygon (always the com.vividsolutions.jts... classes)
>
> I use
> - hibernate 4.3.5
> - hibernate-spatial 4.3 with all dependencies excluded in the pom
> - postgresql-9.3-1102-jdbc41
> - postgis-jdbc-2.1.7
> all running on wildfly 8.1 (and the above JARs are all somewhere in the modules directory of wildfly)
>
> In the DB the field is declared as geometry.
>
> So, anyone has an idea what's going on?
>
> Thank your and best regards, Daniel
>
>
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: cache lookup failed for type 1185046

Daniel Michulke
In reply to this post by Daniel Michulke
Hi Karel,

the stacktrace is:

17:30:47,879 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-4) SQL Error: 0, SQLState: XX000
17:30:47,880 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-4) ERROR: cache lookup failed for type 1221322
17:30:47,887 ERROR [org.jboss.as.ejb3.invocation] (default task-4) JBAS014134: EJB Invocation failed on component FieldService for method public javax.ws.rs.core.Response com.agri_esprit.core.services.FieldService.createField(com.agri_esprit.core.model.Field) throws java.lang.Exception: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190)
[...]
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement
        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
[...]
Caused by: org.hibernate.exception.GenericJDBCException: could not execute statement
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
[...]
Caused by: org.postgresql.util.PSQLException: ERROR: cache lookup failed for type 1221322
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2198) [postgresql-9.3-1102-jdbc41.jar:]
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1927) [postgresql-9.3-1102-jdbc41.jar:]
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) [postgresql-9.3-1102-jdbc41.jar:]
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:561) [postgresql-9.3-1102-jdbc41.jar:]
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:419) [postgresql-9.3-1102-jdbc41.jar:]
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:365) [postgresql-9.3-1102-jdbc41.jar:]
        at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:187) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
        ... 131 more

17:30:47,901 ERROR [com.agri_esprit.core.utils.CoreExceptionMapper] (default task-4) root cause: org.postgresql.util.PSQLException - false - true - ERROR: cache lookup failed for type 1221322

I also have my JBoss module setup as in https://gist.github.com/bjornharrtell/3054462
however, I still have the JARs in the local WEB-INF/lib folder (I don't get classpath problems)

Finally, if I insert the field manually
- I can do so by just inserting 'POLYGON ((7 7, 6 9, 6 11, 7 12, 9 11, 11 12, 13 11, 13 9, 11 7, 7 7))' (without any ST_Geometry... conversion)
- the entity can be subsequently read by hibernate/hibernate-spatial and the geom Field contains the right coordinates.

I hope that helps.

Best regards, Daniel
________________________________________
From: [hidden email] <[hidden email]> on behalf of Karel Maesen <[hidden email]>
Sent: Monday, April 20, 2015 4:03 PM
To: Hibernate Spatial Users Discussion
Subject: Re: [hibernatespatial-users] cache lookup failed for type 1185046

Hi Daniel,

Can you post the stacktrace?

You can simulate the query by replacing the geometry value by st_GeometryFromText(wkt) where wkt is the WKT representation for the geometry. See the postgis documentation: http://postgis.net/docs/manual-2.0/ST_GeometryFromText.html.

It might have something to do with where you place the postgis-jdbc-2.1.7. See for example: https://gist.github.com/bjornharrtell/3054462

Regards,

Karel



> On 20 Apr 2015, at 10:00, Daniel Michulke <[hidden email]> wrote:
>
> Dear all,
>
> I want to persist an entity with a Geometry field using HibernateSpatial/Hibernate on JBoss. The thing is: it doesnt work because of 'org.postgresql.util.PSQLException - false - true - ERROR: cache lookup failed for type 1185046' (the type id changes with every request and is not contained in pg_type or pg_class).
>
> However, what I can do is
> - persist an entity where the Geometry field is NULL
> - SQL INSERT the entity including the geometry field manually
> - the hibernate-spatial tutorial v4.x works.
>
> I was trying to find the problem using postgresql and/or hibernate logs but I only found that:
> - With a loglevel = ALL on org.hibernate there is TRACE message showing a data binding for all parameters except the Geometry parameter.
> - Via the postgresql log I am not able to get the values inserted so I cannot reproduce the exact query manually cause I cannot see the values.
>
> So I am stuck and don't know where to continue my search.
>
> The field definition is:
> @JsonDeserialize(using=PolygonDeserializer.class)
> @Column(columnDefinition="Geometry")
> @Type(type="org.hibernate.spatial.GeometryType")
> private Geometry geom;
>
> I also tried type Polygon (always the com.vividsolutions.jts... classes)
>
> I use
> - hibernate 4.3.5
> - hibernate-spatial 4.3 with all dependencies excluded in the pom
> - postgresql-9.3-1102-jdbc41
> - postgis-jdbc-2.1.7
> all running on wildfly 8.1 (and the above JARs are all somewhere in the modules directory of wildfly)
>
> In the DB the field is declared as geometry.
>
> So, anyone has an idea what's going on?
>
> Thank your and best regards, Daniel
>
>
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: cache lookup failed for type 1185046

Daniel Michulke
Dear Karel,

I had time to dive deeper into the matter and I can tell you the following.

(All infos I obtained by putting a breakpoint in JDBC4PreparedStatement.executeWithFlags())

- Reading (SELECT queries) is not affected and works
- when INSERTing, the wrong type id is written in "preparedParaneters" and the offending paramType is the one attached to the geometry field. This paramType will also be mentioned in the big error "cache lookup failed for type ..."
- However, the INSERT query generated by hibernate ("preparedQuery") is fine and I can copy/paste it in pgadmin and it works exactly as intended.

What I find especially strange is:
- How come the INSERT doesn't work even though the query string is correct? Why does it meddle with types at all (there's no parsing to be done, so why bother?)
- If it were a driver problem, how come it is able to deal with the geometry type when reading?

Are there version mismatches? (Local: postgis 2.1.7 + hibernate 4.3.5 + hibernate spatial 4.3 + postgres 9.3 1102 jdbc41 on Java 7, Server: postgres 9.3 with postgis extension version 2.1.2)

The stacktrace does not contain any reference to postgis - I believe this is ok because postgis registers types in the beginning. Can you confirm that?

Thank you and best regards,

Daniel
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users