[java] 06:18:01,906 ERROR SchemaExport:274 - Unsuccessful: create table EVENTS (EVENT_ID bigint
generated by default as identity (start with 1), EVENT_DATE timestamp, title varchar(255), primary
key (EVENT_ID))看上去像是Generated ID这里出了问题, 你把hbm映射文件贴出来看下...
generated by default as identity (start with 1), EVENT_DATE timestamp, title varchar(255), primary
key (EVENT_ID))看上去像是Generated ID这里出了问题, 你把hbm映射文件贴出来看下...
解决方案 »
- SSH框架,做插入可以,但是作更新和查找就报错
- Spring中如何捕获cp30连接池异常?
- SSH集成的时候,使用HibernateTemplate还是HibernateDaoSupport?
- why !!!!
- 编译EJB时报这样的错误---
- Help! Spring+Hibernate应用中的错误
- 关于java连接mysql数据库的问题
- 免费提供把EJb转换成适合Jboss和Weblogic的程序
- 请教高手,MDB怎么实现:接收到某条消息后,怎样通知服务器,使下次仍能接收该消息?
- jsp执行顺序问题
- 如何搭建EJB3.0的开发环境
- 我用lucene写的indexer.java为网站建立索引,请教问题!
楼主仔细检查一下
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping> <class name="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class></hibernate-mapping>
Now, to execute and test all of this, follow these steps: Run ant run -Daction=store to store something into the database and, of course, to generate the database schema before through hbm2ddl. Now disable hbm2ddl by commenting out the property in your hibernate.cfg.xml file. Usually you only leave it turned on in continous unit testing, but another run of hbm2ddl would drop everything you have stored - the create configuration setting actually translates into "drop all tables from the schema, then re-create all tables, when the SessionFactory is build". If you now call Ant with -Daction=list, you should see the events you have stored so far. You can of course also call the store action a few times more. Note: Most new Hibernate users fail at this point and we see questions about Table not found error messages regularly. However, if you follow the steps outlined above you will not have this problem, as hbm2ddl creates the database schema on the first run, and subsequent application restarts will use this schema. If you change the mapping and/or database schema, you have to re-enable hbm2ddl once again. 可我不知道该如何:generate the database schema before through hbm2ddl。
错误信息处好象说的我的table schema都没有创建成功的
what mean?
改为
<property name="title" type="java.lang.String" column="TITLE"/>
这个不影响的,因为DB中的表字段,也就是title的,hibernate可自动映射成功的,说明文档上特地有此说明的。
D, EVENT_DATE, title) values (null, '2007-04-20 06:17:59.984', 'MyEvent')]看这里。如果你的hibernate.cfg.xml没有映射到这个文件的话是找不到TABLE的。如果映射过了的话。请检查一下你的代码否将EVENT_ID的值赋给了空值。因为主键不能为空。
首先在hibernate.cfg.xml文件里设置<property name="hbm2ddl.auto">create</property>
这一项,然后跑ant run -Daction=store,然后将<property name="hbm2ddl.auto">create</property>用<!-- -->注释掉,再跑ant run -Daction=list
就可以看到数据库里的纪录了
通过这次试验我发现一个道理,就是:耐心是最好的老师!
我的技术blog:
http://www.blogcn.com/user77/yklzz/index.html?