Hibernate is not auto-creating a table that does not exist in the DB
I had the same issue, this worked for me -
<property name="hibernate.hbm2ddl.auto">create</property>
The following scenario could be another reason why Hibernate cannot auto-create your table:
@Entity
public class Employee {
@Id
@GeneratedValue
private String empID;
private String name;
}
The table Employee
will not be auto-created by Hibernate since empID
is a String
and it has the @GeneratedValue
annotation. empID
should be an int
or long
.
I had this problem sometime and I changed my id
field that had the @GeneratedValue
annotation to be of type int
and Hibernate auto-created the table.