在我数据库里有test数据库,其中有一人user表,用hibernate映射到User类,配置时URL为:jdbc:mysql://localhost:3306/test
但发布运行后有错误:如下:
Hibernate operation: could not execute query; bad SQL grammar [select user0_.id as id, user0_.username as username0_, user0_.password as password0_ from test__user user0_ where username=?]; Table 'test.test__user' doesn't exist这错误中表怎么变成test__user了,明明我数据库表名是user,郁闷了。不知道为什么,请教一下。
但发布运行后有错误:如下:
Hibernate operation: could not execute query; bad SQL grammar [select user0_.id as id, user0_.username as username0_, user0_.password as password0_ from test__user user0_ where username=?]; Table 'test.test__user' doesn't exist这错误中表怎么变成test__user了,明明我数据库表名是user,郁闷了。不知道为什么,请教一下。
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/test</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</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>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/web/bo/User.hbm.xml</value></list>
</property></bean>
hibernate-mapping>
<class name="com.web.bo.User" table="user" catalog="test">
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<property name="username" type="string">
<column name="username" length="20" not-null="true" />
</property>
<property name="password" type="string">
<column name="password" />
</property>
</class>
</hibernate-mapping>
也让我们学习一下啊。呵呵。
<class name="com.web.bo.User" table="user" catalog="test">把自动生成的catalog="test"删掉!!!