1. 程式人生 > >Hibernate 異常:Association references unmapped class

Hibernate 異常:Association references unmapped class

Hibernate 異常:

Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class

錯誤: 所有有跟這張表有關聯的 .hbm.xml 的CLASS路徑是否正確.

解決的方法:看各個包中的對映檔案中的內容,如
<many-to-one name="district" class="db.basic.register.District" fetch="select">
            <column name="districtid" length="6" not-null="true" />
        </many-to-one>
        <many-to-one name="users" class="db.basic.register.Users" fetch="select">
            <column name="usersid" not-null="true" />
中的class 後面的路徑是不是對,如果不對改過來即可