2 回答

TA貢獻1827條經驗 獲得超8個贊
您可以通過注釋(我更喜歡這個)或在XML文件中定義實體映射。根據錯誤,它正在查找xml文件Person.hbm.xml在文件夾HibernateExposed中(從您的配置文件中查看它)。因此,您需要創建具有實體名稱和所有屬性的Person.hbm.xml文件。例如:<mapping resource="HibernateExposed/Person.hbm.xml" />
<entity-mappings>
<entity class="your_package_name.Produto" name="Produto">
<attributes>
<property name="nome"
type="value"
not-null="value"
update="value"/>
//put all other attributes from Produto class
</attributes>
</entity>
</entity-mappings>
但在這種情況下,您不需要使用注釋。如果要使用批注,請更改為類似@Entityhibernate.cfg.xml<mapping class="your_package_name.Produto"/>

TA貢獻1808條經驗 獲得超4個贊
我解決了使用hibernate.properties文件而不是hibernate.cfg.xml配置hibernate的問題。
我在內存中使用了H2,使用了jdbc URL(H2中的默認值之一):jdbc:h2:mem:test,在hibernate.properties上配置。(此鏈接中的更多內容: http://www.h2database.com/html/features.html#database_url)
我已經按照本教程的所有步驟進行解決方案:https://www.youtube.com/watch?v=MA4tM17H6_M
添加回答
舉報