update to v3.1.2

git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@9198 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Xiaogang Cao 2006-02-02 15:35:28 +00:00
parent 9b5c1fc8c5
commit a11f2367e3
3 changed files with 21 additions and 4 deletions

View File

@ -35,7 +35,7 @@
<title>HIBERNATE - 符合Java习惯的关系数据库持久化</title>
<subtitle>Hibernate参考文档</subtitle>
<releaseinfo>3.1.1</releaseinfo>
<releaseinfo>3.1.2</releaseinfo>
</bookinfo>
<toc/>

View File

@ -1071,7 +1071,7 @@
</para>
</sect2>
<sect2 id="mapping-declaration-timestamp" revision="3">
<sect2 id="mapping-declaration-timestamp" revision="4">
<title>timestamp (optional)</title>
<para>
@ -1140,7 +1140,7 @@
</programlistingco>
<para>
注意,<literal>&lt;timestamp&gt;</literal><literal>&lt;version type="timestamp"&gt;</literal>是等价的。并且<literal>&lt;timestamp use-db="true"&gt;</literal><literal>&lt;version type="dbtimestamp"&gt;</literal>是等价的。
注意,<literal>&lt;timestamp&gt;</literal><literal>&lt;version type="timestamp"&gt;</literal>是等价的。并且<literal>&lt;timestamp source="true"&gt;</literal><literal>&lt;version type="dbtimestamp"&gt;</literal>是等价的。
</para>
</sect2>

View File

@ -123,7 +123,7 @@ session.close();]]></programlisting>
</sect1>
<sect1 id="batch-direct" revision="2">
<sect1 id="batch-direct" revision="3">
<title>DML(数据操作语言)风格的操作(DML-style operations)</title>
<para>
@ -189,6 +189,23 @@ session.close();]]></programlisting>
tx.commit();
session.close();]]></programlisting>
<para>
HQL <literal>UPDATE</literal>语句,默认不会影响更新实体的<xref linkend="mapping-declaration-version">version</xref>或者<xref linkend="mapping-declaration-timestamp">timestamp</xref>属性值。这和EJB3规范是一致的。但是通过使用<literal>versioned update</literal>你可以强制Hibernate正确的重置<literal>version</literal>或者<literal>timestamp</literal>属性值。这通过在<literal>UPDATE</literal>关键字后面增加<literal>VERSIONED</literal>关键字来实现的。
</para>
<programlisting><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
String hqlVersionedUpdate = "update versioned Customer set name = :newName where name = :oldName";
int updatedEntities = s.createQuery( hqlUpdate )
.setString( "newName", newName )
.setString( "oldName", oldName )
.executeUpdate();
tx.commit();
session.close();]]></programlisting>
<para>
注意,自定义的版本类型(<literal>org.hibernate.usertype.UserVersionType</literal>)不允许和<literal>update versioned</literal>语句联用。
</para>
<para>
执行一个HQL <literal>DELETE</literal>,同样使用 <literal>Query.executeUpdate()</literal> 方法:
</para>