如果控制台在运行测试类后显示此内容
07:32:36,883 DEBUG SchemaExport:377 - create table Employee1 (empId integer not null, name varchar(255), primary key (empId))
07:32:37,022 INFO SchemaExport:268 - schema export complete
07:32:37,024 INFO DriverManagerConnectionProvider:170 - cleaning up connection pool: jdbc:derby://localhost:1527/sample;create=true
该表未显示在数据库中
package com.hibernate.chapter1;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class TestEmployee {
public static void main(String[] args) {
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(Employee1.class);
config.configure("hibernate.cfg.xml");
new SchemaExport(config).create(true, true);
}
}
测试类如下所示:
package com.hibernate.chapter1;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class TestEmployee {
public static void main(String[] args) {
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(Employee1.class);
config.configure("hibernate.cfg.xml");
new SchemaExport(config).create(true, true);
}
}