From hibernate-commits at lists.jboss.org Tue Aug 31 09:03:19 2010 Content-Type: multipart/mixed; boundary="===============2720312109107441866==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r20287 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content. Date: Tue, 31 Aug 2010 09:03:19 -0400 Message-ID: <201008311303.o7VD3JRb012755@svn01.web.mwc.hst.phx2.redhat.com> --===============2720312109107441866== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: steve.ebersole(a)jboss.com Date: 2010-08-31 09:03:19 -0400 (Tue, 31 Aug 2010) New Revision: 20287 Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutor= ial_annotations.xml Log: HHH-5444 - Write annotations tutorial chapter Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/conten= t/tutorial_annotations.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_annotations.xml 2010-08-31 12:43:29 UTC (rev 20286) +++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tuto= rial_annotations.xml 2010-08-31 13:03:19 UTC (rev 20287) @@ -34,44 +34,65 @@ The annotated entity Java class The entity class in this tutorial is org.hibernate.= tutorial.annotations.Event - - Notes About the Entity - - - The entity class is still using JavaBean conventio= ns. 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 @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 def= ault table name would have been - EVENT). - - - - - @javax.persistence.Id marks the property defining the - entity's identifier. @javax.persis= tence.GeneratedValue and - @org.hibernate.annotations.GenericG= enerator work in tandem - to indicate that Hibernate should use Hibernate's = increment generation - strategy for this entity's identifier values. - - - - - Just as discussed in , the - date property needs special han= dling to account for its special naming - and its SQL type. - - - + which is still following JavaBean conventions. In fact the cl= ass itself is exactly the same as we saw + in , th= e only difference being the use of + annotations to provide the metadata instead of a separate hbm.xml file. + + + Identifying the class as an entity + @Entity +(a)Table( name =3D "EVENTS" ) +public class Event { + ... +} + + + + The @javax.persistence.Entity a= nnotation 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 n= ame would have been + EVENT). + + + + Identifying the identifier property + @Id +(a)GeneratedValue(generator=3D"increment") +(a)GenericGenerator(name=3D"increment", strategy =3D "increment") +public Long getId() { + return id; +} + + + + @javax.persistence.Id marks the= property defining the + entity's identifier. @javax.persistence.Genera= tedValue and + @org.hibernate.annotations.GenericGenerator work in tandem + to indicate that Hibernate should use Hibernate's inc= rement generation + strategy for this entity's identifier values. + + + + Identifying basic properties + public String getTitle() { + return title; +} + +(a)Temporal(TemporalType.TIMESTAMP) +(a)Column(name =3D "EVENT_DATE") +public Date getDate() { + return date; +} + + + + Just as discussed in , the + date property needs special handling to acc= ount for its special naming + and its SQL type. + =
--===============2720312109107441866==--