This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Is Hibernate will create schema also? Say I am writing one POJO class TEST and there is no table with name "TEST".
The following will create Table "TEST" in DB?
@Entity
public class Test {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
long id;
private String chin ;
private String emr ;
public void setId(long id) {
this.id = id;
}
public long getId() {
return id ;
}
public void setChin(String chin) {
this.chin = chin;
}
public String getChin () {
return chin;
}
public void setEmr(String emr) {
this.emr = emr;
}
Add the following line in your hibernate.cfg.xml and execute your application:
<property name="hbm2ddl.auto">create</property>
But the disadvantage of this property is it will create schema every time whenever you restart your application. You will be lost your stored data. If you don't want to use this property then just change it to:
<property name="hbm2ddl.auto">none</property>