Hibernate SVN: r19618 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-26 12:20:08 -0400 (Wed, 26 May 2010)
New Revision: 19618
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 merge natural id documentation
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:19:35 UTC (rev 19617)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:20:08 UTC (rev 19618)
@@ -4515,20 +4515,47 @@
<section id="mapping-declaration-naturalid">
<title>Natural-id</title>
- <programlisting role="XML"><natural-id mutable="true|false"/>
- <property ... />
- <many-to-one ... />
- ......
-</natural-id></programlisting>
-
<para>Although we recommend the use of surrogate keys as primary keys,
you should try to identify natural keys for all entities. A natural key
is a property or combination of properties that is unique and non-null.
- It is also immutable. Map the properties of the natural key inside the
+ It is also immutable. Map the properties of the natural key as
+ <classname>@NaturalId</classname> or map them inside the
<literal><natural-id></literal> element. Hibernate will generate
the necessary unique key and nullability constraints and, as a result,
your mapping will be more self-documenting.</para>
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Citizen {
+ @Id
+ @GeneratedValue
+ private Integer id;
+ private String firstname;
+ private String lastname;
+
+ @NaturalId
+ @ManyToOne
+ private State state;
+
+ @NaturalId
+ private String ssn;
+ ...
+}
+
+
+
+//and later on query
+List results = s.createCriteria( Citizen.class )
+ .add( Restrictions.naturalId().set( "ssn", "1234" ).set( "state", ste ) )
+ .list();</programlisting>
+
+ <para>Or in XML,</para>
+
+ <programlisting role="XML"><natural-id mutable="true|false"/>
+ <property ... />
+ <many-to-one ... />
+ ......
+</natural-id></programlisting>
+
<para>It is recommended that you implement <literal>equals()</literal>
and <literal>hashCode()</literal> to compare the natural key properties
of the entity.</para>
14 years, 7 months
Hibernate SVN: r19617 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-26 12:19:35 -0400 (Wed, 26 May 2010)
New Revision: 19617
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 Merge <properties> section with annotations own construct
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:19:02 UTC (rev 19616)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:19:35 UTC (rev 19617)
@@ -4739,35 +4739,41 @@
unique key of the <literal>Person</literal> table, instead of to the
primary key:</para>
- <programlisting role="XML"><many-to-one name="person"
+ <programlisting role="XML"><many-to-one name="owner"
class="Person" property-ref="name">
<column name="firstName"/>
<column name="initial"/>
<column name="lastName"/>
</many-to-one></programlisting>
- <para>The use of this outside the context of mapping legacy data is not
- recommended.</para>
- </section>
+ <note>
+ <para>When using annotations as a mapping strategy, such construct is
+ not necessary as the binding between a column and its related column
+ on the associated table is done directly</para>
- <programlisting><import
- class="ClassName"
- rename="ShortName"
-/></programlisting>
+ <programlisting>@Entity
+class Person {
+ @Id Integer personNumber;
+ String firstName;
+ @Column(name="I")
+ String initial;
+ String lastName;
+}
- <calloutlist>
- <callout arearefs="import1">
- <para><literal>class</literal>: the fully qualified class name of
- any Java class.</para>
- </callout>
+@Entity
+class Home {
+ @ManyToOne
+ @JoinColumns({
+ @JoinColumn(name="first_name", referencedColumnName="firstName"),
+ @JoinColumn(name="init", referencedColumnName="I"),
+ @JoinColumn(name="last_name", referencedColumnName="lastName"),
+ })
+ Person owner
+}</programlisting>
+ </note>
- <callout arearefs="import2">
- <para><literal>rename</literal> (optional - defaults to the
- unqualified class name): a name that can be used in the query
- language.</para>
- </callout>
- </calloutlist>
- </programlistingco>
+ <para>The use of this outside the context of mapping legacy data is not
+ recommended.</para>
</section>
<section id="mapping-types-anymapping" revision="2">
14 years, 7 months
Hibernate SVN: r19616 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-26 12:19:02 -0400 (Wed, 26 May 2010)
New Revision: 19616
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 move xml specific constructs to its dedicated section
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:18:28 UTC (rev 19615)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:19:02 UTC (rev 19616)
@@ -371,6 +371,182 @@
<literal>Dog.hbm.xml</literal>, or if using inheritance,
<literal>Animal.hbm.xml</literal>.</para>
</section>
+
+ <section id="mapping-declaration-key">
+ <title>Key</title>
+
+ <para>The <literal><key></literal> element is featured a few
+ times within this guide. It appears anywhere the parent mapping
+ element defines a join to a new table that references the primary key
+ of the original table. It also defines the foreign key in the joined
+ table:</para>
+
+ <programlistingco role="XML">
+ <areaspec>
+ <area coords="2" id="key1" />
+
+ <area coords="3" id="key2" />
+
+ <area coords="4" id="key3" />
+
+ <area coords="5" id="key4" />
+
+ <area coords="6" id="key5" />
+
+ <area coords="7" id="key6" />
+ </areaspec>
+
+ <programlisting><key
+ column="columnname"
+ on-delete="noaction|cascade"
+ property-ref="propertyName"
+ not-null="true|false"
+ update="true|false"
+ unique="true|false"
+/></programlisting>
+
+ <calloutlist>
+ <callout arearefs="key1">
+ <para><literal>column</literal> (optional): the name of the
+ foreign key column. This can also be specified by nested
+ <literal><column></literal> element(s).</para>
+ </callout>
+
+ <callout arearefs="key2">
+ <para><literal>on-delete</literal> (optional - defaults to
+ <literal>noaction</literal>): specifies whether the foreign key
+ constraint has database-level cascade delete enabled.</para>
+ </callout>
+
+ <callout arearefs="key3">
+ <para><literal>property-ref</literal> (optional): specifies that
+ the foreign key refers to columns that are not the primary key
+ of the original table. It is provided for legacy data.</para>
+ </callout>
+
+ <callout arearefs="key4">
+ <para><literal>not-null</literal> (optional): specifies that the
+ foreign key columns are not nullable. This is implied whenever
+ the foreign key is also part of the primary key.</para>
+ </callout>
+
+ <callout arearefs="key5">
+ <para><literal>update</literal> (optional): specifies that the
+ foreign key should never be updated. This is implied whenever
+ the foreign key is also part of the primary key.</para>
+ </callout>
+
+ <callout arearefs="key6">
+ <para><literal>unique</literal> (optional): specifies that the
+ foreign key should have a unique constraint. This is implied
+ whenever the foreign key is also the primary key.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+
+ <para>For systems where delete performance is important, we recommend
+ that all keys should be defined
+ <literal>on-delete="cascade"</literal>. Hibernate uses a
+ database-level <literal>ON CASCADE DELETE</literal> constraint,
+ instead of many individual <literal>DELETE</literal> statements. Be
+ aware that this feature bypasses Hibernate's usual optimistic locking
+ strategy for versioned data.</para>
+
+ <para>The <literal>not-null</literal> and <literal>update</literal>
+ attributes are useful when mapping a unidirectional one-to-many
+ association. If you map a unidirectional one-to-many association to a
+ non-nullable foreign key, you <emphasis>must</emphasis> declare the
+ key column using <literal><key
+ not-null="true"></literal>.</para>
+ </section>
+
+ <section id="mapping-declaration-import">
+ <title>Import</title>
+
+ <para>If your application has two persistent classes with the same
+ name, and you do not want to specify the fully qualified package name
+ in Hibernate queries, classes can be "imported" explicitly, rather
+ than relying upon <literal>auto-import="true"</literal>. You can also
+ import classes and interfaces that are not explicitly mapped:</para>
+
+ <programlisting role="XML"><import class="java.lang.Object" rename="Universe"/></programlisting>
+
+ <programlistingco role="XML">
+ <areaspec>
+ <area coords="2" id="import1" />
+
+ <area coords="3" id="import2" />
+ </areaspec>
+
+ <programlisting><import
+ class="ClassName"
+ rename="ShortName"
+/></programlisting>
+
+ <calloutlist>
+ <callout arearefs="import1">
+ <para><literal>class</literal>: the fully qualified class name
+ of any Java class.</para>
+ </callout>
+
+ <callout arearefs="import2">
+ <para><literal>rename</literal> (optional - defaults to the
+ unqualified class name): a name that can be used in the query
+ language.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+
+ <note>
+ <para>This feature is unique to hbm.xml and is not supported in
+ annotations.</para>
+ </note>
+ </section>
+
+ <section id="mapping-column" revision="5">
+ <title>Column and formula elements</title>
+
+ <para>Mapping elements which accept a <literal>column</literal>
+ attribute will alternatively accept a
+ <literal><column></literal> subelement. Likewise,
+ <literal><formula></literal> is an alternative to the
+ <literal>formula</literal> attribute. For example:</para>
+
+ <programlisting role="XML"><column
+ name="column_name"
+ length="N"
+ precision="N"
+ scale="N"
+ not-null="true|false"
+ unique="true|false"
+ unique-key="multicolumn_unique_key_name"
+ index="index_name"
+ sql-type="sql_type_name"
+ check="SQL expression"
+ default="SQL expression"
+ read="SQL expression"
+ write="SQL expression"/></programlisting>
+
+ <programlisting role="XML"><formula>SQL expression</formula></programlisting>
+
+ <para>Most of the attributes on <literal>column</literal> provide a
+ means of tailoring the DDL during automatic schema generation. The
+ <literal>read</literal> and <literal>write</literal> attributes allow
+ you to specify custom SQL that Hibernate will use to access the
+ column's value. For more on this, see the discussion of <link
+ linkend="mapping-column-read-and-write">column read and write
+ expressions</link>.</para>
+
+ <para>The <literal>column</literal> and <literal>formula</literal>
+ elements can even be combined within the same property or association
+ mapping to express, for example, exotic join conditions.</para>
+
+ <programlisting role="XML"><many-to-one name="homeAddress" class="Address"
+ insert="false" update="false">
+ <column name="person_id" not-null="true" length="10"/>
+ <formula>'MAILING'</formula>
+</many-to-one></programlisting>
+ </section>
</section>
<section id="mapping-declaration-class" revision="3">
@@ -4574,155 +4750,6 @@
recommended.</para>
</section>
- <section id="mapping-declaration-key">
- <title>Key</title>
-
- <para>The <literal><key></literal> element has featured a few
- times within this guide. It appears anywhere the parent mapping element
- defines a join to a new table that references the primary key of the
- original table. It also defines the foreign key in the joined
- table:</para>
-
- <programlistingco role="XML">
- <areaspec>
- <area coords="2" id="key1" />
-
- <area coords="3" id="key2" />
-
- <area coords="4" id="key3" />
-
- <area coords="5" id="key4" />
-
- <area coords="6" id="key5" />
-
- <area coords="7" id="key6" />
- </areaspec>
-
- <programlisting><key
- column="columnname"
- on-delete="noaction|cascade"
- property-ref="propertyName"
- not-null="true|false"
- update="true|false"
- unique="true|false"
-/></programlisting>
-
- <calloutlist>
- <callout arearefs="key1">
- <para><literal>column</literal> (optional): the name of the
- foreign key column. This can also be specified by nested
- <literal><column></literal> element(s).</para>
- </callout>
-
- <callout arearefs="key2">
- <para><literal>on-delete</literal> (optional - defaults to
- <literal>noaction</literal>): specifies whether the foreign key
- constraint has database-level cascade delete enabled.</para>
- </callout>
-
- <callout arearefs="key3">
- <para><literal>property-ref</literal> (optional): specifies that
- the foreign key refers to columns that are not the primary key of
- the original table. It is provided for legacy data.</para>
- </callout>
-
- <callout arearefs="key4">
- <para><literal>not-null</literal> (optional): specifies that the
- foreign key columns are not nullable. This is implied whenever the
- foreign key is also part of the primary key.</para>
- </callout>
-
- <callout arearefs="key5">
- <para><literal>update</literal> (optional): specifies that the
- foreign key should never be updated. This is implied whenever the
- foreign key is also part of the primary key.</para>
- </callout>
-
- <callout arearefs="key6">
- <para><literal>unique</literal> (optional): specifies that the
- foreign key should have a unique constraint. This is implied
- whenever the foreign key is also the primary key.</para>
- </callout>
- </calloutlist>
- </programlistingco>
-
- <para>For systems where delete performance is important, we recommend
- that all keys should be defined <literal>on-delete="cascade"</literal>.
- Hibernate uses a database-level <literal>ON CASCADE DELETE</literal>
- constraint, instead of many individual <literal>DELETE</literal>
- statements. Be aware that this feature bypasses Hibernate's usual
- optimistic locking strategy for versioned data.</para>
-
- <para>The <literal>not-null</literal> and <literal>update</literal>
- attributes are useful when mapping a unidirectional one-to-many
- association. If you map a unidirectional one-to-many association to a
- non-nullable foreign key, you <emphasis>must</emphasis> declare the key
- column using <literal><key not-null="true"></literal>.</para>
- </section>
-
- <section id="mapping-column" revision="5">
- <title>Column and formula elements</title>
-
- <para>Mapping elements which accept a <literal>column</literal>
- attribute will alternatively accept a <literal><column></literal>
- subelement. Likewise, <literal><formula></literal> is an
- alternative to the <literal>formula</literal> attribute. For
- example:</para>
-
- <programlisting role="XML"><column
- name="column_name"
- length="N"
- precision="N"
- scale="N"
- not-null="true|false"
- unique="true|false"
- unique-key="multicolumn_unique_key_name"
- index="index_name"
- sql-type="sql_type_name"
- check="SQL expression"
- default="SQL expression"
- read="SQL expression"
- write="SQL expression"/></programlisting>
-
- <programlisting role="XML"><formula>SQL expression</formula></programlisting>
-
- <para>Most of the attributes on <literal>column</literal> provide a
- means of tailoring the DDL during automatic schema generation. The
- <literal>read</literal> and <literal>write</literal> attributes allow
- you to specify custom SQL that Hibernate will use to access the column's
- value. For more on this, see the discussion of <link
- linkend="mapping-column-read-and-write">column read and write
- expressions</link>.</para>
-
- <para>The <literal>column</literal> and <literal>formula</literal>
- elements can even be combined within the same property or association
- mapping to express, for example, exotic join conditions.</para>
-
- <programlisting role="XML"><many-to-one name="homeAddress" class="Address"
- insert="false" update="false">
- <column name="person_id" not-null="true" length="10"/>
- <formula>'MAILING'</formula>
-</many-to-one></programlisting>
- </section>
-
- <section id="mapping-declaration-import">
- <title>Import</title>
-
- <para>If your application has two persistent classes with the same name,
- and you do not want to specify the fully qualified package name in
- Hibernate queries, classes can be "imported" explicitly, rather than
- relying upon <literal>auto-import="true"</literal>. You can also import
- classes and interfaces that are not explicitly mapped:</para>
-
- <programlisting role="XML"><import class="java.lang.Object" rename="Universe"/></programlisting>
-
- <programlistingco role="XML">
- <areaspec>
- <area coords="2" id="import1" />
-
- <area coords="3" id="import2" />
- </areaspec>
-
<programlisting><import
class="ClassName"
rename="ShortName"
14 years, 7 months
Hibernate SVN: r19615 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-26 12:18:28 -0400 (Wed, 26 May 2010)
New Revision: 19615
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 Merge @Any documentation
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:17:33 UTC (rev 19614)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:18:28 UTC (rev 19615)
@@ -4747,21 +4747,62 @@
<title>Any</title>
<para>There is one more type of property mapping. The
- <literal><any></literal> mapping element defines a polymorphic
- association to classes from multiple tables. This type of mapping
- requires more than one column. The first column contains the type of the
- associated entity. The remaining columns contain the identifier. It is
- impossible to specify a foreign key constraint for this kind of
- association. This is not the usual way of mapping polymorphic
- associations and you should use this only in special cases. For example,
- for audit logs, user session data, etc.</para>
+ <classname>@Any</classname> mapping defines a polymorphic association to
+ classes from multiple tables. This type of mapping requires more than
+ one column. The first column contains the type of the associated entity.
+ The remaining columns contain the identifier. It is impossible to
+ specify a foreign key constraint for this kind of association. This is
+ not the usual way of mapping polymorphic associations and you should use
+ this only in special cases. For example, for audit logs, user session
+ data, etc.</para>
- <para>The <literal>meta-type</literal> attribute allows the application
- to specify a custom type that maps database column values to persistent
- classes that have identifier properties of the type specified by
- <literal>id-type</literal>. You must specify the mapping from values of
- the meta-type to class names.</para>
+ <para>The <classname>@Any</classname> annotation describes the column
+ holding the metadata information. To link the value of the metadata
+ information and an actual entity type, The
+ <classname>@AnyDef</classname> and <classname>@AnyDefs</classname>
+ annotations are used. The <literal>metaType</literal> attribute allows
+ the application to specify a custom type that maps database column
+ values to persistent classes that have identifier properties of the type
+ specified by <literal>idType</literal>. You must specify the mapping
+ from values of the <literal>metaType</literal> to class names.</para>
+ <programlisting language="JAVA" role="JAVA">@Any( metaColumn = @Column( name = "property_type" ), fetch=FetchType.EAGER )
+@AnyMetaDef(
+ idType = "integer",
+ metaType = "string",
+ metaValues = {
+ @MetaValue( value = "S", targetEntity = StringProperty.class ),
+ @MetaValue( value = "I", targetEntity = IntegerProperty.class )
+ } )
+@JoinColumn( name = "property_id" )
+public Property getMainProperty() {
+ return mainProperty;
+}</programlisting>
+
+ <para>Note that <classname>@AnyDef</classname> can be mutualized and
+ reused. It is recommended to place it as a package metadata in this
+ case.</para>
+
+ <programlisting language="JAVA" role="JAVA">//on a package
+@AnyMetaDef( name="property"
+ idType = "integer",
+ metaType = "string",
+ metaValues = {
+ @MetaValue( value = "S", targetEntity = StringProperty.class ),
+ @MetaValue( value = "I", targetEntity = IntegerProperty.class )
+ } )
+package org.hibernate.test.annotations.any;
+
+
+//in a class
+ @Any( metaDef="property", metaColumn = @Column( name = "property_type" ), fetch=FetchType.EAGER )
+ @JoinColumn( name = "property_id" )
+ public Property getMainProperty() {
+ return mainProperty;
+ }</programlisting>
+
+ <para>The hbm.xml equivalent is:</para>
+
<programlisting role="XML"><any name="being" id-type="long" meta-type="string">
<meta-value value="TBL_ANIMAL" class="Animal"/>
<meta-value value="TBL_HUMAN" class="Human"/>
@@ -4770,6 +4811,11 @@
<column name="id"/>
</any></programlisting>
+ <note>
+ <para>You cannot mutualize the metadata in hbm.xml as you can in
+ annotations.</para>
+ </note>
+
<programlistingco role="XML">
<areaspec>
<area coords="2" id="any1" />
14 years, 7 months
Hibernate SVN: r19614 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-26 12:17:33 -0400 (Wed, 26 May 2010)
New Revision: 19614
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 Merge property documentation
I've decided to keep the split because the annotation concepts are layered fairly differently than
the xml ones on properties.
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:16:55 UTC (rev 19613)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:17:33 UTC (rev 19614)
@@ -3206,39 +3206,577 @@
<section id="mapping-declaration-property" revision="4">
<title>Property</title>
- <para>The <literal><property></literal> element declares a
- persistent JavaBean style property of the class.</para>
+ <para>You need to decide which property needs to be made persistent in a
+ given entity. This differs slightly between the annotation driven
+ metadata and the hbm.xml files.</para>
- <programlistingco role="XML">
- <areaspec>
- <area coords="2" id="property1" />
+ <section>
+ <title>Property mapping with annotations</title>
- <area coords="3" id="property2" />
+ <para>In the annotations world, every non static non transient
+ property (field or method depending on the access type) of an entity
+ is considered persistent, unless you annotate it as
+ <literal>@Transient</literal>. Not having an annotation for your
+ property is equivalent to the appropriate <literal>@Basic</literal>
+ annotation.</para>
- <area coords="4" id="property3" />
+ <para>The <literal>@Basic</literal> annotation allows you to declare
+ the fetching strategy for a property. If set to
+ <literal>LAZY</literal>, specifies that this property should be
+ fetched lazily when the instance variable is first accessed. It
+ requires build-time bytecode instrumentation, if your classes are not
+ instrumented, property level lazy loading is silently ignored. The
+ default is <literal>EAGER</literal>. You can also mark a property as
+ not optional thanks to the <classname>@Basic.optional</classname>
+ attribute. This will ensure that the underlying column are not
+ nullable (if possible). Note that a better approach is to use the
+ <classname>@NotNull</classname> annotation of the Bean Validation
+ specification.</para>
- <areaset coords="" id="property4-5">
- <area coords="5" id="property4" />
+ <para>Let's look at a few examples:</para>
- <area coords="6" id="property5" />
- </areaset>
+ <programlisting language="JAVA" role="JAVA">public transient int counter; //transient property
- <area coords="7" id="property6" />
+private String firstname; //persistent property
- <area coords="8" id="property7" />
+@Transient
+String getLengthInMeter() { ... } //transient property
- <area coords="9" id="property8" />
+String getName() {... } // persistent property
- <area coords="10" id="property9" />
+@Basic
+int getLength() { ... } // persistent property
- <area coords="11" id="property10" />
+@Basic(fetch = FetchType.LAZY)
+String getDetailedComment() { ... } // persistent property
- <area coords="12" id="property11" />
+(a)Temporal(TemporalType.TIME)
+java.util.Date getDepartureTime() { ... } // persistent property
- <area coords="13" id="property12" />
- </areaspec>
+(a)Enumerated(EnumType.STRING)
+Starred getNote() { ... } //enum persisted as String in database</programlisting>
- <programlisting><property
+ <para><literal>counter</literal>, a transient field, and
+ <literal>lengthInMeter</literal>, a method annotated as
+ <literal>@Transient</literal>, and will be ignored by the Hibernate.
+ <literal>name</literal>, <literal>length</literal>, and
+ <literal>firstname</literal> properties are mapped persistent and
+ eagerly fetched (the default for simple properties). The
+ <literal>detailedComment</literal> property value will be lazily
+ fetched from the database once a lazy property of the entity is
+ accessed for the first time. Usually you don't need to lazy simple
+ properties (not to be confused with lazy association fetching). The
+ recommended alternative is to use the projection capability of JP-QL
+ (Java Persistence Query Language) or Criteria queries.</para>
+
+ <para>JPA support property mapping of all basic types supported by
+ Hibernate (all basic Java types , their respective wrappers and
+ serializable classes). Hibernate Annotations supports out of the box
+ enum type mapping either into a ordinal column (saving the enum
+ ordinal) or a string based column (saving the enum string
+ representation): the persistence representation, defaulted to ordinal,
+ can be overridden through the <literal>@Enumerated</literal>
+ annotation as shown in the <literal>note</literal> property
+ example.</para>
+
+ <para></para>
+
+ <para>In plain Java APIs, the temporal precision of time is not
+ defined. When dealing with temporal data you might want to describe
+ the expected precision in database. Temporal data can have
+ <literal>DATE</literal>, <literal>TIME</literal>, or
+ <literal>TIMESTAMP</literal> precision (ie the actual date, only the
+ time, or both). Use the <literal>@Temporal</literal> annotation to
+ fine tune that.</para>
+
+ <para><literal>@Lob</literal> indicates that the property should be
+ persisted in a Blob or a Clob depending on the property type:
+ <classname>java.sql.Clob</classname>,
+ <classname>Character[]</classname>, <classname>char[]</classname> and
+ java.lang.<classname>String</classname> will be persisted in a Clob.
+ <classname>java.sql.Blob</classname>, <classname>Byte[]</classname>,
+ <classname>byte[] </classname>and <classname>Serializable</classname>
+ type will be persisted in a Blob.</para>
+
+ <programlisting language="JAVA" role="JAVA">@Lob
+public String getFullText() {
+ return fullText;
+}
+
+@Lob
+public byte[] getFullCode() {
+ return fullCode;
+}</programlisting>
+
+ <para>If the property type implements
+ <classname>java.io.Serializable</classname> and is not a basic type,
+ and if the property is not annotated with <literal>@Lob</literal>,
+ then the Hibernate <literal>serializable</literal> type is
+ used.</para>
+
+ <section>
+ <title>Type</title>
+
+ <para>You can also manually specify a type using the
+ <literal>@org.hibernate.annotations.Type</literal> and some
+ parameters if needed. <classname>@Type.type</classname> could
+ be:</para>
+
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>The name of a Hibernate basic type: <literal>integer,
+ string, character, date, timestamp, float, binary, serializable,
+ object, blob</literal> etc.</para>
+ </listitem>
+
+ <listitem>
+ <para>The name of a Java class with a default basic type:
+ <literal>int, float, char, java.lang.String, java.util.Date,
+ java.lang.Integer, java.sql.Clob</literal> etc.</para>
+ </listitem>
+
+ <listitem>
+ <para>The name of a serializable Java class.</para>
+ </listitem>
+
+ <listitem>
+ <para>The class name of a custom type:
+ <literal>com.illflow.type.MyCustomType</literal> etc.</para>
+ </listitem>
+ </orderedlist>
+
+ <para>If you do not specify a type, Hibernate will use reflection
+ upon the named property and guess the correct Hibernate type.
+ Hibernate will attempt to interpret the name of the return class of
+ the property getter using, in order, rules 2, 3, and 4.</para>
+
+ <para><literal>@org.hibernate.annotations.TypeDef</literal> and
+ <literal>@org.hibernate.annotations.TypeDefs</literal> allows you to
+ declare type definitions. These annotations can be placed at the
+ class or package level. Note that these definitions are global for
+ the session factory (even when defined at the class level). If the
+ type is used on a single entity, you can place the definition on the
+ entity itself. Otherwise, it is recommended to place the definition
+ at the package level. In the example below, when Hibernate
+ encounters a property of class <literal>PhoneNumer</literal>, it
+ delegates the persistence strategy to the custom mapping type
+ <literal>PhoneNumberType</literal>. However, properties belonging to
+ other classes, too, can delegate their persistence strategy to
+ <literal>PhoneNumberType</literal>, by explicitly using the
+ <literal>@Type</literal> annotation.</para>
+
+ <note>
+ <para>Package level annotations are placed in a file named
+ <filename>package-info.java</filename> in the appropriate package.
+ Place your annotations before the package declaration.</para>
+ </note>
+
+ <programlisting language="JAVA" role="JAVA">@TypeDef(
+ name = "phoneNumber",
+ defaultForType = PhoneNumber.class,
+ typeClass = PhoneNumberType.class
+)
+
+@Entity
+public class ContactDetails {
+ [...]
+ private PhoneNumber localPhoneNumber;
+ @Type(type="phoneNumber")
+ private OverseasPhoneNumber overseasPhoneNumber;
+ [...]
+}</programlisting>
+
+ <para>The following example shows the usage of the
+ <literal>parameters</literal> attribute to customize the
+ TypeDef.</para>
+
+ <programlisting language="JAVA" role="JAVA">//in org/hibernate/test/annotations/entity/package-info.java
+@TypeDefs(
+ {
+ @TypeDef(
+ name="caster",
+ typeClass = CasterStringType.class,
+ parameters = {
+ @Parameter(name="cast", value="lower")
+ }
+ )
+ }
+)
+package org.hibernate.test.annotations.entity;
+
+//in org/hibernate/test/annotations/entity/Forest.java
+public class Forest {
+ @Type(type="caster")
+ public String getSmallText() {
+ ...
+} </programlisting>
+
+ <para>When using composite user type, you will have to express
+ column definitions. The <literal>@Columns</literal> has been
+ introduced for that purpose.</para>
+
+ <programlisting language="JAVA" role="JAVA">@Type(type="org.hibernate.test.annotations.entity.MonetaryAmountUserType")
+@Columns(columns = {
+ @Column(name="r_amount"),
+ @Column(name="r_currency")
+})
+public MonetaryAmount getAmount() {
+ return amount;
+}
+
+
+public class MonetaryAmount implements Serializable {
+ private BigDecimal amount;
+ private Currency currency;
+ ...
+}</programlisting>
+ </section>
+
+ <section>
+ <title>Access type</title>
+
+ <para>By default the access type of a class hierarchy is defined by
+ the position of the <classname>@Id</classname> or
+ <classname>@EmbeddedId</classname> annotations. If these annotations
+ are on a field, then only fields are considered for persistence and
+ the state is accessed via the field. If there annotations are on a
+ getter, then only the getters are considered for persistence and the
+ state is accessed via the getter/setter. That works well in practice
+ and is the recommended approach.<note>
+ <para>The placement of annotations within a class hierarchy has
+ to be consistent (either field or on property) to be able to
+ determine the default access type. It is recommended to stick to
+ one single annotation placement strategy throughout your whole
+ application.</para>
+ </note></para>
+
+ <para>However in some situations, you need to:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>force the access type of the entity hierarchy</para>
+ </listitem>
+
+ <listitem>
+ <para>override the access type of a specific entity in the class
+ hierarchy</para>
+ </listitem>
+
+ <listitem>
+ <para>override the access type of an embeddable type</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>The best use case is an embeddable class used by several
+ entities that might not use the same access type. In this case it is
+ better to force the access type at the embeddable class
+ level.</para>
+
+ <para>To force the access type on a given class, use the
+ <classname>@Access</classname> annotation as showed below:</para>
+
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Order {
+ @Id private Long id;
+ public Long getId() { return id; }
+ public void setId(Long id) { this.id = id; }
+
+ @Embedded private Address address;
+ public Address getAddress() { return address; }
+ public void setAddress() { this.address = address; }
+}
+
+@Entity
+public class User {
+ private Long id;
+ @Id public Long getId() { return id; }
+ public void setId(Long id) { this.id = id; }
+
+ private Address address;
+ @Embedded public Address getAddress() { return address; }
+ public void setAddress() { this.address = address; }
+}
+
+@Embeddable
+(a)Access(AcessType.PROPERTY)
+public class Address {
+ private String street1;
+ public String getStreet1() { return street1; }
+ public void setStreet1() { this.street1 = street1; }
+
+ private hashCode; //not persistent
+}</programlisting>
+
+ <para>You can also override the access type of a single property
+ while keeping the other properties standard.</para>
+
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class Order {
+ @Id private Long id;
+ public Long getId() { return id; }
+ public void setId(Long id) { this.id = id; }
+ @Transient private String userId;
+ @Transient private String orderId;
+
+ @Access(AccessType.PROPERTY)
+ public String getOrderNumber() { return userId + ":" + orderId; }
+ public void setOrderNumber() { this.userId = ...; this.orderId = ...; }
+}</programlisting>
+
+ <para>In this example, the default access type is
+ <classname>FIELD</classname> except for the
+ <literal>orderNumber</literal> property. Note that the corresponding
+ field, if any must be marked as <classname>@Transient</classname> or
+ <code>transient</code>.</para>
+
+ <note>
+ <title>@org.hibernate.annotations.AccessType</title>
+
+ <para>The annotation
+ <classname>@org.hibernate.annotations.AccessType</classname>
+ should be considered deprecated for FIELD and PROPERTY access. It
+ is still useful however if you need to use a custom access
+ type.</para>
+ </note>
+ </section>
+
+ <section>
+ <title>Optimistic lock</title>
+
+ <para>It is sometimes useful to avoid increasing the version number
+ even if a given property is dirty (particularly collections). You
+ can do that by annotating the property (or collection) with
+ <literal>@OptimisticLock(excluded=true)</literal>.</para>
+
+ <para>More formally, specifies that updates to this property do not
+ require acquisition of the optimistic lock.</para>
+ </section>
+
+ <section id="entity-mapping-property-column">
+ <title>Declaring column attributes</title>
+
+ <para>The column(s) used for a property mapping can be defined using
+ the <literal>@Column</literal> annotation. Use it to override
+ default values (see the JPA specification for more information on
+ the defaults). You can use this annotation at the property level for
+ properties that are:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>not annotated at all</para>
+ </listitem>
+
+ <listitem>
+ <para>annotated with <literal>@Basic</literal></para>
+ </listitem>
+
+ <listitem>
+ <para>annotated with <literal>@Version</literal></para>
+ </listitem>
+
+ <listitem>
+ <para>annotated with <literal>@Lob</literal></para>
+ </listitem>
+
+ <listitem>
+ <para>annotated with <literal>@Temporal</literal></para>
+ </listitem>
+ </itemizedlist>
+
+ <programlisting language="JAVA" role="JAVA">
+@Entity
+public class Flight implements Serializable {
+...
+@Column(updatable = false, name = "flight_name", nullable = false, length=50)
+public String getName() { ... }
+ </programlisting>
+
+ <para>The <literal>name</literal> property is mapped to the
+ <literal>flight_name</literal> column, which is not nullable, has a
+ length of 50 and is not updatable (making the property
+ immutable).</para>
+
+ <para>This annotation can be applied to regular properties as well
+ as <literal>@Id</literal> or <literal>@Version</literal>
+ properties.</para>
+
+ <programlistingco>
+ <areaspec>
+ <area coords="2" id="hm1" />
+
+ <area coords="3" id="hm2" />
+
+ <area coords="4" id="hm3" />
+
+ <area coords="5" id="hm4" />
+
+ <area coords="6" id="hm5" />
+
+ <area coords="7" id="hm6" />
+
+ <area coords="8" id="hm7" />
+
+ <area coords="9" id="hm8" />
+
+ <area coords="10" id="hm9" />
+
+ <area coords="11" id="hm10" />
+ </areaspec>
+
+ <programlisting>@Column(
+ name="columnName";
+ boolean unique() default false;
+ boolean nullable() default true;
+ boolean insertable() default true;
+ boolean updatable() default true;
+ String columnDefinition() default "";
+ String table() default "";
+ int length() default 255;
+ int precision() default 0; // decimal precision
+ int scale() default 0; // decimal scale</programlisting>
+
+ <calloutlist>
+ <callout arearefs="hm1">
+ <para><literal>name</literal> (optional): the column name
+ (default to the property name)</para>
+ </callout>
+
+ <callout arearefs="hm2">
+ <para><literal>unique</literal> (optional): set a unique
+ constraint on this column or not (default false)</para>
+ </callout>
+
+ <callout arearefs="hm3">
+ <para><literal>nullable</literal> (optional): set the column
+ as nullable (default true).</para>
+ </callout>
+
+ <callout arearefs="hm4">
+ <para><literal>insertable</literal> (optional): whether or not
+ the column will be part of the insert statement (default
+ true)</para>
+ </callout>
+
+ <callout arearefs="hm5">
+ <para><literal>updatable</literal> (optional): whether or not
+ the column will be part of the update statement (default
+ true)</para>
+ </callout>
+
+ <callout arearefs="hm6">
+ <para><literal>columnDefinition</literal> (optional): override
+ the sql DDL fragment for this particular column (non
+ portable)</para>
+ </callout>
+
+ <callout arearefs="hm7">
+ <para><literal>table</literal> (optional): define the targeted
+ table (default primary table)</para>
+ </callout>
+
+ <callout arearefs="hm8">
+ <para><literal><literal>length</literal></literal> (optional):
+ column length (default 255)</para>
+ </callout>
+
+ <callout arearefs="hm8">
+ <para><literal><literal>precision</literal></literal>
+ (optional): column decimal precision (default 0)</para>
+ </callout>
+
+ <callout arearefs="hm10">
+ <para><literal><literal>scale</literal></literal> (optional):
+ column decimal scale if useful (default 0)</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+ </section>
+
+ <section>
+ <title>Formula</title>
+
+ <para>Sometimes, you want the Database to do some computation for
+ you rather than in the JVM, you might also create some kind of
+ virtual column. You can use a SQL fragment (aka formula) instead of
+ mapping a property into a column. This kind of property is read only
+ (its value is calculated by your formula fragment).</para>
+
+ <programlisting language="JAVA" role="JAVA">@Formula("obj_length * obj_height * obj_width")
+public long getObjectVolume()</programlisting>
+
+ <para>The SQL fragment can be as complex as you want and even
+ include subselects.</para>
+ </section>
+
+ <section>
+ <title>Non-annotated property defaults</title>
+
+ <para>If a property is not annotated, the following rules
+ apply:<itemizedlist>
+ <listitem>
+ <para>If the property is of a single type, it is mapped as
+ @Basic</para>
+ </listitem>
+
+ <listitem>
+ <para>Otherwise, if the type of the property is annotated as
+ @Embeddable, it is mapped as @Embedded</para>
+ </listitem>
+
+ <listitem>
+ <para>Otherwise, if the type of the property is
+ <classname>Serializable</classname>, it is mapped as
+ <classname>@Basic</classname> in a column holding the object
+ in its serialized version</para>
+ </listitem>
+
+ <listitem>
+ <para>Otherwise, if the type of the property is
+ <classname>java.sql.Clob</classname> or
+ <classname>java.sql.Blob</classname>, it is mapped as
+ <classname>@Lob</classname> with the appropriate
+ <classname>LobType</classname></para>
+ </listitem>
+ </itemizedlist></para>
+ </section>
+ </section>
+
+ <section>
+ <title>Property mapping with hbm.xml</title>
+
+ <para>The <literal><property></literal> element declares a
+ persistent JavaBean style property of the class.</para>
+
+ <programlistingco role="XML">
+ <areaspec>
+ <area coords="2" id="property1" />
+
+ <area coords="3" id="property2" />
+
+ <area coords="4" id="property3" />
+
+ <areaset coords="" id="property4-5">
+ <area coords="5" id="property4" />
+
+ <area coords="6" id="property5" />
+ </areaset>
+
+ <area coords="7" id="property6" />
+
+ <area coords="8" id="property7" />
+
+ <area coords="9" id="property8" />
+
+ <area coords="10" id="property9" />
+
+ <area coords="11" id="property10" />
+
+ <area coords="12" id="property11" />
+
+ <area coords="13" id="property12" />
+ </areaspec>
+
+ <programlisting><property
name="propertyName"
column="column_name"
type="typename"
@@ -3259,144 +3797,146 @@
scale="S"
/></programlisting>
- <calloutlist>
- <callout arearefs="property1">
- <para><literal>name</literal>: the name of the property, with an
- initial lowercase letter.</para>
- </callout>
+ <calloutlist>
+ <callout arearefs="property1">
+ <para><literal>name</literal>: the name of the property, with an
+ initial lowercase letter.</para>
+ </callout>
- <callout arearefs="property2">
- <para><literal>column</literal> (optional - defaults to the
- property name): the name of the mapped database table column. This
- can also be specified by nested <literal><column></literal>
- element(s).</para>
- </callout>
+ <callout arearefs="property2">
+ <para><literal>column</literal> (optional - defaults to the
+ property name): the name of the mapped database table column.
+ This can also be specified by nested
+ <literal><column></literal> element(s).</para>
+ </callout>
- <callout arearefs="property3">
- <para><literal>type</literal> (optional): a name that indicates
- the Hibernate type.</para>
- </callout>
+ <callout arearefs="property3">
+ <para><literal>type</literal> (optional): a name that indicates
+ the Hibernate type.</para>
+ </callout>
- <callout arearefs="property4-5">
- <para><literal>update, insert</literal> (optional - defaults to
- <literal>true</literal>): specifies that the mapped columns should
- be included in SQL <literal>UPDATE</literal> and/or
- <literal>INSERT</literal> statements. Setting both to
- <literal>false</literal> allows a pure "derived" property whose
- value is initialized from some other property that maps to the
- same column(s), or by a trigger or other application.</para>
- </callout>
+ <callout arearefs="property4-5">
+ <para><literal>update, insert</literal> (optional - defaults to
+ <literal>true</literal>): specifies that the mapped columns
+ should be included in SQL <literal>UPDATE</literal> and/or
+ <literal>INSERT</literal> statements. Setting both to
+ <literal>false</literal> allows a pure "derived" property whose
+ value is initialized from some other property that maps to the
+ same column(s), or by a trigger or other application.</para>
+ </callout>
- <callout arearefs="property6">
- <para><literal>formula</literal> (optional): an SQL expression
- that defines the value for a <emphasis>computed</emphasis>
- property. Computed properties do not have a column mapping of
- their own.</para>
- </callout>
+ <callout arearefs="property6">
+ <para><literal>formula</literal> (optional): an SQL expression
+ that defines the value for a <emphasis>computed</emphasis>
+ property. Computed properties do not have a column mapping of
+ their own.</para>
+ </callout>
- <callout arearefs="property7">
- <para><literal>access</literal> (optional - defaults to
- <literal>property</literal>): the strategy Hibernate uses for
- accessing the property value.</para>
- </callout>
+ <callout arearefs="property7">
+ <para><literal>access</literal> (optional - defaults to
+ <literal>property</literal>): the strategy Hibernate uses for
+ accessing the property value.</para>
+ </callout>
- <callout arearefs="property8">
- <para><literal>lazy</literal> (optional - defaults to
- <literal>false</literal>): specifies that this property should be
- fetched lazily when the instance variable is first accessed. It
- requires build-time bytecode instrumentation.</para>
- </callout>
+ <callout arearefs="property8">
+ <para><literal>lazy</literal> (optional - defaults to
+ <literal>false</literal>): specifies that this property should
+ be fetched lazily when the instance variable is first accessed.
+ It requires build-time bytecode instrumentation.</para>
+ </callout>
- <callout arearefs="property9">
- <para><literal>unique</literal> (optional): enables the DDL
- generation of a unique constraint for the columns. Also, allow
- this to be the target of a <literal>property-ref</literal>.</para>
- </callout>
+ <callout arearefs="property9">
+ <para><literal>unique</literal> (optional): enables the DDL
+ generation of a unique constraint for the columns. Also, allow
+ this to be the target of a
+ <literal>property-ref</literal>.</para>
+ </callout>
- <callout arearefs="property10">
- <para><literal>not-null</literal> (optional): enables the DDL
- generation of a nullability constraint for the columns.</para>
- </callout>
+ <callout arearefs="property10">
+ <para><literal>not-null</literal> (optional): enables the DDL
+ generation of a nullability constraint for the columns.</para>
+ </callout>
- <callout arearefs="property11">
- <para><literal>optimistic-lock</literal> (optional - defaults to
- <literal>true</literal>): specifies that updates to this property
- do or do not require acquisition of the optimistic lock. In other
- words, it determines if a version increment should occur when this
- property is dirty.</para>
- </callout>
+ <callout arearefs="property11">
+ <para><literal>optimistic-lock</literal> (optional - defaults to
+ <literal>true</literal>): specifies that updates to this
+ property do or do not require acquisition of the optimistic
+ lock. In other words, it determines if a version increment
+ should occur when this property is dirty.</para>
+ </callout>
- <callout arearefs="property12">
- <para><literal>generated</literal> (optional - defaults to
- <literal>never</literal>): specifies that this property value is
- actually generated by the database. See the discussion of <link
- linkend="mapping-generated">generated properties</link> for more
- information.</para>
- </callout>
- </calloutlist>
- </programlistingco>
+ <callout arearefs="property12">
+ <para><literal>generated</literal> (optional - defaults to
+ <literal>never</literal>): specifies that this property value is
+ actually generated by the database. See the discussion of <link
+ linkend="mapping-generated">generated properties</link> for more
+ information.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
- <para><emphasis>typename</emphasis> could be:</para>
+ <para><emphasis>typename</emphasis> could be:</para>
- <orderedlist spacing="compact">
- <listitem>
- <para>The name of a Hibernate basic type: <literal>integer, string,
- character, date, timestamp, float, binary, serializable, object,
- blob</literal> etc.</para>
- </listitem>
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>The name of a Hibernate basic type: <literal>integer,
+ string, character, date, timestamp, float, binary, serializable,
+ object, blob</literal> etc.</para>
+ </listitem>
- <listitem>
- <para>The name of a Java class with a default basic type:
- <literal>int, float, char, java.lang.String, java.util.Date,
- java.lang.Integer, java.sql.Clob</literal> etc.</para>
- </listitem>
+ <listitem>
+ <para>The name of a Java class with a default basic type:
+ <literal>int, float, char, java.lang.String, java.util.Date,
+ java.lang.Integer, java.sql.Clob</literal> etc.</para>
+ </listitem>
- <listitem>
- <para>The name of a serializable Java class.</para>
- </listitem>
+ <listitem>
+ <para>The name of a serializable Java class.</para>
+ </listitem>
- <listitem>
- <para>The class name of a custom type:
- <literal>com.illflow.type.MyCustomType</literal> etc.</para>
- </listitem>
- </orderedlist>
+ <listitem>
+ <para>The class name of a custom type:
+ <literal>com.illflow.type.MyCustomType</literal> etc.</para>
+ </listitem>
+ </orderedlist>
- <para>If you do not specify a type, Hibernate will use reflection upon
- the named property and guess the correct Hibernate type. Hibernate will
- attempt to interpret the name of the return class of the property getter
- using, in order, rules 2, 3, and 4. In certain cases you will need the
- <literal>type</literal> attribute. For example, to distinguish between
- <literal>Hibernate.DATE</literal> and
- <literal>Hibernate.TIMESTAMP</literal>, or to specify a custom
- type.</para>
+ <para>If you do not specify a type, Hibernate will use reflection upon
+ the named property and guess the correct Hibernate type. Hibernate
+ will attempt to interpret the name of the return class of the property
+ getter using, in order, rules 2, 3, and 4. In certain cases you will
+ need the <literal>type</literal> attribute. For example, to
+ distinguish between <literal>Hibernate.DATE</literal> and
+ <literal>Hibernate.TIMESTAMP</literal>, or to specify a custom
+ type.</para>
- <para>The <literal>access</literal> attribute allows you to control how
- Hibernate accesses the property at runtime. By default, Hibernate will
- call the property get/set pair. If you specify
- <literal>access="field"</literal>, Hibernate will bypass the get/set
- pair and access the field directly using reflection. You can specify
- your own strategy for property access by naming a class that implements
- the interface
- <literal>org.hibernate.property.PropertyAccessor</literal>.</para>
+ <para>The <literal>access</literal> attribute allows you to control
+ how Hibernate accesses the property at runtime. By default, Hibernate
+ will call the property get/set pair. If you specify
+ <literal>access="field"</literal>, Hibernate will bypass the get/set
+ pair and access the field directly using reflection. You can specify
+ your own strategy for property access by naming a class that
+ implements the interface
+ <literal>org.hibernate.property.PropertyAccessor</literal>.</para>
- <para>A powerful feature is derived properties. These properties are by
- definition read-only. The property value is computed at load time. You
- declare the computation as an SQL expression. This then translates to a
- <literal>SELECT</literal> clause subquery in the SQL query that loads an
- instance:</para>
+ <para>A powerful feature is derived properties. These properties are
+ by definition read-only. The property value is computed at load time.
+ You declare the computation as an SQL expression. This then translates
+ to a <literal>SELECT</literal> clause subquery in the SQL query that
+ loads an instance:</para>
- <programlisting role="XML">
+ <programlisting role="XML">
<property name="totalPrice"
formula="( SELECT SUM (li.quantity*p.price) FROM LineItem li, Product p
WHERE li.productId = p.productId
AND li.customerId = customerId
AND li.orderNumber = orderNumber )"/></programlisting>
- <para>You can reference the entity table by not declaring an alias on a
- particular column. This would be <literal>customerId</literal> in the
- given example. You can also use the nested
- <literal><formula></literal> mapping element if you do not want to
- use the attribute.</para>
+ <para>You can reference the entity table by not declaring an alias on
+ a particular column. This would be <literal>customerId</literal> in
+ the given example. You can also use the nested
+ <literal><formula></literal> mapping element if you do not want
+ to use the attribute.</para>
+ </section>
</section>
<section id="mapping-declaration-manytoone" revision="5">
14 years, 7 months
Hibernate SVN: r19613 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-26 12:16:55 -0400 (Wed, 26 May 2010)
New Revision: 19613
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
Fix typo on doc
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 15:54:28 UTC (rev 19612)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-05-26 16:16:55 UTC (rev 19613)
@@ -1537,9 +1537,9 @@
)
public Integer getId() { ... } </programlisting>
- <para>The scope of a generator definitioncan be the application or the
- class. Class-defined generators are not visible outside the class and
- can override application level generators. Application level
+ <para>The scope of a generator definition can be the application or
+ the class. Class-defined generators are not visible outside the class
+ and can override application level generators. Application level
generators are defined in JPA's XML deployment descriptors (see XXXXXX
<xref linkend="xml-overriding" />):</para>
14 years, 7 months
Hibernate SVN: r19612 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-26 11:54:28 -0400 (Wed, 26 May 2010)
New Revision: 19612
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml
Log:
HHH-5263 - Improve preface
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml 2010-05-26 11:09:16 UTC (rev 19611)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml 2010-05-26 15:54:28 UTC (rev 19612)
@@ -38,7 +38,8 @@
objects versus relational databases. Hibernate is an Object/Relational Mapping solution for Java environments.
The term Object/Relational Mapping refers to the technique of mapping a data representation from an object model
to a relational data model with a SQL-based schema;
- see <ulink url="http://en.wikipedia.org/wiki/Object-relational_mapping"/> for a discussion.
+ see <ulink url="http://en.wikipedia.org/wiki/Object-relational_mapping">http://en.wikipedia.org/wiki/Object-relational_mapping</ulink>
+ for a discussion.
</para>
<note>
@@ -50,12 +51,12 @@
<itemizedlist>
<listitem>
<para>
- <ulink url="http://www.agiledata.org/essays/dataModeling101.html"/>
+ <ulink url="http://www.agiledata.org/essays/dataModeling101.html">http://www.agiledata.org/essays/dataModeling101.html</ulink>
</para>
</listitem>
<listitem>
<para>
- <ulink url="http://en.wikipedia.org/wiki/Data_modeling"/>
+ <ulink url="http://en.wikipedia.org/wiki/Data_modeling">http://en.wikipedia.org/wiki/Data_modeling</ulink>
</para>
</listitem>
</itemizedlist>
@@ -145,19 +146,54 @@
</listitem>
</orderedlist>
- <para>
- If you have questions, use the user forum linked on the Hibernate website. We also
- provide a JIRA issue tracking system for bug reports and feature requests. If you
- are interested in the development of Hibernate, join the developer mailing list. If
- you are interested in translating this documentation into your language, contact us
- on the developer mailing list.
- </para>
+ <para>
+ There are a number of ways to become involved in the Hibernate community, including
+ <itemizedlist>
+ <listitem>
+ <para>
+ Trying stuff out and reporting bugs. See
+ <ulink url="http://hibernate.org/issuetracker.html">http://hibernate.org/issuetracker.html</ulink>
+ details.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Trying your hand at fixing some bugs or implementing enhancements. Again, see
+ <ulink url="http://hibernate.org/issuetracker.html">http://hibernate.org/issuetracker.html</ulink>
+ details.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <ulink url="http://hibernate.org/community.html">http://hibernate.org/community.html</ulink> list
+ a few ways to engage in the community.
+ <itemizedlist>
+ <listitem>
+ <para>
+ There are forums for users to ask questions and receive help from the community.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ There are also <ulink url="http://en.wikipedia.org/wiki/Internet_Relay_Chat">IRC</ulink>
+ channels for both user and developer discussions.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Helping improve or translate this documentation. Contact us on the developer mailing list
+ if you have interest.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Evangelizing Hibernate within your organization.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
- <para>
- Commercial development support, production support, and training for Hibernate is
- available through JBoss Inc. (see http://www.hibernate.org/SupportTraining/).
- Hibernate is a Professional Open Source project and a critical component of the
- JBoss Enterprise Middleware System (JEMS) suite of products.
- </para>
-
</preface>
14 years, 7 months
Hibernate SVN: r19611 - core/trunk/annotations/src/main/java/org/hibernate/type.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-26 07:09:16 -0400 (Wed, 26 May 2010)
New Revision: 19611
Modified:
core/trunk/annotations/src/main/java/org/hibernate/type/EnumType.java
Log:
HHH-5147 Applied patch and removed obsolete code and comments
Modified: core/trunk/annotations/src/main/java/org/hibernate/type/EnumType.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/type/EnumType.java 2010-05-26 09:43:07 UTC (rev 19610)
+++ core/trunk/annotations/src/main/java/org/hibernate/type/EnumType.java 2010-05-26 11:09:16 UTC (rev 19611)
@@ -24,27 +24,29 @@
package org.hibernate.type;
import java.io.Serializable;
-import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.hibernate.HibernateException;
-import org.hibernate.util.StringHelper;
import org.hibernate.usertype.EnhancedUserType;
import org.hibernate.usertype.ParameterizedType;
import org.hibernate.util.ReflectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.hibernate.util.StringHelper;
/**
* Enum type mapper
* Try and find the appropriate SQL type depending on column metadata
* <p/>
* TODO implements readobject/writeobject to recalculate the enumclasses
+ *
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
@SuppressWarnings("unchecked")
public class EnumType implements EnhancedUserType, ParameterizedType, Serializable {
@@ -56,7 +58,8 @@
* in order to check the trace-enablement. Driving this via a central Log-specific class
* would alleviate that performance hit, and yet still allow more "normal" logging usage/config.
*/
- private static final boolean IS_VALUE_TRACING_ENABLED = LoggerFactory.getLogger( StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled();
+ private static final boolean IS_VALUE_TRACING_ENABLED = LoggerFactory.getLogger( StringHelper.qualifier( Type.class.getName() ) )
+ .isTraceEnabled();
private transient Logger log;
private Logger log() {
@@ -75,12 +78,10 @@
private Class<? extends Enum> enumClass;
private transient Object[] enumValues;
- private String catalog;
- private String schema;
private int sqlType = Types.INTEGER; //before any guessing
public int[] sqlTypes() {
- return new int[]{sqlType};
+ return new int[] { sqlType };
}
public Class<? extends Enum> returnedClass() {
@@ -95,7 +96,7 @@
return x == null ? 0 : x.hashCode();
}
-
+
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
Object object = rs.getObject( names[0] );
if ( rs.wasNull() ) {
@@ -106,7 +107,7 @@
}
if ( object instanceof Number ) {
initEnumValues();
- int ordinal = ( (Number) object ).intValue();
+ int ordinal = ( ( Number ) object ).intValue();
if ( ordinal < 0 || ordinal >= enumValues.length ) {
throw new IllegalArgumentException( "Unknown ordinal value for enum " + enumClass + ": " + ordinal );
}
@@ -116,36 +117,37 @@
return enumValues[ordinal];
}
else {
- String name = (String) object;
+ String name = ( String ) object;
if ( IS_VALUE_TRACING_ENABLED ) {
log().debug( "Returning '{}' as column {}", name, names[0] );
}
try {
return Enum.valueOf( enumClass, name );
}
- catch (IllegalArgumentException iae) {
+ catch ( IllegalArgumentException iae ) {
throw new IllegalArgumentException( "Unknown name value for enum " + enumClass + ": " + name, iae );
}
}
}
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
- //if (!guessed) guessType( st, index );
if ( value == null ) {
- if ( IS_VALUE_TRACING_ENABLED ) log().debug( "Binding null to parameter: {}", index );
+ if ( IS_VALUE_TRACING_ENABLED ) {
+ log().debug( "Binding null to parameter: {}", index );
+ }
st.setNull( index, sqlType );
}
else {
boolean isOrdinal = isOrdinal( sqlType );
if ( isOrdinal ) {
- int ordinal = ( (Enum<?>) value ).ordinal();
+ int ordinal = ( ( Enum<?> ) value ).ordinal();
if ( IS_VALUE_TRACING_ENABLED ) {
log().debug( "Binding '{}' to parameter: {}", ordinal, index );
}
st.setObject( index, Integer.valueOf( ordinal ), sqlType );
}
else {
- String enumString = ( (Enum<?>) value ).name();
+ String enumString = ( ( Enum<?> ) value ).name();
if ( IS_VALUE_TRACING_ENABLED ) {
log().debug( "Binding '{}' to parameter: {}", enumString, index );
}
@@ -183,7 +185,7 @@
}
public Serializable disassemble(Object value) throws HibernateException {
- return (Serializable) value;
+ return ( Serializable ) value;
}
public Object assemble(Serializable cached, Object owner) throws HibernateException {
@@ -199,23 +201,13 @@
try {
enumClass = ReflectHelper.classForName( enumClassName, this.getClass() ).asSubclass( Enum.class );
}
- catch (ClassNotFoundException exception) {
+ catch ( ClassNotFoundException exception ) {
throw new HibernateException( "Enum class not found", exception );
}
- // is might be good to call it here, to see a possible error immediately
- // initEnumValue();
-
- //nullify unnullified properties yuck!
- schema = parameters.getProperty( SCHEMA );
- if ( "".equals( schema ) ) schema = null;
- catalog = parameters.getProperty( CATALOG );
- if ( "".equals( catalog ) ) catalog = null;
-// table = parameters.getProperty( TABLE );
-// column = parameters.getProperty( COLUMN );
+
String type = parameters.getProperty( TYPE );
if ( type != null ) {
- sqlType = Integer.decode( type ).intValue();
-// guessed = true;
+ sqlType = Integer.decode( type );
}
}
@@ -224,41 +216,32 @@
*/
private void initEnumValues() {
if ( enumValues == null ) {
- try {
- Method method = enumClass.getDeclaredMethod( "values" );
- enumValues = (Object[]) method.invoke( null );
+ this.enumValues = enumClass.getEnumConstants();
+ if ( enumValues == null ) {
+ throw new NullPointerException( "Failed to init enumValues" );
}
- catch (Exception e) {
- throw new HibernateException( "Error while accessing enum.values(): " + enumClass, e );
- }
}
}
- // is might be good to call initEnumValues() here, to see a possible error immediatelly, otherwise leave it commented
-// private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
-// initEnumValues();
-// ois.defaultReadObject();
-// }
-
public String objectToSQLString(Object value) {
boolean isOrdinal = isOrdinal( sqlType );
if ( isOrdinal ) {
- int ordinal = ( (Enum) value ).ordinal();
+ int ordinal = ( ( Enum ) value ).ordinal();
return Integer.toString( ordinal );
}
else {
- return '\'' + ( (Enum) value ).name() + '\'';
+ return '\'' + ( ( Enum ) value ).name() + '\'';
}
}
public String toXMLString(Object value) {
boolean isOrdinal = isOrdinal( sqlType );
if ( isOrdinal ) {
- int ordinal = ( (Enum) value ).ordinal();
+ int ordinal = ( ( Enum ) value ).ordinal();
return Integer.toString( ordinal );
}
else {
- return ( (Enum) value ).name();
+ return ( ( Enum ) value ).name();
}
}
@@ -271,11 +254,11 @@
}
return enumValues[ordinal];
}
- catch(NumberFormatException e) {
+ catch ( NumberFormatException e ) {
try {
return Enum.valueOf( enumClass, xmlValue );
}
- catch (IllegalArgumentException iae) {
+ catch ( IllegalArgumentException iae ) {
throw new IllegalArgumentException( "Unknown name value for enum " + enumClass + ": " + xmlValue, iae );
}
}
14 years, 7 months
Hibernate SVN: r19610 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator: engine/groups and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-26 05:43:07 -0400 (Wed, 26 May 2010)
New Revision: 19610
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/SingleThreadCachedTraversableResolver.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java
Log:
HV-274 some coding style fixes
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java 2010-05-25 20:45:26 UTC (rev 19609)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java 2010-05-26 09:43:07 UTC (rev 19610)
@@ -28,7 +28,7 @@
import java.util.Set;
/**
- * Top level class for programmatically configured constraints.
+ * Top level class for constraints configured via the programmatic API.
*
* @author Hardy Ferentschik
*/
@@ -51,6 +51,7 @@
protected <A extends Annotation> void addConstraintConfig(ConstraintDef<?> definition) {
Class<?> beanClass = definition.beanType;
+ @SuppressWarnings( "unchecked")
ConstraintDefAccessor<A> defAccessor = new ConstraintDefAccessor<A>(
beanClass,
( Class<A> ) definition.constraintType,
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java 2010-05-25 20:45:26 UTC (rev 19609)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java 2010-05-26 09:43:07 UTC (rev 19610)
@@ -30,7 +30,7 @@
*
* @author Hardy Ferentschik
*/
-public class GroupChain {
+public final class GroupChain {
/**
* The list of single groups to be used this validation.
@@ -78,11 +78,11 @@
public void assertDefaultGroupSequenceIsExpandable(List<Class<?>> defaultGroupSequence) {
for ( Map.Entry<Class<?>, List<Group>> entry : sequenceMap.entrySet() ) {
Class<?> sequence = entry.getKey();
- List<Group> groupList = entry.getValue();
+ List<Group> groups = entry.getValue();
List<Group> defaultGroupList = buildTempGroupList( defaultGroupSequence, sequence );
- int defaultGroupIndex = containsDefaultGroupAtIndex( sequence, groupList );
+ int defaultGroupIndex = containsDefaultGroupAtIndex( sequence, groups );
if ( defaultGroupIndex != -1 ) {
- ensureDefaultGroupSequenceIsExpandable( groupList, defaultGroupList, defaultGroupIndex );
+ ensureDefaultGroupSequenceIsExpandable( groups, defaultGroupList, defaultGroupIndex );
}
}
}
@@ -113,11 +113,11 @@
}
private List<Group> buildTempGroupList(List<Class<?>> defaultGroupSequence, Class<?> sequence) {
- List<Group> groupList = new ArrayList<Group>();
+ List<Group> groups = new ArrayList<Group>();
for ( Class<?> clazz : defaultGroupSequence ) {
Group g = new Group( clazz, sequence );
- groupList.add( g );
+ groups.add( g );
}
- return groupList;
+ return groups;
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/SingleThreadCachedTraversableResolver.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/SingleThreadCachedTraversableResolver.java 2010-05-25 20:45:26 UTC (rev 19609)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/SingleThreadCachedTraversableResolver.java 2010-05-26 09:43:07 UTC (rev 19610)
@@ -94,7 +94,7 @@
return cachedLH.isCascadable;
}
- private static class TraversableHolder {
+ private static final class TraversableHolder {
private final Object traversableObject;
private final Path.Node traversableProperty;
private final Class<?> rootBeanType;
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java 2010-05-25 20:45:26 UTC (rev 19609)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java 2010-05-26 09:43:07 UTC (rev 19610)
@@ -99,11 +99,16 @@
defaultLocale = Locale.getDefault();
if ( userResourceBundleLocator == null ) {
- userResourceBundleLocator = new PlatformResourceBundleLocator( USER_VALIDATION_MESSAGES );
+ this.userResourceBundleLocator = new CachingResourceBundleLocator(
+ new PlatformResourceBundleLocator(
+ USER_VALIDATION_MESSAGES
+ )
+ );
}
+ else {
+ this.userResourceBundleLocator = new CachingResourceBundleLocator( userResourceBundleLocator );
+ }
- this.userResourceBundleLocator = new CachingResourceBundleLocator( userResourceBundleLocator );
-
this.defaultResourceBundleLocator =
new CachingResourceBundleLocator(
new PlatformResourceBundleLocator( DEFAULT_VALIDATION_MESSAGES )
14 years, 7 months
Hibernate SVN: r19609 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-25 16:45:26 -0400 (Tue, 25 May 2010)
New Revision: 19609
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml
Log:
HHH-5263 - Improve preface
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml 2010-05-25 20:30:50 UTC (rev 19608)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/preface.xml 2010-05-25 20:45:26 UTC (rev 19609)
@@ -2,10 +2,10 @@
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
- ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ Copyright (c) 2010, Red Hat Inc. or third-party contributors as
~ indicated by the @author tags or express copyright attribution
~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
+ ~ distributed under license by Red Hat Inc.
~
~ This copyrighted material is made available to anyone wishing to use, modify,
~ copy, or redistribute it subject to the terms and conditions of the GNU
@@ -33,23 +33,50 @@
<title>Preface</title>
<para>
- Working with object-oriented software and a relational database can be cumbersome
- and time consuming in today's enterprise environments. Hibernate is an Object/Relational
- Mapping tool for Java environments. The term Object/Relational Mapping (ORM) refers to
- the technique of mapping a data representation from an object model to a relational
- data model with a SQL-based schema.
+ Working with both Object-Oriented software and Relational Databases can be cumbersome and time consuming.
+ Development costs are significantly higher due to a paradigm mismatch between how data is represented in
+ objects versus relational databases. Hibernate is an Object/Relational Mapping solution for Java environments.
+ The term Object/Relational Mapping refers to the technique of mapping a data representation from an object model
+ to a relational data model with a SQL-based schema;
+ see <ulink url="http://en.wikipedia.org/wiki/Object-relational_mapping"/> for a discussion.
</para>
+ <note>
+ <para>
+ While having a strong background in SQL is not required to use Hibernate, having a basic understanding of
+ the concepts can greatly help you understand Hibernate more fully and quickly. Probably the single
+ best background is an understanding of data modeling principles. You might want to consider these resources
+ as a good starting point:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <ulink url="http://www.agiledata.org/essays/dataModeling101.html"/>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <ulink url="http://en.wikipedia.org/wiki/Data_modeling"/>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </note>
+
<para>
- Hibernate not only takes care of the mapping from Java classes to
- database tables (and from Java data types to SQL data types), but also provides data
- query and retrieval facilities. It can also significantly reduce development time otherwise
- spent with manual data handling in SQL and JDBC.
+ Hibernate not only takes care of the mapping from Java classes to database tables (and from Java data types to
+ SQL data types), but also provides data query and retrieval facilities. It can also significantly reduce
+ development time otherwise spent with manual data handling in SQL and JDBC.
</para>
<para>
- Hibernate's goal is to relieve the developer from 95 percent of common data persistence
- related programming tasks. Hibernate may not be the best solution for data-centric
+ Hibernate’s design goal is to relieve the developer from 95% of common data persistence-related programming
+ tasks by eliminating the need for manual, hand-crafted data processing using SQL and JDBC. However, unlike
+ many other persistence solutions, Hibernate does not hide the power of SQL from you and guarantees that your
+ investment in relational technology and knowledge is as valid as always.
+ </para>
+
+ <para>
+ Hibernate may not be the best solution for data-centric
applications that only use stored-procedures to implement the business logic in the
database, it is most useful with object-oriented domain models and business logic in
the Java-based middle-tier. However, Hibernate can certainly help you to remove or
14 years, 7 months