Reputation: 7631
<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 I was going through this article on hibernate.
generator class ="native"
mean and what does it do?Upvotes: 1
Views: 112
Reputation: 5837
Answers to your questions:
1)Is this the best guide for starters. - It is an official and first ever documentation for hibernate. I rather prefer "Hibernate in Action"
2) There are several generators
in hibernate, depends on requirement we need to choose the proper one, Basically it is used to generate the primary key. For example if you use generator="assigned"
i.e., you need to manually assign a primary key before you call session.save(entity)
. Here native
means hibernate will take care of generating primary key based on the database dialect you provided in configuration. It uses sequence if you use oracle and auto_increment if you use mysql or postgres
3) id denotes the primary key, others are properties, Hope this is for a convention.
4) Older applications still uses xmls. It is better to start with xmls while learning then convert them to annotations.
Upvotes: 1
Reputation: 17435
Upvotes: 2
Reputation: 160191
auto_increment
in MySql, etc.Upvotes: 2