[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映射文件贴出来看下...

解决方案 »

  1.   

    hbm 贴出来 我也觉得是那里的问题
    楼主仔细检查一下
      

  2.   

    应该没问题的,hibernate_reference上难道写错了,我该是copy的<?xml version="1.0"?>
    <!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>
      

  3.   

    补充下,原文档上有这样的话:
    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都没有创建成功的
      

  4.   

    to pioneer_csdn(春天):
    what mean?
      

  5.   

    <property name="title"/>
    改为
    <property name="title" type="java.lang.String" column="TITLE"/>
      

  6.   

    to greatzheng(达不溜西):
    这个不影响的,因为DB中的表字段,也就是title的,hibernate可自动映射成功的,说明文档上特地有此说明的。
      

  7.   

    [java] java.sql.SQLException: Table not found: EVENTS in statement [insert into EVENTS (EVENT_I
    D, EVENT_DATE, title) values (null, '2007-04-20 06:17:59.984', 'MyEvent')]看这里。如果你的hibernate.cfg.xml没有映射到这个文件的话是找不到TABLE的。如果映射过了的话。请检查一下你的代码否将EVENT_ID的值赋给了空值。因为主键不能为空。
      

  8.   

    原文档的那段英文的大致意思是:
    首先在hibernate.cfg.xml文件里设置<property name="hbm2ddl.auto">create</property>
    这一项,然后跑ant run -Daction=store,然后将<property name="hbm2ddl.auto">create</property>用<!-- -->注释掉,再跑ant run -Daction=list
    就可以看到数据库里的纪录了
      

  9.   

    不过我也遇到一个问题就是,在我没有注释掉<property name="hbm2ddl.auto">create</property>的时候,每次重启ant,数据库里的数据总是不被清空,晕倒!
      

  10.   

    建议楼换一个最简单的表.只有VARCHAR类型的.再映射一下.注意大小写.
      

  11.   

    嘿嘿,我自己的问题解决了。因为我预先把tutorial里的代码拷过来跑了一遍,然后又在hibernate.cfg.xml里删除了暂时没有用到的person.hbm.xml文件的映射,这导致后来我重启的时候,event表是不能被成功删除的,因为有person_event表引用了这个表的主键作为外键,所以造成虽然设置了<property name="hbm2ddl.auto">create</property>,表没有重建也没有被清空数据。
    通过这次试验我发现一个道理,就是:耐心是最好的老师!
    我的技术blog:
    http://www.blogcn.com/user77/yklzz/index.html?
      

  12.   

    呵呵,运行的时候带action参数,好像是这样的.