Topic: 【Hibernate】再请教一个初级问题 SQLGrammarException

  Print this page

1.【Hibernate】再请教一个初级问题 SQLGrammarException Copy to clipboard
Posted by: sc33
Posted on: 2006-02-03 16:26

程序运行时出现如下错误:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Save failed.
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.ehot.hibernate.HibernateTest.main(HibernateTest.java:22)
Caused by: java.sql.BatchUpdateException: Table 'hibernatedemo.hibernatedemo__echo_message' doesn't exist
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:896)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
... 8 more

EchoMessage.hbm.xml 文件如下。我使用的是MySQL数据库,不知有没有影响!

<?xml version="1.0"?>
<!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 - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.ehot.hibernate.EchoMessage" table="echo_message" catalog="hibernatedemo">
<id name="id" type="integer">
<column name="id" />
<generator class="increment"></generator>
</id>
<property name="msg" type="string">
<column name="msg" />
</property>
</class>
</hibernate-mapping>

2.Re:【Hibernate】再请教一个初级问题 SQLGrammarException [Re: sc33] Copy to clipboard
Posted by: why
Posted on: 2006-02-03 22:17

Please show us your source code
Are you following some tutorial?

3.Re:【Hibernate】再请教一个初级问题 SQLGrammarException [Re: sc33] Copy to clipboard
Posted by: jigsaw
Posted on: 2006-02-03 22:47

Caused by: java.sql.BatchUpdateException: Table 'hibernatedemo.hibernatedemo__echo_message' doesn't exist

???

4.Re:【Hibernate】再请教一个初级问题 SQLGrammarException [Re: jigsaw] Copy to clipboard
Posted by: sc33
Posted on: 2006-02-04 01:18

jigsaw wrote:
Caused by: java.sql.BatchUpdateException: Table 'hibernatedemo.hibernatedemo__echo_message' doesn't exist

???

I think I didn't clear which is my question. Sorry for it.

My question is that the element "table" are filled "echo_message", not "hibernatedemo__echo_message" in the file "EchoMessage.hbm.xml". I want to know why they generated "hibernatedemo__echo_message" here?

5.Re:【Hibernate】再请教一个初级问题 SQLGrammarException [Re: sc33] Copy to clipboard
Posted by: forsoft
Posted on: 2006-02-21 15:22

change

<class name="com.ehot.hibernate.EchoMessage" table="echo_message" catalog="hibernatedemo">

to

<class name="com.ehot.hibernate.EchoMessage" table="echo_message">


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923