问题描述
我有这部分hibernate映射xml文件,我正在寻找一个很好的例子来说明原生的意思。
<休眠映射>
< class name =com.hib.Tasktable =tasks>
< id name =idtype =intcolumn =id>
< generator class =native/>
< / id>
我知道这与独特的标识符属性有关,但我真的想要一个例子。 / b>
对于新手问题抱歉,我是一般的新手休眠和编程:)
谢谢!
原生意味着
您的生成器将根据您当前的数据库支持使用标识或序列列。
文档解释了每个策略
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/mapping.html#mapping-declaration-id b
$ b 原生
已分配
让应用程序在调用save()之前为该对象分配一个标识符。如果没有指定元素,这就是默认策略。
例如:
在Mysql如果您将主键列作为auto_increment,则数据库将使用此策略进行更新。
I have this part of hibernate mapping xml file, and I was looking for a good example for what does native mean.
<hibernate-mapping>
<class name="com.hib.Task" table="tasks">
<id name="id" type="int" column="id" >
<generator class="native"/>
</id>
I know it's something related to unique identifier property, but I would really like to have an example.
Sorry for the newbie question, I'm new to hibernate and programming in general :)Thank you!
Native means Your generator will use identity or sequence columns according to what your current database support.
Docs explained about each strategy here
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/mapping.html#mapping-declaration-id
native
assigned
For example:In Mysql if you have primary key column as a auto_increment, the db will be updated using this strategy
这篇关于本地生成器类在休眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!