Reputation: 2409
I am trying to connect Hibernate(3.2.5) with PostgreSQL 8.2., but I am getting following exception when I try to map the class Certificate with relation certificate in the hbm.xml file:
PSQLException: ERROR: relation "certificate" does not exist
The SQL for creating Certificate:
CREATE TABLE "Certificate"
(
id bigint NOT NULL,
name text,
CONSTRAINT certificate_pk1 PRIMARY KEY (id)
)
WITHOUT OIDS;
The POJO clas 'Certificate' is:
public class Certificate implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String toString() {
return "model.Certificate[id=" + id + "]";
}
}
The hibernate.cfg.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost /Company</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">abc123</property>
<mapping resource="hibernate.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Upvotes: 0
Views: 718
Reputation: 127456
This is the error:
PSQLException: ERROR: relation "certificate" does not exist
And this is your table:
"Certificate"
The database is searching for lower case "certificate", you created UPPER case "Certificate".
Use the same casing and double quotes around all identifiers, or just use lower case to make things simple.
Upvotes: 4