From hibernate-commits at lists.jboss.org Thu Aug 19 21:01:03 2010
Content-Type: multipart/mixed; boundary="===============3115153843469684537=="
MIME-Version: 1.0
From: hibernate-commits at lists.jboss.org
To: hibernate-commits at lists.jboss.org
Subject: [hibernate-commits] Hibernate SVN: r20200 -
core/trunk/documentation/quickstart/src/main/docbook/en-US/content.
Date: Thu, 19 Aug 2010 21:01:03 -0400
Message-ID: <201008200101.o7K113Ta005269@svn01.web.mwc.hst.phx2.redhat.com>
--===============3115153843469684537==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: misty(a)redhat.com
Date: 2010-08-19 21:01:03 -0400 (Thu, 19 Aug 2010)
New Revision: 20200
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutor=
ial_native.xml
Log:
HHH-5541
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/conten=
t/tutorial_native.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tuto=
rial_native.xml 2010-08-20 00:30:53 UTC (rev 20199)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tuto=
rial_native.xml 2010-08-20 01:01:03 UTC (rev 20200)
@@ -13,9 +13,11 @@
=
- The tutorials in this guide use Maven, in order to leverage it=
s transitive dependency management
- capabilities and its integration with many development environ=
ments (IDEs). You can use another build
- tool, adapting the examples to fit your needs.
+ The tutorials in this guide use Maven, in order to leverage its
+ transitive dependency management capabilities and its integrat=
ion
+ with many development environments (IDEs). You can use another build tool, adapting the exa=
mples
+ to fit your needs.
=
@@ -40,8 +42,11 @@
Create the entity Java class
=
- Create a file namedsrc/main/java/org/hibernate/t=
utorial/hbm/Event.java,
- containing the text in.
+ Create a file named
+ src/main/java/org/hibernate/tutorial/hbm/Event.j=
ava,
+ containing the text in.
=
@@ -83,7 +88,7 @@
Create the entity mapping file
=
- Create a file namedsrc/main/resources/org/hibern=
ate/tutorial/native/Event.hbm.xml,
+ Create a file named src/main/resources/org/hiber=
nate/tutorial/native/Event.hbm.xml,
with the contents in .
=
@@ -101,79 +106,104 @@
=
- Functions of the class element=
title>
+ Functions of the class element=
- The class attribute, combined h=
ere with the package
- attribute from the containing hibernate-m=
apping element, names the FQN of
- the class you want to define as an entity.
+ The class attribute, combined h=
ere
+ with the package attribute from=
the
+ containing hibernate-mapping el=
ement,
+ names the FQN of the class you want to define as an
+ entity.
- The table attribute names the d=
atabase table which contains the data for
- this entity.
+ The table attribute names the
+ database table which contains the data for this en=
tity.
=
- Instances of Event are now mapped t=
o rows in the EVENTS
- table. Hibernate uses the id element to=
uniquely identify rows in the table.
+ Instances of the Event class are now
+ mapped to rows in the EVENTS
+ table. Hibernate uses the id element to
+ uniquely identify rows in the table.
- It is not strictly necessary that the id element map to the table's actual
- primary key column(s), but it is the normal convention=
. Tables mapped in Hibernate do not even
- need to define primary keys. However, the Hibernate te=
am strongly
- recommends that all schemas define proper referential =
integrity. Therefore id
- and primary key are used interchangea=
bly throughout Hibernate documentation.
+ It is not strictly necessary for the id
+ element to map to the table's actual primary key colum=
n(s),
+ but this type of mapping is conventional. Tables mappe=
d in
+ Hibernate do not even need to define primary keys. How=
ever,
+ the Hibernate team strongly recom=
mends
+ that all schemas define proper referential
+ integrity. Therefore id and
+ primary key are used interchangeably
+ throughout Hibernate documentation.
- The id element here identifies the EVENT_ID column as the
- primary key of the EVENTS table. It als=
o identifies the id
- property of the Event class as the =
property to hold the identifier value.
+ The id element here identifies the EVENT_ID column as the primary =
key of
+ the EVENTS table. It =
also
+ identifies the id property of the
+ Event class as the property contain=
ing
+ the identifier value.
+
+ The generator element nested inside the
+ id element informs Hibernate about which
+ strategy is used to generated primary key values for this
+ entity. In this example, a sequence-like value generation is
+ used.
+
- The important thing to be aware of about the gene=
rator element nested inside the
- id element is that it informs Hibernate=
which strategy is used to generated primary
- key values for this entity. In this instance, it uses a se=
quence-like value generation.
+ The two property elements declare the
+ remaining two properties of the Event
+ class: date andtitle=
. The
+ date property mapping includes the
+ column attribute, but the
+ title does not. In the absence of a
+ column attribute, Hibernate uses the pr=
operty
+ name as the column name. This is appropriate for
+ title, but since date is a
+ reserved keyword in most databases, you need to specify a
+ different word for the column name.
- The two property elements declare the r=
emaining two properties of the
- Event class: date andtitle. The
- date property mapping include the column attribute, but the
- title does not. In the absence of a column attribute, Hibernate
- uses the property name as the column name. This is appropr=
iate for title, but since
- date is a reserved keyword in most data=
bases, you need to specify a non-reserved
- word for the column name.
+ The title mapping also lacks a
+ type attribute. The types declared and =
used
+ in the mapping files are neither Java data types nor SQL
+ database types. Instead, they are Hiber=
nate
+ mapping types. Hibernate mapping type=
s are
+ converters which translate between Java and SQL data
+ types. Hibernate attempts to determine the correct convers=
ion
+ and mapping type autonomously if the type
+ attribute is not present in the mapping, by using Java
+ reflection to determine the Java type of the declared prop=
erty
+ and using a default mapping type for that Java type.
- The title mapping also lacks a type attribute. The types
- declared and used in the mapping files are neither Java da=
ta types nor SQL database types. Instead,
- they are Hibernate mapping types. Hibernate mapping types are
- converters which translate between Java and SQL data types=
. Hibernate attempts to determine the correct
- conversion and mapping type autonomously if the t=
ype attribute is not present in the
- mapping, by using Java reflection to determine the Java ty=
pe of the declared property and using a
- default mapping type for that Java type.
+ In some cases this automatic detection might not choose the
+ default you expect or need, as seen with the
+ date property. Hibernate cannot know if=
the
+ property, which is of type
+ java.util.Date, should map to a SQL
+ DATE, TIME, or
+ TIMESTAMP datatype. Full date and time
+ information is preserved by mapping the property to a
+ timestamp converter.
-
- In some cases this automatic detection might not have the =
default you expect or need, as seen with the
- date property. Hibernate cannot know if=
the property, which is of type
- java.util.Date, should map to a SQL=
DATE,
- TIME, or TIMESTAMP d=
atatype. Full date and time information is
- preserved by mapping the property to a timestamp<=
/literal>
- converter.
-
=
-
+
- Hibernate makes this mapping type determination using =
reflection when the mapping files are
- processed. This can take time and resources. If startu=
p performance is important, consider
- explicitly defining the type to use.
+ Hibernate makes this mapping type determination using
+ reflection when the mapping files are processed. This =
can
+ take time and resources. If startup performance is
+ important, consider explicitly defining the type to us=
e.
-
+
=
--===============3115153843469684537==--