org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()

HibernateでIDが自動生成(autoincrementのような)したい場合に、
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()
と出る。
マッピングファイルのgeneratorクラスの設定が原因。

    <id
        name="nid"
        type="int"
        column="nid"
    >
        <meta attribute="field-description">
           @hibernate.id
            generator-class="identity" <- ここ
            type="int"
            column="nid"

        </meta>
        <generator class="identity" />  <- ここ

のように、classにidentityと設定することによって解決。