spring+hibernate配置自动生成数据库表,总是不成功??
applicationContext.xml里的配置如下:
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/test"></property>
<property name="username" value="root"></property>
<property name="password" value="admin"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/wenruijie/dao/Users.hbm.xml</value>
</list>
</property>
com/wenruijie/dao/Users.hbm.xml里的配置如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.wenruijie.dao.Users" table="usersb" catalog="health">
<id name="id" type="java.lang.String">
<column name="id" />
<generator class="native"></generator>
</id>
<property name="name" type="java.lang.String">
<column name="Name" />
</property>
<property name="password" type="java.lang.String">
<column name="Password" />
</property>
</class>
</hibernate-mapping>
访问时不能自动生成table表,还出现如下错误
org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.wenruijie.dao.Users]; SQL [insert into health.usersb (Name, Password) values (?, ?)]; nested exception is
org.hibernate.exception.SQLGrammarException: could not insert: [com.wenruijie.dao.Users]
o