Spring和hibernate集合的框架中只要在applicationContext.xml文件中配置如下:
<prop key="hibernate.hbm2ddl.auto">update</prop>
Hibernate框架中只要在hibernate.cfg.xml里加上如下代码:
<property name="hbm2ddl.auto">update</property>
update:只是更新,没有就创建
create: 每次都是新创建
create-drop: 用完就会删除表
hibernate.cfg.xml 可以通过idea自动生成
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url"/>
<property name="connection.driver_class"/>
<property name="connection.username"/>
<property