28. Legacy Domain Model

<div class="sectionbody">
<div class="exampleblock">
<div class="title">Example 501. Declaring a version property in `hbm.xml`</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight">`&lt;!--
  ~ Hibernate, Relational Persistence for Idiomatic Java
  ~
  ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
  ~ See the lgpl.txt file in the root directory or &lt;http://www.gnu.org/licenses/lgpl-2.1.html&gt;.
  --&gt;
&lt;version
    column="version_column"
    name="propertyName"
    type="typename"
    access="field|property|ClassName"
    unsaved-value="null|negative|undefined"
    generated="never|always"
    insert="true|false"
    node="element-name|@attribute-name|element/@attribute|."
/&gt;`</pre>    ## 29. Legacy Hibernate Criteria Queries

<div class="sectionbody">
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">

</td>
<td class="content">
<div class="paragraph">

This appendix covers the legacy Hibernate `org.hibernate.Criteria` API, which should be considered deprecated.

</div>
<div class="paragraph">

New development should focus on the JPA javax.persistence.criteria.CriteriaQuery API.
Eventually, Hibernate-specific criteria features will be ported as extensions to the JPA `javax.persistence.criteria.CriteriaQuery`.
For details on the JPA APIs, see [Criteria](#criteria).

</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">

Hibernate features an intuitive, extensible criteria query API.

</div>
<div class="sect2">
</div>
</div>
</div>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: %;">
<col style="width: %;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top">

column
</td>
<td class="tableblock halign-left valign-top">

The name of the column holding the version number. Optional, defaults to the property name.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

name
</td>
<td class="tableblock halign-left valign-top">

The name of a property of the persistent class.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

type
</td>
<td class="tableblock halign-left valign-top">

The type of the version number. Optional, defaults to `integer`.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

access
</td>
<td class="tableblock halign-left valign-top">

Hibernate&#8217;s strategy for accessing the property value. Optional, defaults to `property`.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

unsaved-value
</td>
<td class="tableblock halign-left valign-top">

Indicates that an instance is newly instantiated and thus unsaved.
This distinguishes it from detached instances that were saved or loaded in a previous session.
The default value, `undefined`, indicates that the identifier property value should be used. Optional.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

generated
</td>
<td class="tableblock halign-left valign-top">

Indicates that the version property value is generated by the database. Optional, defaults to `never`.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

insert
</td>
<td class="tableblock halign-left valign-top">

Whether or not to include the `version` column in SQL `insert` statements.
Defaults to `true`, but you can set it to `false` if the database column is defined with a default value of `0`.
</td>
</tr>
</tbody>
</table>
<div class="exampleblock">
<div class="title">Example 502. The timestamp element in `hbm.xml`</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight">`&lt;!--
  ~ Hibernate, Relational Persistence for Idiomatic Java
  ~
  ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
  ~ See the lgpl.txt file in the root directory or &lt;http://www.gnu.org/licenses/lgpl-2.1.html&gt;.
  --&gt;
&lt;timestamp
    column="timestamp_column"
    name="propertyName"
    access="field|property|ClassName"
    unsaved-value="null|undefined"
    source="vm|db"
    generated="never|always"
    node="element-name|@attribute-name|element/@attribute|."
/&gt;`</pre>
</div>
</div>
</div>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: %;">
<col style="width: %;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top">

column
</td>
<td class="tableblock halign-left valign-top">

The name of the column which holds the timestamp. Optional, defaults to the property name
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

name
</td>
<td class="tableblock halign-left valign-top">

The name of a JavaBeans style property of Java type `Date` or `Timestamp` of the persistent class.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

access
</td>
<td class="tableblock halign-left valign-top">

The strategy Hibernate uses to access the property value. Optional, defaults to `property`.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

unsaved-value
</td>
<td class="tableblock halign-left valign-top">

A version property which indicates than instance is newly instantiated, and unsaved.
This distinguishes it from detached instances that were saved or loaded in a previous session.
The default value of `undefined` indicates that Hibernate uses the identifier property value.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

source
</td>
<td class="tableblock halign-left valign-top">

Whether Hibernate retrieves the timestamp from the database or the current JVM.
Database-based timestamps incur an overhead because Hibernate needs to query the database each time to determine the incremental next value.
However, database-derived timestamps are safer to use in a clustered environment.
Not all database dialects are known to support the retrieval of the database&#8217;s current timestamp.
Others may also be unsafe for locking because of lack of precision.
</td>
</tr>
<tr>
<td class="tableblock halign-left valign-top">

generated
</td>
<td class="tableblock halign-left valign-top">

Whether the timestamp property value is generated by the database. Optional, defaults to `never`.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect1">

results matching ""

    No results matching ""