From 5d6317e71534beaecac0cea2c858fcd765a04146 Mon Sep 17 00:00:00 2001 From: mstanleyjones Date: Wed, 13 Oct 2010 13:35:50 +1000 Subject: [PATCH] Edit the Annotations tutorial. --- .../en-US/content/tutorial_annotations.xml | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml b/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml index 0cb001e683..be6e43a159 100644 --- a/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml +++ b/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml @@ -5,38 +5,40 @@ Tutorial Using Native Hibernate APIs and Annotation Mappings - This tutorial is located within the download bundle under basic and illustrates - - - - using annotations to provide mapping information - - - - - using the native Hibernate APIs - - - + This tutorial is located within the download bundle under basic. + + Objectives + + + Use annotations to provide mapping information + + + + + Use the native Hibernate APIs + + + +
The Hibernate configuration file - The contents are exactly the same as in . - The single difference is the mapping element at the very end naming the - annotated entity class using the class attribute. + The contents are identical to , with one important + difference. The mapping element at the very end naming the annotated entity class using + the attribute.
The annotated entity Java class - The entity class in this tutorial is org.hibernate.tutorial.annotations.Event - which is still following JavaBean conventions. In fact the class itself is exactly the same as we saw - in , the only difference being the use of - annotations to provide the metadata instead of a separate hbm.xml file. + The entity class in this tutorial is org.hibernate.tutorial.annotations.Event which + follows JavaBean conventions. In fact the class itself is identical to the one in , except that annotations are used to provide the metadata, + rather than a separate hbm.xml file. @@ -49,17 +51,18 @@ public class Event { - The @javax.persistence.Entity annotation is used to mark a - class as an entity. It's function is essentially the same as the class - mapping element discussed in . - Additionally the @javax.persistence.Table annotation is - used to explicitly specify the table name (the default table name would have been - EVENT). + + The @javax.persistence.Entity annotation is used to mark a class as an entity. + It functions the same as the class mapping element discussed in . Additionally the + @javax.persistence.Table annotation explicitly specifies the table + name. Without this specification, the default table name would be EVENT). - Identifying the identifier property - @Id + Identifying the identifier property + @Id @GeneratedValue(generator="increment") @GenericGenerator(name="increment", strategy = "increment") public Long getId() { @@ -68,7 +71,7 @@ public Long getId() { - @javax.persistence.Id marks the property defining the + @javax.persistence.Id marks the property which defines the entity's identifier. @javax.persistence.GeneratedValue and @org.hibernate.annotations.GenericGenerator work in tandem to indicate that Hibernate should use Hibernate's increment generation @@ -76,8 +79,8 @@ public Long getId() { - Identifying basic properties - public String getTitle() { + Identifying basic properties + public String getTitle() { return title; } @@ -89,9 +92,8 @@ public Date getDate() { - Just as discussed in , the - date property needs special handling to account for its special naming - and its SQL type. + As in , the date property needs + special handling to account for its special naming and its SQL type.
@@ -106,23 +108,21 @@ public Date getDate() {
Take it further! - - Try the following exercises: - - - - With help of the Developer Guide, add an association to - the Event entity to model a message thread. - - - - - With help of the Developer Guide, add a callback to - receive notifications when an Event is created, updated or deleted. Try - the same with an event listener. - - + Practice Exercises + + + Add an association to the Event entity to model a message thread. Use the + Developer Guide as a guide. + + + + + Add a callback to receive notifications when an Event is created, updated or + deleted. Try the same with an event listener. Use the Developer + Guide as a guide. + +