|
From: <hib...@li...> - 2006-08-01 09:29:11
|
Author: honma
Date: 2006-08-01 05:29:01 -0400 (Tue, 01 Aug 2006)
New Revision: 10183
Modified:
trunk/Hibernate3/doc/reference/ja/modules/architecture.xml
trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml
trunk/Hibernate3/doc/reference/ja/modules/configuration.xml
trunk/Hibernate3/doc/reference/ja/modules/performance.xml
trunk/Hibernate3/doc/reference/ja/modules/persistent_classes.xml
trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml
trunk/Hibernate3/doc/reference/ja/modules/session_api.xml
trunk/Hibernate3/doc/reference/ja/modules/tutorial.xml
Log:
for v3.2.0.
Modified: trunk/Hibernate3/doc/reference/ja/modules/architecture.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/architecture.xml 2006-07-31 20:27:50 UTC (rev 10182)
+++ trunk/Hibernate3/doc/reference/ja/modules/architecture.xml 2006-08-01 09:29:01 UTC (rev 10183)
@@ -7,6 +7,9 @@
<title>T/title>
<para>
+ A (very) high-level view of the Hibernate architecture:
+ </para>
+ <para>
HibernateA[LeN`́iɁjxr[F
</para>
@@ -20,12 +23,23 @@
</mediaobject>
<para>
+ This diagram shows Hibernate using the database and configuration data to
+ provide persistence services (and persistent objects) to the application.
+ </para>
+ <para>
̐}ibernateAAvP[VɑĉiT[rX
iƉiIuWFNgj邽߂ɁAf[^x[XƐݒ[^Ƃ Ă܂B
</para>
<para>
+ We would like to show a more detailed view of the runtime architecture.
+ Unfortunately, Hibernate is flexible and supports several approaches. We will
+ show the two extremes. The "lite" architecture has the application
+ provide its own JDBC connections and manage its own transactions. This approach
+ uses a minimal subset of Hibernate's APIs:
+ </para>
+ <para>
ŎsA[LeN`̂ڍׂȃr[܂傤B
ɂAHibernate͏_낢Av[`|[gĂ܂B
ł́A2̋ɒ[ȗ܂B
@@ -44,6 +58,10 @@
</mediaobject>
<para>
+ The "full cream" architecture abstracts the application away from the
+ underlying JDBC/JTA APIs and lets Hibernate take care of the details.
+ </para>
+ <para>
udvA[LeN`́AAvP[V̉ɈʒuBCAPI ĒۉȀڍׂ̖ʓ|ernateɌ܂B
</para>
@@ -65,6 +83,13 @@
<term>SessionFactory (<literal>org.hibernate.SessionFactory</literal>)</term>
<listitem>
<para>
+ A threadsafe (immutable) cache of compiled mappings for a single database.
+ A factory for <literal>Session</literal> and a client of
+ <literal>ConnectionProvider</literal>. Might hold an optional (second-level)
+ cache of data that is reusable between transactions, at a
+ process- or cluster-level.
+ </para>
+ <para>
1̃f[^x[XɑpCꂽ}bsO XbhZ[tȁiXVs\́jLbVB
<literal>Session</literal> ̃t@Ngł
@@ -78,8 +103,15 @@
<term>Session (<literal>org.hibernate.Session</literal>)</term>
<listitem>
<para>
+ A single-threaded, short-lived object representing a conversation between
+ the application and the persistent store. Wraps a JDBC connection. Factory
+ for <literal>Transaction</literal>. Holds a mandatory (first-level) cache
+ of persistent objects, used when navigating the object graph or looking up
+ objects by identifier.
+ </para>
+ <para>
AvP[VƉiXgAƂ̑ΘbA
- VOEXbhŒZ̃IuWFNgB
+ VOXbhŒZ̃IuWFNgB
JDBCRlNVbv܂B
<literal>Transaction</literal> ̃t@NgłB
iIuWFNg̕K{́iꎟjLbV܂B
@@ -92,6 +124,14 @@
<term>Persistent objects Collections</term>
<listitem>
<para>
+ Short-lived, single threaded objects containing persistent state and business
+ function. These might be ordinary JavaBeans/POJOs, the only special thing about
+ them is that they are currently associated with (exactly one)
+ <literal>Session</literal>. As soon as the <literal>Session</literal> is closed,
+ they will be detached and free to use in any application layer (e.g. directly
+ as data transfer objects to and from presentation).
+ </para>
+ <para>
iƃrWlX\bhAZŃVOXbh̃IuWFNgB
ʏJavaBeans/POJÔƂAIȂƂ́A
̎_ł́i1́j <literal>Session</literal> Ɗ֘AĂ邱ƂłB
@@ -106,6 +146,12 @@
<term>Transient detached objects Collections</term>
<listitem>
<para>
+ Instances of persistent classes that are not currently associated with a
+ <literal>Session</literal>. They may have been instantiated by
+ the application and not (yet) persisted or they may have been instantiated by a
+ closed <literal>Session</literal>.
+ </para>
+ <para>
_ł<literal>Session</literal> Ɗ֘AĂȂA
iNX̃CX^XB
łɃAvP[VŃCX^XāA܂iȂA
@@ -117,8 +163,16 @@
<term>Transaction (<literal>org.hibernate.Transaction</literal>)</term>
<listitem>
<para>
+ (Optional) A single-threaded, short-lived object used by the application to
+ specify atomic units of work. Abstracts application from underlying JDBC,
+ JTA or CORBA transaction. A <literal>Session</literal> might span several
+ <literal>Transaction</literal>s in some cases. However, transaction demarcation,
+ either using the underlying API or <literal>Transaction</literal>, is never
+ optional!
+ </para>
+ <para>
(IvV)qPUnit of Work)肷邽߂ɁAAvP[Vgp
- VOEXbhŒZȃIuWFNgB
+ VOXbhŒZȃIuWFNgB
ɈʒuBCAJTAACORBAgUNVvP[V𒊏ۉ܂B
<literal>Session</literal> ́Aɂ <literal>Transaction</literal> 邩@@ -131,6 +185,11 @@
<term>ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</literal>)</term>
<listitem>
<para>
+ (Optional) A factory for (and pool of) JDBC connections. Abstracts application from
+ underlying <literal>Datasource</literal> or <literal>DriverManager</literal>.
+ Not exposed to application, but can be extended/implemented by the developer.
+ </para>
+ <para>
(IvV)JDBCRlNViƂ̃v[j̃t@NgB
̑wɈʒuliteral>Datasource</literal> <literal>DriverManager</literal> vP[V𒊏ۉ܂B
@@ -142,6 +201,10 @@
<term>TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)</term>
<listitem>
<para>
+ (Optional) A factory for <literal>Transaction</literal> instances. Not exposed to the
+ application, but can be extended/implemented by the developer.
+ </para>
+ <para>
(IvV) <literal>Transaction</literal> CX^X̃t@NgB
AvP[Vɂ͌AJ҂p܂͎邱Ƃ͉\łB
</para>
@@ -151,6 +214,10 @@
<term><emphasis>Extension Interfaces</emphasis></term>
<listitem>
<para>
+ Hibernate offers many optional extension interfaces you can implement to customize
+ the behavior of your persistence layer. See the API documentation for details.
+ </para>
+ <para>
HibernatéAiw̐U镑X^}CY邽߂ɁA
̃IvVgC^tF[XӂĂ܂B
ڍׂPIhLgƂĂB
@@ -161,6 +228,11 @@
</para>
<para>
+ Given a "lite" architecture, the application bypasses the
+ <literal>Transaction</literal>/<literal>TransactionFactory</literal> and/or
+ <literal>ConnectionProvider</literal> APIs to talk to JTA or JDBC directly.
+ </para>
+ <para>
uyvA[LeN`ł́AAvP[V͒TABCƑΘb邽߂ɁA
<literal>Transaction</literal> literal>TransactionFactory</literal> <literal>ConnectionProvider</literal> CpX܂B
@@ -170,6 +242,11 @@
<sect1 id="architecture-states" revision="1">
<title>CX^X̏/title>
<para>
+ An instance of a persistent classes may be in one of three different states,
+ which are defined with respect to a <emphasis>persistence context</emphasis>.
+ The Hibernate <literal>Session</literal> object is the persistence context:
+ </para>
+ <para>
iNX̃CX^X́ÂR̈قȂԂ̂ǂꂩɂȂB
A <emphasis>iReLXg</emphasis> ɂČ܂B
Hibernate<literal>Session</literal> IuWFNgAiReLXgɂȂB
@@ -180,6 +257,11 @@
<term>transient</term>
<listitem>
<para>
+ The instance is not, and has never been associated with
+ any persistence context. It has no persistent identity
+ (primary key value).
+ </para>
+ <para>
̏̃CX^X́A݂ĉߋɂĂ
iReLXgɊ֘AÂĂ܂܂AiIDi[̒lj Ă܂@@ -190,6 +272,15 @@
<term>persistent</term>
<listitem>
<para>
+ The instance is currently associated with a persistence
+ context. It has a persistent identity (primary key value)
+ and, perhaps, a corresponding row in the database. For a
+ particular persistence context, Hibernate
+ <emphasis>guarantees</emphasis> that persistent identity
+ is equivalent to Java identity (in-memory location of the
+ object).
+ </para>
+ <para>
̏̃CX^X́A̎_ʼniReLXgɊ֘AÂĂ܂B
܂AiIDi[̒ljA
Ă̓f[^x[XɑΉĂ傤B
@@ -203,6 +294,15 @@
<term>detached</term>
<listitem>
<para>
+ The instance was once associated with a persistence
+ context, but that context was closed, or the instance
+ was serialized to another process. It has a persistent
+ identity and, perhaps, a corrsponding row in the database.
+ For detached instances, Hibernate makes no guarantees
+ about the relationship between persistent identity and
+ Java identity.
+ </para>
+ <para>
̏̃CX^X́AĉiReLXgɊ֘AÂA
̃ReLXgN[YꂽA邢́A
̃vZXɂ̃CX^XVACYꂽłB
@@ -219,6 +319,11 @@
<title>JMXƂ̓</title>
<para>
+ JMX is the J2EE standard for management of Java components. Hibernate may be managed via
+ a JMX standard service. We provide an MBean implementation in the distribution,
+ <literal>org.hibernate.jmx.HibernateService</literal>.
+ </para>
+ <para>
JMXavaR|[lgǗ2EEWłB
JMXWT[rXāAHibernate͊ǗB
fBXgr[V̒<literal>org.hibernate.jmx.HibernateService</literal> Ƃ
@@ -226,6 +331,11 @@
</para>
<para>
+ For an example how to deploy Hibernate as a JMX service on the JBoss Application Server,
+ please see the JBoss User Guide. On JBoss AS, you also get these benefits if you deploy
+ using JMX:
+ </para>
+ <para>
JBoss AvP[VT[o[HibernateT[rXƂăfvC@̗ẮA
JBoss [UKChƂĂB JBoss AvP[VT[o[ɂāA
JMXăfvCÃbg܂B
@@ -234,6 +344,16 @@
<itemizedlist>
<listitem>
<para>
+ <emphasis>Session Management:</emphasis> The Hibernate <literal>Session</literal>'s lifecycle
+ can be automatically bound to the scope of a JTA transaction. This means you no
+ longer have to manually open and close the <literal>Session</literal>, this
+ becomes the job of a JBoss EJB interceptor. You also don't have to worry about
+ transaction demarcation in your code anymore (unless you'd like to write a portable
+ persistence layer of course, use the optional Hibernate <literal>Transaction</literal>
+ API for this). You call the <literal>HibernateContext</literal> to access a
+ <literal>Session</literal>.
+ </para>
+ <para>
<emphasis>ZbVǗ:</emphasis> Hibernate<literal>Session</literal> ̃CtTCŃA
ITAgUNṼXR[vɌт܂BA <literal>Session</literal> [vN[Y肷vȂƂ܂B
@@ -247,6 +367,14 @@
</listitem>
<listitem>
<para>
+ <emphasis>HAR deployment:</emphasis> Usually you deploy the Hibernate JMX service using a JBoss
+ service deployment descriptor (in an EAR and/or SAR file), it supports all the usual
+ configuration options of a Hibernate <literal>SessionFactory</literal>. However, you still
+ have to name all your mapping files in the deployment descriptor. If you decide to use
+ the optional HAR deployment, JBoss will automatically detect all mapping files in your
+ HAR file.
+ </para>
+ <para>
<emphasis>HAR fvC:</emphasis> ʏ(EAR ܂SAR t@CɂJBoss T[rX
fvCgfBXNv^āAHibernate JMX T[rXvC܂B
AHibernate<literal>SessionFactory</literal> ̑SĂ̈IȐݒvV -259,11 +387,18 @@
</itemizedlist>
<para>
+ Consult the JBoss AS user guide for more information about these options.
+ </para>
+ <para>
̃IvVɂĂ̏ڍׂȏ́AJBossAvP[VT[o[UKCh QlɂĂB
</para>
<para>
+ Another feature available as a JMX service are runtime Hibernate statistics. See
+ <xref linkend="configuration-optional-statistics"/>.
+ </para>
+ <para>
JMXT[rXƂėp\ȑ̋@\ɁAHibernatesvB
<xref linkend="configuration-optional-statistics"/> ĂB
</para>
@@ -272,24 +407,48 @@
<sect1 id="architecture-jca" revision="1">
<title>JCA T|[g</title>
<para>
+ Hibernate may also be configured as a JCA connector. Please see the website for more
+ details. Please note that Hibernate JCA support is still considered experimental.
+ </para>
+ <para>
Hibernate JCA RlN^ƂĂ܂BڍׂɂẮAWebTCgĂB
Hibernate JCA T|[ǵÂƂiKƂčlĂ邱ƂɒӂĂB
</para>
</sect1>
- <sect1 id="architecture-current-session" revision="1">
+ <sect1 id="architecture-current-session" revision="2">
<title>ReLXgZbV</title>
<para>
+ Most applications using Hibernate need some form of "contextual" sessions, where a given
+ session is in effect throughout the scope of a given context. However, across applications
+ the definition of what constitutes a context is typically different; and different contexts
+ define different scopes to the notion of current. Applications using Hibernate prior
+ to version 3.0 tended to utilize either home-grown <literal>ThreadLocal</literal>-based
+ contextual sessions, helper classes such as <literal>HibernateUtil</literal>, or utilized
+ third-party frameworks (such as Spring or Pico) which provided proxy/interception-based contextual sessions.
+ </para>
+ <para>
Hibernate AvP[V́AقƂAȂ̌`ReLXg"ZbVKvɂȂB
uReLXgZbVv́AReLXg̃XR[v̂ȂŗLbV̂ƂłB
- AӂAAvP[VƂɃReLXĝ͈̒قȂB
+ AʏvP[VƂɃReLXĝ͈̒قȂB
قȂ镡̃ReLXǵA_ɑĈقȂR[v`܂B
o[W3.0OHibernate ł́A <literal>ThreadLocal</literal> x[X́uReLXgZbVv p邩A <literal>HibernateUtil</literal> ̂悤ȃwp[NX𗘗p邩A
proxy/interception x[X́uReLXgZbVv iSpring ico ̂悤ȁjT[hp[eB̃t[[N𗘗p邩̂ǂꂩłB
+ iSpring ico ̂悤ȁjT[hp[eB̃t[[N𗘗p邩̂ꂩłB
</para>
+
<para>
+ Starting with version 3.0.1, Hibernate added the <literal>SessionFactory.getCurrentSession()</literal>
+ method. Initially, this assumed usage of <literal>JTA</literal> transactions, where the
+ <literal>JTA</literal> transaction defined both the scope and context of a current session.
+ The Hibernate team maintains that, given the maturity of the numerous stand-alone
+ <literal>JTA TransactionManager</literal> implementations out there, most (if not all)
+ applications should be using <literal>JTA</literal> transaction management whether or not
+ they are deployed into a <literal>J2EE</literal> container. Based on that, the
+ <literal>JTA</literal>-based contextual sessions is all you should ever need to use.
+ </para>
+ <para>
o[W 3.0.1 Hibernate ɂ<literal>SessionFactory.getCurrentSession()</literal>
܂B A <literal>JTA</literal> gUNV̎gpĂ܂B
<literal>JTA</literal> gUNV́Ã݂ZbṼXR[vƃReLXg̗`܂B
@@ -301,15 +460,30 @@
̍lɊƁA <literal>JTA</literal> x[X́uReLXgZbVv gȂł傤B
</para>
-
+
<para>
+ However, as of version 3.1, the processing behind
+ <literal>SessionFactory.getCurrentSession()</literal> is now pluggable. To that
+ end, a new extension interface (<literal>org.hibernate.context.CurrentSessionContext</literal>)
+ and a new configuration parameter (<literal>hibernate.current_session_context_class</literal>)
+ have been added to allow pluggability of the scope and context of defining current sessions.
+ </para>
+ <para>
Ao[W 3.1 A <literal>SessionFactory.getCurrentSession()</literal> ̌A
vKuɂȂB
āÃ݂ZbV`R[vƃReLXg̃vKreB\ɂ邽߂ɁA
VgC^tF[X ( <literal>org.hibernate.context.CurrentSessionContext</literal> ) V\p[^ ( <literal>hibernate.current_session_context_class</literal> ) ljB
</para>
+
<para>
+ See the Javadocs for the <literal>org.hibernate.context.CurrentSessionContext</literal>
+ interface for a detailed discussion of its contract. It defines a single method,
+ <literal>currentSession()</literal>, by which the implementation is responsible for
+ tracking the current contextual session. Out-of-the-box, Hibernate comes with three
+ implementations of this interface.
+ </para>
+ <para>
<literal>org.hibernate.context.CurrentSessionContext</literal> C^tF[X̋KĂ ڍׂȓJavadoc ƂĂB
́A <literal>currentSession()</literal> Ƃ1̃\bh
@@ -320,43 +494,91 @@
<itemizedlist>
<listitem>
<para>
+ <literal>org.hibernate.context.JTASessionContext</literal> - current sessions
+ are tracked and scoped by a <literal>JTA</literal> transaction. The processing
+ here is exactly the same as in the older JTA-only approach. See the Javadocs
+ for details.
+ </para>
+ <para>
<literal>org.hibernate.context.JTASessionContext</literal> -
<literal>JTA</literal> gUNVɂāÃ݂ZbVǐՂ
- XR[v߂܂B̏́AÂ JTÃAv[`Ƃ܂łB
- ڍׂ́AJavadoc ƂĂB
+ XR[v߂܂B̏́AÂJTÃAv[`Ƃ܂łB
+ ڍׂavadocƂĂB
</para>
</listitem>
<listitem>
<para>
+ <literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current
+ sessions are tracked by thread of execution. Again, see the Javadocs for details.
+ </para>
+ <para>
<literal>org.hibernate.context.ThreadLocalSessionContext</literal> -
Xbh̎sɂāÃ݂ZbVǐՂB
- ڍׂ́AJavadoc ƂĂB
+ ڍׂavadocƂĂB
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>org.hibernate.context.ManagedSessionContext</literal> - current
+ sessions are tracked by thread of execution. However, you are responsible to
+ bind and unbind a <literal>Session</literal> instance with static methods
+ on this class, it does never open, flush, or close a <literal>Session</literal>.
+ </para>
+ <para>
+ <literal>org.hibernate.context.ManagedSessionContext</literal> -
+ Xbh̎sɂāÃ݂ZbVǐՂB
+ ÃNXtatic\bh<literal>Session</literal> CX^X oCh/AoChC͂ȂɂB
+ <literal>Session</literal> [vAtbVAN[Y܂+ </para>
+ </listitem>
</itemizedlist>
<para>
- ̎́A"1ZbV - 1f[^x[XgUNV" vO~Of܂B
- ܂A <emphasis>NGXgƂ̃ZbV</emphasis> ƂĒmĂgĂ܂B
+ The first two implementations provide a "one session - one database transaction" programming
+ model, also known and used as <emphasis>session-per-request</emphasis>. The beginning
+ and end of a Hibernate session is defined by the duration of a database transaction.
+ If you use programatic transaction demarcation in plain JSE without JTA, you are adviced to
+ use the Hibernate <literal>Transaction</literal> API to hide the underlying transaction system
+ from your code. If you use JTA, use the JTA interfaces to demarcate transactions. If you
+ execute in an EJB container that supports CMT, transaction boundaries are defined declaratively
+ and you don't need any transaction or session demarcation operations in your code.
+ Refer to <xref linkend="transactions"/> for more information and code examples.
+ </para>
+ <para>
+ n߂̎́A"1ZbV - 1f[^x[XgUNV" vO~Of܂B
+ <emphasis>NGXgƂ̃ZbVisession-per-requestj</emphasis> ƂĂĂgĂ܂B
Hibernate ZbV̊JnƏÍAf[^x[XgUNV̊܂B
- AvOɂgUNVEݒJ2SE TA/UserTransaction/BMT pj
- ȂʂɂUNVVXe邽߂ɁA
- Hibernate <literal>Transaction</literal> łB
- ACMT |[gJB Rei[œ삳ȂAgUNVÉA
- 錾IɒłAgUNVbV̋Eݒւ̂悤ȑKvƂȂ- ڍׂȏ[h̗A <xref linkend="transactions"/> ƂĂB
+ JTAʂSEŁAvOgUNVEݒsȂ
+ R[hb̃gUNVVXe邽߂ɁA
+ Hibernate <literal>Transaction</literal> APIƂ悢ł傤B
+ JTAȂgUNV̋Eݒ́AJTAC^[tFCXĂB
+ CMT|[gBReiŎsȂgUNVE͐錾Iɒł邽߁A
+ R[hgUNVbV̋E肷v͂+ ڍׂȏ[h̗A <xref linkend="transactions"/> ƂĂB
</para>
<para>
- <literal>hibernate.current_session_context_class</literal> \p[^́A
+ The <literal>hibernate.current_session_context_class</literal> configuration parameter
+ defines which <literal>org.hibernate.context.CurrentSessionContext</literal> implementation
+ should be used. Note that for backwards compatibility, if this config param is not set
+ but a <literal>org.hibernate.transaction.TransactionManagerLookup</literal> is configured,
+ Hibernate will use the <literal>org.hibernate.context.JTASessionContext</literal>.
+ Typically, the value of this parameter would just name the implementation class to
+ use; for the three out-of-the-box implementations, however, there are two corresponding
+ short names, "jta", "thread", and "managed".
+ </para>
+ <para>
+ <literal>hibernate.current_session_context_class</literal> ݒ[^́A
<literal>org.hibernate.context.CurrentSessionContext</literal> ̂ǂ̎肵܂B
- ʌ݊̂߁A̍\p[^ݒ肳ꂸ- <literal>org.hibernate.transaction.TransactionManagerLookup</literal> ݒ肳ꍇ́A
- <literal>org.hibernate.context.JTASessionContext</literal> ܂B
- ʏ̃p[^̒lɂ́A2̂ɎĝAgp̎NX̖O肵܂A
- "jta" "thread" Ƃꂼȗӂ܂B
+ ʌ݊̂߁Ãp[^ݒ肳ꂸ
+ <literal>org.hibernate.transaction.TransactionManagerLookup</literal> ݒ肳ꍇA
+ Hibernate<literal>org.hibernate.context.JTASessionContext</literal> ƂɒӂĂB
+ ʏ킱̃p[^̒lɂ́A3̎̒pNX̖Oڎw肵܂B
+ A"jta", "thread", "managed"Ƃꂼȗӂ܂B
</para>
</sect1>
</chapter>
+
Modified: trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml 2006-07-31 20:27:50 UTC (rev 10182)
+++ trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml 2006-08-01 09:29:01 UTC (rev 10183)
@@ -97,7 +97,7 @@
- <sect2 id="mapping-declaration-doctype" revision="2">
+ <sect2 id="mapping-declaration-doctype" revision="3">
<title>Doctype</title>
<para>
@@ -108,6 +108,135 @@
C^[lbgɂDt@CƂȂ
NXpX̓āADTD錾FĂB
</para>
+
+
+
+ <sect3 id="mapping-declaration-entity-resolution">
+ <title>
+ EntityResolver
+
+ GeBeBE]o
+ </title>
+ <para>
+
+
+ As mentioned previously, Hibernate will first attempt to resolve DTDs in its classpath. The
+ manner in which it does this is by registering a custom <literal>org.xml.sax.EntityResolver</literal>
+ implementation with the SAXReader it uses to read in the xml files. This custom
+ <literal>EntityResolver</literal> recognizes two different systemId namespaces.
+
+
+
+
+
+
+
+ Oq悤ɁAHibernate͂܂̃NXpXDTD悤Ƃ܂B
+ DTD̉́A
+ JX^ <literal>org.xml.sax.EntityResolver</literal> ̎^邱Ƃɂčs܂B
+ ̂Ƃ <literal>EntityResolver</literal> ̎́A
+ XMLt@Cݍނ߂AX[_ibernateɓo^B
+ ̃JX^<literal>EntityResolver</literal> ̈قȂXeIDOŔFB
+
+
+
+
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+
+
+ a <literal>hibernate namespace</literal> is recognized whenever the
+ resolver encounteres a systemId starting with
+ <literal>http://hibernate.sourceforge.net/</literal>; the resolver
+ attempts to resolve these entities via the classlaoder which loaded
+ the Hibernate classes.
+
+
+
+
+
+ <literal>HibernateO/literal> ́A]o
+ <literal>http://hibernate.sourceforge.net/</literal> Ŏn܂XeIDɓBƂ+ KFB
+ ă]óAHibernatẽNXɂă[hꂽNX[_āA
+ ̃GeBeB悤Ƃ܂B
+
+
+
+
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+
+
+ a <literal>user namespace</literal> is recognized whenever the
+ resolver encounteres a systemId using a <literal>classpath://</literal>
+ URL protocol; the resolver will attempt to resolve these entities
+ via (1) the current thread context classloader and (2) the
+ classloader which loaded the Hibernate classes.
+
+
+
+
+
+
+ <literal>[UO/literal>́A]o
+ URLvgR<literal>classpath://</literal> VXeIDɓBƂ+ KFBă]óA(1)݂̃XbhReLXgāA܂+ (2)HibernatẽNXɂă[hꂽNX[_āA
+ ̃GeBeB悤Ƃ܂B
+
+
+
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+
+ An example of utilizing user namespacing:
+
+
+
+ ĹA[UOF
+
+
+ </para>
+ <programlisting><![CDATA[<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" [
+ <!ENTITY types SYSTEM "classpath://your/domain/types.xml">
+]>
+
+<hibernate-mapping package="your.domain">
+ <class name="MyEntity">
+ <id name="id" type="my-custom-id-type">
+ ...
+ </id>
+ <class>
+ &types;
+</hibernate-mapping>]]></programlisting>
+ <para>
+
+
+ Where <literal>types.xml</literal> is a resource in the <literal>your.domain</literal>
+ package and contains a custom <xref linkend="mapping-types-custom">typedef</xref>.
+
+
+
+
+
+ literal>types.xml</literal> <literal>your.domain</literal>pbP[W\[Xł
+ JX^ <xref linkend="mapping-types-custom">typedef</xref>ނ܂B
+
+
+ </para>
+ </sect3>
+
+
</sect2>
<sect2 id="mapping-declaration-mapping" revision="3">
Modified: trunk/Hibernate3/doc/reference/ja/modules/configuration.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/configuration.xml 2006-07-31 20:27:50 UTC (rev 10182)
+++ trunk/Hibernate3/doc/reference/ja/modules/configuration.xml 2006-08-01 09:29:01 UTC (rev 10183)
@@ -689,9 +689,26 @@
JDBCgUNV̏ꍇA <literal>after_transaction</literal> ŃN[Y܂B
<para>
<emphasis role="strong"></emphasis>
- <literal>on_close</literal> (default) | <literal>after_transaction</literal> |
- <literal>after_statement</literal> | <literal>auto</literal>
+ <literal>auto</literal> (default) | <literal>on_close</literal> |
+ <literal>after_transaction</literal> | <literal>after_statement</literal>
</para>
+
+ <para>
+ Note that this setting only affects <literal>Session</literal>s returned from
+ <literal>SessionFactory.openSession</literal>. For <literal>Session</literal>s
+ obtained through <literal>SessionFactory.getCurrentSession</literal>, the
+ <literal>CurrentSessionContext</literal> implementation configured for use
+ controls the connection release mode for those <literal>Session</literal>s.
+ See <xref linkend="architecture-current-session"/>
+
+ ӂĂB̐ݒ <literal>SessionFactory.openSession</literal> 擾 <literal>Session</literal> ɌB
+ <literal>SessionFactory.getCurrentSession</literal> Ď擾
+ <literal>Session</literal> ł́A<literal>CurrentSessionContext</literal>
+ ̎ɂāARlNṼ[X[h肵܂B
+ <xref linkend="architecture-current-session"/> ƂĂB
+ </para>
+
</entry>
</row>
<row>
@@ -906,7 +923,7 @@
</tgroup>
</table>
- <table frame="topbot" id="configuration-misc-properties" revision="9">
+ <table frame="topbot" id="configuration-misc-properties" revision="10">
<title>̑̃vpeB</title>
<tgroup cols="2">
<colspec colname="c1" colwidth="1*"/>
@@ -929,7 +946,7 @@
<para>
<emphasis role="strong"></emphasis>
<literal>jta</literal> | <literal>thread</literal> |
- <literal>custom.Class</literal>
+ <literal>managed</literal> | <literal>custom.Class</literal>
</para>
</entry>
</row>
Modified: trunk/Hibernate3/doc/reference/ja/modules/performance.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/performance.xml 2006-07-31 20:27:50 UTC (rev 10182)
+++ trunk/Hibernate3/doc/reference/ja/modules/performance.xml 2006-08-01 09:29:01 UTC (rev 10183)
@@ -634,11 +634,23 @@
l܂LbVf[^o܂jB
</para>
- <para>
- ftHgł́AHibernateVMx̃LbVHCache܂BiJCST|[g͌ݐ炸A
- Hibernatȅ̃o[Wł͍폜ł傤jB <literal>hibernate.cache.provider_class</literal>
- vpeBɁA <literal>org.hibernate.cache.CacheProvider</literal> NX̖O肷邱ƂŁA
- ʂ̎邱Ƃ܂B
+ <para revision="1">
+
+ You have the option to tell Hibernate which caching implementation to use by
+ specifying the name of a class that implements <literal>org.hibernate.cache.CacheProvider</literal>
+ using the property <literal>hibernate.cache.provider_class</literal>. Hibernate
+ comes bundled with a number of built-in integrations with open-source cache providers
+ (listed below); additionally, you could implement your own and plug it in as
+ outlined above. Note that versions prior to 3.2 defaulted to use EhCache as the
+ default cache provider; that is no longer the case as of 3.2.
+
+ HibernategpbV́A<literal>hibernate.cache.provider_class</literal> vpeB+ <literal>org.hibernate.cache.CacheProvider</literal> NX肷邱ƂŕύXł܂B
+ Hibernate͑̃I[v\[X̃LbVvoC_gCŎĂ܂iXgjB
+ āAOɐ悤ɁAȂgƎ̎āAgݍނƂ܂B
+ o[W3.2OłhCacheftHg̃LbVvoC_ł邱ƂɒӂĂB
+ o[W3.2ł͂Ă͂܂+
</para>
<table frame="topbot" id="cacheproviders" revision="1">
Modified: trunk/Hibernate3/doc/reference/ja/modules/persistent_classes.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/persistent_classes.xml 2006-07-31 20:27:50 UTC (rev 10182)
+++ trunk/Hibernate3/doc/reference/ja/modules/persistent_classes.xml 2006-08-01 09:29:01 UTC (rev 10183)
@@ -461,7 +461,7 @@
</sect1>
- <sect1 id="persistent-classes-tuplizers" revision="0">
+ <sect1 id="persistent-classes-tuplizers" revision="1">
<title>Tuplizer</title>
<para>
@@ -511,7 +511,7 @@
public class CustomMapTuplizerImpl
- extends org.hibernate.tuple.DynamicMapEntityTuplizer {
+ extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {
// override the buildInstantiator() method to plug in our custom map...
protected final Instantiator buildInstantiator(
org.hibernate.mapping.PersistentClass mappingInfo) {
@@ -531,7 +531,7 @@
</sect1>
<para>
- <!-- TODO: vpeBƃvLVpbP[W̃[Ugt[[N邱-->
+ TODO: vpeBƃvLVpbP[W̃[Ugt[[N邱 </para>
</chapter>
Modified: trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml 2006-07-31 20:27:50 UTC (rev 10182)
+++ trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml 2006-08-01 09:29:01 UTC (rev 10183)
@@ -1,548 +1,874 @@
-<?xml version="1.0" encoding="Shift_JIS"?>
-<chapter id="querysql" revision="2">
- <title>lCeBuSQL</title>
-
- <para>f[^x[X̃lCeBuSQLgăNG邱Ƃ܂B
- NGqgacle<literal>CONNECT</literal> L[[ĥ悤ɁA
- f[^x[XƎ̋@\𗘗pƂɎg܂B
- SQL/JDBCڎgpĂvP[Vbernateւ̈ڍsՂɂĂ܂B</para>
-
- <para>Hibernate3ł́AAXVA폜Aǂݍݏ̂悤ȂׂĂ- SQLiXgAhvV[Wށjł܂B</para>
-
- <sect1 id="querysql-creating" revision="3">
- <title> <literal>SQLQuery</literal> ̎gp</title>
-
- <para>lCeBuQLNG̎s<literal>SQLQuery</literal>
- C^[tFCXĐ䂵܂B
- <literal>SQLQuery</literal> C^[tFCX- <literal>Session.createSQLQuery()</literal> яoĎ擾܂B
- ɊȒPȏꍇÂ悤Ȍ`܂B</para>
-
- <programlisting><![CDATA[List cats = sess.createSQLQuery("select * from cats")
- .addEntity(Cat.class)
- .list();]]></programlisting>
-
- <para>̃NGŎw肳̂LɎ܂B</para>
-
- <itemizedlist>
- <listitem>
- <para>SQLNGara>
- </listitem>
-
- <listitem>
- <para>NGԂGeBeB</para>
- </listitem>
- </itemizedlist>
-
- <para>ł́A
- UgZbǵ̗A}bsOt@CŎw肳ꂽƓƉ肳B
- ̃e[uLNGł͖ƂȂB
- ̌`́AdĂ݂ɂȂ/para>
-
- <programlisting><![CDATA[List cats = sess.createSQLQuery("select {cat.*} from cats cat")
- .addEntity("cat", Cat.class)
- .list();]]></programlisting>
-
- <para>̃NGŎw肳̂LɎ܂B</para>
-
- <itemizedlist>
- <listitem>
- <para>SQLNG iHibernateʖ߂̃v[Xz_ށj</para>
- </listitem>
-
- <listitem>
- <para>NGԂGeBeBQLe[u̕ʖ</para>
- </listitem>
- </itemizedlist>
-
- <para><literal>addEntity()</literal> \bhɂA
- SQL̃e[uʖƕԂGeBeBNXAtA
- NG̃UgZbg̍\肵܂B</para>
-
- <para><literal>addJoin()</literal> \bhA
- ̃GeBeBƂ̊֘AƃRNV[h܂B</para>
-
- <programlisting><![CDATA[List cats = sess.createSQLQuery(
- "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id"
- )
- .addEntity("cat", Cat.class)
- .addJoin("kitten", "cat.kittens")
- .list();]]></programlisting>
-
- <para>lCeBuSQLNǴAPȃXJlJl- GeBeB̑gݍ킹ĂłB</para>
-
- <programlisting><![CDATA[Double max = (Double) sess.createSQLQuery("select max(cat.weight) as maxWeight from cats cat")
- .addScalar("maxWeight", Hibernate.DOUBLE);
- .uniqueResult();]]></programlisting>
-
- <para>Ahbmt@CɃUgZbg̃}bsOqA
- NGŎgp邱Ƃł܂B</para>
-
- <programlisting><![CDATA[List cats = sess.createSQLQuery(
- "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id"
- )
- .setResultSetMapping("catAndKitten")
- .list();]]></programlisting>
- </sect1>
-
- <sect1 id="querysql-aliasreferences">
- <title>ʖƃvpeB̎Q/title>
- <para><literal>{cat.*}</literal> Ƃ\ĹAuׂẴvpeBvȗ`łB
- AIɃJĂłA
- ̏ꍇ́AHibernateɊevpeBɑΉLʖł傤B
- ʖ̂߂̃v[Xz_́Ae[u̕ʖɂďCvpeBłB
- Ĺ̗Aʂ̃e[ui<literal>cat_log</literal>j }bsO^f[^Œꂽ <literal>Cat</literal> ܂B
- DނȂwhere߂̒łAvpeB̕ʖ邱ƂɋCĂB</para>
-
- <para>OtNGɑ<literal>{}</literal> \͕K{ł<emphasis>Ȃ</emphasis> łB
- <xref linkend="querysql-namedqueries"/> ƂĂB</para>
-
- <programlisting><![CDATA[String sql = "select cat.originalId as {cat.id}, " +
- "cat.mateid as {cat.mate}, cat.sex as {cat.sex}, " +
- "cat.weight*10 as {cat.weight}, cat.name as {cat.name} " +
- "from cat_log cat where {cat.mate} = :catId"
-
-List loggedCats = sess.createSQLQuery(sql)
- .addEntity("cat", Cat.class)
- .setLong("catId", catId)
- .list();]]></programlisting>
-
- <para><emphasis>ӁF</emphasis> IɊevpeB
- NX <emphasis>ƃTuNX</emphasis> ׂ̂ẴvpeB߂ȂȂ/para>
-
-
- <para>ʖɑ}̂\Ɏ܂B
- ӁF\̕ʖ͈łB
- ꂼʖ͈łgpɂ͂炭قȂ閼O܂B</para>
-
- <table frame="topbot" id="aliasinjection-summary">
- <title>ʖɑ}O</title>
-
- <tgroup cols="4">
- <colspec colwidth="1*" />
-
- <colspec colwidth="1*" />
-
- <colspec colwidth="2.5*" />
-
- <thead>
- <row>
- <entry></entry>
- <entry>\</entry>
- <entry>entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>PȃvpeB</entry>
- <entry><literal>{[aliasname].[propertyname]}</literal></entry>
- <entry><literal>A_NAME as {item.name}</literal></entry>
- </row>
- <row>
- <entry>vpeB</entry>
- <entry><literal>{[aliasname].[componentname].[propertyname]}</literal></entry>
- <entry><literal>CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}</literal></entry>
- </row>
- <row>
- <entry>GeBeB̃NXʂ</entry>
- <entry><literal>{[aliasname].class}</literal></entry>
- <entry><literal>DISC as {item.class}</literal></entry>
- </row>
- <row>
- <entry>GeBeB̑SvpeB</entry>
- <entry><literal>{[aliasname].*}</literal></entry>
- <entry><literal>{item.*}</literal></entry>
- </row>
- <row>
- <entry>RNṼL[</entry>
- <entry><literal>{[aliasname].key}</literal></entry>
- <entry><literal>ORGID as {coll.key}</literal></entry>
- </row>
- <row>
- <entry>RNVD</entry>
- <entry><literal>{[aliasname].id}</literal></entry>
- <entry><literal>EMPID as {coll.id}</literal></entry>
- </row>
- <row>
- <entry>RNV̗vf</entry>
- <entry><literal>{[aliasname].element}</literal></entry>
- <entry><literal>XID as {coll.element}</literal></entry>
- <entry></entry>
- </row>
- <row>
- <entry>RNV̗vf̃vpeB</entry>
- <entry><literal>{[aliasname].element.[propertyname]}</literal></entry>
- <entry><literal>NAME as {coll.element.name}</literal></entry>
- </row>
- <row>
- <entry>RNV̗vf̑SvpeB</entry>
- <entry><literal>{[aliasname].element.*}</literal></entry>
- <entry><literal>{coll.element.*}</literal></entry>
- </row>
- <row>
- <entry>RNV̑SvpeB</entry>
- <entry><literal>{[aliasname].*}</literal></entry>
- <entry><literal>{coll.*}</literal></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect1>
-
- <sect1 id="querysql-namedqueries" revision="3">
- <title>OtSQLNG</title>
-
- <para>OtSQLNG̓}bsOhLgŒ邱ƂłA
- OtHQLNGƑSĂԂƂł܂B
- ̏ꍇA<literal>addEntity()</literal> яoKv<emphasis>Ȃ</emphasis> łB</para>
-
- <programlisting><![CDATA[<sql-query name="persons">
- <return alias="person" class="eg.Person"/>
- SELECT person.NAME AS {person.name},
- person.AGE AS {person.age},
- person.SEX AS {person.sex}
- FROM PERSON person
- WHERE person.NAME LIKE :namePattern
-</sql-query>]]></programlisting>
-
- <programlisting><![CDATA[List people = sess.getNamedQuery("persons")
- .setString("namePattern", namePattern)
- .setMaxResults(50)
- .list();]]></programlisting>
-
- <para>֘A邽߂ƃRNVG`邽߂ɁAꂼ <literal><return-join></literal> <literal><load-collection></literal>
- vf܂B</para>
-
- <programlisting><![CDATA[<sql-query name="personsWith">
- <return alias="person" class="eg.Person"/>
- <return-join alias="address" property="person.mailingAddress"/>
- SELECT person.NAME AS {person.name},
- person.AGE AS {person.age},
- person.SEX AS {person.sex},
- adddress.STREET AS {address.street},
- adddress.CITY AS {address.city},
- adddress.STATE AS {address.state},
- adddress.ZIP AS {address.zip}
- FROM PERSON person
- JOIN ADDRESS adddress
- ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'
- WHERE person.NAME LIKE :namePattern
-</sql-query>]]></programlisting>
-
- <para>OtSQLNG̓XJlƂ܂B
- <literal><return-scalar></literal> vfāA
- ʖibernatě^ȂȂ/para>
-
- <programlisting><![CDATA[<sql-query name="mySqlQuery">
- <return-scalar column="name" type="string"/>
- <return-scalar column="age" type="long"/>
- SELECT p.NAME AS name,
- p.AGE AS age,
- FROM PERSON p WHERE p.NAME LIKE 'Hiber%'
-</sql-query>]]></programlisting>
-
-
- <para>UgZbg̃}bsOiteral><resultset></literal>
- ɊOo邱Ƃł܂B
- ̖OtNGōėp<literal>setResultSetMapping()</literal>
- APIčėp܂B
- </para>
-
- <programlisting><![CDATA[<resultset name="personAddress">
- <return alias="person" class="eg.Person"/>
- <return-join alias="address" property="person.mailingAddress"/>
-</resultset>
-
-<sql-query name="personsWith" resultset-ref="personAddress">
- SELECT person.NAME AS {person.name},
- person.AGE AS {person.age},
- person.SEX AS {person.sex},
- adddress.STREET AS {address.street},
- adddress.CITY AS {address.city},
- adddress.STATE AS {address.state},
- adddress.ZIP AS {address.zip}
- FROM PERSON person
- JOIN ADDRESS adddress
- ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'
- WHERE person.NAME LIKE :namePattern
-</sql-query>]]></programlisting>
-
- <sect2 id="propertyresults">
- <title>ʖIɎw肷邽߂return-property </title>
-
- <para>ʖ߂<literal>{}</literal> \A
- <literal><return-property></literal> A
- ǂ̗ʖ̂ł܂B</para>
-
- <programlisting><![CDATA[<sql-query name="mySqlQuery">
- <return alias="person" class="eg.Person">
- <return-property name="name" column="myName"/>
- <return-property name="age" column="myAge"/>
- <return-property name="sex" column="mySex"/>
- </return>
- SELECT person.NAME AS myName,
- person.AGE AS myAge,
- person.SEX AS mySex,
- FROM PERSON person WHERE person.NAME LIKE :name
-</sql-query>
-]]></programlisting>
-
- <para><literal><return-property></literal> ͕̗܂B
- AvpeBߍׂȂƂA
- <literal>{}</literal> \̐܂B</para>
-
- <programlisting><![CDATA[<sql-query name="organizationCurrentEmployments">
- <return alias="emp" class="Employment">
- <return-property name="salary">
- <return-column name="VALUE"/>
- <return-column name="CURRENCY"/>
- </return-property>
- <return-property name="endDate" column="myEndDate"/>
- </return>
- SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},
- STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},
- REGIONCODE as {emp.regionCode}, EID AS {emp.id}, VALUE, CURRENCY
- FROM EMPLOYMENT
- WHERE EMPLOYER = :id AND ENDDATE IS NULL
- ORDER BY STARTDATE ASC
-</sql-query>]]></programlisting>
-
- <para>̗́A}߂<literal>{}</literal> \ƂA
- <literal><return-property></literal> Ă邱ƂɒӂĂB
- vpeB̂悤ɎQƂ邩ׂ܂B</para>
-
- <para>}bsOdiscriminator ܂܂A
- discriminator ̗w肷邽߂ɁA<return-discriminator>
- Ȃ/para>
- </sect2>
-
- <sect2 id="sp_query" revision="1">
- <title>₢킹邽߂ɃXgAhvV[W</title>
-
- <para>Hibernate̓o[W3XgAhvV[WƃXgAhoR̖₢킹
- T|[gB
- ȍ~̑́̕AĂ͂܂B
- XgAhvV[WgAhernateŎg߂ɂ́A
- 1Ԗڂ̏o̓p[^ƂăUgZbgȂȂ- Oracle 9i͂o[Wj̃XgAhvV[W̗ȉɎ܂B</para>
-
- <programlisting><![CDATA[CREATE OR REPLACE FUNCTION selectAllEmployments
- RETURN SYS_REFCURSOR
-AS
- st_cursor SYS_REFCURSOR;
-BEGIN
- OPEN st_cursor FOR
- SELECT EMPLOYEE, EMPLOYER,
- STARTDATE, ENDDATE,
- REGIONCODE, EID, VALUE, CURRENCY
- FROM EMPLOYMENT;
- RETURN st_cursor;
- END;]]></programlisting>
-
- <para>Hibernateł̃NG߂ɂ́A
- OtNGŃ}bsOvB</para>
-
- <programlisting><![CDATA[<sql-query name="selectAllEmployees_SP" callable="true">
- <return alias="emp" class="Employment">
- <return-property name="employee" column="EMPLOYEE"/>
- <return-property name="employer" column="EMPLOYER"/>
- <return-property name="startDate" column="STARTDATE"/>
- <return-property name="endDate" column="ENDDATE"/>
- <return-property name="regionCode" column="REGIONCODE"/>
- <return-property name="id" column="EID"/>
- <return-property name="salary">
- <return-column name="VALUE"/>
- <return-column name="CURRENCY"/>
- </return-property>
- </return>
- { ? = call selectAllEmployments() }
-</sql-query>]]></programlisting>
-
- <para>ӁF̂ƂXgAhvV[W̓XJƃGeBeB݂̂łB
- <literal><return-join></literal> <literal><load-collection></literal>
- ̓T|[g܂/para>
-
- <sect3 id="querysql-limits-storedprocedures" revision="1">
- <title>XgAhvV[W̃[Ɛ/title>
-
- <para>HibernateŃXgAhvV[W߂ɂ́A
- ̃vV[W͂̃[ɏvB
- [ɏĂȂvV[ẂAHibernateŎgƂ͂ł܂- ĂȂvV[ŴłA
- <literal>session.connection()</literal> ĎsȂȂ- [̓f[^x[XƂɈقȂB
- XgAhvV[W̃Z}eBbNXƃV^bNX́A
- f[^x[Xx_ƂɈقȂ邽߂łB</para>
-
- <para><literal>setFirstResult()/setMaxResults()</literal> āA
- XgAhvV[WNG[W邱Ƃ͂ł܂/para>
-
- <para>яoWłL92ɏ]ƂłB
- <literal>{ ? = call functionName(<parameters>) }</literal> <literal>{ ? = call procedureName(<parameters>) }</literal> łB
- lCeBuȌĂяo\̓T|[g܂/para>
-
- <para>Oracleɂ͉L̃[KpB</para>
-
- <itemizedlist spacing="compact">
- <listitem>
- <para>̓UgZbgȂȂ- vV[W̑UgZbg߁A
- <literal>OUT</literal> łȂȂ- Oracle 90ł́A<literal>SYS_REFCURSOR</literal> ƂɂĂł܂B
- Oracleł<literal>REF CURSOR</literal> ^`vB
- Oracle̕ƂĂB</para>
- </listitem>
- </itemizedlist>
-
- <para>SybaseS SQLT[o[ɓKp[LɎ܂B</para>
-
- <itemizedlist spacing="compact">
- <listitem>
- <para>vV[W̓UgZbgȂȂ- T[o[͕̃UgZbgƍXVJEg܂A
- Hibernateڂ̃UgZbgƂɒӂĂB
- ׂ̑͂Ď̂Ă܂B</para>
- </listitem>
-
- <listitem>
- <para>vV[W̒<literal>SET NOCOUNT ON</literal> A
- 炭悭Ȃ傤B
- AKvł͂/para>
- </listitem>
- </itemizedlist>
- </sect3>
- </sect2>
- </sect1>
-
- <sect1 id="querysql-cud">
- <title>쐬AXVA폜̂߂̃JX^SQL</title>
-
- <para>Hibernate3͍쐬AXVA폜̂߂̃JX^SQLpł܂B
- NXƃRNV̉i@\́ARtBO[Vɐꂽ iinsertsqlAdeletesqlAupdatesqlȂǁj̃ZbgłɕێĂ܂B
- ̕
- <literal><sql-insert></literal>A
- <literal><sql-delete></literal>A
- <literal><sql-update></literal> Ƃ}bsO^OD悳B</para>
-
- <programlisting><![CDATA[<class name="Person">
- <id name="id">
- <generator class="increment"/>
- </id>
- <property name="name" not-null="true"/>
- <sql-insert>INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )</sql-insert>
- <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?</sql-update>
- <sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>
-</class>]]></programlisting>
-
- <para>SQLڃf[^x[XŎs邽߁AD݂̕RɎgpł܂B
- f[^x[XƎQLAR}bsÕ|[^reBB</para>
-
- <para><literal>callable</literal> bgA
- XgAhvV[Wpł܂B</para>
-
- <programlisting><![CDATA[<class name="Person">
- <id name="id">
- <generator class="increment"/>
- </id>
- <property name="name" not-null="true"/>
- <sql-insert callable="true">{call createPerson (?, ?)}</sql-insert>
- <sql-delete callable="true">{? = call deletePerson (?)}</sql-delete>
- <sql-update callable="true">{? = call updatePerson (?, ?)}</sql-update>
-</class>]]></programlisting>
-
- <para>̂Ƃʒup[^̏Ԃ͂ƂĂvłB
- Ȃ킿AHibernate鏇łȂȂ/para>
-
- <para><literal>org.hiberante.persister.entity</literal> x̃fobOO L邱ƂɂāAԂ߂܂B
- ̃x邱ƂɂAGeBeB̍쐬AXVA폜Ȃǂ- gpÓIQLo͂B
- iF邽߂ɂ́AHibernateIQL[o[Ch JX^SQLbsOt@CɊ܂߂ȂƂłBj</para>
-
- <para>XgAhvV[W͑}/폜ꂽsKv
- iǂݍ݂̏ꍇ́AԂȂ͕ԂłjB
- sibernateSQL̐`FbN邩B
- HibernatéACUD̂߂̐l̏o̓p[^ƂāA
- SQL̍ŏ̃p[^^܂B</para>
-
- <programlisting><![CDATA[CREATE OR REPLACE FUNCTION updatePerson (uid IN NUMBER, uname IN VARCHAR2)
- RETURN NUMBER IS
-BEGIN
-
- update PERSON
- set
- NAME = uname,
- where
- ID = uid;
-
- return SQL%ROWCOUNT;
-
-END updatePerson;]]></programlisting>
- </sect1>
-
- <sect1 id="querysql-load">
- <title>[ĥ߂̃JX^SQL</title>
-
- <para>GeBeBݍނ߂̓ƎQLiQLjNGł܂B</para>
-
- <programlisting><![CDATA[<sql-query name="person">
- <return alias="pers" class="Person" lock-mode="upgrade"/>
- SELECT NAME AS {pers.name}, ID AS {pers.id}
- FROM PERSON
- WHERE ID=?
- FOR UPDATE
-</sql-query>]]></programlisting>
-
- <para>A܂ɁiȑOc_jOtNG̐錾łB
- ̖OtNGX̃}bsOƂł܂B</para>
-
- <programlisting><![CDATA[<class name="Person">
- <id name="id">
- <generator class="increment"/>
- </id>
- <property name="name" not-null="true"/>
- <loader query-ref="person"/>
-</class>]]></programlisting>
-
-
- <para>XgAhvV[Wł삵܂B</para>
-
- <para>̂悤ɁARNV[h邽߂̃NGĂ悢łB</para>
-
- <programlisting><![CDATA[<set name="employments" inverse="true">
- <key/>
- <one-to-many class="Employment"/>
- <loader query-ref="employments"/>
-</set>]]></programlisting>
-
- <programlisting><![CDATA[<sql-query name="employments">
- <load-collection alias="emp" role="Person.employments"/>
- SELECT {emp.*}
- FROM EMPLOYMENT emp
- WHERE EMPLOYER = :id
- ORDER BY STARTDATE ASC, EMPLOYEE ASC
-</sql-query>]]></programlisting>
-
- <para>̂悤ɁAtFb`ɂRNV[h GeBeB[_[`ł܂B</para>
-
- <programlisting><![CDATA[<sql-query name="person">
- <return alias="pers" class="Person"/>
- <return-join alias="emp" property="pers.employments"/>
- SELECT NAME AS {pers.*}, {emp.*}
- FROM PERSON pers
- LEFT OUTER JOIN EMPLOYMENT emp
- ON pers.ID = emp.PERSON_ID
- WHERE ID=?
-</sql-query>]]></programlisting>
- </sect1>
-
+<?xml version="1.0" encoding="Shift_JIS"?>
+<chapter id="querysql" revision="2">
+ <title>lCeBuSQL</title>
+
+ <para>f[^x[X̃lCeBuSQLgăNG邱Ƃ܂B
+ NGqgacle<literal>CONNECT</literal> L[[ĥ悤ɁA
+ f[^x[XƎ̋@\𗘗pƂɎg܂B
+ SQL/JDBCڎgpĂvP[Vbernateւ̈ڍsՂɂĂ܂B</para>
+
+ <para>Hibernate3ł́AAXVA폜Aǂݍݏ̂悤ȂׂĂ+ SQLiXgAhvV[Wށjł܂B</para>
+
+ <sect1 id="querysql-creating" revision="4">
+ <title><literal>SQLQuery</literal> ̎gp</title>
+
+ <para>lCeBuQLNG̎s<literal>SQLQuery</literal>
+ C^[tFCXĐ䂵܂B
+ <literal>SQLQuery</literal> C^[tFCX+ <literal>Session.createSQLQuery()</literal> яoĎ擾܂B
+ The following describes how to use this API for querying.
+ PIĖ₢킹@Ő܂B</para>
+܂+
+ <sect2>
+ <title>Scalar queries@@XJ[̃NG</title>
+
+ <para>The most basic SQL query is to get a list of scalars
+ (values).</para>
+
+ <para>ł{IQLNG̓XJ[ilj̃Xg邱ƂłB</para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").list();
+sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").list();
+]]></programlisting>
+
+ <para>These will both return a List of Object arrays (Object[]) with
+ scalar values for each column in the CATS table. Hibernate will use
+ ResultSetMetadata to deduce the actual order and types of the returned
+ scalar values.</para>
+
+ <para>͂ǂACATSe[ůeJ̃XJ[l+ Objectzbject[]j̃Xg܂B
+ ԂXJ[l̎ۂ̏Ԃƌ^𐄘_邽߂ɁA
+ HibernateesultSetMetadatap܂B</para>
+
+ <para>To avoid the overhead of using
+ <literal>ResultSetMetadata</literal> or simply to be more explicit in
+ what is returned one can use <literal>addScalar()</literal>.</para>
+
+ <para><literal>ResultSetMetadata</literal> p[o[wbh邽߁A
+ ͒PɉԂmɂ邽߁A<literal>addScalar()</literal>
+ ܂B</para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
+ .addScalar("ID", Hibernate.LONG)
+ .addScalar("NAME", Hibernate.STRING)
+ .addScalar("BIRTHDATE", Hibernate.DATE)
+]]></programlisting>
+
+ <para>This query specified:</para>
+
+ <para>̃NGŎw肳̂LɎ܂B</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>the SQL query string</para>
+ <para>SQLNGara>
+ </listitem>
+
+ <listitem>
+ <para>the columns and types to return</para>
+ <para>ԂJƌ^</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>This will still return Object arrays, but now it will not use
+ <literal>ResultSetMetdata</literal> but will instead explicitly get the
+ ID, NAME and BIRTHDATE column as respectively a Long, String and a Short
+ from the underlying resultset. This also means that only these three
+ columns will be returned, even though the query is using
+ <literal>*</literal> and could return more than the three listed
+ columns.</para>
+
+ <para>܂ObjectzԂ܂A
+ <literal>ResultSetMetdata</literal> p܂+ Ȃɂ郊UgZbg IDANAMEABIRTHDATE Jꂼ LongAStringAShort ƂĖIɎ擾܂B
+ R̃Ĵ݂ł邱Ƃ܂B
+ ƂANG <literal>*</literal> pA
+ R̃JĂB</para>
+
+ <para>It is possible to leave out the type information for all or some
+ of the scalars.</para>
+
+ <para>XJ[̌^Ƃ܂B</para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
+ .addScalar("ID", Hibernate.LONG)
+ .addScalar("NAME")
+ .addScalar("BIRTHDATE")
+]]></programlisting>
+
+ <para>This is essentially the same query as before, but now
+ <literal>ResultSetMetaData</literal> is used to decide the type of NAME
+ and BIRTHDATE where as the type of ID is explicitly specified.</para>
+
+ <para>{IɑOƓNGłA
+ NAME BIRTHDATE ̌^߂邽߂<literal>ResultSetMetaData</literal>
+ p܂BID ̌^͖IɎw肳܂Biwhere as ̖/para>
+
+ <para>How the java.sql.Types returned from ResultSetMetaData is mapped
+ to Hibernate types is controlled by the Dialect. If a specific type is
+ not mapped or does not result in the expected type it is possible to
+ customize it via calls to <literal>registerHibernateType</literal> in
+ the Dialect.</para>
+
+ <para>
+ ResultSetMetaData java.sql.Types bernate ̌^+ }bsO邱Ƃ́ADialect 䂵܂B
+ ꂽ^}bsOȂAʂ̌^ƈقȂA
+ Dialect <literal>registerHibernateType</literal> яoA
+ JX^}CYł܂B
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Entity queries@@GeBeB NG</title>
+
+ <para>The above queries were all about returning scalar values,
+ basically returning the "raw" values from the resultset. The following
+ shows how to get entity objects from a native sql query via
+ <literal>addEntity()</literal>.</para>
+
+ <para>܂ł̃NǴAׂăXJ[lłB
+ IɁAUgZbgHv̒l܂B
+ ȍ~ł́A<literal>addEntity()</literal> ɂAlCeBuSQLNG GeBeBIuWFNg@܂B</para>
+
+ <programlisting><![CDATA[sess.createSQLQuery...
[truncated message content] |