Hi everybody,
I'm using Hibernate via JPA on JBoss 4.2.3 with PostgreSQL 8.3 as a backend. I'm tying to persist a very simple POJO looking like this:
Code:
@Entity
public class Player {
private String nickname;
private int id = -1;
@Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
}
Everything works fine when starting up the server, it gets a connection, but when I call em.persist() the database log and Hibernate are reporting that the table doesn't exist.
Code:
ERROR [AbstractFlushingEventListener]11:35:30,054 ERROR [JDBCExceptionReporter] ERROR: relation "player" does not exist
11:35:30,054 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
postgres-ds.xml
Code:
<datasources>
<local-tx-datasource>
<jndi-name>PostgresDS</jndi-name>
<connection-url>jdbc:postgresql://127.0.0.1:5432/db1</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<user-name>user1</user-name>
<password>****</password>
<min-pool-size>1</min-pool-size>
<max-pool-size>4</max-pool-size>
</local-tx-datasource>
</datasources>
Is it a misunderstanding on my side? I always thought that Hibernate or any other JPA-Provider would take care of "everything" including creation of the database tables and columns?
If I create the table myself everything works fine.