I am having some problems trying to work with PostgreSQL and Hibernate, more specifically, the issue mentioned in the title. I\'ve been searching the net for a few hours now
Another answer may be to check schema permissions - which may be useful for others who happen to come across the subject heading of this question. I had the same exact symptoms regarding the error message which was;
<SQL Error: 0, SQLState: 42P01>
<ERROR: relation "tablename" does not exist>
The solution was to enable permissions on that schema for the user I was using to log in with.
Also: Noting that a good diagnostic tool here is to log into the postgres command line console with the same user your program is using and attempt to access the table and schema in the same way.
I've just solved the same / similar problem by specifying the schema.
@Entity
@Table(name = "mytable", schema="myschema")
public class MyTable implements Serializable {
...
Your JDBC URL is "jdbc:postgresql:postgres/tommy" which is unusual. The documentation suggests "jdbc://hostname/databasename". Modern installations come with a "postgres" database that almost definitely isn't what you want to connect to; I don't know how strict the JDBC driver's URL parsing is.
What are you expecting your database name and hostname to be? e.g. what are your parameters to psql to connect to the database that way?
Tip: in postgresql.conf, some settings you may consider:
log_connections = on
log_disconnections = on
log_line_prefix = '%t %c %q%u@%h:%d '
If the error is what I think (you're connecting to the wrong database), this would log things like the database name along with the error in your postgresql.log file.