![](/img/trans.png)
[英]A couple of questions about the use of Hibernate and ORM with Oracle
[英]Couple of questions in hibernate ORM.
<hibernate mapping package="org.hibernate.tutorial.domain">
<class name="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>
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html#tutorial-firstapp我正在閱讀有關休眠的這篇文章。
generator class ="native"
是什么意思,它有什么作用? auto_increment
等。 您的問題的答案:
1)這是入門的最佳指南。 -這是休眠的正式且有史以來第一個文檔。 我更喜歡“行動中的休眠”
2)休眠中有幾個generators
,根據需求我們需要選擇合適的生成器,基本上它是用來生成主鍵的。 例如,如果您使用generator="assigned"
即您需要在調用session.save(entity)
之前手動分配一個主鍵。 在這里, native
意味着休眠將根據您在配置中提供的數據庫方言來生成主鍵。 如果使用oracle,則使用序列;如果使用mysql或postgres,則使用auto_increment
3)id表示主鍵,其他是屬性,希望這是為了約定。
4)較舊的應用程序仍使用xmls。 最好在學習時從xml開始,然后將其轉換為注釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.