Tuesday, February 25, 2014

Resolve Error: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet

Removed
Working in a JPA project, I had this error:

javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
....
Caused by: org.postgresql.util.PSQLException: ERROR: relation .. does not exist

This error can appear if you are working with two schema in your database. If you are declaring a persistence.xml with only one persistence-unit, there will be an ambiguity as Hibernate will not know the schema on which you are working.
So to resolve this, one possible solution is to add schema name in you entity.

@Entity
@Table(name = "my_table", schema="schema_one")
public class MyTable implements java.io.Serializable

1 comment :

Articles les plus consultés