hibernate中update不能自动建表是为什么
<?xmlversion='1.0'encoding='UTF-8'?><!DOCTYPEhibernate-configurationPUBLIC"-//Hiberna...
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="show_sql">ture</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/leejuen/hibernate/Student.hbm.xml" />
</session-factory>
</hibernate-configuration>
配置文件是这样的按理说会自动在mysql中建立一张表的,可是没有建立。但如果数据库中存在这张表却能更新。 展开
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="show_sql">ture</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/leejuen/hibernate/Student.hbm.xml" />
</session-factory>
</hibernate-configuration>
配置文件是这样的按理说会自动在mysql中建立一张表的,可是没有建立。但如果数据库中存在这张表却能更新。 展开
2个回答
2014-02-15
展开全部
property name="hbm2ddl.auto">update</property>
说明是更新了,存在的,才有更新
说明是更新了,存在的,才有更新
追问
但是李刚的书上却是能自动更新啊,如果没有表会自动建立的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询