3

Configuration()methotを使用したい。しかし、私はこのエラーを受け取ります:

Initial SessionFactory creation failed.org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.example.domain.Lesson"/>

AnnotationConfiguratin()メソッドを使用すると、Hibernateはクラスを読み取ることができます。私はこれを理解していません:

<mapping class="com.example.Lesson"/>Configurationメソッドを使用すると、Hibernateが定義を認識できないのはなぜですか?

私のhibernate.cfg.xmlファイル:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.password">****</property>
        <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/DB</property>
        <property name="hibernate.connection.username">postgres</property>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>   

        <mapping resource="com.example/Lesson.hbm.xml" /> 

        <mapping class="com.example.Lesson"/>


    </session-factory>
</hibernate-configuration>

私のレッスンクラス:

    public class Lesson implements java.io.Serializable {

        private int id;
        private String lesson;
        private Set lessons = new HashSet(0);

        public Lesson() {
        }


        public Lesson(int id, String lesson, Set lessons) {
            this.id = id;
            this.id = id;
            this.lessons = lessons;
        }


        continue..



}

私はbhm.xmlファイルを持っていたreverse engineering.ので、アノテーションを使用したくありません。

何か案が?

4

1 に答える 1

1

<mapping class="com.example.Lesson"/>から削除するだけhibernate.cfg.xmlです。が存在するので必要ありませんLesson.hbm.xml

于 2013-01-16T13:49:12.340 に答える