HHH-3556: Envers documentation partially migrated
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15498 1b8cb986-b30d-0410-93ca-fae66ebed9b2
|
@ -1,56 +0,0 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||||
<!ENTITY versionNumber "3.3.0.GA">
|
||||
<!ENTITY copyrightYear "2004">
|
||||
<!ENTITY copyrightHolder "Red Hat Middleware, LLC.">
|
||||
]>
|
||||
|
||||
<book>
|
||||
|
||||
<bookinfo>
|
||||
<title>Hibernate Envers - Easy Entity Auditing</title>
|
||||
<subtitle>Hibernate Envers Reference Documentation</subtitle>
|
||||
<releaseinfo>&versionNumber;</releaseinfo>
|
||||
<productnumber>&versionNumber;</productnumber>
|
||||
<issuenum>1</issuenum>
|
||||
<copyright>
|
||||
<year>©rightYear;</year>
|
||||
<holder>©rightHolder;</holder>
|
||||
</copyright>
|
||||
<xi:include href="legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<!-- include translators... -->
|
||||
</bookinfo>
|
||||
|
||||
<toc/>
|
||||
|
||||
<xi:include href="content/preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/quickstart.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/example.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/configuration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/revisionlog.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/exceptions.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
</book>
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||||
<!ENTITY versionNumber "3.3.0.GA">
|
||||
<!ENTITY copyrightYear "2004">
|
||||
<!ENTITY copyrightHolder "Red Hat Middleware, LLC.">
|
||||
]>
|
||||
|
||||
<book>
|
||||
|
||||
<bookinfo>
|
||||
<title>HIBERNATE - Relational Persistence for Idiomatic Java</title>
|
||||
<subtitle>Hibernate Reference Documentation</subtitle>
|
||||
<releaseinfo>&versionNumber;</releaseinfo>
|
||||
<productnumber>&versionNumber;</productnumber>
|
||||
<issuenum>1</issuenum>
|
||||
<mediaobject>
|
||||
<imageobject role="fo">
|
||||
<imagedata fileref="images/hibernate_logo_a.png" align="center" />
|
||||
</imageobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="images/hibernate_logo_a.png" depth="3cm" />
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
<copyright>
|
||||
<year>©rightYear;</year>
|
||||
<holder>©rightHolder;</holder>
|
||||
</copyright>
|
||||
<xi:include href="legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<!-- include translators... -->
|
||||
</bookinfo>
|
||||
|
||||
<toc/>
|
||||
|
||||
<xi:include href="content/preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/tutorial.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/architecture.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/configuration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/persistent_classes.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/basic_mapping.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/collection_mapping.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/association_mapping.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/component_mapping.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/inheritance_mapping.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/session_api.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/transactions.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/events.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/batch.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/query_hql.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/query_criteria.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/query_sql.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/filters.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/xml.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/performance.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/toolset_guide.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/example_parentchild.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/example_weblog.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="content/example_mappings.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
<xi:include href="content/best_practices.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
|
||||
</book>
|
||||
|
|
@ -0,0 +1,382 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="architecture">
|
||||
|
||||
<title>Architecture</title>
|
||||
|
||||
<sect1 id="architecture-overview" revision="1">
|
||||
<title>Overview</title>
|
||||
|
||||
<para>
|
||||
A (very) high-level view of the Hibernate architecture:
|
||||
</para>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject role="fo">
|
||||
<imagedata fileref="../images/overview.svg" format="SVG" align="center"/>
|
||||
</imageobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="../images/overview.png" format="PNG" align="center"/>
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
|
||||
<para>
|
||||
This diagram shows Hibernate using the database and configuration data to
|
||||
provide persistence services (and persistent objects) to the application.
|
||||
</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>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject role="fo">
|
||||
<imagedata fileref="../images/lite.svg" format="SVG" align="center"/>
|
||||
</imageobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="../images/lite.png" format="PNG" align="center"/>
|
||||
</imageobject>
|
||||
</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>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject role="fo">
|
||||
<imagedata fileref="../images/full_cream.svg" format="SVG" align="center"/>
|
||||
</imageobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="../images/full_cream.png" format="PNG" align="center"/>
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
|
||||
<para>
|
||||
Heres some definitions of the objects in the diagrams:
|
||||
|
||||
<variablelist spacing="compact">
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Persistent objects and 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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Transient and detached objects and 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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</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>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="architecture-states" revision="1">
|
||||
<title>Instance states</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>
|
||||
|
||||
<variablelist spacing="compact">
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<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 corresponding row in the database.
|
||||
For detached instances, Hibernate makes no guarantees
|
||||
about the relationship between persistent identity and
|
||||
Java identity.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="architecture-jmx" revision="1">
|
||||
<title>JMX Integration</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>
|
||||
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>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<emphasis>Session Management:</emphasis> The Hibernate <literal>Session</literal>'s life cycle
|
||||
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>
|
||||
</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>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Consult the JBoss AS user guide for more information about these options.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Another feature available as a JMX service are runtime Hibernate statistics. See
|
||||
<xref linkend="configuration-optional-statistics"/>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="architecture-jca" revision="1">
|
||||
<title>JCA Support</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>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="architecture-current-session" revision="2">
|
||||
<title>Contextual Sessions</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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
|
||||
<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>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current
|
||||
sessions are tracked by thread of execution. Again, see the Javadocs for details.
|
||||
</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>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
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 programmatic transaction demarcation in plain JSE without JTA, you are advised 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>
|
||||
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 three corresponding
|
||||
short names, "jta", "thread", and "managed".
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,650 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="associations">
|
||||
|
||||
<title>Association Mappings</title>
|
||||
|
||||
<sect1 id="assoc-intro" revision="1">
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>
|
||||
Association mappings are the often most difficult thing to get right. In
|
||||
this section we'll go through the canonical cases one by one, starting
|
||||
with unidirectional mappings, and then considering the bidirectional cases.
|
||||
We'll use <literal>Person</literal> and <literal>Address</literal> in all
|
||||
the examples.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
We'll classify associations by whether or not they map to an intervening
|
||||
join table, and by multiplicity.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Nullable foreign keys are not considered good practice in traditional data
|
||||
modelling, so all our examples use not null foreign keys. This is not a
|
||||
requirement of Hibernate, and the mappings will all work if you drop the
|
||||
nullability constraints.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="assoc-unidirectional" revision="1">
|
||||
<title>Unidirectional associations</title>
|
||||
|
||||
<sect2 id="assoc-unidirectional-m21">
|
||||
<title>many to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>unidirectional many-to-one association</emphasis> is the most
|
||||
common kind of unidirectional association.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
not-null="true"/>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key, addressId bigint not null )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-unidirectional-121">
|
||||
<title>one to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>unidirectional one-to-one association on a foreign key</emphasis>
|
||||
is almost identical. The only difference is the column unique constraint.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
unique="true"
|
||||
not-null="true"/>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key, addressId bigint not null unique )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
A <emphasis>unidirectional one-to-one association on a primary key</emphasis>
|
||||
usually uses a special id generator. (Notice that we've reversed the direction
|
||||
of the association in this example.)
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="personId">
|
||||
<generator class="foreign">
|
||||
<param name="property">person</param>
|
||||
</generator>
|
||||
</id>
|
||||
<one-to-one name="person" constrained="true"/>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table Address ( personId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-unidirectional-12m">
|
||||
<title>one to many</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>unidirectional one-to-many association on a foreign key</emphasis>
|
||||
is a very unusual case, and is not really recommended.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<set name="addresses">
|
||||
<key column="personId"
|
||||
not-null="true"/>
|
||||
<one-to-many class="Address"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table Address ( addressId bigint not null primary key, personId bigint not null )
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
We think it's better to use a join table for this kind of association.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="assoc-unidirectional-join" revision="1">
|
||||
<title>Unidirectional associations with join tables</title>
|
||||
|
||||
<sect2 id="assoc-unidirectional-join-12m">
|
||||
<title>one to many</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>unidirectional one-to-many association on a join table</emphasis>
|
||||
is much preferred. Notice that by specifying <literal>unique="true"</literal>,
|
||||
we have changed the multiplicity from many-to-many to one-to-many.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<set name="addresses" table="PersonAddress">
|
||||
<key column="personId"/>
|
||||
<many-to-many column="addressId"
|
||||
unique="true"
|
||||
class="Address"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table PersonAddress ( personId not null, addressId bigint not null primary key )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-unidirectional-join-m21">
|
||||
<title>many to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>unidirectional many-to-one association on a join table</emphasis>
|
||||
is quite common when the association is optional.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<join table="PersonAddress"
|
||||
optional="true">
|
||||
<key column="personId" unique="true"/>
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
not-null="true"/>
|
||||
</join>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table PersonAddress ( personId bigint not null primary key, addressId bigint not null )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-unidirectional-join-121">
|
||||
<title>one to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>unidirectional one-to-one association on a join table</emphasis>
|
||||
is extremely unusual, but possible.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<join table="PersonAddress"
|
||||
optional="true">
|
||||
<key column="personId"
|
||||
unique="true"/>
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
not-null="true"
|
||||
unique="true"/>
|
||||
</join>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table PersonAddress ( personId bigint not null primary key, addressId bigint not null unique )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-unidirectional-join-m2m">
|
||||
<title>many to many</title>
|
||||
|
||||
<para>
|
||||
Finally, we have a <emphasis>unidirectional many-to-many association</emphasis>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<set name="addresses" table="PersonAddress">
|
||||
<key column="personId"/>
|
||||
<many-to-many column="addressId"
|
||||
class="Address"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table PersonAddress ( personId bigint not null, addressId bigint not null, primary key (personId, addressId) )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="assoc-bidirectional" revision="1">
|
||||
<title>Bidirectional associations</title>
|
||||
|
||||
<sect2 id="assoc-bidirectional-m21" revision="2">
|
||||
<title>one to many / many to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>bidirectional many-to-one association</emphasis> is the
|
||||
most common kind of association. (This is the standard parent/child
|
||||
relationship.)
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
not-null="true"/>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<set name="people" inverse="true">
|
||||
<key column="addressId"/>
|
||||
<one-to-many class="Person"/>
|
||||
</set>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key, addressId bigint not null )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
If you use a <literal>List</literal> (or other indexed collection) you need
|
||||
to set the <literal>key</literal> column of the foreign key to <literal>not null</literal>,
|
||||
and let Hibernate manage the association from the collections side to maintain the index
|
||||
of each element (making the other side virtually inverse by setting
|
||||
<literal>update="false"</literal> and <literal>insert="false"</literal>):
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id"/>
|
||||
...
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
not-null="true"
|
||||
insert="false"
|
||||
update="false"/>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id"/>
|
||||
...
|
||||
<list name="people">
|
||||
<key column="addressId" not-null="true"/>
|
||||
<list-index column="peopleIdx"/>
|
||||
<one-to-many class="Person"/>
|
||||
</list>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
It is important that you define <literal>not-null="true"</literal> on the
|
||||
<literal><key></literal> element of the collection mapping if the
|
||||
underlying foreign key column is <literal>NOT NULL</literal>. Don't only
|
||||
declare <literal>not-null="true"</literal> on a possible nested
|
||||
<literal><column></literal> element, but on the <literal><key></literal>
|
||||
element.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-bidirectional-121">
|
||||
<title>one to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>bidirectional one-to-one association on a foreign key</emphasis>
|
||||
is quite common.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
unique="true"
|
||||
not-null="true"/>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<one-to-one name="person"
|
||||
property-ref="address"/>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key, addressId bigint not null unique )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
A <emphasis>bidirectional one-to-one association on a primary key</emphasis>
|
||||
uses the special id generator.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<one-to-one name="address"/>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="personId">
|
||||
<generator class="foreign">
|
||||
<param name="property">person</param>
|
||||
</generator>
|
||||
</id>
|
||||
<one-to-one name="person"
|
||||
constrained="true"/>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table Address ( personId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="assoc-bidirectional-join" revision="1">
|
||||
<title>Bidirectional associations with join tables</title>
|
||||
|
||||
<sect2 id="assoc-bidirectional-join-12m">
|
||||
<title>one to many / many to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>bidirectional one-to-many association on a join table</emphasis>.
|
||||
Note that the <literal>inverse="true"</literal> can go on either end of the
|
||||
association, on the collection, or on the join.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<set name="addresses"
|
||||
table="PersonAddress">
|
||||
<key column="personId"/>
|
||||
<many-to-many column="addressId"
|
||||
unique="true"
|
||||
class="Address"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<join table="PersonAddress"
|
||||
inverse="true"
|
||||
optional="true">
|
||||
<key column="addressId"/>
|
||||
<many-to-one name="person"
|
||||
column="personId"
|
||||
not-null="true"/>
|
||||
</join>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table PersonAddress ( personId bigint not null, addressId bigint not null primary key )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-bidirectional-join-121">
|
||||
<title>one to one</title>
|
||||
|
||||
<para>
|
||||
A <emphasis>bidirectional one-to-one association on a join table</emphasis>
|
||||
is extremely unusual, but possible.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<join table="PersonAddress"
|
||||
optional="true">
|
||||
<key column="personId"
|
||||
unique="true"/>
|
||||
<many-to-one name="address"
|
||||
column="addressId"
|
||||
not-null="true"
|
||||
unique="true"/>
|
||||
</join>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<join table="PersonAddress"
|
||||
optional="true"
|
||||
inverse="true">
|
||||
<key column="addressId"
|
||||
unique="true"/>
|
||||
<many-to-one name="person"
|
||||
column="personId"
|
||||
not-null="true"
|
||||
unique="true"/>
|
||||
</join>
|
||||
</class>]]></programlisting>
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table PersonAddress ( personId bigint not null primary key, addressId bigint not null unique )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="assoc-bidirectional-join-m2m" revision="1">
|
||||
<title>many to many</title>
|
||||
|
||||
<para>
|
||||
Finally, we have a <emphasis>bidirectional many-to-many association</emphasis>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="id" column="personId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<set name="addresses" table="PersonAddress">
|
||||
<key column="personId"/>
|
||||
<many-to-many column="addressId"
|
||||
class="Address"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id" column="addressId">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<set name="people" inverse="true" table="PersonAddress">
|
||||
<key column="addressId"/>
|
||||
<many-to-many column="personId"
|
||||
class="Person"/>
|
||||
</set>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
create table Person ( personId bigint not null primary key )
|
||||
create table PersonAddress ( personId bigint not null, addressId bigint not null, primary key (personId, addressId) )
|
||||
create table Address ( addressId bigint not null primary key )
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="assoc-complex">
|
||||
<title>More complex association mappings</title>
|
||||
|
||||
<para>
|
||||
More complex association joins are <emphasis>extremely</emphasis> rare.
|
||||
Hibernate makes it possible to handle more complex situations using
|
||||
SQL fragments embedded in the mapping document. For example, if a table
|
||||
with historical account information data defines
|
||||
<literal>accountNumber</literal>, <literal>effectiveEndDate</literal>
|
||||
and <literal>effectiveStartDate</literal>columns, mapped as follows:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<properties name="currentAccountKey">
|
||||
<property name="accountNumber" type="string" not-null="true"/>
|
||||
<property name="currentAccount" type="boolean">
|
||||
<formula>case when effectiveEndDate is null then 1 else 0 end</formula>
|
||||
</property>
|
||||
</properties>
|
||||
<property name="effectiveEndDate" type="date"/>
|
||||
<property name="effectiveStateDate" type="date" not-null="true"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Then we can map an association to the <emphasis>current</emphasis> instance
|
||||
(the one with null <literal>effectiveEndDate</literal>) using:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<many-to-one name="currentAccountInfo"
|
||||
property-ref="currentAccountKey"
|
||||
class="AccountInfo">
|
||||
<column name="accountNumber"/>
|
||||
<formula>'1'</formula>
|
||||
</many-to-one>]]></programlisting>
|
||||
|
||||
<para>
|
||||
In a more complex example, imagine that the association between
|
||||
<literal>Employee</literal> and <literal>Organization</literal> is maintained
|
||||
in an <literal>Employment</literal> table full of historical employment data.
|
||||
Then an association to the employee's <emphasis>most recent</emphasis> employer
|
||||
(the one with the most recent <literal>startDate</literal>) might be mapped this way:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<join>
|
||||
<key column="employeeId"/>
|
||||
<subselect>
|
||||
select employeeId, orgId
|
||||
from Employments
|
||||
group by orgId
|
||||
having startDate = max(startDate)
|
||||
</subselect>
|
||||
<many-to-one name="mostRecentEmployer"
|
||||
class="Organization"
|
||||
column="orgId"/>
|
||||
</join>]]></programlisting>
|
||||
|
||||
<para>
|
||||
You can get quite creative with this functionality, but it is usually more practical
|
||||
to handle these kinds of cases using HQL or a criteria query.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,374 @@
|
|||
<?xml version='1.0' encoding="iso-8859-1"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="batch">
|
||||
<title>Batch processing</title>
|
||||
|
||||
<para>
|
||||
A naive approach to inserting 100 000 rows in the database using Hibernate might
|
||||
look like this:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
for ( int i=0; i<100000; i++ ) {
|
||||
Customer customer = new Customer(.....);
|
||||
session.save(customer);
|
||||
}
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
<para>
|
||||
This would fall over with an <literal>OutOfMemoryException</literal> somewhere
|
||||
around the 50 000th row. That's because Hibernate caches all the newly inserted
|
||||
<literal>Customer</literal> instances in the session-level cache.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In this chapter we'll show you how to avoid this problem. First, however, if you
|
||||
are doing batch processing, it is absolutely critical that you enable the use of
|
||||
JDBC batching, if you intend to achieve reasonable performance. Set the JDBC batch
|
||||
size to a reasonable number (say, 10-50):
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[hibernate.jdbc.batch_size 20]]></programlisting>
|
||||
|
||||
<para id="disablebatching" revision="1">
|
||||
Note that Hibernate disables insert batching at the JDBC level transparently if you
|
||||
use an <literal>identiy</literal> identifier generator.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You also might like to do this kind of work in a process where interaction with
|
||||
the second-level cache is completely disabled:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[hibernate.cache.use_second_level_cache false]]></programlisting>
|
||||
|
||||
<para>
|
||||
However, this is not absolutely necessary, since we can explicitly set the
|
||||
<literal>CacheMode</literal> to disable interaction with the second-level cache.
|
||||
</para>
|
||||
|
||||
<sect1 id="batch-inserts">
|
||||
<title>Batch inserts</title>
|
||||
|
||||
<para>
|
||||
When making new objects persistent, you must <literal>flush()</literal> and
|
||||
then <literal>clear()</literal> the session regularly, to control the size of
|
||||
the first-level cache.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
for ( int i=0; i<100000; i++ ) {
|
||||
Customer customer = new Customer(.....);
|
||||
session.save(customer);
|
||||
if ( i % 20 == 0 ) { //20, same as the JDBC batch size
|
||||
//flush a batch of inserts and release memory:
|
||||
session.flush();
|
||||
session.clear();
|
||||
}
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="batch-update" >
|
||||
<title>Batch updates</title>
|
||||
|
||||
<para>
|
||||
For retrieving and updating data the same ideas apply. In addition, you need to
|
||||
use <literal>scroll()</literal> to take advantage of server-side cursors for
|
||||
queries that return many rows of data.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
ScrollableResults customers = session.getNamedQuery("GetCustomers")
|
||||
.setCacheMode(CacheMode.IGNORE)
|
||||
.scroll(ScrollMode.FORWARD_ONLY);
|
||||
int count=0;
|
||||
while ( customers.next() ) {
|
||||
Customer customer = (Customer) customers.get(0);
|
||||
customer.updateStuff(...);
|
||||
if ( ++count % 20 == 0 ) {
|
||||
//flush a batch of updates and release memory:
|
||||
session.flush();
|
||||
session.clear();
|
||||
}
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="batch-statelesssession">
|
||||
<title>The StatelessSession interface</title>
|
||||
<para>
|
||||
Alternatively, Hibernate provides a command-oriented API that may be used for
|
||||
streaming data to and from the database in the form of detached objects. A
|
||||
<literal>StatelessSession</literal> has no persistence context associated
|
||||
with it and does not provide many of the higher-level life cycle semantics.
|
||||
In particular, a stateless session does not implement a first-level cache nor
|
||||
interact with any second-level or query cache. It does not implement
|
||||
transactional write-behind or automatic dirty checking. Operations performed
|
||||
using a stateless session do not ever cascade to associated instances. Collections
|
||||
are ignored by a stateless session. Operations performed via a stateless session
|
||||
bypass Hibernate's event model and interceptors. Stateless sessions are vulnerable
|
||||
to data aliasing effects, due to the lack of a first-level cache. A stateless
|
||||
session is a lower-level abstraction, much closer to the underlying JDBC.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[StatelessSession session = sessionFactory.openStatelessSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
ScrollableResults customers = session.getNamedQuery("GetCustomers")
|
||||
.scroll(ScrollMode.FORWARD_ONLY);
|
||||
while ( customers.next() ) {
|
||||
Customer customer = (Customer) customers.get(0);
|
||||
customer.updateStuff(...);
|
||||
session.update(customer);
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Note that in this code example, the <literal>Customer</literal> instances returned
|
||||
by the query are immediately detached. They are never associated with any persistence
|
||||
context.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <literal>insert(), update()</literal> and <literal>delete()</literal> operations
|
||||
defined by the <literal>StatelessSession</literal> interface are considered to be
|
||||
direct database row-level operations, which result in immediate execution of a SQL
|
||||
<literal>INSERT, UPDATE</literal> or <literal>DELETE</literal> respectively. Thus,
|
||||
they have very different semantics to the <literal>save(), saveOrUpdate()</literal>
|
||||
and <literal>delete()</literal> operations defined by the <literal>Session</literal>
|
||||
interface.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="batch-direct" revision="3">
|
||||
<title>DML-style operations</title>
|
||||
|
||||
<para>
|
||||
As already discussed, automatic and transparent object/relational mapping is concerned
|
||||
with the management of object state. This implies that the object state is available
|
||||
in memory, hence manipulating (using the SQL <literal>Data Manipulation Language</literal>
|
||||
(DML) statements: <literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</literal>)
|
||||
data directly in the database will not affect in-memory state. However, Hibernate provides methods
|
||||
for bulk SQL-style DML statement execution which are performed through the
|
||||
Hibernate Query Language (<link linkend="queryhql">HQL</link>).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The pseudo-syntax for <literal>UPDATE</literal> and <literal>DELETE</literal> statements
|
||||
is: <literal>( UPDATE | DELETE ) FROM? EntityName (WHERE where_conditions)?</literal>. Some
|
||||
points to note:
|
||||
</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
In the from-clause, the FROM keyword is optional
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
There can only be a single entity named in the from-clause; it can optionally be
|
||||
aliased. If the entity name is aliased, then any property references must
|
||||
be qualified using that alias; if the entity name is not aliased, then it is
|
||||
illegal for any property references to be qualified.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
No <link linkend="queryhql-joins-forms">joins</link> (either implicit or explicit)
|
||||
can be specified in a bulk HQL query. Sub-queries may be used in the where-clause;
|
||||
the subqueries, themselves, may contain joins.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The where-clause is also optional.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
As an example, to execute an HQL <literal>UPDATE</literal>, use the
|
||||
<literal>Query.executeUpdate()</literal> method (the method is named for
|
||||
those familiar with JDBC's <literal>PreparedStatement.executeUpdate()</literal>):
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
String hqlUpdate = "update Customer c set c.name = :newName where c.name = :oldName";
|
||||
// or String hqlUpdate = "update 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>
|
||||
HQL <literal>UPDATE</literal> statements, by default do not effect the
|
||||
<link linkend="mapping-declaration-version">version</link>
|
||||
or the <link linkend="mapping-declaration-timestamp">timestamp</link> property values
|
||||
for the affected entities; this is in keeping with the EJB3 specification. However,
|
||||
you can force Hibernate to properly reset the <literal>version</literal> or
|
||||
<literal>timestamp</literal> property values through the use of a <literal>versioned update</literal>.
|
||||
This is achieved by adding the <literal>VERSIONED</literal> keyword after the <literal>UPDATE</literal>
|
||||
keyword.
|
||||
</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>
|
||||
Note that custom version types (<literal>org.hibernate.usertype.UserVersionType</literal>)
|
||||
are not allowed in conjunction with a <literal>update versioned</literal> statement.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To execute an HQL <literal>DELETE</literal>, use the same <literal>Query.executeUpdate()</literal>
|
||||
method:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
String hqlDelete = "delete Customer c where c.name = :oldName";
|
||||
// or String hqlDelete = "delete Customer where name = :oldName";
|
||||
int deletedEntities = s.createQuery( hqlDelete )
|
||||
.setString( "oldName", oldName )
|
||||
.executeUpdate();
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>int</literal> value returned by the <literal>Query.executeUpdate()</literal>
|
||||
method indicate the number of entities effected by the operation. Consider this may or may not
|
||||
correlate to the number of rows effected in the database. An HQL bulk operation might result in
|
||||
multiple actual SQL statements being executed, for joined-subclass, for example. The returned
|
||||
number indicates the number of actual entities affected by the statement. Going back to the
|
||||
example of joined-subclass, a delete against one of the subclasses may actually result
|
||||
in deletes against not just the table to which that subclass is mapped, but also the "root"
|
||||
table and potentially joined-subclass tables further down the inheritence hierarchy.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The pseudo-syntax for <literal>INSERT</literal> statements is:
|
||||
<literal>INSERT INTO EntityName properties_list select_statement</literal>. Some
|
||||
points to note:
|
||||
</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form.
|
||||
</para>
|
||||
<para>
|
||||
The properties_list is analogous to the <literal>column speficiation</literal>
|
||||
in the SQL <literal>INSERT</literal> statement. For entities involved in mapped
|
||||
inheritence, only properties directly defined on that given class-level can be
|
||||
used in the properties_list. Superclass properties are not allowed; and subclass
|
||||
properties do not make sense. In other words, <literal>INSERT</literal>
|
||||
statements are inherently non-polymorphic.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
select_statement can be any valid HQL select query, with the caveat that the return types
|
||||
must match the types expected by the insert. Currently, this is checked during query
|
||||
compilation rather than allowing the check to relegate to the database. Note however
|
||||
that this might cause problems between Hibernate <literal>Type</literal>s which are
|
||||
<emphasis>equivalent</emphasis> as opposed to <emphasis>equal</emphasis>. This might cause
|
||||
issues with mismatches between a property defined as a <literal>org.hibernate.type.DateType</literal>
|
||||
and a property defined as a <literal>org.hibernate.type.TimestampType</literal>, even though the
|
||||
database might not make a distinction or might be able to handle the conversion.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
For the id property, the insert statement gives you two options. You can either
|
||||
explicitly specify the id property in the properties_list (in which case its value
|
||||
is taken from the corresponding select expression) or omit it from the properties_list
|
||||
(in which case a generated value is used). This later option is only available when
|
||||
using id generators that operate in the database; attempting to use this option with
|
||||
any "in memory" type generators will cause an exception during parsing. Note that
|
||||
for the purposes of this discussion, in-database generators are considered to be
|
||||
<literal>org.hibernate.id.SequenceGenerator</literal> (and its subclasses) and
|
||||
any implementors of <literal>org.hibernate.id.PostInsertIdentifierGenerator</literal>.
|
||||
The most notable exception here is <literal>org.hibernate.id.TableHiLoGenerator</literal>,
|
||||
which cannot be used because it does not expose a selectable way to get its values.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
For properties mapped as either <literal>version</literal> or <literal>timestamp</literal>,
|
||||
the insert statement gives you two options. You can either specify the property in the
|
||||
properties_list (in which case its value is taken from the corresponding select expressions)
|
||||
or omit it from the properties_list (in which case the <literal>seed value</literal> defined
|
||||
by the <literal>org.hibernate.type.VersionType</literal> is used).
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
An example HQL <literal>INSERT</literal> statement execution:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
String hqlInsert = "insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...";
|
||||
int createdEntities = s.createQuery( hqlInsert )
|
||||
.executeUpdate();
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
|
@ -0,0 +1,250 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="best-practices" revision="3">
|
||||
<title>Best Practices</title>
|
||||
|
||||
<variablelist spacing="compact">
|
||||
<varlistentry>
|
||||
<term>Write fine-grained classes and map them using <literal><component></literal>.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use an <literal>Address</literal> class to encapsulate <literal>street</literal>,
|
||||
<literal>suburb</literal>, <literal>state</literal>, <literal>postcode</literal>.
|
||||
This encourages code reuse and simplifies refactoring.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Declare identifier properties on persistent classes.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Hibernate makes identifier properties optional. There are all sorts of reasons why
|
||||
you should use them. We recommend that identifiers be 'synthetic' (generated, with
|
||||
no business meaning).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Identify natural keys.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Identify natural keys for all entities, and map them using
|
||||
<literal><natural-id></literal>. Implement <literal>equals()</literal> and
|
||||
<literal>hashCode()</literal> to compare the properties that make up the natural key.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Place each class mapping in its own file.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Don't use a single monolithic mapping document. Map <literal>com.eg.Foo</literal> in
|
||||
the file <literal>com/eg/Foo.hbm.xml</literal>. This makes particularly good sense in
|
||||
a team environment.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Load mappings as resources.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Deploy the mappings along with the classes they map.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Consider externalising query strings.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
This is a good practice if your queries call non-ANSI-standard SQL functions.
|
||||
Externalising the query strings to mapping files will make the application more
|
||||
portable.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Use bind variables.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
As in JDBC, always replace non-constant values by "?". Never use string manipulation to
|
||||
bind a non-constant value in a query! Even better, consider using named parameters in
|
||||
queries.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Don't manage your own JDBC connections.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Hibernate lets the application manage JDBC connections. This approach should be considered
|
||||
a last-resort. If you can't use the built-in connections providers, consider providing your
|
||||
own implementation of <literal>org.hibernate.connection.ConnectionProvider</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Consider using a custom type.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Suppose you have a Java type, say from some library, that needs to be persisted but doesn't
|
||||
provide the accessors needed to map it as a component. You should consider implementing
|
||||
<literal>org.hibernate.UserType</literal>. This approach frees the application
|
||||
code from implementing transformations to / from a Hibernate type.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Use hand-coded JDBC in bottlenecks.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
In performance-critical areas of the system, some kinds of operations might benefit from
|
||||
direct JDBC. But please, wait until you <emphasis>know</emphasis> something is a bottleneck.
|
||||
And don't assume that direct JDBC is necessarily faster. If you need to use direct JDBC, it might
|
||||
be worth opening a Hibernate <literal>Session</literal> and using that JDBC connection. That
|
||||
way you can still use the same transaction strategy and underlying connection provider.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Understand <literal>Session</literal> flushing.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
From time to time the Session synchronizes its persistent state with the database. Performance will
|
||||
be affected if this process occurs too often. You may sometimes minimize unnecessary flushing by
|
||||
disabling automatic flushing or even by changing the order of queries and other operations within a
|
||||
particular transaction.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>In a three tiered architecture, consider using detached objects.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
When using a servlet / session bean architecture, you could pass persistent objects loaded in
|
||||
the session bean to and from the servlet / JSP layer. Use a new session to service each request.
|
||||
Use <literal>Session.merge()</literal> or <literal>Session.saveOrUpdate()</literal> to
|
||||
synchronize objects with the database.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>In a two tiered architecture, consider using long persistence contexts.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Database Transactions have to be as short as possible for best scalability. However, it is often
|
||||
neccessary to implement long running <emphasis>application transactions</emphasis>, a single
|
||||
unit-of-work from the point of view of a user. An application transaction might span several
|
||||
client request/response cycles. It is common to use detached objects to implement application
|
||||
transactions. An alternative, extremely appropriate in two tiered architecture, is to maintain
|
||||
a single open persistence contact (session) for the whole life cycle of the application transaction
|
||||
and simply disconnect from the JDBC connection at the end of each request and reconnect at the
|
||||
beginning of the subsequent request. Never share a single session across more than one application
|
||||
transaction, or you will be working with stale data.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Don't treat exceptions as recoverable.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
This is more of a necessary practice than a "best" practice. When an exception occurs, roll back
|
||||
the <literal>Transaction</literal> and close the <literal>Session</literal>. If you don't, Hibernate
|
||||
can't guarantee that in-memory state accurately represents persistent state. As a special case of this,
|
||||
do not use <literal>Session.load()</literal> to determine if an instance with the given identifier
|
||||
exists on the database; use <literal>Session.get()</literal> or a query instead.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Prefer lazy fetching for associations.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use eager fetching sparingly. Use proxies and lazy collections for most associations to classes that
|
||||
are not likely to be completely held in the second-level cache. For associations to cached classes,
|
||||
where there is an a extremely high probability of a cache hit, explicitly disable eager fetching using
|
||||
<literal>lazy="false"</literal>. When an join fetching is appropriate to a particular use
|
||||
case, use a query with a <literal>left join fetch</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
Use the <emphasis>open session in view</emphasis> pattern, or a disciplined
|
||||
<emphasis>assembly phase</emphasis> to avoid problems with unfetched data.
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Hibernate frees the developer from writing tedious <emphasis>Data Transfer Objects</emphasis> (DTO).
|
||||
In a traditional EJB architecture, DTOs serve dual purposes: first, they work around the problem
|
||||
that entity beans are not serializable; second, they implicitly define an assembly phase where
|
||||
all data to be used by the view is fetched and marshalled into the DTOs before returning control
|
||||
to the presentation tier. Hibernate eliminates the first purpose. However, you will still need
|
||||
an assembly phase (think of your business methods as having a strict contract with the presentation
|
||||
tier about what data is available in the detached objects) unless you are prepared to hold the
|
||||
persistence context (the session) open across the view rendering process. This is not a limitation
|
||||
of Hibernate! It is a fundamental requirement of safe transactional data access.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Consider abstracting your business logic from Hibernate.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Hide (Hibernate) data-access code behind an interface. Combine the <emphasis>DAO</emphasis> and
|
||||
<emphasis>Thread Local Session</emphasis> patterns. You can even have some classes persisted by
|
||||
handcoded JDBC, associated to Hibernate via a <literal>UserType</literal>. (This advice is
|
||||
intended for "sufficiently large" applications; it is not appropriate for an application with
|
||||
five tables!)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Don't use exotic association mappings.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Good usecases for a real many-to-many associations are rare. Most of the time you need
|
||||
additional information stored in the "link table". In this case, it is much better to
|
||||
use two one-to-many associations to an intermediate link class. In fact, we think that
|
||||
most associations are one-to-many and many-to-one, you should be careful when using any
|
||||
other association style and ask yourself if it is really neccessary.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Prefer bidirectional associations.</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Unidirectional associations are more difficult to query. In a large application, almost
|
||||
all associations must be navigable in both directions in queries.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,429 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="components">
|
||||
<title>Component Mapping</title>
|
||||
|
||||
<para>
|
||||
The notion of a <emphasis>component</emphasis> is re-used in several different contexts,
|
||||
for different purposes, throughout Hibernate.
|
||||
</para>
|
||||
|
||||
<sect1 id="components-dependentobjects" revision="2" >
|
||||
<title>Dependent objects</title>
|
||||
|
||||
<para>
|
||||
A component is a contained object that is persisted as a value type, not an entity
|
||||
reference. The term "component" refers to the object-oriented notion of composition
|
||||
(not to architecture-level components). For example, you might model a person like this:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[public class Person {
|
||||
private java.util.Date birthday;
|
||||
private Name name;
|
||||
private String key;
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
private void setKey(String key) {
|
||||
this.key=key;
|
||||
}
|
||||
public java.util.Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
public void setBirthday(java.util.Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
public Name getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(Name name) {
|
||||
this.name = name;
|
||||
}
|
||||
......
|
||||
......
|
||||
}]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[public class Name {
|
||||
char initial;
|
||||
String first;
|
||||
String last;
|
||||
public String getFirst() {
|
||||
return first;
|
||||
}
|
||||
void setFirst(String first) {
|
||||
this.first = first;
|
||||
}
|
||||
public String getLast() {
|
||||
return last;
|
||||
}
|
||||
void setLast(String last) {
|
||||
this.last = last;
|
||||
}
|
||||
public char getInitial() {
|
||||
return initial;
|
||||
}
|
||||
void setInitial(char initial) {
|
||||
this.initial = initial;
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
Now <literal>Name</literal> may be persisted as a component of
|
||||
<literal>Person</literal>. Notice that <literal>Name</literal> defines getter
|
||||
and setter methods for its persistent properties, but doesn't need to declare
|
||||
any interfaces or identifier properties.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Our Hibernate mapping would look like:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="eg.Person" table="person">
|
||||
<id name="Key" column="pid" type="string">
|
||||
<generator class="uuid"/>
|
||||
</id>
|
||||
<property name="birthday" type="date"/>
|
||||
<component name="Name" class="eg.Name"> <!-- class attribute optional -->
|
||||
<property name="initial"/>
|
||||
<property name="first"/>
|
||||
<property name="last"/>
|
||||
</component>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The person table would have the columns <literal>pid</literal>,
|
||||
<literal>birthday</literal>,
|
||||
<literal>initial</literal>,
|
||||
<literal>first</literal> and
|
||||
<literal>last</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Like all value types, components do not support shared references. In other words, two
|
||||
persons could have the same name, but the two person objects would contain two independent
|
||||
name ojects, only "the same" by value. The null value semantics of a component are
|
||||
<emphasis>ad hoc</emphasis>. When reloading the containing object, Hibernate will assume
|
||||
that if all component columns are null, then the entire component is null. This should
|
||||
be okay for most purposes.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The properties of a component may be of any Hibernate type (collections, many-to-one
|
||||
associations, other components, etc). Nested components should <emphasis>not</emphasis>
|
||||
be considered an exotic usage. Hibernate is intended to support a very fine-grained
|
||||
object model.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <literal><component></literal> element allows a <literal><parent></literal>
|
||||
subelement that maps a property of the component class as a reference back to the
|
||||
containing entity.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="eg.Person" table="person">
|
||||
<id name="Key" column="pid" type="string">
|
||||
<generator class="uuid"/>
|
||||
</id>
|
||||
<property name="birthday" type="date"/>
|
||||
<component name="Name" class="eg.Name" unique="true">
|
||||
<parent name="namedPerson"/> <!-- reference back to the Person -->
|
||||
<property name="initial"/>
|
||||
<property name="first"/>
|
||||
<property name="last"/>
|
||||
</component>
|
||||
</class>]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="components-incollections" revision="1">
|
||||
<title>Collections of dependent objects</title>
|
||||
|
||||
<para>
|
||||
Collections of components are supported (eg. an array of type
|
||||
<literal>Name</literal>). Declare your component collection by
|
||||
replacing the <literal><element></literal> tag with a
|
||||
<literal><composite-element></literal> tag.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="someNames" table="some_names" lazy="true">
|
||||
<key column="id"/>
|
||||
<composite-element class="eg.Name"> <!-- class attribute required -->
|
||||
<property name="initial"/>
|
||||
<property name="first"/>
|
||||
<property name="last"/>
|
||||
</composite-element>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Note: if you define a <literal>Set</literal> of composite elements, it is
|
||||
very important to implement <literal>equals()</literal> and
|
||||
<literal>hashCode()</literal> correctly.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Composite elements may contain components but not collections. If your
|
||||
composite element itself contains
|
||||
components, use the <literal><nested-composite-element></literal>
|
||||
tag. This is a pretty exotic case - a collection of components which
|
||||
themselves have components. By this stage you should be asking yourself
|
||||
if a one-to-many association is more appropriate. Try remodelling the
|
||||
composite element as an entity - but note that even though the Java model
|
||||
is the same, the relational model and persistence semantics are still
|
||||
slightly different.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Please note that a composite element mapping doesn't support null-able properties
|
||||
if you're using a <literal><set></literal>. Hibernate
|
||||
has to use each columns value to identify a record when deleting objects
|
||||
(there is no separate primary key column in the composite element table),
|
||||
which is not possible with null values. You have to either use only
|
||||
not-null properties in a composite-element or choose a
|
||||
<literal><list></literal>, <literal><map></literal>,
|
||||
<literal><bag></literal> or <literal><idbag></literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A special case of a composite element is a composite element with a nested
|
||||
<literal><many-to-one></literal> element. A mapping like this allows
|
||||
you to map extra columns of a many-to-many association table to the
|
||||
composite element class. The following is a many-to-many association
|
||||
from <literal>Order</literal> to <literal>Item</literal> where
|
||||
<literal>purchaseDate</literal>, <literal>price</literal> and
|
||||
<literal>quantity</literal> are properties of the association:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="eg.Order" .... >
|
||||
....
|
||||
<set name="purchasedItems" table="purchase_items" lazy="true">
|
||||
<key column="order_id">
|
||||
<composite-element class="eg.Purchase">
|
||||
<property name="purchaseDate"/>
|
||||
<property name="price"/>
|
||||
<property name="quantity"/>
|
||||
<many-to-one name="item" class="eg.Item"/> <!-- class attribute is optional -->
|
||||
</composite-element>
|
||||
</set>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Of course, there can't be a reference to the purchae on the other side, for
|
||||
bidirectional association navigation. Remember that components are value types and
|
||||
don't allow shared references. A single <literal>Purchase</literal> can be in the
|
||||
set of an <literal>Order</literal>, but it can't be referenced by the <literal>Item</literal>
|
||||
at the same time.
|
||||
</para>
|
||||
|
||||
<para>Even ternary (or quaternary, etc) associations are possible:</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="eg.Order" .... >
|
||||
....
|
||||
<set name="purchasedItems" table="purchase_items" lazy="true">
|
||||
<key column="order_id">
|
||||
<composite-element class="eg.OrderLine">
|
||||
<many-to-one name="purchaseDetails class="eg.Purchase"/>
|
||||
<many-to-one name="item" class="eg.Item"/>
|
||||
</composite-element>
|
||||
</set>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Composite elements may appear in queries using the same syntax as
|
||||
associations to other entities.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="components-asmapindex">
|
||||
<title>Components as Map indices</title>
|
||||
|
||||
<para>
|
||||
The <literal><composite-map-key></literal> element lets you map a
|
||||
component class as the key of a <literal>Map</literal>. Make sure you override
|
||||
<literal>hashCode()</literal> and <literal>equals()</literal> correctly on
|
||||
the component class.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="components-compositeid" revision="1">
|
||||
<title>Components as composite identifiers</title>
|
||||
|
||||
<para>
|
||||
You may use a component as an identifier of an entity class. Your component
|
||||
class must satisfy certain requirements:
|
||||
</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
It must implement <literal>java.io.Serializable</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
It must re-implement <literal>equals()</literal> and
|
||||
<literal>hashCode()</literal>, consistently with the database's
|
||||
notion of composite key equality.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
<emphasis>Note: in Hibernate3, the second requirement is not an absolutely hard
|
||||
requirement of Hibernate. But do it anyway.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You can't use an <literal>IdentifierGenerator</literal> to generate composite keys.
|
||||
Instead the application must assign its own identifiers.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Use the <literal><composite-id></literal> tag (with nested
|
||||
<literal><key-property></literal> elements) in place of the usual
|
||||
<literal><id></literal> declaration. For example, the
|
||||
<literal>OrderLine</literal> class has a primary key that depends upon
|
||||
the (composite) primary key of <literal>Order</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="OrderLine">
|
||||
|
||||
<composite-id name="id" class="OrderLineId">
|
||||
<key-property name="lineId"/>
|
||||
<key-property name="orderId"/>
|
||||
<key-property name="customerId"/>
|
||||
</composite-id>
|
||||
|
||||
<property name="name"/>
|
||||
|
||||
<many-to-one name="order" class="Order"
|
||||
insert="false" update="false">
|
||||
<column name="orderId"/>
|
||||
<column name="customerId"/>
|
||||
</many-to-one>
|
||||
....
|
||||
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Now, any foreign keys referencing the <literal>OrderLine</literal> table are also
|
||||
composite. You must declare this in your mappings for other classes. An association
|
||||
to <literal>OrderLine</literal> would be mapped like this:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<many-to-one name="orderLine" class="OrderLine">
|
||||
<!-- the "class" attribute is optional, as usual -->
|
||||
<column name="lineId"/>
|
||||
<column name="orderId"/>
|
||||
<column name="customerId"/>
|
||||
</many-to-one>]]></programlisting>
|
||||
|
||||
<para>
|
||||
(Note that the <literal><column></literal> tag is an alternative to the
|
||||
<literal>column</literal> attribute everywhere.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A <literal>many-to-many</literal> association to <literal>OrderLine</literal> also
|
||||
uses the composite foreign key:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="undeliveredOrderLines">
|
||||
<key column name="warehouseId"/>
|
||||
<many-to-many class="OrderLine">
|
||||
<column name="lineId"/>
|
||||
<column name="orderId"/>
|
||||
<column name="customerId"/>
|
||||
</many-to-many>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The collection of <literal>OrderLine</literal>s in <literal>Order</literal> would
|
||||
use:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="orderLines" inverse="true">
|
||||
<key>
|
||||
<column name="orderId"/>
|
||||
<column name="customerId"/>
|
||||
</key>
|
||||
<one-to-many class="OrderLine"/>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
(The <literal><one-to-many></literal> element, as usual, declares no columns.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If <literal>OrderLine</literal> itself owns a collection, it also has a composite
|
||||
foreign key.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="OrderLine">
|
||||
....
|
||||
....
|
||||
<list name="deliveryAttempts">
|
||||
<key> <!-- a collection inherits the composite key type -->
|
||||
<column name="lineId"/>
|
||||
<column name="orderId"/>
|
||||
<column name="customerId"/>
|
||||
</key>
|
||||
<list-index column="attemptId" base="1"/>
|
||||
<composite-element class="DeliveryAttempt">
|
||||
...
|
||||
</composite-element>
|
||||
</set>
|
||||
</class>]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="components-dynamic" revision="1">
|
||||
<title>Dynamic components</title>
|
||||
|
||||
<para>
|
||||
You may even map a property of type <literal>Map</literal>:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<dynamic-component name="userAttributes">
|
||||
<property name="foo" column="FOO" type="string"/>
|
||||
<property name="bar" column="BAR" type="integer"/>
|
||||
<many-to-one name="baz" class="Baz" column="BAZ_ID"/>
|
||||
</dynamic-component>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The semantics of a <literal><dynamic-component></literal> mapping are identical
|
||||
to <literal><component></literal>. The advantage of this kind of mapping is
|
||||
the ability to determine the actual properties of the bean at deployment time, just
|
||||
by editing the mapping document. Runtime manipulation of the mapping document is
|
||||
also possible, using a DOM parser. Even better, you can access (and change) Hibernate's
|
||||
configuration-time metamodel via the <literal>Configuration</literal> object.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
|
@ -0,0 +1,292 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="events">
|
||||
<title>Interceptors and events</title>
|
||||
|
||||
<para>
|
||||
It is often useful for the application to react to certain events that occur
|
||||
inside Hibernate. This allows implementation of certain kinds of generic
|
||||
functionality, and extension of Hibernate functionality.
|
||||
</para>
|
||||
|
||||
<sect1 id="objectstate-interceptors" revision="3">
|
||||
<title>Interceptors</title>
|
||||
|
||||
<para>
|
||||
The <literal>Interceptor</literal> interface provides callbacks from the session to the
|
||||
application allowing the application to inspect and/or manipulate properties of a
|
||||
persistent object before it is saved, updated, deleted or loaded. One
|
||||
possible use for this is to track auditing information. For example, the following
|
||||
<literal>Interceptor</literal> automatically sets the <literal>createTimestamp</literal>
|
||||
when an <literal>Auditable</literal> is created and updates the
|
||||
<literal>lastUpdateTimestamp</literal> property when an <literal>Auditable</literal> is
|
||||
updated.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You may either implement <literal>Interceptor</literal> directly or (better) extend
|
||||
<literal>EmptyInterceptor</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package org.hibernate.test;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.EmptyInterceptor;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
public class AuditInterceptor extends EmptyInterceptor {
|
||||
|
||||
private int updates;
|
||||
private int creates;
|
||||
private int loads;
|
||||
|
||||
public void onDelete(Object entity,
|
||||
Serializable id,
|
||||
Object[] state,
|
||||
String[] propertyNames,
|
||||
Type[] types) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public boolean onFlushDirty(Object entity,
|
||||
Serializable id,
|
||||
Object[] currentState,
|
||||
Object[] previousState,
|
||||
String[] propertyNames,
|
||||
Type[] types) {
|
||||
|
||||
if ( entity instanceof Auditable ) {
|
||||
updates++;
|
||||
for ( int i=0; i < propertyNames.length; i++ ) {
|
||||
if ( "lastUpdateTimestamp".equals( propertyNames[i] ) ) {
|
||||
currentState[i] = new Date();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onLoad(Object entity,
|
||||
Serializable id,
|
||||
Object[] state,
|
||||
String[] propertyNames,
|
||||
Type[] types) {
|
||||
if ( entity instanceof Auditable ) {
|
||||
loads++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onSave(Object entity,
|
||||
Serializable id,
|
||||
Object[] state,
|
||||
String[] propertyNames,
|
||||
Type[] types) {
|
||||
|
||||
if ( entity instanceof Auditable ) {
|
||||
creates++;
|
||||
for ( int i=0; i<propertyNames.length; i++ ) {
|
||||
if ( "createTimestamp".equals( propertyNames[i] ) ) {
|
||||
state[i] = new Date();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void afterTransactionCompletion(Transaction tx) {
|
||||
if ( tx.wasCommitted() ) {
|
||||
System.out.println("Creations: " + creates + ", Updates: " + updates, "Loads: " + loads);
|
||||
}
|
||||
updates=0;
|
||||
creates=0;
|
||||
loads=0;
|
||||
}
|
||||
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
Interceptors come in two flavors: <literal>Session</literal>-scoped and
|
||||
<literal>SessionFactory</literal>-scoped.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A <literal>Session</literal>-scoped interceptor is specified
|
||||
when a session is opened using one of the overloaded SessionFactory.openSession()
|
||||
methods accepting an <literal>Interceptor</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]></programlisting>
|
||||
|
||||
<para>
|
||||
A <literal>SessionFactory</literal>-scoped interceptor is registered with the <literal>Configuration</literal>
|
||||
object prior to building the <literal>SessionFactory</literal>. In this case, the supplied interceptor
|
||||
will be applied to all sessions opened from that <literal>SessionFactory</literal>; this is true unless
|
||||
a session is opened explicitly specifying the interceptor to use. <literal>SessionFactory</literal>-scoped
|
||||
interceptors must be thread safe, taking care to not store session-specific state since multiple
|
||||
sessions will use this interceptor (potentially) concurrently.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="objectstate-events" revision="4">
|
||||
<title>Event system</title>
|
||||
|
||||
<para>
|
||||
If you have to react to particular events in your persistence layer, you may
|
||||
also use the Hibernate3 <emphasis>event</emphasis> architecture. The event
|
||||
system can be used in addition or as a replacement for interceptors.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Essentially all of the methods of the <literal>Session</literal> interface correlate
|
||||
to an event. You have a <literal>LoadEvent</literal>, a <literal>FlushEvent</literal>, etc
|
||||
(consult the XML configuration-file DTD or the <literal>org.hibernate.event</literal>
|
||||
package for the full list of defined event types). When a request is made of one of
|
||||
these methods, the Hibernate <literal>Session</literal> generates an appropriate
|
||||
event and passes it to the configured event listeners for that type. Out-of-the-box,
|
||||
these listeners implement the same processing in which those methods always resulted.
|
||||
However, you are free to implement a customization of one of the listener interfaces
|
||||
(i.e., the <literal>LoadEvent</literal> is processed by the registered implemenation
|
||||
of the <literal>LoadEventListener</literal> interface), in which case their
|
||||
implementation would be responsible for processing any <literal>load()</literal> requests
|
||||
made of the <literal>Session</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The listeners should be considered effectively singletons; meaning, they are shared between
|
||||
requests, and thus should not save any state as instance variables.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A custom listener should implement the appropriate interface for the event it wants to
|
||||
process and/or extend one of the convenience base classes (or even the default event
|
||||
listeners used by Hibernate out-of-the-box as these are declared non-final for this
|
||||
purpose). Custom listeners can either be registered programmatically through the
|
||||
<literal>Configuration</literal> object, or specified in the Hibernate configuration
|
||||
XML (declarative configuration through the properties file is not supported). Here's an
|
||||
example of a custom load event listener:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyLoadListener implements LoadEventListener {
|
||||
// this is the single method defined by the LoadEventListener interface
|
||||
public void onLoad(LoadEvent event, LoadEventListener.LoadType loadType)
|
||||
throws HibernateException {
|
||||
if ( !MySecurity.isAuthorized( event.getEntityClassName(), event.getEntityId() ) ) {
|
||||
throw MySecurityException("Unauthorized access");
|
||||
}
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
You also need a configuration entry telling Hibernate to use the listener in addition
|
||||
to the default listener:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<hibernate-configuration>
|
||||
<session-factory>
|
||||
...
|
||||
<event type="load">
|
||||
<listener class="com.eg.MyLoadListener"/>
|
||||
<listener class="org.hibernate.event.def.DefaultLoadEventListener"/>
|
||||
</event>
|
||||
</session-factory>
|
||||
</hibernate-configuration>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Instead, you may register it programmatically:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Configuration cfg = new Configuration();
|
||||
LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };
|
||||
cfg.EventListeners().setLoadEventListeners(stack);]]></programlisting>
|
||||
|
||||
<para>
|
||||
Listeners registered declaratively cannot share instances. If the same class name is
|
||||
used in multiple <literal><listener/></literal> elements, each reference will
|
||||
result in a separate instance of that class. If you need the capability to share
|
||||
listener instances between listener types you must use the programmatic registration
|
||||
approach.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Why implement an interface and define the specific type during configuration? Well, a
|
||||
listener implementation could implement multiple event listener interfaces. Having the
|
||||
type additionally defined during registration makes it easier to turn custom listeners on
|
||||
or off during configuration.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="objectstate-decl-security" revision="2">
|
||||
<title>Hibernate declarative security</title>
|
||||
<para>
|
||||
Usually, declarative security in Hibernate applications is managed in a session facade
|
||||
layer. Now, Hibernate3 allows certain actions to be permissioned via JACC, and authorized
|
||||
via JAAS. This is optional functionality built on top of the event architecture.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
First, you must configure the appropriate event listeners, to enable the use of JAAS
|
||||
authorization.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<listener type="pre-delete" class="org.hibernate.secure.JACCPreDeleteEventListener"/>
|
||||
<listener type="pre-update" class="org.hibernate.secure.JACCPreUpdateEventListener"/>
|
||||
<listener type="pre-insert" class="org.hibernate.secure.JACCPreInsertEventListener"/>
|
||||
<listener type="pre-load" class="org.hibernate.secure.JACCPreLoadEventListener"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Note that <literal><listener type="..." class="..."/></literal> is just a shorthand
|
||||
for <literal><event type="..."><listener class="..."/></event></literal>
|
||||
when there is exactly one listener for a particular event type.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<grant role="admin" entity-name="User" actions="insert,update,read"/>
|
||||
<grant role="su" entity-name="User" actions="*"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The role names are the roles understood by your JACC provider.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="example">
|
||||
|
||||
<title>Short example</title>
|
||||
|
||||
<para>
|
||||
For example, using the entities defined above, the following code will generate
|
||||
revision number 1, which will contain two new <literal>Person</literal> and
|
||||
two new <literal>Address</literal> entities:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[entityManager.getTransaction().begin();
|
||||
|
||||
Address address1 = new Address("Privet Drive", 4);
|
||||
Person person1 = new Person("Harry", "Potter", address1);
|
||||
|
||||
Address address2 = new Address("Grimmauld Place", 12);
|
||||
Person person2 = new Person("Hermione", "Granger", address2);
|
||||
|
||||
entityManager.persist(address1);
|
||||
entityManager.persist(address2);
|
||||
entityManager.persist(person1);
|
||||
entityManager.persist(person2);
|
||||
|
||||
entityManager.getTransaction().commit();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Now we change some entities. This will generate revision number 2, which will contain
|
||||
modifications of one person entity and two address entities (as the collection of
|
||||
persons living at <literal>address2</literal> and <literal>address1</literal> changes):
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[entityManager.getTransaction().begin();
|
||||
|
||||
Address address1 = entityManager.find(Address.class, address1.getId());
|
||||
Person person2 = entityManager.find(Person.class, person2.getId());
|
||||
|
||||
// Changing the address's house number
|
||||
address1.setHouseNumber(5)
|
||||
|
||||
// And moving Hermione to Harry
|
||||
person2.setAddress(address1);
|
||||
|
||||
entityManager.getTransaction().commit();]]></programlisting>
|
||||
|
||||
<para>
|
||||
We can retrieve the old versions (the audit) easily:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[AuditReader reader = AuditReaderFactory.get(entityManager);
|
||||
|
||||
Person person2_rev1 = reader.find(Person.class, person2.getId(), 1);
|
||||
assert person2_rev1.getAddress().equals(new Address("Grimmauld Place", 12));
|
||||
|
||||
Address address1_rev1 = reader.find(Address.class, address1.getId(), 1);
|
||||
assert address1_rev1.getPersons().getSize() == 1;
|
||||
|
||||
// and so on]]></programlisting>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,685 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="example-mappings">
|
||||
<title>Example: Various Mappings</title>
|
||||
|
||||
<para>
|
||||
This chapters shows off some more complex association mappings.
|
||||
</para>
|
||||
|
||||
<sect1 id="example-mappings-emp">
|
||||
<title>Employer/Employee</title>
|
||||
|
||||
<para>
|
||||
The following model of the relationship between <literal>Employer</literal> and
|
||||
<literal>Employee</literal> uses an actual entity class (<literal>Employment</literal>)
|
||||
to represent the association. This is done because there might be more than one
|
||||
period of employment for the same two parties. Components are used to model monetary
|
||||
values and employee names.
|
||||
</para>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="../images/EmployerEmployee.png" format="PNG" align="center" />
|
||||
</imageobject>
|
||||
<imageobject role="fo">
|
||||
<imagedata fileref="../images/EmployerEmployee.png" format="PNG" align="center" width="17cm" />
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
|
||||
<para>
|
||||
Heres a possible mapping document:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<hibernate-mapping>
|
||||
|
||||
<class name="Employer" table="employers">
|
||||
<id name="id">
|
||||
<generator class="sequence">
|
||||
<param name="sequence">employer_id_seq</param>
|
||||
</generator>
|
||||
</id>
|
||||
<property name="name"/>
|
||||
</class>
|
||||
|
||||
<class name="Employment" table="employment_periods">
|
||||
|
||||
<id name="id">
|
||||
<generator class="sequence">
|
||||
<param name="sequence">employment_id_seq</param>
|
||||
</generator>
|
||||
</id>
|
||||
<property name="startDate" column="start_date"/>
|
||||
<property name="endDate" column="end_date"/>
|
||||
|
||||
<component name="hourlyRate" class="MonetaryAmount">
|
||||
<property name="amount">
|
||||
<column name="hourly_rate" sql-type="NUMERIC(12, 2)"/>
|
||||
</property>
|
||||
<property name="currency" length="12"/>
|
||||
</component>
|
||||
|
||||
<many-to-one name="employer" column="employer_id" not-null="true"/>
|
||||
<many-to-one name="employee" column="employee_id" not-null="true"/>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Employee" table="employees">
|
||||
<id name="id">
|
||||
<generator class="sequence">
|
||||
<param name="sequence">employee_id_seq</param>
|
||||
</generator>
|
||||
</id>
|
||||
<property name="taxfileNumber"/>
|
||||
<component name="name" class="Name">
|
||||
<property name="firstName"/>
|
||||
<property name="initial"/>
|
||||
<property name="lastName"/>
|
||||
</component>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>]]></programlisting>
|
||||
|
||||
<para>
|
||||
And heres the table schema generated by <literal>SchemaExport</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[create table employers (
|
||||
id BIGINT not null,
|
||||
name VARCHAR(255),
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
create table employment_periods (
|
||||
id BIGINT not null,
|
||||
hourly_rate NUMERIC(12, 2),
|
||||
currency VARCHAR(12),
|
||||
employee_id BIGINT not null,
|
||||
employer_id BIGINT not null,
|
||||
end_date TIMESTAMP,
|
||||
start_date TIMESTAMP,
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
create table employees (
|
||||
id BIGINT not null,
|
||||
firstName VARCHAR(255),
|
||||
initial CHAR(1),
|
||||
lastName VARCHAR(255),
|
||||
taxfileNumber VARCHAR(255),
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
alter table employment_periods
|
||||
add constraint employment_periodsFK0 foreign key (employer_id) references employers
|
||||
alter table employment_periods
|
||||
add constraint employment_periodsFK1 foreign key (employee_id) references employees
|
||||
create sequence employee_id_seq
|
||||
create sequence employment_id_seq
|
||||
create sequence employer_id_seq]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-mappings-authorwork">
|
||||
<title>Author/Work</title>
|
||||
|
||||
<para>
|
||||
Consider the following model of the relationships between <literal>Work</literal>,
|
||||
<literal>Author</literal> and <literal>Person</literal>. We represent the relationship
|
||||
between <literal>Work</literal> and <literal>Author</literal> as a many-to-many
|
||||
association. We choose to represent the relationship between <literal>Author</literal>
|
||||
and <literal>Person</literal> as one-to-one association. Another possibility would be to
|
||||
have <literal>Author</literal> extend <literal>Person</literal>.
|
||||
</para>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="../images/AuthorWork.png" format="PNG" align="center" />
|
||||
</imageobject>
|
||||
<imageobject role="fo">
|
||||
<imagedata fileref="../images/AuthorWork.png" format="PNG" align="center" width="17cm" />
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
|
||||
<para>
|
||||
The following mapping document correctly represents these relationships:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<hibernate-mapping>
|
||||
|
||||
<class name="Work" table="works" discriminator-value="W">
|
||||
|
||||
<id name="id" column="id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<discriminator column="type" type="character"/>
|
||||
|
||||
<property name="title"/>
|
||||
<set name="authors" table="author_work">
|
||||
<key column name="work_id"/>
|
||||
<many-to-many class="Author" column name="author_id"/>
|
||||
</set>
|
||||
|
||||
<subclass name="Book" discriminator-value="B">
|
||||
<property name="text"/>
|
||||
</subclass>
|
||||
|
||||
<subclass name="Song" discriminator-value="S">
|
||||
<property name="tempo"/>
|
||||
<property name="genre"/>
|
||||
</subclass>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Author" table="authors">
|
||||
|
||||
<id name="id" column="id">
|
||||
<!-- The Author must have the same identifier as the Person -->
|
||||
<generator class="assigned"/>
|
||||
</id>
|
||||
|
||||
<property name="alias"/>
|
||||
<one-to-one name="person" constrained="true"/>
|
||||
|
||||
<set name="works" table="author_work" inverse="true">
|
||||
<key column="author_id"/>
|
||||
<many-to-many class="Work" column="work_id"/>
|
||||
</set>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Person" table="persons">
|
||||
<id name="id" column="id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="name"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>]]></programlisting>
|
||||
|
||||
<para>
|
||||
There are four tables in this mapping. <literal>works</literal>,
|
||||
<literal>authors</literal> and <literal>persons</literal> hold work, author
|
||||
and person data respectively. <literal>author_work</literal> is an association
|
||||
table linking authors to works. Heres the table schema, as generated by
|
||||
<literal>SchemaExport</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[create table works (
|
||||
id BIGINT not null generated by default as identity,
|
||||
tempo FLOAT,
|
||||
genre VARCHAR(255),
|
||||
text INTEGER,
|
||||
title VARCHAR(255),
|
||||
type CHAR(1) not null,
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
create table author_work (
|
||||
author_id BIGINT not null,
|
||||
work_id BIGINT not null,
|
||||
primary key (work_id, author_id)
|
||||
)
|
||||
|
||||
create table authors (
|
||||
id BIGINT not null generated by default as identity,
|
||||
alias VARCHAR(255),
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
create table persons (
|
||||
id BIGINT not null generated by default as identity,
|
||||
name VARCHAR(255),
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
alter table authors
|
||||
add constraint authorsFK0 foreign key (id) references persons
|
||||
alter table author_work
|
||||
add constraint author_workFK0 foreign key (author_id) references authors
|
||||
alter table author_work
|
||||
add constraint author_workFK1 foreign key (work_id) references works]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-mappings-customerorderproduct">
|
||||
<title>Customer/Order/Product</title>
|
||||
|
||||
<para>
|
||||
Now consider a model of the relationships between <literal>Customer</literal>,
|
||||
<literal>Order</literal> and <literal>LineItem</literal> and <literal>Product</literal>.
|
||||
There is a one-to-many association between <literal>Customer</literal> and
|
||||
<literal>Order</literal>, but how should we represent <literal>Order</literal> /
|
||||
<literal>LineItem</literal> / <literal>Product</literal>? I've chosen to map
|
||||
<literal>LineItem</literal> as an association class representing the many-to-many
|
||||
association between <literal>Order</literal> and <literal>Product</literal>. In
|
||||
Hibernate, this is called a composite element.
|
||||
</para>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="../images/CustomerOrderProduct.png" format="PNG" align="center" />
|
||||
</imageobject>
|
||||
<imageobject role="fo">
|
||||
<imagedata fileref="../images/CustomerOrderProduct.png" format="PNG" align="center" width="17cm" />
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
|
||||
<para>
|
||||
The mapping document:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<hibernate-mapping>
|
||||
|
||||
<class name="Customer" table="customers">
|
||||
<id name="id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="name"/>
|
||||
<set name="orders" inverse="true">
|
||||
<key column="customer_id"/>
|
||||
<one-to-many class="Order"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Order" table="orders">
|
||||
<id name="id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="date"/>
|
||||
<many-to-one name="customer" column="customer_id"/>
|
||||
<list name="lineItems" table="line_items">
|
||||
<key column="order_id"/>
|
||||
<list-index column="line_number"/>
|
||||
<composite-element class="LineItem">
|
||||
<property name="quantity"/>
|
||||
<many-to-one name="product" column="product_id"/>
|
||||
</composite-element>
|
||||
</list>
|
||||
</class>
|
||||
|
||||
<class name="Product" table="products">
|
||||
<id name="id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="serialNumber"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>]]></programlisting>
|
||||
|
||||
<para>
|
||||
<literal>customers</literal>, <literal>orders</literal>, <literal>line_items</literal> and
|
||||
<literal>products</literal> hold customer, order, order line item and product data
|
||||
respectively. <literal>line_items</literal> also acts as an association table linking
|
||||
orders with products.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[create table customers (
|
||||
id BIGINT not null generated by default as identity,
|
||||
name VARCHAR(255),
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
create table orders (
|
||||
id BIGINT not null generated by default as identity,
|
||||
customer_id BIGINT,
|
||||
date TIMESTAMP,
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
create table line_items (
|
||||
line_number INTEGER not null,
|
||||
order_id BIGINT not null,
|
||||
product_id BIGINT,
|
||||
quantity INTEGER,
|
||||
primary key (order_id, line_number)
|
||||
)
|
||||
|
||||
create table products (
|
||||
id BIGINT not null generated by default as identity,
|
||||
serialNumber VARCHAR(255),
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
alter table orders
|
||||
add constraint ordersFK0 foreign key (customer_id) references customers
|
||||
alter table line_items
|
||||
add constraint line_itemsFK0 foreign key (product_id) references products
|
||||
alter table line_items
|
||||
add constraint line_itemsFK1 foreign key (order_id) references orders]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="misc">
|
||||
<title>Miscellaneous example mappings</title>
|
||||
|
||||
<para>
|
||||
These examples are all taken from the Hibernate test suite. You
|
||||
will find many other useful example mappings there. Look in the
|
||||
<literal>test</literal> folder of the Hibernate distribution.
|
||||
</para>
|
||||
|
||||
<para>TODO: put words around this stuff</para>
|
||||
|
||||
<sect2 id="example-mappings-typed-onetone">
|
||||
<title>"Typed" one-to-one association</title>
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
<id name="name"/>
|
||||
<one-to-one name="address"
|
||||
cascade="all">
|
||||
<formula>name</formula>
|
||||
<formula>'HOME'</formula>
|
||||
</one-to-one>
|
||||
<one-to-one name="mailingAddress"
|
||||
cascade="all">
|
||||
<formula>name</formula>
|
||||
<formula>'MAILING'</formula>
|
||||
</one-to-one>
|
||||
</class>
|
||||
|
||||
<class name="Address" batch-size="2"
|
||||
check="addressType in ('MAILING', 'HOME', 'BUSINESS')">
|
||||
<composite-id>
|
||||
<key-many-to-one name="person"
|
||||
column="personName"/>
|
||||
<key-property name="type"
|
||||
column="addressType"/>
|
||||
</composite-id>
|
||||
<property name="street" type="text"/>
|
||||
<property name="state"/>
|
||||
<property name="zip"/>
|
||||
</class>]]></programlisting>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="example-mappings-composite-key">
|
||||
<title>Composite key example</title>
|
||||
<programlisting><![CDATA[<class name="Customer">
|
||||
|
||||
<id name="customerId"
|
||||
length="10">
|
||||
<generator class="assigned"/>
|
||||
</id>
|
||||
|
||||
<property name="name" not-null="true" length="100"/>
|
||||
<property name="address" not-null="true" length="200"/>
|
||||
|
||||
<list name="orders"
|
||||
inverse="true"
|
||||
cascade="save-update">
|
||||
<key column="customerId"/>
|
||||
<index column="orderNumber"/>
|
||||
<one-to-many class="Order"/>
|
||||
</list>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Order" table="CustomerOrder" lazy="true">
|
||||
<synchronize table="LineItem"/>
|
||||
<synchronize table="Product"/>
|
||||
|
||||
<composite-id name="id"
|
||||
class="Order$Id">
|
||||
<key-property name="customerId" length="10"/>
|
||||
<key-property name="orderNumber"/>
|
||||
</composite-id>
|
||||
|
||||
<property name="orderDate"
|
||||
type="calendar_date"
|
||||
not-null="true"/>
|
||||
|
||||
<property name="total">
|
||||
<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 )
|
||||
</formula>
|
||||
</property>
|
||||
|
||||
<many-to-one name="customer"
|
||||
column="customerId"
|
||||
insert="false"
|
||||
update="false"
|
||||
not-null="true"/>
|
||||
|
||||
<bag name="lineItems"
|
||||
fetch="join"
|
||||
inverse="true"
|
||||
cascade="save-update">
|
||||
<key>
|
||||
<column name="customerId"/>
|
||||
<column name="orderNumber"/>
|
||||
</key>
|
||||
<one-to-many class="LineItem"/>
|
||||
</bag>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="LineItem">
|
||||
|
||||
<composite-id name="id"
|
||||
class="LineItem$Id">
|
||||
<key-property name="customerId" length="10"/>
|
||||
<key-property name="orderNumber"/>
|
||||
<key-property name="productId" length="10"/>
|
||||
</composite-id>
|
||||
|
||||
<property name="quantity"/>
|
||||
|
||||
<many-to-one name="order"
|
||||
insert="false"
|
||||
update="false"
|
||||
not-null="true">
|
||||
<column name="customerId"/>
|
||||
<column name="orderNumber"/>
|
||||
</many-to-one>
|
||||
|
||||
<many-to-one name="product"
|
||||
insert="false"
|
||||
update="false"
|
||||
not-null="true"
|
||||
column="productId"/>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Product">
|
||||
<synchronize table="LineItem"/>
|
||||
|
||||
<id name="productId"
|
||||
length="10">
|
||||
<generator class="assigned"/>
|
||||
</id>
|
||||
|
||||
<property name="description"
|
||||
not-null="true"
|
||||
length="200"/>
|
||||
<property name="price" length="3"/>
|
||||
<property name="numberAvailable"/>
|
||||
|
||||
<property name="numberOrdered">
|
||||
<formula>
|
||||
( select sum(li.quantity)
|
||||
from LineItem li
|
||||
where li.productId = productId )
|
||||
</formula>
|
||||
</property>
|
||||
|
||||
</class>]]></programlisting>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="example-mappings-composite-key-manytomany">
|
||||
<title>Many-to-many with shared composite key attribute</title>
|
||||
<programlisting><![CDATA[<class name="User" table="`User`">
|
||||
<composite-id>
|
||||
<key-property name="name"/>
|
||||
<key-property name="org"/>
|
||||
</composite-id>
|
||||
<set name="groups" table="UserGroup">
|
||||
<key>
|
||||
<column name="userName"/>
|
||||
<column name="org"/>
|
||||
</key>
|
||||
<many-to-many class="Group">
|
||||
<column name="groupName"/>
|
||||
<formula>org</formula>
|
||||
</many-to-many>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Group" table="`Group`">
|
||||
<composite-id>
|
||||
<key-property name="name"/>
|
||||
<key-property name="org"/>
|
||||
</composite-id>
|
||||
<property name="description"/>
|
||||
<set name="users" table="UserGroup" inverse="true">
|
||||
<key>
|
||||
<column name="groupName"/>
|
||||
<column name="org"/>
|
||||
</key>
|
||||
<many-to-many class="User">
|
||||
<column name="userName"/>
|
||||
<formula>org</formula>
|
||||
</many-to-many>
|
||||
</set>
|
||||
</class>
|
||||
]]></programlisting>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="example-mappings-content-discrimination">
|
||||
<title>Content based discrimination</title>
|
||||
<programlisting><![CDATA[<class name="Person"
|
||||
discriminator-value="P">
|
||||
|
||||
<id name="id"
|
||||
column="person_id"
|
||||
unsaved-value="0">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
|
||||
|
||||
<discriminator
|
||||
type="character">
|
||||
<formula>
|
||||
case
|
||||
when title is not null then 'E'
|
||||
when salesperson is not null then 'C'
|
||||
else 'P'
|
||||
end
|
||||
</formula>
|
||||
</discriminator>
|
||||
|
||||
<property name="name"
|
||||
not-null="true"
|
||||
length="80"/>
|
||||
|
||||
<property name="sex"
|
||||
not-null="true"
|
||||
update="false"/>
|
||||
|
||||
<component name="address">
|
||||
<property name="address"/>
|
||||
<property name="zip"/>
|
||||
<property name="country"/>
|
||||
</component>
|
||||
|
||||
<subclass name="Employee"
|
||||
discriminator-value="E">
|
||||
<property name="title"
|
||||
length="20"/>
|
||||
<property name="salary"/>
|
||||
<many-to-one name="manager"/>
|
||||
</subclass>
|
||||
|
||||
<subclass name="Customer"
|
||||
discriminator-value="C">
|
||||
<property name="comments"/>
|
||||
<many-to-one name="salesperson"/>
|
||||
</subclass>
|
||||
|
||||
</class>]]></programlisting>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="example-mappings-association-alternatekeys" revision="2">
|
||||
<title>Associations on alternate keys</title>
|
||||
<programlisting><![CDATA[<class name="Person">
|
||||
|
||||
<id name="id">
|
||||
<generator class="hilo"/>
|
||||
</id>
|
||||
|
||||
<property name="name" length="100"/>
|
||||
|
||||
<one-to-one name="address"
|
||||
property-ref="person"
|
||||
cascade="all"
|
||||
fetch="join"/>
|
||||
|
||||
<set name="accounts"
|
||||
inverse="true">
|
||||
<key column="userId"
|
||||
property-ref="userId"/>
|
||||
<one-to-many class="Account"/>
|
||||
</set>
|
||||
|
||||
<property name="userId" length="8"/>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
|
||||
<id name="id">
|
||||
<generator class="hilo"/>
|
||||
</id>
|
||||
|
||||
<property name="address" length="300"/>
|
||||
<property name="zip" length="5"/>
|
||||
<property name="country" length="25"/>
|
||||
<many-to-one name="person" unique="true" not-null="true"/>
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Account">
|
||||
<id name="accountId" length="32">
|
||||
<generator class="uuid"/>
|
||||
</id>
|
||||
|
||||
<many-to-one name="user"
|
||||
column="userId"
|
||||
property-ref="userId"/>
|
||||
|
||||
<property name="type" not-null="true"/>
|
||||
|
||||
</class>]]></programlisting>
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,388 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="example-parentchild">
|
||||
<title>Example: Parent/Child</title>
|
||||
|
||||
<para>
|
||||
One of the very first things that new users try to do with Hibernate is to model a parent / child type
|
||||
relationship. There are two different approaches to this. For various reasons the most convenient
|
||||
approach, especially for new users, is to model both <literal>Parent</literal> and <literal>Child</literal>
|
||||
as entity classes with a <literal><one-to-many></literal> association from <literal>Parent</literal>
|
||||
to <literal>Child</literal>. (The alternative approach is to declare the <literal>Child</literal> as a
|
||||
<literal><composite-element></literal>.) Now, it turns out that default semantics of a one to many
|
||||
association (in Hibernate) are much less close to the usual semantics of a parent / child relationship than
|
||||
those of a composite element mapping. We will explain how to use a <emphasis>bidirectional one to many
|
||||
association with cascades</emphasis> to model a parent / child relationship efficiently and elegantly.
|
||||
It's not at all difficult!
|
||||
</para>
|
||||
|
||||
<sect1 id="example-parentchild-collections">
|
||||
<title>A note about collections</title>
|
||||
|
||||
<para>
|
||||
Hibernate collections are considered to be a logical part of their owning entity; never of the
|
||||
contained entities. This is a crucial distinction! It has the following consequences:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
When we remove / add an object from / to a collection, the version number of the collection owner
|
||||
is incremented.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
If an object that was removed from a collection is an instance of a value type (eg, a composite
|
||||
element), that object will cease to be persistent and its state will be completely removed from
|
||||
the database. Likewise, adding a value type instance to the collection will cause its state to be
|
||||
immediately persistent.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
On the other hand, if an entity is removed from a collection (a one-to-many or many-to-many
|
||||
association), it will not be deleted, by default. This behaviour is completely consistent - a
|
||||
change to the internal state of another entity should not cause the associated entity to vanish!
|
||||
Likewise, adding an entity to a collection does not cause that entity to become persistent, by
|
||||
default.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Instead, the default behaviour is that adding an entity to a collection merely creates a link between
|
||||
the two entities, while removing it removes the link. This is very appropriate for all sorts of cases.
|
||||
Where it is not appropriate at all is the case of a parent / child relationship, where the life of the
|
||||
child is bound to the life cycle of the parent.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-parentchild-bidir">
|
||||
<title>Bidirectional one-to-many</title>
|
||||
|
||||
<para>
|
||||
Suppose we start with a simple <literal><one-to-many></literal> association from
|
||||
<literal>Parent</literal> to <literal>Child</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="children">
|
||||
<key column="parent_id"/>
|
||||
<one-to-many class="Child"/>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
If we were to execute the following code
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Parent p = .....;
|
||||
Child c = new Child();
|
||||
p.getChildren().add(c);
|
||||
session.save(c);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Hibernate would issue two SQL statements:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>an <literal>INSERT</literal> to create the record for <literal>c</literal></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
an <literal>UPDATE</literal> to create the link from <literal>p</literal> to
|
||||
<literal>c</literal>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
This is not only inefficient, but also violates any <literal>NOT NULL</literal> constraint on the
|
||||
<literal>parent_id</literal> column. We can fix the nullability constraint violation by specifying
|
||||
<literal>not-null="true"</literal> in the collection mapping:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="children">
|
||||
<key column="parent_id" not-null="true"/>
|
||||
<one-to-many class="Child"/>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
However, this is not the recommended solution.
|
||||
</para>
|
||||
<para>
|
||||
The underlying cause of this behaviour is that the link (the foreign key <literal>parent_id</literal>)
|
||||
from <literal>p</literal> to <literal>c</literal> is not considered part of the state of the
|
||||
<literal>Child</literal> object and is therefore not created in the <literal>INSERT</literal>. So the
|
||||
solution is to make the link part of the <literal>Child</literal> mapping.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<many-to-one name="parent" column="parent_id" not-null="true"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
(We also need to add the <literal>parent</literal> property to the <literal>Child</literal> class.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Now that the <literal>Child</literal> entity is managing the state of the link, we tell the collection
|
||||
not to update the link. We use the <literal>inverse</literal> attribute.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="children" inverse="true">
|
||||
<key column="parent_id"/>
|
||||
<one-to-many class="Child"/>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The following code would be used to add a new <literal>Child</literal>
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
|
||||
Child c = new Child();
|
||||
c.setParent(p);
|
||||
p.getChildren().add(c);
|
||||
session.save(c);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
<para>
|
||||
And now, only one SQL <literal>INSERT</literal> would be issued!
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To tighten things up a bit, we could create an <literal>addChild()</literal> method of
|
||||
<literal>Parent</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[public void addChild(Child c) {
|
||||
c.setParent(this);
|
||||
children.add(c);
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
Now, the code to add a <literal>Child</literal> looks like
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
|
||||
Child c = new Child();
|
||||
p.addChild(c);
|
||||
session.save(c);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-parentchild-cascades">
|
||||
<title>Cascading life cycle</title>
|
||||
|
||||
<para>
|
||||
The explicit call to <literal>save()</literal> is still annoying. We will address this by
|
||||
using cascades.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="children" inverse="true" cascade="all">
|
||||
<key column="parent_id"/>
|
||||
<one-to-many class="Child"/>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
This simplifies the code above to
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
|
||||
Child c = new Child();
|
||||
p.addChild(c);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Similarly, we don't need to iterate over the children when saving or deleting a <literal>Parent</literal>.
|
||||
The following removes <literal>p</literal> and all its children from the database.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
|
||||
session.delete(p);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
<para>
|
||||
However, this code
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
|
||||
Child c = (Child) p.getChildren().iterator().next();
|
||||
p.getChildren().remove(c);
|
||||
c.setParent(null);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
<para>
|
||||
will not remove <literal>c</literal> from the database; it will ony remove the link to <literal>p</literal>
|
||||
(and cause a <literal>NOT NULL</literal> constraint violation, in this case). You need to explicitly
|
||||
<literal>delete()</literal> the <literal>Child</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
|
||||
Child c = (Child) p.getChildren().iterator().next();
|
||||
p.getChildren().remove(c);
|
||||
session.delete(c);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Now, in our case, a <literal>Child</literal> can't really exist without its parent. So if we remove
|
||||
a <literal>Child</literal> from the collection, we really do want it to be deleted. For this, we must
|
||||
use <literal>cascade="all-delete-orphan"</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set name="children" inverse="true" cascade="all-delete-orphan">
|
||||
<key column="parent_id"/>
|
||||
<one-to-many class="Child"/>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Note: even though the collection mapping specifies <literal>inverse="true"</literal>, cascades are
|
||||
still processed by iterating the collection elements. So if you require that an object be saved,
|
||||
deleted or updated by cascade, you must add it to the collection. It is not enough to simply call
|
||||
<literal>setParent()</literal>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-parentchild-update">
|
||||
<title>Cascades and <literal>unsaved-value</literal></title>
|
||||
|
||||
<para>
|
||||
Suppose we loaded up a <literal>Parent</literal> in one <literal>Session</literal>, made some changes
|
||||
in a UI action and wish to persist these changes in a new session by calling <literal>update()</literal>.
|
||||
The <literal>Parent</literal> will contain a collection of childen and, since cascading update is enabled,
|
||||
Hibernate needs to know which children are newly instantiated and which represent existing rows in the
|
||||
database. Lets assume that both <literal>Parent</literal> and <literal>Child</literal> have genenerated
|
||||
identifier properties of type <literal>Long</literal>. Hibernate will use the identifier and
|
||||
version/timestamp property value to determine which of the children are new. (See
|
||||
<xref linkend="objectstate-saveorupdate"/>.) <emphasis>In Hibernate3, it is no longer necessary to specify
|
||||
an <literal>unsaved-value</literal> explicitly.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The following code will update <literal>parent</literal> and <literal>child</literal> and insert
|
||||
<literal>newChild</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[//parent and child were both loaded in a previous session
|
||||
parent.addChild(child);
|
||||
Child newChild = new Child();
|
||||
parent.addChild(newChild);
|
||||
session.update(parent);
|
||||
session.flush();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Well, that's all very well for the case of a generated identifier, but what about assigned identifiers
|
||||
and composite identifiers? This is more difficult, since Hibernate can't use the identifier property to
|
||||
distinguish between a newly instantiated object (with an identifier assigned by the user) and an
|
||||
object loaded in a previous session. In this case, Hibernate will either use the timestamp or version
|
||||
property, or will actually query the second-level cache or, worst case, the database, to see if the
|
||||
row exists.
|
||||
</para>
|
||||
|
||||
<!-- undocumenting
|
||||
<para>
|
||||
There is one further possibility. The <literal>Interceptor</literal> method named
|
||||
<literal>isUnsaved()</literal> lets the application implement its own strategy for distinguishing
|
||||
newly instantiated objects. For example, you could define a base class for your persistent classes.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[public class Persistent {
|
||||
private boolean _saved = false;
|
||||
public void onSave() {
|
||||
_saved=true;
|
||||
}
|
||||
public void onLoad() {
|
||||
_saved=true;
|
||||
}
|
||||
......
|
||||
public boolean isSaved() {
|
||||
return _saved;
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
(The <literal>saved</literal> property is non-persistent.)
|
||||
Now implement <literal>isUnsaved()</literal>, along with <literal>onLoad()</literal>
|
||||
and <literal>onSave()</literal> as follows.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[public Boolean isUnsaved(Object entity) {
|
||||
if (entity instanceof Persistent) {
|
||||
return new Boolean( !( (Persistent) entity ).isSaved() );
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onLoad(Object entity,
|
||||
Serializable id,
|
||||
Object[] state,
|
||||
String[] propertyNames,
|
||||
Type[] types) {
|
||||
|
||||
if (entity instanceof Persistent) ( (Persistent) entity ).onLoad();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onSave(Object entity,
|
||||
Serializable id,
|
||||
Object[] state,
|
||||
String[] propertyNames,
|
||||
Type[] types) {
|
||||
|
||||
if (entity instanceof Persistent) ( (Persistent) entity ).onSave();
|
||||
return false;
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
Don't worry; in Hibernate3 you don't need to write any of this kind of code if you don't want to.
|
||||
</para>
|
||||
-->
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-parentchild-conclusion">
|
||||
<title>Conclusion</title>
|
||||
|
||||
<para>
|
||||
There is quite a bit to digest here and it might look confusing first time around. However, in practice,
|
||||
it all works out very nicely. Most Hibernate applications use the parent / child pattern in many places.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
We mentioned an alternative in the first paragraph. None of the above issues exist in the case of
|
||||
<literal><composite-element></literal> mappings, which have exactly the semantics of a parent / child
|
||||
relationship. Unfortunately, there are two big limitations to composite element classes: composite elements
|
||||
may not own collections, and they should not be the child of any entity other than the unique parent.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
|
@ -0,0 +1,457 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="example-weblog">
|
||||
<title>Example: Weblog Application</title>
|
||||
|
||||
<sect1 id="example-weblog-classes">
|
||||
<title>Persistent Classes</title>
|
||||
|
||||
<para>
|
||||
The persistent classes represent a weblog, and an item posted
|
||||
in a weblog. They are to be modelled as a standard parent/child
|
||||
relationship, but we will use an ordered bag, instead of a set.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package eg;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Blog {
|
||||
private Long _id;
|
||||
private String _name;
|
||||
private List _items;
|
||||
|
||||
public Long getId() {
|
||||
return _id;
|
||||
}
|
||||
public List getItems() {
|
||||
return _items;
|
||||
}
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
public void setId(Long long1) {
|
||||
_id = long1;
|
||||
}
|
||||
public void setItems(List list) {
|
||||
_items = list;
|
||||
}
|
||||
public void setName(String string) {
|
||||
_name = string;
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[package eg;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class BlogItem {
|
||||
private Long _id;
|
||||
private Calendar _datetime;
|
||||
private String _text;
|
||||
private String _title;
|
||||
private Blog _blog;
|
||||
|
||||
public Blog getBlog() {
|
||||
return _blog;
|
||||
}
|
||||
public Calendar getDatetime() {
|
||||
return _datetime;
|
||||
}
|
||||
public Long getId() {
|
||||
return _id;
|
||||
}
|
||||
public String getText() {
|
||||
return _text;
|
||||
}
|
||||
public String getTitle() {
|
||||
return _title;
|
||||
}
|
||||
public void setBlog(Blog blog) {
|
||||
_blog = blog;
|
||||
}
|
||||
public void setDatetime(Calendar calendar) {
|
||||
_datetime = calendar;
|
||||
}
|
||||
public void setId(Long long1) {
|
||||
_id = long1;
|
||||
}
|
||||
public void setText(String string) {
|
||||
_text = string;
|
||||
}
|
||||
public void setTitle(String string) {
|
||||
_title = string;
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-weblog-mappings">
|
||||
<title>Hibernate Mappings</title>
|
||||
|
||||
<para>
|
||||
The XML mappings should now be quite straightforward.
|
||||
</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">
|
||||
|
||||
<hibernate-mapping package="eg">
|
||||
|
||||
<class
|
||||
name="Blog"
|
||||
table="BLOGS">
|
||||
|
||||
<id
|
||||
name="id"
|
||||
column="BLOG_ID">
|
||||
|
||||
<generator class="native"/>
|
||||
|
||||
</id>
|
||||
|
||||
<property
|
||||
name="name"
|
||||
column="NAME"
|
||||
not-null="true"
|
||||
unique="true"/>
|
||||
|
||||
<bag
|
||||
name="items"
|
||||
inverse="true"
|
||||
order-by="DATE_TIME"
|
||||
cascade="all">
|
||||
|
||||
<key column="BLOG_ID"/>
|
||||
<one-to-many class="BlogItem"/>
|
||||
|
||||
</bag>
|
||||
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>]]></programlisting>
|
||||
|
||||
<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">
|
||||
|
||||
<hibernate-mapping package="eg">
|
||||
|
||||
<class
|
||||
name="BlogItem"
|
||||
table="BLOG_ITEMS"
|
||||
dynamic-update="true">
|
||||
|
||||
<id
|
||||
name="id"
|
||||
column="BLOG_ITEM_ID">
|
||||
|
||||
<generator class="native"/>
|
||||
|
||||
</id>
|
||||
|
||||
<property
|
||||
name="title"
|
||||
column="TITLE"
|
||||
not-null="true"/>
|
||||
|
||||
<property
|
||||
name="text"
|
||||
column="TEXT"
|
||||
not-null="true"/>
|
||||
|
||||
<property
|
||||
name="datetime"
|
||||
column="DATE_TIME"
|
||||
not-null="true"/>
|
||||
|
||||
<many-to-one
|
||||
name="blog"
|
||||
column="BLOG_ID"
|
||||
not-null="true"/>
|
||||
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="example-weblog-code">
|
||||
<title>Hibernate Code</title>
|
||||
|
||||
<para>
|
||||
The following class demonstrates some of the kinds of things
|
||||
we can do with these classes, using Hibernate.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package eg;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
|
||||
public class BlogMain {
|
||||
|
||||
private SessionFactory _sessions;
|
||||
|
||||
public void configure() throws HibernateException {
|
||||
_sessions = new Configuration()
|
||||
.addClass(Blog.class)
|
||||
.addClass(BlogItem.class)
|
||||
.buildSessionFactory();
|
||||
}
|
||||
|
||||
public void exportTables() throws HibernateException {
|
||||
Configuration cfg = new Configuration()
|
||||
.addClass(Blog.class)
|
||||
.addClass(BlogItem.class);
|
||||
new SchemaExport(cfg).create(true, true);
|
||||
}
|
||||
|
||||
public Blog createBlog(String name) throws HibernateException {
|
||||
|
||||
Blog blog = new Blog();
|
||||
blog.setName(name);
|
||||
blog.setItems( new ArrayList() );
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
session.persist(blog);
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
return blog;
|
||||
}
|
||||
|
||||
public BlogItem createBlogItem(Blog blog, String title, String text)
|
||||
throws HibernateException {
|
||||
|
||||
BlogItem item = new BlogItem();
|
||||
item.setTitle(title);
|
||||
item.setText(text);
|
||||
item.setBlog(blog);
|
||||
item.setDatetime( Calendar.getInstance() );
|
||||
blog.getItems().add(item);
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
session.update(blog);
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public BlogItem createBlogItem(Long blogid, String title, String text)
|
||||
throws HibernateException {
|
||||
|
||||
BlogItem item = new BlogItem();
|
||||
item.setTitle(title);
|
||||
item.setText(text);
|
||||
item.setDatetime( Calendar.getInstance() );
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
Blog blog = (Blog) session.load(Blog.class, blogid);
|
||||
item.setBlog(blog);
|
||||
blog.getItems().add(item);
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public void updateBlogItem(BlogItem item, String text)
|
||||
throws HibernateException {
|
||||
|
||||
item.setText(text);
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
session.update(item);
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBlogItem(Long itemid, String text)
|
||||
throws HibernateException {
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
BlogItem item = (BlogItem) session.load(BlogItem.class, itemid);
|
||||
item.setText(text);
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
public List listAllBlogNamesAndItemCounts(int max)
|
||||
throws HibernateException {
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
List result = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery(
|
||||
"select blog.id, blog.name, count(blogItem) " +
|
||||
"from Blog as blog " +
|
||||
"left outer join blog.items as blogItem " +
|
||||
"group by blog.name, blog.id " +
|
||||
"order by max(blogItem.datetime)"
|
||||
);
|
||||
q.setMaxResults(max);
|
||||
result = q.list();
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Blog getBlogAndAllItems(Long blogid)
|
||||
throws HibernateException {
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
Blog blog = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery(
|
||||
"from Blog as blog " +
|
||||
"left outer join fetch blog.items " +
|
||||
"where blog.id = :blogid"
|
||||
);
|
||||
q.setParameter("blogid", blogid);
|
||||
blog = (Blog) q.uniqueResult();
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
return blog;
|
||||
}
|
||||
|
||||
public List listBlogsAndRecentItems() throws HibernateException {
|
||||
|
||||
Session session = _sessions.openSession();
|
||||
Transaction tx = null;
|
||||
List result = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery(
|
||||
"from Blog as blog " +
|
||||
"inner join blog.items as blogItem " +
|
||||
"where blogItem.datetime > :minDate"
|
||||
);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.roll(Calendar.MONTH, false);
|
||||
q.setCalendar("minDate", cal);
|
||||
|
||||
result = q.list();
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
if (tx!=null) tx.rollback();
|
||||
throw he;
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="exceptions">
|
||||
<title>Mapping exceptions</title>
|
||||
|
||||
<sect1 id="exceptions-wontbesupported">
|
||||
|
||||
<title>What isn't and will not be supported</title>
|
||||
|
||||
<para>
|
||||
Bags (the corresponding Java type is List), as they can contain non-unique elements.
|
||||
The reason is that persisting, for example a bag of String-s, violates a principle
|
||||
of relational databases: that each table is a set of tuples. In case of bags,
|
||||
however (which require a join table), if there is a duplicate element, the two
|
||||
tuples corresponding to the elements will be the same. Hibernate allows this,
|
||||
however Envers (or more precisely: the database connector) will throw an exception
|
||||
when trying to persist two identical elements, because of a unique constraint violation.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
There are at least two ways out if you need bag semantics:
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
use an indexed collection, with the <literal>@IndexColumn</literal> annotation, or
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
provide a unique id for your elements with the <literal>@CollectionId</literal> annotation.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="exceptions-willbesupported" revision="2">
|
||||
|
||||
<title>What isn't and <emphasis>will</emphasis> be supported</title>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
collections of components
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
relations in components
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
joined and table-per-class inheritance
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="exceptions-onetomanyjoincolumn" revision="3">
|
||||
|
||||
<title><literal>@OneToMany</literal>+<literal>@JoinColumn</literal></title>
|
||||
|
||||
<para>
|
||||
When a collection is mapped using these two annotations, Hibernate doesn't
|
||||
generate a join table. Envers, however, has to do this, so that when you read the
|
||||
revisions in which the related entity has changed, you don't get false results.
|
||||
</para>
|
||||
<para>
|
||||
To be able to name the additional join table, there is a special annotation:
|
||||
<literal>@AuditJoinTable</literal>, which has similar semantics to JPA's
|
||||
<literal>@JoinTable</literal>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="filters">
|
||||
<title>Filtering data</title>
|
||||
|
||||
<para>
|
||||
Hibernate3 provides an innovative new approach to handling data with "visibility" rules.
|
||||
A <emphasis>Hibernate filter</emphasis> is a global, named, parameterized filter that may be
|
||||
enabled or disabled for a particular Hibernate session.
|
||||
</para>
|
||||
|
||||
<sect1 id="objectstate-filters" revision="1">
|
||||
<title>Hibernate filters</title>
|
||||
|
||||
<para>
|
||||
Hibernate3 adds the ability to pre-define filter criteria and attach those filters at both
|
||||
a class and a collection level. A filter criteria is the ability to define a restriction clause
|
||||
very similiar to the existing "where" attribute available on the class and various collection
|
||||
elements. Except these filter conditions can be parameterized. The application can then make
|
||||
the decision at runtime whether given filters should be enabled and what their parameter
|
||||
values should be. Filters can be used like database views, but parameterized inside the
|
||||
application.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In order to use filters, they must first be defined and then attached to the appropriate
|
||||
mapping elements. To define a filter, use the <literal><filter-def/></literal> element
|
||||
within a <literal><hibernate-mapping/></literal> element:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<filter-def name="myFilter">
|
||||
<filter-param name="myFilterParam" type="string"/>
|
||||
</filter-def>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Then, this filter can be attached to a class:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="myClass" ...>
|
||||
...
|
||||
<filter name="myFilter" condition=":myFilterParam = MY_FILTERED_COLUMN"/>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
or, to a collection:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<set ...>
|
||||
<filter name="myFilter" condition=":myFilterParam = MY_FILTERED_COLUMN"/>
|
||||
</set>]]></programlisting>
|
||||
|
||||
<para>
|
||||
or, even to both (or multiples of each) at the same time.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The methods on <literal>Session</literal> are: <literal>enableFilter(String filterName)</literal>,
|
||||
<literal>getEnabledFilter(String filterName)</literal>, and <literal>disableFilter(String filterName)</literal>.
|
||||
By default, filters are <emphasis>not</emphasis> enabled for a given session; they must be explcitly
|
||||
enabled through use of the <literal>Session.enableFilter()</literal> method, which returns an
|
||||
instance of the <literal>Filter</literal> interface. Using the simple filter defined above, this
|
||||
would look like:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[session.enableFilter("myFilter").setParameter("myFilterParam", "some-value");]]></programlisting>
|
||||
|
||||
<para>
|
||||
Note that methods on the org.hibernate.Filter interface do allow the method-chaining common to much of Hibernate.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A full example, using temporal data with an effective record date pattern:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<filter-def name="effectiveDate">
|
||||
<filter-param name="asOfDate" type="date"/>
|
||||
</filter-def>
|
||||
|
||||
<class name="Employee" ...>
|
||||
...
|
||||
<many-to-one name="department" column="dept_id" class="Department"/>
|
||||
<property name="effectiveStartDate" type="date" column="eff_start_dt"/>
|
||||
<property name="effectiveEndDate" type="date" column="eff_end_dt"/>
|
||||
...
|
||||
<!--
|
||||
Note that this assumes non-terminal records have an eff_end_dt set to
|
||||
a max db date for simplicity-sake
|
||||
-->
|
||||
<filter name="effectiveDate"
|
||||
condition=":asOfDate BETWEEN eff_start_dt and eff_end_dt"/>
|
||||
</class>
|
||||
|
||||
<class name="Department" ...>
|
||||
...
|
||||
<set name="employees" lazy="true">
|
||||
<key column="dept_id"/>
|
||||
<one-to-many class="Employee"/>
|
||||
<filter name="effectiveDate"
|
||||
condition=":asOfDate BETWEEN eff_start_dt and eff_end_dt"/>
|
||||
</set>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Then, in order to ensure that you always get back currently effective records, simply
|
||||
enable the filter on the session prior to retrieving employee data:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session session = ...;
|
||||
session.enableFilter("effectiveDate").setParameter("asOfDate", new Date());
|
||||
List results = session.createQuery("from Employee as e where e.salary > :targetSalary")
|
||||
.setLong("targetSalary", new Long(1000000))
|
||||
.list();
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
In the HQL above, even though we only explicitly mentioned a salary constraint on the results,
|
||||
because of the enabled filter the query will return only currently active employees who have
|
||||
a salary greater than a million dollars.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note: if you plan on using filters with outer joining (either through HQL or load fetching) be
|
||||
careful of the direction of the condition expression. Its safest to set this up for left
|
||||
outer joining; in general, place the parameter first followed by the column name(s) after
|
||||
the operator.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
After being defined a filter might be attached to multiple entities and/or
|
||||
collections each with its own condition. That can be tedious when the
|
||||
conditions are the same each time. Thus <literal><filter-def/></literal>
|
||||
allows defining a default condition, either as an attribute or CDATA:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<filter-def name="myFilter" condition="abc > xyz">...</filter-def>
|
||||
<filter-def name="myOtherFilter">abc=xyz</filter-def>]]></programlisting>
|
||||
|
||||
<para>
|
||||
This default condition will then be used whenever the filter is attached to something
|
||||
without specifying a condition. Note that this means you can give a specific condition
|
||||
as part of the attachment of the filter which overrides the default condition in that
|
||||
particular case.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,518 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="inheritance">
|
||||
<title>Inheritance Mapping</title>
|
||||
|
||||
<sect1 id="inheritance-strategies" revision="3">
|
||||
<title>The Three Strategies</title>
|
||||
|
||||
<para>
|
||||
Hibernate supports the three basic inheritance mapping strategies:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
table per class hierarchy
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
table per subclass
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
table per concrete class
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
In addition, Hibernate supports a fourth, slightly different kind of
|
||||
polymorphism:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
implicit polymorphism
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
It is possible to use different mapping strategies for different
|
||||
branches of the same inheritance hierarchy, and then make use of implicit
|
||||
polymorphism to achieve polymorphism across the whole hierarchy. However,
|
||||
Hibernate does not support mixing <literal><subclass></literal>,
|
||||
and <literal><joined-subclass></literal> and
|
||||
<literal><union-subclass></literal> mappings under the same root
|
||||
<literal><class></literal> element. It is possible to mix together
|
||||
the table per hierarchy and table per subclass strategies, under the
|
||||
the same <literal><class></literal> element, by combining the
|
||||
<literal><subclass></literal> and <literal><join></literal>
|
||||
elements (see below).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
It is possible to define <literal>subclass</literal>, <literal>union-subclass</literal>,
|
||||
and <literal>joined-subclass</literal> mappings in separate mapping documents, directly beneath
|
||||
<literal>hibernate-mapping</literal>. This allows you to extend a class hierachy just by adding
|
||||
a new mapping file. You must specify an <literal>extends</literal> attribute in the subclass mapping,
|
||||
naming a previously mapped superclass. Note: Previously this feature made the ordering of the mapping
|
||||
documents important. Since Hibernate3, the ordering of mapping files does not matter when using the
|
||||
extends keyword. The ordering inside a single mapping file still needs to be defined as superclasses
|
||||
before subclasses.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
<hibernate-mapping>
|
||||
<subclass name="DomesticCat" extends="Cat" discriminator-value="D">
|
||||
<property name="name" type="string"/>
|
||||
</subclass>
|
||||
</hibernate-mapping>]]></programlisting>
|
||||
|
||||
|
||||
<sect2 id="inheritance-tableperclass" >
|
||||
<title>Table per class hierarchy</title>
|
||||
|
||||
<para>
|
||||
Suppose we have an interface <literal>Payment</literal>, with implementors
|
||||
<literal>CreditCardPayment</literal>, <literal>CashPayment</literal>,
|
||||
<literal>ChequePayment</literal>. The table per hierarchy mapping would
|
||||
look like:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Payment" table="PAYMENT">
|
||||
<id name="id" type="long" column="PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<discriminator column="PAYMENT_TYPE" type="string"/>
|
||||
<property name="amount" column="AMOUNT"/>
|
||||
...
|
||||
<subclass name="CreditCardPayment" discriminator-value="CREDIT">
|
||||
<property name="creditCardType" column="CCTYPE"/>
|
||||
...
|
||||
</subclass>
|
||||
<subclass name="CashPayment" discriminator-value="CASH">
|
||||
...
|
||||
</subclass>
|
||||
<subclass name="ChequePayment" discriminator-value="CHEQUE">
|
||||
...
|
||||
</subclass>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Exactly one table is required. There is one big limitation of this mapping
|
||||
strategy: columns declared by the subclasses, such as <literal>CCTYPE</literal>,
|
||||
may not have <literal>NOT NULL</literal> constraints.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="inheritance-tablepersubclass">
|
||||
<title>Table per subclass</title>
|
||||
|
||||
<para>
|
||||
A table per subclass mapping would look like:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Payment" table="PAYMENT">
|
||||
<id name="id" type="long" column="PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="amount" column="AMOUNT"/>
|
||||
...
|
||||
<joined-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
|
||||
<key column="PAYMENT_ID"/>
|
||||
<property name="creditCardType" column="CCTYPE"/>
|
||||
...
|
||||
</joined-subclass>
|
||||
<joined-subclass name="CashPayment" table="CASH_PAYMENT">
|
||||
<key column="PAYMENT_ID"/>
|
||||
...
|
||||
</joined-subclass>
|
||||
<joined-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
|
||||
<key column="PAYMENT_ID"/>
|
||||
...
|
||||
</joined-subclass>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Four tables are required. The three subclass tables have primary
|
||||
key associations to the superclass table (so the relational model
|
||||
is actually a one-to-one association).
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="inheritance-tablepersubclass-discriminator" revision="2">
|
||||
<title>Table per subclass, using a discriminator</title>
|
||||
|
||||
<para>
|
||||
Note that Hibernate's implementation of table per subclass requires
|
||||
no discriminator column. Other object/relational mappers use a
|
||||
different implementation of table per subclass which requires a type
|
||||
discriminator column in the superclass table. The approach taken by
|
||||
Hibernate is much more difficult to implement but arguably more
|
||||
correct from a relational point of view. If you would like to use
|
||||
a discriminator column with the table per subclass strategy, you
|
||||
may combine the use of <literal><subclass></literal> and
|
||||
<literal><join></literal>, as follow:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Payment" table="PAYMENT">
|
||||
<id name="id" type="long" column="PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<discriminator column="PAYMENT_TYPE" type="string"/>
|
||||
<property name="amount" column="AMOUNT"/>
|
||||
...
|
||||
<subclass name="CreditCardPayment" discriminator-value="CREDIT">
|
||||
<join table="CREDIT_PAYMENT">
|
||||
<key column="PAYMENT_ID"/>
|
||||
<property name="creditCardType" column="CCTYPE"/>
|
||||
...
|
||||
</join>
|
||||
</subclass>
|
||||
<subclass name="CashPayment" discriminator-value="CASH">
|
||||
<join table="CASH_PAYMENT">
|
||||
<key column="PAYMENT_ID"/>
|
||||
...
|
||||
</join>
|
||||
</subclass>
|
||||
<subclass name="ChequePayment" discriminator-value="CHEQUE">
|
||||
<join table="CHEQUE_PAYMENT" fetch="select">
|
||||
<key column="PAYMENT_ID"/>
|
||||
...
|
||||
</join>
|
||||
</subclass>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The optional <literal>fetch="select"</literal> declaration tells Hibernate
|
||||
not to fetch the <literal>ChequePayment</literal> subclass data using an
|
||||
outer join when querying the superclass.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="inheritance-mixing-tableperclass-tablepersubclass">
|
||||
<title>Mixing table per class hierarchy with table per subclass</title>
|
||||
|
||||
<para>
|
||||
You may even mix the table per hierarchy and table per subclass strategies
|
||||
using this approach:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Payment" table="PAYMENT">
|
||||
<id name="id" type="long" column="PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<discriminator column="PAYMENT_TYPE" type="string"/>
|
||||
<property name="amount" column="AMOUNT"/>
|
||||
...
|
||||
<subclass name="CreditCardPayment" discriminator-value="CREDIT">
|
||||
<join table="CREDIT_PAYMENT">
|
||||
<property name="creditCardType" column="CCTYPE"/>
|
||||
...
|
||||
</join>
|
||||
</subclass>
|
||||
<subclass name="CashPayment" discriminator-value="CASH">
|
||||
...
|
||||
</subclass>
|
||||
<subclass name="ChequePayment" discriminator-value="CHEQUE">
|
||||
...
|
||||
</subclass>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
For any of these mapping strategies, a polymorphic association to the root
|
||||
<literal>Payment</literal> class is mapped using
|
||||
<literal><many-to-one></literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<many-to-one name="payment" column="PAYMENT_ID" class="Payment"/>]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="inheritance-tableperconcrete" revision="2">
|
||||
<title>Table per concrete class</title>
|
||||
|
||||
<para>
|
||||
There are two ways we could go about mapping the table per concrete class
|
||||
strategy. The first is to use <literal><union-subclass></literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Payment">
|
||||
<id name="id" type="long" column="PAYMENT_ID">
|
||||
<generator class="sequence"/>
|
||||
</id>
|
||||
<property name="amount" column="AMOUNT"/>
|
||||
...
|
||||
<union-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
|
||||
<property name="creditCardType" column="CCTYPE"/>
|
||||
...
|
||||
</union-subclass>
|
||||
<union-subclass name="CashPayment" table="CASH_PAYMENT">
|
||||
...
|
||||
</union-subclass>
|
||||
<union-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
|
||||
...
|
||||
</union-subclass>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Three tables are involved for the subclasses. Each table defines columns for
|
||||
all properties of the class, including inherited properties.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The limitation of this approach is that if a property is mapped on the
|
||||
superclass, the column name must be the same on all subclass tables.
|
||||
(We might relax this in a future release of Hibernate.) The identity
|
||||
generator strategy is not allowed in union subclass inheritance, indeed
|
||||
the primary key seed has to be shared accross all unioned subclasses
|
||||
of a hierarchy.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If your superclass is abstract, map it with <literal>abstract="true"</literal>.
|
||||
Of course, if it is not abstract, an additional table (defaults to
|
||||
<literal>PAYMENT</literal> in the example above) is needed to hold instances
|
||||
of the superclass.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="inheritance-tableperconcreate-polymorphism">
|
||||
<title>Table per concrete class, using implicit polymorphism</title>
|
||||
|
||||
<para>
|
||||
An alternative approach is to make use of implicit polymorphism:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="CreditCardPayment" table="CREDIT_PAYMENT">
|
||||
<id name="id" type="long" column="CREDIT_PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="amount" column="CREDIT_AMOUNT"/>
|
||||
...
|
||||
</class>
|
||||
|
||||
<class name="CashPayment" table="CASH_PAYMENT">
|
||||
<id name="id" type="long" column="CASH_PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="amount" column="CASH_AMOUNT"/>
|
||||
...
|
||||
</class>
|
||||
|
||||
<class name="ChequePayment" table="CHEQUE_PAYMENT">
|
||||
<id name="id" type="long" column="CHEQUE_PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="amount" column="CHEQUE_AMOUNT"/>
|
||||
...
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Notice that nowhere do we mention the <literal>Payment</literal> interface
|
||||
explicitly. Also notice that properties of <literal>Payment</literal> are
|
||||
mapped in each of the subclasses. If you want to avoid duplication, consider
|
||||
using XML entities
|
||||
(e.g. <literal>[ <!ENTITY allproperties SYSTEM "allproperties.xml"> ]</literal>
|
||||
in the <literal>DOCTYPE</literal> declartion and
|
||||
<literal>&allproperties;</literal> in the mapping).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The disadvantage of this approach is that Hibernate does not generate SQL
|
||||
<literal>UNION</literal>s when performing polymorphic queries.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For this mapping strategy, a polymorphic association to <literal>Payment</literal>
|
||||
is usually mapped using <literal><any></literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<any name="payment" meta-type="string" id-type="long">
|
||||
<meta-value value="CREDIT" class="CreditCardPayment"/>
|
||||
<meta-value value="CASH" class="CashPayment"/>
|
||||
<meta-value value="CHEQUE" class="ChequePayment"/>
|
||||
<column name="PAYMENT_CLASS"/>
|
||||
<column name="PAYMENT_ID"/>
|
||||
</any>]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="inheritace-mixingpolymorphism">
|
||||
<title>Mixing implicit polymorphism with other inheritance mappings</title>
|
||||
|
||||
<para>
|
||||
There is one further thing to notice about this mapping. Since the subclasses
|
||||
are each mapped in their own <literal><class></literal> element (and since
|
||||
<literal>Payment</literal> is just an interface), each of the subclasses could
|
||||
easily be part of another inheritance hierarchy! (And you can still use polymorphic
|
||||
queries against the <literal>Payment</literal> interface.)
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="CreditCardPayment" table="CREDIT_PAYMENT">
|
||||
<id name="id" type="long" column="CREDIT_PAYMENT_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<discriminator column="CREDIT_CARD" type="string"/>
|
||||
<property name="amount" column="CREDIT_AMOUNT"/>
|
||||
...
|
||||
<subclass name="MasterCardPayment" discriminator-value="MDC"/>
|
||||
<subclass name="VisaPayment" discriminator-value="VISA"/>
|
||||
</class>
|
||||
|
||||
<class name="NonelectronicTransaction" table="NONELECTRONIC_TXN">
|
||||
<id name="id" type="long" column="TXN_ID">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
...
|
||||
<joined-subclass name="CashPayment" table="CASH_PAYMENT">
|
||||
<key column="PAYMENT_ID"/>
|
||||
<property name="amount" column="CASH_AMOUNT"/>
|
||||
...
|
||||
</joined-subclass>
|
||||
<joined-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
|
||||
<key column="PAYMENT_ID"/>
|
||||
<property name="amount" column="CHEQUE_AMOUNT"/>
|
||||
...
|
||||
</joined-subclass>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Once again, we don't mention <literal>Payment</literal> explicitly. If we
|
||||
execute a query against the <literal>Payment</literal> interface - for
|
||||
example, <literal>from Payment</literal> - Hibernate
|
||||
automatically returns instances of <literal>CreditCardPayment</literal>
|
||||
(and its subclasses, since they also implement <literal>Payment</literal>),
|
||||
<literal>CashPayment</literal> and <literal>ChequePayment</literal> but
|
||||
not instances of <literal>NonelectronicTransaction</literal>.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="inheritance-limitations">
|
||||
<title>Limitations</title>
|
||||
|
||||
<para>
|
||||
There are certain limitations to the "implicit polymorphism" approach to
|
||||
the table per concrete-class mapping strategy. There are somewhat less
|
||||
restrictive limitations to <literal><union-subclass></literal>
|
||||
mappings.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The following table shows the limitations of table per concrete-class
|
||||
mappings, and of implicit polymorphism, in Hibernate.
|
||||
</para>
|
||||
|
||||
<table frame="topbot">
|
||||
<title>Features of inheritance mappings</title>
|
||||
<tgroup cols='8' align='left' colsep='1' rowsep='1'>
|
||||
<colspec colname='c1' colwidth="1*"/>
|
||||
<colspec colname='c2' colwidth="1*"/>
|
||||
<colspec colname='c3' colwidth="1*"/>
|
||||
<colspec colname='c4' colwidth="1*"/>
|
||||
<colspec colname='c5' colwidth="1*"/>
|
||||
<colspec colname='c6' colwidth="1*"/>
|
||||
<colspec colname='c7' colwidth="1*"/>
|
||||
<colspec colname='c8' colwidth="1*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Inheritance strategy</entry>
|
||||
<entry>Polymorphic many-to-one</entry>
|
||||
<entry>Polymorphic one-to-one</entry>
|
||||
<entry>Polymorphic one-to-many</entry>
|
||||
<entry>Polymorphic many-to-many</entry>
|
||||
<entry>Polymorphic <literal>load()/get()</literal></entry>
|
||||
<entry>Polymorphic queries</entry>
|
||||
<entry>Polymorphic joins</entry>
|
||||
<entry>Outer join fetching</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>table per class-hierarchy</entry>
|
||||
<entry><literal><many-to-one></literal></entry>
|
||||
<entry><literal><one-to-one></literal></entry>
|
||||
<entry><literal><one-to-many></literal></entry>
|
||||
<entry><literal><many-to-many></literal></entry>
|
||||
<entry><literal>s.get(Payment.class, id)</literal></entry>
|
||||
<entry><literal>from Payment p</literal></entry>
|
||||
<entry><literal>from Order o join o.payment p</literal></entry>
|
||||
<entry><emphasis>supported</emphasis></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>table per subclass</entry>
|
||||
<entry><literal><many-to-one></literal></entry>
|
||||
<entry><literal><one-to-one></literal></entry>
|
||||
<entry><literal><one-to-many></literal></entry>
|
||||
<entry><literal><many-to-many></literal></entry>
|
||||
<entry><literal>s.get(Payment.class, id)</literal></entry>
|
||||
<entry><literal>from Payment p</literal></entry>
|
||||
<entry><literal>from Order o join o.payment p</literal></entry>
|
||||
<entry><emphasis>supported</emphasis></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>table per concrete-class (union-subclass)</entry>
|
||||
<entry><literal><many-to-one></literal></entry>
|
||||
<entry><literal><one-to-one></literal></entry>
|
||||
<entry><literal><one-to-many></literal> (for <literal>inverse="true"</literal> only)</entry>
|
||||
<entry><literal><many-to-many></literal></entry>
|
||||
<entry><literal>s.get(Payment.class, id)</literal></entry>
|
||||
<entry><literal>from Payment p</literal></entry>
|
||||
<entry><literal>from Order o join o.payment p</literal></entry>
|
||||
<entry><emphasis>supported</emphasis></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>table per concrete class (implicit polymorphism)</entry>
|
||||
<entry><literal><any></literal></entry>
|
||||
<entry><emphasis>not supported</emphasis></entry>
|
||||
<entry><emphasis>not supported</emphasis></entry>
|
||||
<entry><literal><many-to-any></literal></entry>
|
||||
<entry><literal>s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()</literal></entry>
|
||||
<entry><literal>from Payment p</literal></entry>
|
||||
<entry><emphasis>not supported</emphasis></entry>
|
||||
<entry><emphasis>not supported</emphasis></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
|
@ -0,0 +1,561 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="persistent-classes" revision="2">
|
||||
<title>Persistent Classes</title>
|
||||
|
||||
<para>
|
||||
Persistent classes are classes in an application that implement the entities
|
||||
of the business problem (e.g. Customer and Order in an E-commerce application).
|
||||
Not all instances of a persistent class are considered to be in the persistent
|
||||
state - an instance may instead be transient or detached.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Hibernate works best if these classes follow some simple rules, also known
|
||||
as the Plain Old Java Object (POJO) programming model. However, none of these
|
||||
rules are hard requirements. Indeed, Hibernate3 assumes very little about
|
||||
the nature of your persistent objects. You may express a domain model in other
|
||||
ways: using trees of <literal>Map</literal> instances, for example.
|
||||
</para>
|
||||
|
||||
<sect1 id="persistent-classes-pojo">
|
||||
<title>A simple POJO example</title>
|
||||
|
||||
<para>
|
||||
Most Java applications require a persistent class representing felines.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package eg;
|
||||
import java.util.Set;
|
||||
import java.util.Date;
|
||||
|
||||
public class Cat {
|
||||
private Long id; // identifier
|
||||
|
||||
private Date birthdate;
|
||||
private Color color;
|
||||
private char sex;
|
||||
private float weight;
|
||||
private int litterId;
|
||||
|
||||
private Cat mother;
|
||||
private Set kittens = new HashSet();
|
||||
|
||||
private void setId(Long id) {
|
||||
this.id=id;
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
void setBirthdate(Date date) {
|
||||
birthdate = date;
|
||||
}
|
||||
public Date getBirthdate() {
|
||||
return birthdate;
|
||||
}
|
||||
|
||||
void setWeight(float weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
public float getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
void setSex(char sex) {
|
||||
this.sex=sex;
|
||||
}
|
||||
public char getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
void setLitterId(int id) {
|
||||
this.litterId = id;
|
||||
}
|
||||
public int getLitterId() {
|
||||
return litterId;
|
||||
}
|
||||
|
||||
void setMother(Cat mother) {
|
||||
this.mother = mother;
|
||||
}
|
||||
public Cat getMother() {
|
||||
return mother;
|
||||
}
|
||||
void setKittens(Set kittens) {
|
||||
this.kittens = kittens;
|
||||
}
|
||||
public Set getKittens() {
|
||||
return kittens;
|
||||
}
|
||||
|
||||
// addKitten not needed by Hibernate
|
||||
public void addKitten(Cat kitten) {
|
||||
kitten.setMother(this);
|
||||
kitten.setLitterId( kittens.size() );
|
||||
kittens.add(kitten);
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
There are four main rules to follow here:
|
||||
</para>
|
||||
|
||||
|
||||
<sect2 id="persistent-classes-pojo-constructor" revision="1">
|
||||
<title>Implement a no-argument constructor</title>
|
||||
|
||||
<para>
|
||||
<literal>Cat</literal> has a no-argument constructor. All persistent classes must
|
||||
have a default constructor (which may be non-public) so that Hibernate can instantiate
|
||||
them using <literal>Constructor.newInstance()</literal>. We strongly recommend having a
|
||||
default constructor with at least <emphasis>package</emphasis> visibility for runtime proxy
|
||||
generation in Hibernate.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="persistent-classes-pojo-identifier" revision="2">
|
||||
<title>Provide an identifier property (optional)</title>
|
||||
|
||||
<para>
|
||||
<literal>Cat</literal> has a property called <literal>id</literal>. This property
|
||||
maps to the primary key column of a database table. The property might have been called
|
||||
anything, and its type might have been any primitive type, any primitive "wrapper"
|
||||
type, <literal>java.lang.String</literal> or <literal>java.util.Date</literal>. (If
|
||||
your legacy database table has composite keys, you can even use a user-defined class
|
||||
with properties of these types - see the section on composite identifiers later.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The identifier property is strictly optional. You can leave them off and let Hibernate
|
||||
keep track of object identifiers internally. We do not recommend this, however.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In fact, some functionality is available only to classes which declare an
|
||||
identifier property:
|
||||
</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
Transitive reattachment for detached objects (cascade update or cascade
|
||||
merge) - see <xref linkend="objectstate-transitive"/>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>Session.saveOrUpdate()</literal>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>Session.merge()</literal>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
We recommend you declare consistently-named identifier properties on persistent
|
||||
classes. We further recommend that you use a nullable (ie. non-primitive) type.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="persistent-classes-pojo-final">
|
||||
<title>Prefer non-final classes (optional)</title>
|
||||
<para>
|
||||
A central feature of Hibernate, <emphasis>proxies</emphasis>, depends upon the
|
||||
persistent class being either non-final, or the implementation of an interface
|
||||
that declares all public methods.
|
||||
</para>
|
||||
<para>
|
||||
You can persist <literal>final</literal> classes that do not implement an interface
|
||||
with Hibernate, but you won't be able to use proxies for lazy association fetching -
|
||||
which will limit your options for performance tuning.
|
||||
</para>
|
||||
<para>
|
||||
You should also avoid declaring <literal>public final</literal> methods on the
|
||||
non-final classes. If you want to use a class with a <literal>public final</literal>
|
||||
method, you must explicitly disable proxying by setting <literal>lazy="false"</literal>.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="persistent-classes-pojo-accessors" revision="2">
|
||||
<title>Declare accessors and mutators for persistent fields (optional)</title>
|
||||
|
||||
<para>
|
||||
<literal>Cat</literal> declares accessor methods for all its persistent fields.
|
||||
Many other ORM tools directly persist instance variables. We believe it is
|
||||
better to provide an indirection between the relational schema and internal
|
||||
data structures of the class. By default, Hibernate persists JavaBeans style
|
||||
properties, and recognizes method names of the form <literal>getFoo</literal>,
|
||||
<literal>isFoo</literal> and <literal>setFoo</literal>. You may switch to direct
|
||||
field access for particular properties, if needed.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Properties need <emphasis>not</emphasis> be declared public - Hibernate can
|
||||
persist a property with a default, <literal>protected</literal> or
|
||||
<literal>private</literal> get / set pair.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="persistent-classes-inheritance">
|
||||
<title>Implementing inheritance</title>
|
||||
|
||||
<para>
|
||||
A subclass must also observe the first and second rules. It inherits its
|
||||
identifier property from the superclass, <literal>Cat</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package eg;
|
||||
|
||||
public class DomesticCat extends Cat {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
protected void setName(String name) {
|
||||
this.name=name;
|
||||
}
|
||||
}]]></programlisting>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="persistent-classes-equalshashcode" revision="1">
|
||||
<title>Implementing <literal>equals()</literal> and <literal>hashCode()</literal></title>
|
||||
|
||||
<para>
|
||||
You have to override the <literal>equals()</literal> and <literal>hashCode()</literal>
|
||||
methods if you
|
||||
</para>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
intend to put instances of persistent classes in a <literal>Set</literal>
|
||||
(the recommended way to represent many-valued associations)
|
||||
<emphasis>and</emphasis>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
intend to use reattachment of detached instances
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Hibernate guarantees equivalence of persistent identity (database row) and Java identity
|
||||
only inside a particular session scope. So as soon as we mix instances retrieved in
|
||||
different sessions, we must implement <literal>equals()</literal> and
|
||||
<literal>hashCode()</literal> if we wish to have meaningful semantics for
|
||||
<literal>Set</literal>s.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The most obvious way is to implement <literal>equals()</literal>/<literal>hashCode()</literal>
|
||||
by comparing the identifier value of both objects. If the value is the same, both must
|
||||
be the same database row, they are therefore equal (if both are added to a <literal>Set</literal>,
|
||||
we will only have one element in the <literal>Set</literal>). Unfortunately, we can't use that
|
||||
approach with generated identifiers! Hibernate will only assign identifier values to objects
|
||||
that are persistent, a newly created instance will not have any identifier value! Furthermore,
|
||||
if an instance is unsaved and currently in a <literal>Set</literal>, saving it will assign
|
||||
an identifier value to the object. If <literal>equals()</literal> and <literal>hashCode()</literal>
|
||||
are based on the identifier value, the hash code would change, breaking the contract of the
|
||||
<literal>Set</literal>. See the Hibernate website for a full discussion of this problem. Note
|
||||
that this is not a Hibernate issue, but normal Java semantics of object identity and equality.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
We recommend implementing <literal>equals()</literal> and <literal>hashCode()</literal>
|
||||
using <emphasis>Business key equality</emphasis>. Business key equality means that the
|
||||
<literal>equals()</literal> method compares only the properties that form the business
|
||||
key, a key that would identify our instance in the real world (a
|
||||
<emphasis>natural</emphasis> candidate key):
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[public class Cat {
|
||||
|
||||
...
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) return true;
|
||||
if ( !(other instanceof Cat) ) return false;
|
||||
|
||||
final Cat cat = (Cat) other;
|
||||
|
||||
if ( !cat.getLitterId().equals( getLitterId() ) ) return false;
|
||||
if ( !cat.getMother().equals( getMother() ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = getMother().hashCode();
|
||||
result = 29 * result + getLitterId();
|
||||
return result;
|
||||
}
|
||||
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
Note that a business key does not have to be as solid as a database
|
||||
primary key candidate (see <xref linkend="transactions-basics-identity"/>).
|
||||
Immutable or unique properties are usually good
|
||||
candidates for a business key.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="persistent-classes-dynamicmodels">
|
||||
<title>Dynamic models</title>
|
||||
|
||||
<para>
|
||||
<emphasis>Note that the following features are currently considered
|
||||
experimental and may change in the near future.</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Persistent entities don't necessarily have to be represented as POJO classes
|
||||
or as JavaBean objects at runtime. Hibernate also supports dynamic models
|
||||
(using <literal>Map</literal>s of <literal>Map</literal>s at runtime) and the
|
||||
representation of entities as DOM4J trees. With this approach, you don't
|
||||
write persistent classes, only mapping files.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
By default, Hibernate works in normal POJO mode. You may set a default entity
|
||||
representation mode for a particular <literal>SessionFactory</literal> using the
|
||||
<literal>default_entity_mode</literal> configuration option (see
|
||||
<xref linkend="configuration-optional-properties"/>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The following examples demonstrates the representation using <literal>Map</literal>s.
|
||||
First, in the mapping file, an <literal>entity-name</literal> has to be declared
|
||||
instead of (or in addition to) a class name:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<hibernate-mapping>
|
||||
|
||||
<class entity-name="Customer">
|
||||
|
||||
<id name="id"
|
||||
type="long"
|
||||
column="ID">
|
||||
<generator class="sequence"/>
|
||||
</id>
|
||||
|
||||
<property name="name"
|
||||
column="NAME"
|
||||
type="string"/>
|
||||
|
||||
<property name="address"
|
||||
column="ADDRESS"
|
||||
type="string"/>
|
||||
|
||||
<many-to-one name="organization"
|
||||
column="ORGANIZATION_ID"
|
||||
class="Organization"/>
|
||||
|
||||
<bag name="orders"
|
||||
inverse="true"
|
||||
lazy="false"
|
||||
cascade="all">
|
||||
<key column="CUSTOMER_ID"/>
|
||||
<one-to-many class="Order"/>
|
||||
</bag>
|
||||
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>]]></programlisting>
|
||||
|
||||
<para>
|
||||
|
||||
Note that even though associations are declared using target class names,
|
||||
the target type of an associations may also be a dynamic entity instead
|
||||
of a POJO.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
After setting the default entity mode to <literal>dynamic-map</literal>
|
||||
for the <literal>SessionFactory</literal>, we can at runtime work with
|
||||
<literal>Map</literal>s of <literal>Map</literal>s:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
Session s = openSession();
|
||||
|
||||
// Create a customer
|
||||
Map david = new HashMap();
|
||||
david.put("name", "David");
|
||||
|
||||
// Create an organization
|
||||
Map foobar = new HashMap();
|
||||
foobar.put("name", "Foobar Inc.");
|
||||
|
||||
// Link both
|
||||
david.put("organization", foobar);
|
||||
|
||||
// Save both
|
||||
s.save("Customer", david);
|
||||
s.save("Organization", foobar);
|
||||
|
||||
tx.commit();
|
||||
s.close();]]></programlisting>
|
||||
|
||||
<para>
|
||||
The advantages of a dynamic mapping are quick turnaround time for prototyping
|
||||
without the need for entity class implementation. However, you lose compile-time
|
||||
type checking and will very likely deal with many exceptions at runtime. Thanks
|
||||
to the Hibernate mapping, the database schema can easily be normalized and sound,
|
||||
allowing to add a proper domain model implementation on top later on.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Entity representation modes can also be set on a per <literal>Session</literal>
|
||||
basis:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);
|
||||
|
||||
// Create a customer
|
||||
Map david = new HashMap();
|
||||
david.put("name", "David");
|
||||
dynamicSession.save("Customer", david);
|
||||
...
|
||||
dynamicSession.flush();
|
||||
dynamicSession.close()
|
||||
...
|
||||
// Continue on pojoSession
|
||||
]]></programlisting>
|
||||
|
||||
|
||||
<para>
|
||||
Please note that the call to <literal>getSession()</literal> using an
|
||||
<literal>EntityMode</literal> is on the <literal>Session</literal> API, not the
|
||||
<literal>SessionFactory</literal>. That way, the new <literal>Session</literal>
|
||||
shares the underlying JDBC connection, transaction, and other context
|
||||
information. This means you don't have tocall <literal>flush()</literal>
|
||||
and <literal>close()</literal> on the secondary <literal>Session</literal>, and
|
||||
also leave the transaction and connection handling to the primary unit of work.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
More information about the XML representation capabilities can be found
|
||||
in <xref linkend="xml"/>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="persistent-classes-tuplizers" revision="1">
|
||||
<title>Tuplizers</title>
|
||||
|
||||
<para>
|
||||
<literal>org.hibernate.tuple.Tuplizer</literal>, and its sub-interfaces, are responsible
|
||||
for managing a particular representation of a piece of data, given that representation's
|
||||
<literal>org.hibernate.EntityMode</literal>. If a given piece of data is thought of as
|
||||
a data structure, then a tuplizer is the thing which knows how to create such a data structure
|
||||
and how to extract values from and inject values into such a data structure. For example,
|
||||
for the POJO entity mode, the correpsonding tuplizer knows how create the POJO through its
|
||||
constructor and how to access the POJO properties using the defined property accessors.
|
||||
There are two high-level types of Tuplizers, represented by the
|
||||
<literal>org.hibernate.tuple.entity.EntityTuplizer</literal> and <literal>org.hibernate.tuple.component.ComponentTuplizer</literal>
|
||||
interfaces. <literal>EntityTuplizer</literal>s are responsible for managing the above mentioned
|
||||
contracts in regards to entities, while <literal>ComponentTuplizer</literal>s do the same for
|
||||
components.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Users may also plug in their own tuplizers. Perhaps you require that a <literal>java.util.Map</literal>
|
||||
implementation other than <literal>java.util.HashMap</literal> be used while in the
|
||||
dynamic-map entity-mode; or perhaps you need to define a different proxy generation strategy
|
||||
than the one used by default. Both would be achieved by defining a custom tuplizer
|
||||
implementation. Tuplizers definitions are attached to the entity or component mapping they
|
||||
are meant to manage. Going back to the example of our customer entity:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<hibernate-mapping>
|
||||
<class entity-name="Customer">
|
||||
<!--
|
||||
Override the dynamic-map entity-mode
|
||||
tuplizer for the customer entity
|
||||
-->
|
||||
<tuplizer entity-mode="dynamic-map"
|
||||
class="CustomMapTuplizerImpl"/>
|
||||
|
||||
<id name="id" type="long" column="ID">
|
||||
<generator class="sequence"/>
|
||||
</id>
|
||||
|
||||
<!-- other properties -->
|
||||
...
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
||||
|
||||
public class CustomMapTuplizerImpl
|
||||
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) {
|
||||
return new CustomMapInstantiator( mappingInfo );
|
||||
}
|
||||
|
||||
private static final class CustomMapInstantiator
|
||||
extends org.hibernate.tuple.DynamicMapInstantitor {
|
||||
// override the generateMap() method to return our custom map...
|
||||
protected final Map generateMap() {
|
||||
return new CustomMap();
|
||||
}
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="persistent-classes-extensions">
|
||||
<title>Extentsions</title>
|
||||
<para>
|
||||
TODO: Document user-extension framework in the property and proxy packages
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -29,56 +29,104 @@
|
|||
<title>Preface</title>
|
||||
|
||||
<para>
|
||||
The Envers project aims to enable easy auditing of persistent classes. All that you
|
||||
have to do is annotate your persistent class or some of its properties, that you
|
||||
want to audit, with <literal>@Audited</literal>. For each audited entity, a table
|
||||
will be created, which will hold the history of changes made to the entity. You
|
||||
can then retrieve and query historical data without much effort.
|
||||
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.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Similarly to Subversion, the library has a concept of revisions. Basically, one
|
||||
transaction is one revision (unless the transaction didn't modify any audited entities).
|
||||
As the revisions are global, having a revision number, you can query for various
|
||||
entities at that revision, retrieving a (partial) view of the database at that
|
||||
revision. You can find a revision number having a date, and the other way round,
|
||||
you can get the date at which a revision was commited.
|
||||
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 and can significantly reduce development time otherwise
|
||||
spent with manual data handling in SQL and JDBC.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The library works with Hibernate and Hibernate Annotations or Entity Manager.
|
||||
For the auditing to work properly, the entities must have immutable unique
|
||||
identifiers (primary keys). You can use Envers wherever Hibernate works:
|
||||
standalone, inside JBoss AS, with JBoss Seam or Spring.
|
||||
Hibernates 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
|
||||
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
|
||||
encapsulate vendor-specific SQL code and will help with the common task of result set
|
||||
translation from a tabular representation to a graph of objects.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Some of the features:
|
||||
If you are new to Hibernate and Object/Relational Mapping or even Java,
|
||||
please follow these steps:
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
versioning of all mappings defined by the JPA specification, except joined and
|
||||
table-per-class inheritance
|
||||
Read <xref linkend="tutorial"/> for a tutorial with step-by-step
|
||||
instructions. The source code for the tutorial is included in the
|
||||
distribution in the <literal>doc/reference/tutorial/</literal>
|
||||
directory.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
versioning of some Hibernate mappings, which extend JPA, like custom types and
|
||||
collections/maps of "simple" types (Strings, Integers, etc.)
|
||||
(see <xref linkend="exceptions"/> for one exception)
|
||||
Read <xref linkend="architecture"/> to understand the environments where
|
||||
Hibernate can be used.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
logging data for each revision using a "revision entity"
|
||||
Have a look at the <literal>eg/</literal> directory in the Hibernate
|
||||
distribution, it contains a simple standalone application. Copy your
|
||||
JDBC driver to the <literal>lib/</literal> directory and edit
|
||||
<literal>etc/hibernate.properties</literal>, specifying correct values for
|
||||
your database. From a command prompt in the distribution directory,
|
||||
type <literal>ant eg</literal> (using Ant), or under Windows, type
|
||||
<literal>build eg</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
querying historical data
|
||||
Use this reference documentation as your primary source of information.
|
||||
Consider reading <emphasis>Java Persistence with Hibernate</emphasis>
|
||||
(http://www.manning.com/bauer2) if you need more help with application
|
||||
design or if you prefer a step-by-step tutorial. Also visit
|
||||
http://caveatemptor.hibernate.org and download the example application
|
||||
for Java Persistence with Hibernate.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
FAQs are answered on the Hibernate website.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Third party demos, examples, and tutorials are linked on the Hibernate
|
||||
website.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The Community Area on the Hibernate website is a good resource for
|
||||
design patterns and various integration solutions (Tomcat, JBoss AS,
|
||||
Struts, EJB, etc.).
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
If you have questions, use the user forum linked on the Hibernate website. We also
|
||||
provide a JIRA issue trackings 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>
|
||||
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>
|
||||
|
|
|
@ -0,0 +1,463 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="querycriteria">
|
||||
<title>Criteria Queries</title>
|
||||
|
||||
<para>
|
||||
Hibernate features an intuitive, extensible criteria query API.
|
||||
</para>
|
||||
|
||||
<sect1 id="querycriteria-creating">
|
||||
<title>Creating a <literal>Criteria</literal> instance</title>
|
||||
|
||||
<para>
|
||||
The interface <literal>org.hibernate.Criteria</literal> represents a query against
|
||||
a particular persistent class. The <literal>Session</literal> is a factory for
|
||||
<literal>Criteria</literal> instances.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Criteria crit = sess.createCriteria(Cat.class);
|
||||
crit.setMaxResults(50);
|
||||
List cats = crit.list();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querycriteria-narrowing">
|
||||
<title>Narrowing the result set</title>
|
||||
|
||||
<para>
|
||||
An individual query criterion is an instance of the interface
|
||||
<literal>org.hibernate.criterion.Criterion</literal>. The class
|
||||
<literal>org.hibernate.criterion.Restrictions</literal> defines
|
||||
factory methods for obtaining certain built-in
|
||||
<literal>Criterion</literal> types.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.like("name", "Fritz%") )
|
||||
.add( Restrictions.between("weight", minWeight, maxWeight) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Restrictions may be grouped logically.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.like("name", "Fritz%") )
|
||||
.add( Restrictions.or(
|
||||
Restrictions.eq( "age", new Integer(0) ),
|
||||
Restrictions.isNull("age")
|
||||
) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.in( "name", new String[] { "Fritz", "Izi", "Pk" } ) )
|
||||
.add( Restrictions.disjunction()
|
||||
.add( Restrictions.isNull("age") )
|
||||
.add( Restrictions.eq("age", new Integer(0) ) )
|
||||
.add( Restrictions.eq("age", new Integer(1) ) )
|
||||
.add( Restrictions.eq("age", new Integer(2) ) )
|
||||
) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
There are quite a range of built-in criterion types (<literal>Restrictions</literal>
|
||||
subclasses), but one that is especially useful lets you specify SQL directly.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.sqlRestriction("lower({alias}.name) like lower(?)", "Fritz%", Hibernate.STRING) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>{alias}</literal> placeholder with be replaced by the row alias
|
||||
of the queried entity.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
An alternative approach to obtaining a criterion is to get it from a
|
||||
<literal>Property</literal> instance. You can create a <literal>Property</literal>
|
||||
by calling <literal>Property.forName()</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
Property age = Property.forName("age");
|
||||
List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.disjunction()
|
||||
.add( age.isNull() )
|
||||
.add( age.eq( new Integer(0) ) )
|
||||
.add( age.eq( new Integer(1) ) )
|
||||
.add( age.eq( new Integer(2) ) )
|
||||
) )
|
||||
.add( Property.forName("name").in( new String[] { "Fritz", "Izi", "Pk" } ) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querycriteria-ordering">
|
||||
<title>Ordering the results</title>
|
||||
|
||||
<para>
|
||||
You may order the results using <literal>org.hibernate.criterion.Order</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.like("name", "F%")
|
||||
.addOrder( Order.asc("name") )
|
||||
.addOrder( Order.desc("age") )
|
||||
.setMaxResults(50)
|
||||
.list();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Property.forName("name").like("F%") )
|
||||
.addOrder( Property.forName("name").asc() )
|
||||
.addOrder( Property.forName("age").desc() )
|
||||
.setMaxResults(50)
|
||||
.list();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querycriteria-associations" revision="2">
|
||||
<title>Associations</title>
|
||||
|
||||
<para>
|
||||
You may easily specify constraints upon related entities by navigating
|
||||
associations using <literal>createCriteria()</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.like("name", "F%") )
|
||||
.createCriteria("kittens")
|
||||
.add( Restrictions.like("name", "F%") )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
note that the second <literal>createCriteria()</literal> returns a new
|
||||
instance of <literal>Criteria</literal>, which refers to the elements of
|
||||
the <literal>kittens</literal> collection.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The following, alternate form is useful in certain circumstances.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.createAlias("kittens", "kt")
|
||||
.createAlias("mate", "mt")
|
||||
.add( Restrictions.eqProperty("kt.name", "mt.name") )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
(<literal>createAlias()</literal> does not create a new instance of
|
||||
<literal>Criteria</literal>.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note that the kittens collections held by the <literal>Cat</literal> instances
|
||||
returned by the previous two queries are <emphasis>not</emphasis> pre-filtered
|
||||
by the criteria! If you wish to retrieve just the kittens that match the
|
||||
criteria, you must use a <literal>ResultTransformer</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.createCriteria("kittens", "kt")
|
||||
.add( Restrictions.eq("name", "F%") )
|
||||
.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)
|
||||
.list();
|
||||
Iterator iter = cats.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
Map map = (Map) iter.next();
|
||||
Cat cat = (Cat) map.get(Criteria.ROOT_ALIAS);
|
||||
Cat kitten = (Cat) map.get("kt");
|
||||
}]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querycriteria-dynamicfetching" revision="1">
|
||||
<title>Dynamic association fetching</title>
|
||||
|
||||
<para>
|
||||
You may specify association fetching semantics at runtime using
|
||||
<literal>setFetchMode()</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
|
||||
.add( Restrictions.like("name", "Fritz%") )
|
||||
.setFetchMode("mate", FetchMode.EAGER)
|
||||
.setFetchMode("kittens", FetchMode.EAGER)
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
This query will fetch both <literal>mate</literal> and <literal>kittens</literal>
|
||||
by outer join. See <xref linkend="performance-fetching"/> for more information.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querycriteria-examples">
|
||||
<title>Example queries</title>
|
||||
|
||||
<para>
|
||||
The class <literal>org.hibernate.criterion.Example</literal> allows
|
||||
you to construct a query criterion from a given instance.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Cat cat = new Cat();
|
||||
cat.setSex('F');
|
||||
cat.setColor(Color.BLACK);
|
||||
List results = session.createCriteria(Cat.class)
|
||||
.add( Example.create(cat) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Version properties, identifiers and associations are ignored. By default,
|
||||
null valued properties are excluded.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You can adjust how the <literal>Example</literal> is applied.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Example example = Example.create(cat)
|
||||
.excludeZeroes() //exclude zero valued properties
|
||||
.excludeProperty("color") //exclude the property named "color"
|
||||
.ignoreCase() //perform case insensitive string comparisons
|
||||
.enableLike(); //use like for string comparisons
|
||||
List results = session.createCriteria(Cat.class)
|
||||
.add(example)
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
You can even use examples to place criteria upon associated objects.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.add( Example.create(cat) )
|
||||
.createCriteria("mate")
|
||||
.add( Example.create( cat.getMate() ) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querycriteria-projection">
|
||||
<title>Projections, aggregation and grouping</title>
|
||||
<para>
|
||||
The class <literal>org.hibernate.criterion.Projections</literal> is a
|
||||
factory for <literal>Projection</literal> instances. We apply a
|
||||
projection to a query by calling <literal>setProjection()</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.setProjection( Projections.rowCount() )
|
||||
.add( Restrictions.eq("color", Color.BLACK) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.setProjection( Projections.projectionList()
|
||||
.add( Projections.rowCount() )
|
||||
.add( Projections.avg("weight") )
|
||||
.add( Projections.max("weight") )
|
||||
.add( Projections.groupProperty("color") )
|
||||
)
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
There is no explicit "group by" necessary in a criteria query. Certain
|
||||
projection types are defined to be <emphasis>grouping projections</emphasis>,
|
||||
which also appear in the SQL <literal>group by</literal> clause.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
An alias may optionally be assigned to a projection, so that the projected value
|
||||
may be referred to in restrictions or orderings. Here are two different ways to
|
||||
do this:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.setProjection( Projections.alias( Projections.groupProperty("color"), "colr" ) )
|
||||
.addOrder( Order.asc("colr") )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.setProjection( Projections.groupProperty("color").as("colr") )
|
||||
.addOrder( Order.asc("colr") )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>alias()</literal> and <literal>as()</literal> methods simply wrap a
|
||||
projection instance in another, aliased, instance of <literal>Projection</literal>.
|
||||
As a shortcut, you can assign an alias when you add the projection to a
|
||||
projection list:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.setProjection( Projections.projectionList()
|
||||
.add( Projections.rowCount(), "catCountByColor" )
|
||||
.add( Projections.avg("weight"), "avgWeight" )
|
||||
.add( Projections.max("weight"), "maxWeight" )
|
||||
.add( Projections.groupProperty("color"), "color" )
|
||||
)
|
||||
.addOrder( Order.desc("catCountByColor") )
|
||||
.addOrder( Order.desc("avgWeight") )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Domestic.class, "cat")
|
||||
.createAlias("kittens", "kit")
|
||||
.setProjection( Projections.projectionList()
|
||||
.add( Projections.property("cat.name"), "catName" )
|
||||
.add( Projections.property("kit.name"), "kitName" )
|
||||
)
|
||||
.addOrder( Order.asc("catName") )
|
||||
.addOrder( Order.asc("kitName") )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
You can also use <literal>Property.forName()</literal> to express projections:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.setProjection( Property.forName("name") )
|
||||
.add( Property.forName("color").eq(Color.BLACK) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
|
||||
.setProjection( Projections.projectionList()
|
||||
.add( Projections.rowCount().as("catCountByColor") )
|
||||
.add( Property.forName("weight").avg().as("avgWeight") )
|
||||
.add( Property.forName("weight").max().as("maxWeight") )
|
||||
.add( Property.forName("color").group().as("color" )
|
||||
)
|
||||
.addOrder( Order.desc("catCountByColor") )
|
||||
.addOrder( Order.desc("avgWeight") )
|
||||
.list();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querycriteria-detachedqueries">
|
||||
<title>Detached queries and subqueries</title>
|
||||
<para>
|
||||
The <literal>DetachedCriteria</literal> class lets you create a query outside the scope
|
||||
of a session, and then later execute it using some arbitrary <literal>Session</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)
|
||||
.add( Property.forName("sex").eq('F') );
|
||||
|
||||
Session session = ....;
|
||||
Transaction txn = session.beginTransaction();
|
||||
List results = query.getExecutableCriteria(session).setMaxResults(100).list();
|
||||
txn.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
<para>
|
||||
A <literal>DetachedCriteria</literal> may also be used to express a subquery. Criterion
|
||||
instances involving subqueries may be obtained via <literal>Subqueries</literal> or
|
||||
<literal>Property</literal>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)
|
||||
.setProjection( Property.forName("weight").avg() );
|
||||
session.createCriteria(Cat.class)
|
||||
.add( Property.forName("weight").gt(avgWeight) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)
|
||||
.setProjection( Property.forName("weight") );
|
||||
session.createCriteria(Cat.class)
|
||||
.add( Subqueries.geAll("weight", weights) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
<para>
|
||||
Even correlated subqueries are possible:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat.class, "cat2")
|
||||
.setProjection( Property.forName("weight").avg() )
|
||||
.add( Property.forName("cat2.sex").eqProperty("cat.sex") );
|
||||
session.createCriteria(Cat.class, "cat")
|
||||
.add( Property.forName("weight").gt(avgWeightForSex) )
|
||||
.list();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
<!--TODO: ResultSetTransformer + aliasing. AliasToBeanTransformer allow returning arbitrary
|
||||
user objects - similar to setResultClass in JDO2. General use of ResultTransformer
|
||||
could also be explained. -->
|
||||
|
||||
<sect1 id="query-criteria-naturalid">
|
||||
<title>Queries by natural identifier</title>
|
||||
|
||||
<para>
|
||||
For most queries, including criteria queries, the query cache is not very efficient,
|
||||
because query cache invalidation occurs too frequently. However, there is one special
|
||||
kind of query where we can optimize the cache invalidation algorithm: lookups by a
|
||||
constant natural key. In some applications, this kind of query occurs frequently.
|
||||
The criteria API provides special provision for this use case.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
First, you should map the natural key of your entity using
|
||||
<literal><natural-id></literal>, and enable use of the second-level cache.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="User">
|
||||
<cache usage="read-write"/>
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<natural-id>
|
||||
<property name="name"/>
|
||||
<property name="org"/>
|
||||
</natural-id>
|
||||
<property name="password"/>
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Note that this functionality is not intended for use with entities with
|
||||
<emphasis>mutable</emphasis> natural keys.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Next, enable the Hibernate query cache.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Now, <literal>Restrictions.naturalId()</literal> allows us to make use of
|
||||
the more efficient cache algorithm.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[session.createCriteria(User.class)
|
||||
.add( Restrictions.naturalId()
|
||||
.set("name", "gavin")
|
||||
.set("org", "hb")
|
||||
).setCacheable(true)
|
||||
.uniqueResult();]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
|
@ -0,0 +1,784 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="querysql" revision="2">
|
||||
<title>Native SQL</title>
|
||||
|
||||
<para>You may also express queries in the native SQL dialect of your
|
||||
database. This is useful if you want to utilize database specific features
|
||||
such as query hints or the <literal>CONNECT</literal> keyword in Oracle. It
|
||||
also provides a clean migration path from a direct SQL/JDBC based
|
||||
application to Hibernate.</para>
|
||||
|
||||
<para>Hibernate3 allows you to specify handwritten SQL (including stored
|
||||
procedures) for all create, update, delete, and load operations.</para>
|
||||
|
||||
<sect1 id="querysql-creating" revision="4">
|
||||
<title>Using a <literal>SQLQuery</literal></title>
|
||||
|
||||
<para>Execution of native SQL queries is controlled via the
|
||||
<literal>SQLQuery</literal> interface, which is obtained by calling
|
||||
<literal>Session.createSQLQuery()</literal>. The following describes how
|
||||
to use this API for querying.</para>
|
||||
|
||||
<sect2>
|
||||
<title>Scalar queries</title>
|
||||
|
||||
<para>The most basic SQL query is to get a list of scalars
|
||||
(values).</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>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>
|
||||
|
||||
<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>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>the SQL query string</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>the columns and types to return</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>This will still return Object arrays, but now it will not use
|
||||
<literal>ResultSetMetadata</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>It is possible to leave out the type information for all or some
|
||||
of the scalars.</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>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>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Entity queries</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>
|
||||
|
||||
<programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").addEntity(Cat.class);
|
||||
sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").addEntity(Cat.class);
|
||||
]]></programlisting>
|
||||
|
||||
<para>This query specified:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>the SQL query string</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>the entity returned by the query</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>Assuming that Cat is mapped as a class with the columns ID, NAME
|
||||
and BIRTHDATE the above queries will both return a List where each
|
||||
element is a Cat entity.</para>
|
||||
|
||||
<para>If the entity is mapped with a <literal>many-to-one</literal> to
|
||||
another entity it is required to also return this when performing the
|
||||
native query, otherwise a database specific "column not found" error
|
||||
will occur. The additional columns will automatically be returned when
|
||||
using the * notation, but we prefer to be explicit as in the following
|
||||
example for a <literal>many-to-one</literal> to a
|
||||
<literal>Dog</literal>:</para>
|
||||
|
||||
<programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS").addEntity(Cat.class);
|
||||
]]></programlisting>
|
||||
|
||||
<para>This will allow cat.getDog() to function properly.</para>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Handling associations and collections</title>
|
||||
|
||||
<para>It is possible to eagerly join in the <literal>Dog</literal> to
|
||||
avoid the possible extra roundtrip for initializing the proxy. This is
|
||||
done via the <literal>addJoin()</literal> method, which allows you to
|
||||
join in an association or collection.</para>
|
||||
|
||||
<programlisting><![CDATA[sess.createSQLQuery("SELECT c.ID, NAME, BIRTHDATE, DOG_ID, D_ID, D_NAME FROM CATS c, DOGS d WHERE c.DOG_ID = d.D_ID")
|
||||
.addEntity("cat", Cat.class)
|
||||
.addJoin("cat.dog");
|
||||
]]></programlisting>
|
||||
|
||||
<para>In this example the returned <literal>Cat</literal>'s will have
|
||||
their <literal>dog</literal> property fully initialized without any
|
||||
extra roundtrip to the database. Notice that we added a alias name
|
||||
("cat") to be able to specify the target property path of the join. It
|
||||
is possible to do the same eager joining for collections, e.g. if the
|
||||
<literal>Cat</literal> had a one-to-many to <literal>Dog</literal>
|
||||
instead.</para>
|
||||
|
||||
<programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, CAT_ID FROM CATS c, DOGS d WHERE c.ID = d.CAT_ID")
|
||||
.addEntity("cat", Cat.class)
|
||||
.addJoin("cat.dogs");
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
At this stage we are reaching the limits of what is possible with native queries without starting to
|
||||
enhance the sql queries to make them usable in Hibernate; the problems starts to arise when returning
|
||||
multiple entities of the same type or when the default alias/column names are not enough.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Returning multiple entities</title>
|
||||
|
||||
<para>Until now the result set column names are assumed to be the same
|
||||
as the column names specified in the mapping document. This can be
|
||||
problematic for SQL queries which join multiple tables, since the same
|
||||
column names may appear in more than one table.</para>
|
||||
|
||||
<para>Column alias injection is needed in the following query (which
|
||||
most likely will fail):</para>
|
||||
|
||||
<programlisting><![CDATA[sess.createSQLQuery("SELECT c.*, m.* FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
|
||||
.addEntity("cat", Cat.class)
|
||||
.addEntity("mother", Cat.class)
|
||||
]]></programlisting>
|
||||
|
||||
<para>The intention for this query is to return two Cat instances per
|
||||
row, a cat and its mother. This will fail since there is a conflict of
|
||||
names since they are mapped to the same column names and on some
|
||||
databases the returned column aliases will most likely be on the form
|
||||
"c.ID", "c.NAME", etc. which are not equal to the columns specified in
|
||||
the mappings ("ID" and "NAME").</para>
|
||||
|
||||
<para>The following form is not vulnerable to column name
|
||||
duplication:</para>
|
||||
|
||||
<programlisting><![CDATA[sess.createSQLQuery("SELECT {cat.*}, {mother.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
|
||||
.addEntity("cat", Cat.class)
|
||||
.addEntity("mother", Cat.class)
|
||||
]]></programlisting>
|
||||
|
||||
<para>This query specified:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>the SQL query string, with placeholders for Hibernate to
|
||||
inject column aliases</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>the entities returned by the query</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>The {cat.*} and {mother.*} notation used above is a shorthand for
|
||||
"all properties". Alternatively, you may list the columns explicitly, but
|
||||
even in this case we let Hibernate inject the SQL column aliases for
|
||||
each property. The placeholder for a column alias is just the property
|
||||
name qualified by the table alias. In the following example, we retrieve
|
||||
Cats and their mothers from a different table (cat_log) to the one
|
||||
declared in the mapping metadata. Notice that we may even use the
|
||||
property aliases in the where clause if we like.</para>
|
||||
|
||||
<programlisting><![CDATA[String sql = "SELECT ID as {c.id}, NAME as {c.name}, " +
|
||||
"BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} " +
|
||||
"FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID";
|
||||
|
||||
List loggedCats = sess.createSQLQuery(sql)
|
||||
.addEntity("cat", Cat.class)
|
||||
.addEntity("mother", Cat.class).list()
|
||||
]]></programlisting>
|
||||
|
||||
<sect3 id="querysql-aliasreferences" revision="2">
|
||||
<title>Alias and property references</title>
|
||||
|
||||
<para>For most cases the above alias injection is needed, but for
|
||||
queries relating to more complex mappings like composite properties,
|
||||
inheritance discriminators, collections etc. there are some specific
|
||||
aliases to use to allow Hibernate to inject the proper aliases.</para>
|
||||
|
||||
<para>The following table shows the different possibilities of using
|
||||
the alias injection. Note: the alias names in the result are examples,
|
||||
each alias will have a unique and probably different name when
|
||||
used.</para>
|
||||
|
||||
<table frame="topbot" id="aliasinjection-summary">
|
||||
<title>Alias injection names</title>
|
||||
|
||||
<tgroup cols="3">
|
||||
<colspec colwidth="1*" />
|
||||
|
||||
<colspec colwidth="1*" />
|
||||
|
||||
<colspec colwidth="2.5*" />
|
||||
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Description</entry>
|
||||
|
||||
<entry>Syntax</entry>
|
||||
|
||||
<entry>Example</entry>
|
||||
</row>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>A simple property</entry>
|
||||
|
||||
<entry><literal>{[aliasname].[propertyname]</literal></entry>
|
||||
|
||||
<entry><literal>A_NAME as {item.name}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>A composite property</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>Discriminator of an entity</entry>
|
||||
|
||||
<entry><literal>{[aliasname].class}</literal></entry>
|
||||
|
||||
<entry><literal>DISC as {item.class}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>All properties of an entity</entry>
|
||||
|
||||
<entry><literal>{[aliasname].*}</literal></entry>
|
||||
|
||||
<entry><literal>{item.*}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>A collection key</entry>
|
||||
|
||||
<entry><literal>{[aliasname].key}</literal></entry>
|
||||
|
||||
<entry><literal>ORGID as {coll.key}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>The id of an collection</entry>
|
||||
|
||||
<entry><literal>{[aliasname].id}</literal></entry>
|
||||
|
||||
<entry><literal>EMPID as {coll.id}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>The element of an collection</entry>
|
||||
|
||||
<entry><literal>{[aliasname].element}</literal></entry>
|
||||
|
||||
<entry><literal>XID as {coll.element}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>roperty of the element in the collection</entry>
|
||||
|
||||
<entry><literal>{[aliasname].element.[propertyname]}</literal></entry>
|
||||
|
||||
<entry><literal>NAME as {coll.element.name}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>All properties of the element in the collection</entry>
|
||||
|
||||
<entry><literal>{[aliasname].element.*}</literal></entry>
|
||||
|
||||
<entry><literal>{coll.element.*}</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>All properties of the the collection</entry>
|
||||
|
||||
<entry><literal>{[aliasname].*}</literal></entry>
|
||||
|
||||
<entry><literal>{coll.*}</literal></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</sect3>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Returning non-managed entities</title>
|
||||
|
||||
<para>It is possible to apply a ResultTransformer to native sql queries. Allowing it to e.g. return non-managed entities.</para>
|
||||
|
||||
<programlisting><![CDATA[sess.createSQLQuery("SELECT NAME, BIRTHDATE FROM CATS")
|
||||
.setResultTransformer(Transformers.aliasToBean(CatDTO.class))]]></programlisting>
|
||||
|
||||
<para>This query specified:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>the SQL query string</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>a result transformer</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
The above query will return a list of <literal>CatDTO</literal> which has been instantiated and injected the values of NAME and BIRTHNAME into its corresponding
|
||||
properties or fields.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Handling inheritance</title>
|
||||
|
||||
<para>Native sql queries which query for entities that is mapped as part
|
||||
of an inheritance must include all properties for the baseclass and all
|
||||
it subclasses.</para>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Parameters</title>
|
||||
|
||||
<para>Native sql queries support positional as well as named
|
||||
parameters:</para>
|
||||
|
||||
<programlisting><![CDATA[Query query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like ?").addEntity(Cat.class);
|
||||
List pusList = query.setString(0, "Pus%").list();
|
||||
|
||||
query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like :name").addEntity(Cat.class);
|
||||
List pusList = query.setString("name", "Pus%").list(); ]]></programlisting>
|
||||
</sect2>
|
||||
|
||||
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querysql-namedqueries" revision="3">
|
||||
<title>Named SQL queries</title>
|
||||
|
||||
<para>Named SQL queries may be defined in the mapping document and called
|
||||
in exactly the same way as a named HQL query. In this case, we do
|
||||
<emphasis>not</emphasis> need to call
|
||||
<literal>addEntity()</literal>.</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>The <literal><return-join></literal> and
|
||||
<literal><load-collection></literal> elements are used to join
|
||||
associations and define queries which initialize collections,
|
||||
respectively.</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},
|
||||
address.STREET AS {address.street},
|
||||
address.CITY AS {address.city},
|
||||
address.STATE AS {address.state},
|
||||
address.ZIP AS {address.zip}
|
||||
FROM PERSON person
|
||||
JOIN ADDRESS address
|
||||
ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'
|
||||
WHERE person.NAME LIKE :namePattern
|
||||
</sql-query>]]></programlisting>
|
||||
|
||||
<para>A named SQL query may return a scalar value. You must declare the
|
||||
column alias and Hibernate type using the
|
||||
<literal><return-scalar></literal> element:</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>You can externalize the resultset mapping informations in a
|
||||
<literal><resultset></literal> element to either reuse them across
|
||||
several named queries or through the
|
||||
<literal>setResultSetMapping()</literal> API.</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},
|
||||
address.STREET AS {address.street},
|
||||
address.CITY AS {address.city},
|
||||
address.STATE AS {address.state},
|
||||
address.ZIP AS {address.zip}
|
||||
FROM PERSON person
|
||||
JOIN ADDRESS address
|
||||
ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'
|
||||
WHERE person.NAME LIKE :namePattern
|
||||
</sql-query>]]></programlisting>
|
||||
|
||||
<para>You can alternatively use the resultset mapping information in your
|
||||
hbm files directly in java code.</para>
|
||||
|
||||
<programlisting><![CDATA[List cats = sess.createSQLQuery(
|
||||
"select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id"
|
||||
)
|
||||
.setResultSetMapping("catAndKitten")
|
||||
.list();]]></programlisting>
|
||||
|
||||
<sect2 id="propertyresults">
|
||||
<title>Using return-property to explicitly specify column/alias
|
||||
names</title>
|
||||
|
||||
<para>With <literal><return-property></literal> you can explicitly
|
||||
tell Hibernate what column aliases to use, instead of using the
|
||||
<literal>{}</literal>-syntax to let Hibernate inject its own
|
||||
aliases.</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> also works with
|
||||
multiple columns. This solves a limitation with the
|
||||
<literal>{}</literal>-syntax which can not allow fine grained control of
|
||||
multi-column properties.</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>Notice that in this example we used
|
||||
<literal><return-property></literal> in combination with the
|
||||
<literal>{}</literal>-syntax for injection. Allowing users to choose how
|
||||
they want to refer column and properties.</para>
|
||||
|
||||
<para>If your mapping has a discriminator you must use
|
||||
<literal><return-discriminator></literal> to specify the
|
||||
discriminator column.</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="sp_query" revision="1">
|
||||
<title>Using stored procedures for querying</title>
|
||||
|
||||
<para>Hibernate 3 introduces support for queries via stored procedures
|
||||
and functions. Most of the following documentation is equivalent for
|
||||
both. The stored procedure/function must return a resultset as the first
|
||||
out-parameter to be able to work with Hibernate. An example of such a
|
||||
stored function in Oracle 9 and higher is as follows:</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>To use this query in Hibernate you need to map it via a named
|
||||
query.</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>Notice stored procedures currently only return scalars and
|
||||
entities. <literal><return-join></literal> and
|
||||
<literal><load-collection></literal> are not supported.</para>
|
||||
|
||||
<sect3 id="querysql-limits-storedprocedures" revision="1">
|
||||
<title>Rules/limitations for using stored procedures</title>
|
||||
|
||||
<para>To use stored procedures with Hibernate the procedures/functions
|
||||
have to follow some rules. If they do not follow those rules they are
|
||||
not usable with Hibernate. If you still want to use these procedures
|
||||
you have to execute them via <literal>session.connection()</literal>.
|
||||
The rules are different for each database, since database vendors have
|
||||
different stored procedure semantics/syntax.</para>
|
||||
|
||||
<para>Stored procedure queries can't be paged with
|
||||
<literal>setFirstResult()/setMaxResults()</literal>.</para>
|
||||
|
||||
<para>Recommended call form is standard SQL92: <literal>{ ? = call
|
||||
functionName(<parameters>) }</literal> or <literal>{ ? = call
|
||||
procedureName(<parameters>}</literal>. Native call syntax is not
|
||||
supported.</para>
|
||||
|
||||
<para>For Oracle the following rules apply:</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>A function must return a result set. The first parameter of
|
||||
a procedure must be an <literal>OUT</literal> that returns a
|
||||
result set. This is done by using a
|
||||
<literal>SYS_REFCURSOR</literal> type in Oracle 9 or 10. In Oracle
|
||||
you need to define a <literal>REF CURSOR</literal> type, see
|
||||
Oracle literature.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>For Sybase or MS SQL server the following rules apply:</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>The procedure must return a result set. Note that since
|
||||
these servers can/will return multiple result sets and update
|
||||
counts, Hibernate will iterate the results and take the first
|
||||
result that is a result set as its return value. Everything else
|
||||
will be discarded.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>If you can enable <literal>SET NOCOUNT ON</literal> in your
|
||||
procedure it will probably be more efficient, but this is not a
|
||||
requirement.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</sect3>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querysql-cud">
|
||||
<title>Custom SQL for create, update and delete</title>
|
||||
|
||||
<para>Hibernate3 can use custom SQL statements for create, update, and
|
||||
delete operations. The class and collection persisters in Hibernate
|
||||
already contain a set of configuration time generated strings (insertsql,
|
||||
deletesql, updatesql etc.). The mapping tags
|
||||
<literal><sql-insert></literal>,
|
||||
<literal><sql-delete></literal>, and
|
||||
<literal><sql-update></literal> override these strings:</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>The SQL is directly executed in your database, so you are free to
|
||||
use any dialect you like. This will of course reduce the portability of
|
||||
your mapping if you use database specific SQL.</para>
|
||||
|
||||
<para>Stored procedures are supported if the <literal>callable</literal>
|
||||
attribute is set:</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>The order of the positional parameters are currently vital, as they
|
||||
must be in the same sequence as Hibernate expects them.</para>
|
||||
|
||||
<para>You can see the expected order by enabling debug logging for the
|
||||
<literal>org.hibernate.persister.entity</literal> level. With this level
|
||||
enabled Hibernate will print out the static SQL that is used to create,
|
||||
update, delete etc. entities. (To see the expected sequence, remember to
|
||||
not include your custom SQL in the mapping files as that will override the
|
||||
Hibernate generated static sql.)</para>
|
||||
|
||||
<para>The stored procedures are in most cases (read: better do it than
|
||||
not) required to return the number of rows inserted/updated/deleted, as
|
||||
Hibernate has some runtime checks for the success of the statement.
|
||||
Hibernate always registers the first statement parameter as a numeric
|
||||
output parameter for the CUD operations:</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>Custom SQL for loading</title>
|
||||
|
||||
<para>You may also declare your own SQL (or HQL) queries for entity
|
||||
loading:</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>This is just a named query declaration, as discussed earlier. You
|
||||
may reference this named query in a class mapping:</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>This even works with stored procedures.</para>
|
||||
|
||||
<para>You may even define a query for collection loading:</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>You could even define an entity loader that loads a collection by
|
||||
join fetching:</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>
|
||||
</chapter>
|
|
@ -1,148 +0,0 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="quickstart">
|
||||
<title>Quickstart</title>
|
||||
|
||||
<para>
|
||||
When configuring your persistence unit (the persistence.xml file), add the following event
|
||||
listeners: (this will allow Envers to check if any audited entities were modified)
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<persistence-unit ...>
|
||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||
<class>...</class>
|
||||
<properties>
|
||||
<property name="hibernate.dialect" ... />
|
||||
<!-- other hibernate properties -->
|
||||
|
||||
<property name="hibernate.ejb.event.post-insert"
|
||||
value="org.hibernate.envers.event.VersionsEventListener" />
|
||||
<property name="hibernate.ejb.event.post-update"
|
||||
value="org.hibernate.envers.event.VersionsEventListener" />
|
||||
<property name="hibernate.ejb.event.post-delete"
|
||||
value="org.hibernate.envers.event.VersionsEventListener" />
|
||||
<property name="hibernate.ejb.event.pre-collection-update"
|
||||
value="org.hibernate.envers.event.VersionsEventListener" />
|
||||
<property name="hibernate.ejb.event.pre-collection-remove"
|
||||
value="org.hibernate.envers.event.VersionsEventListener" />
|
||||
<property name="hibernate.ejb.event.post-collection-recreate"
|
||||
value="org.hibernate.envers.event.VersionsEventListener" />
|
||||
</properties>
|
||||
</persistence-unit>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Then, annotate your persistent class with <literal>@Audited</literal> - this will make all
|
||||
properties versioned. For example:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[import org.hibernate.envers.Audited;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Column;
|
||||
|
||||
@Entity
|
||||
@Audited // that's the important part :)
|
||||
public class Person {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String surname;
|
||||
|
||||
@ManyToOne
|
||||
private Address address;
|
||||
|
||||
// add getters, setters, constructors, equals and hashCode here
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
And the referenced entity:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[@Entity
|
||||
@Audited
|
||||
public class Address {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
private String streetName;
|
||||
|
||||
private Integer houseNumber;
|
||||
|
||||
private Integer flatNumber;
|
||||
|
||||
@OneToMany(mappedBy = "address")
|
||||
private Set<Person> persons;
|
||||
|
||||
// add getters, setters, constructors, equals and hashCode here
|
||||
}
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
And that's it! You create, modify and delete the entites as always. If you look
|
||||
at the generated schema, you will notice that it is unchanged by adding auditing
|
||||
for the Address and Person entities. Also, the data they hold is the same. There are,
|
||||
however, two new tables - <literal>Address_audit</literal> and <literal>Person_audit</literal>,
|
||||
which store the historical data, whenever you commit a transaction.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Instead of annotating the whole class and auditing all properties, you can annotate
|
||||
only some persistent properties with <literal>@Audited</literal>. This will cause only
|
||||
these properties to be audited.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You can access the audit of an entity using the <literal>AuditReader</literal> interface, which you
|
||||
can obtain when having an open EntityManager. See also the javadocs.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[AuditReader reader = AuditReaderFactory.get(entityManager);
|
||||
Person oldPerson = reader.find(Person.class, personId, revision)
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>T find(Class<T> cls, Object primaryKey, Number revision)</literal>
|
||||
method returns an entity with the given primary key, with the data it contained at
|
||||
the given revision. If the entity didn't exist at this revision, <literal>null</literal>
|
||||
is returned. Only the audited properties will be set on the returned entity.
|
||||
The rest will be <literal>null</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You can also get a list of revisions at which an entity was modified using the
|
||||
<literal>getRevisions</literal> method, as well as retrieve the date,
|
||||
at which a revision was created using the <literal>getRevisionDate</literal> method.
|
||||
</para>
|
||||
</chapter>
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="revisionlog">
|
||||
|
||||
<title>Logging data for revisions</title>
|
||||
|
||||
<para>
|
||||
Envers provides an easy way to log additional data for each revision. You simply need
|
||||
to annotate one entity with <literal>@RevisionEntity</literal>, and a new instance of
|
||||
this entity will be persisted when a new revision is created (that is, whenever an
|
||||
audited entity is modified). As revisions are global, you can have at most one revisions entity.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This entity must have at least two properties:
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
an integer- or long-valued property, annotated with <literal>@RevisionNumber</literal>. Most
|
||||
often, this will be an auto-generated primary key.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
a long-valued property, annotated with <literal>@RevisionTimestamp</literal>. Value of
|
||||
this property will be automatically set by Envers.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
You can either add these properties to your entity, or extend
|
||||
<literal>org.hibernate.envers.DefaultRevisionEntity</literal>, which already has those two properties.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To fill the entity with additional data, you'll need to implement the
|
||||
<literal>org.jboss.envers.RevisionListener</literal> interface. Its newRevision method will
|
||||
be called when a new revision is created, before persisting the revision entity.
|
||||
The implementation should be stateless and thread-safe. The listener then has to be
|
||||
attached to the revisions entity by specifying it as a parameter to the
|
||||
<literal>@RevisionEntity</literal> annotation.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A simplest example of a revisions entity, which with each revision associates the
|
||||
username of the user making the change is:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package org.jboss.envers.example;
|
||||
|
||||
import org.hibernate.envers.RevisionEntity;
|
||||
import org.hibernate.envers.DefaultRevisionEntity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@RevisionEntity(ExampleListener.class)
|
||||
public class ExampleRevEntity extends DefaultRevisionEntity {
|
||||
private String username;
|
||||
|
||||
public String getUsername() { return username; }
|
||||
public void setUsername(String username) { this.username = username; }
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
Or, if you don't want to extend any class:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package org.hibernate.envers.example;
|
||||
|
||||
import org.hibernate.envers.RevisionNumber;
|
||||
import org.hibernate.envers.RevisionTimestamp;
|
||||
import org.hibernate.envers.RevisionEntity;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@RevisionEntity(ExampleListener.class)
|
||||
public class ExampleRevEntity {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@RevisionNumber
|
||||
private int id;
|
||||
|
||||
@RevisionTimestamp
|
||||
private long timestamp;
|
||||
|
||||
private String username;
|
||||
|
||||
// Getters, setters, equals, hashCode ...
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
An example listener, which, if used in a JBoss Seam application, stores the
|
||||
currently logged in user username:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[package org.hibernate.envers.example;
|
||||
|
||||
import org.hibernate.envers.RevisionListener;
|
||||
import org.jboss.seam.security.Identity;
|
||||
import org.jboss.seam.Component;
|
||||
|
||||
public class ExampleListener implements RevisionListener {
|
||||
public void newRevision(Object revisionEntity) {
|
||||
ExampleRevEntity exampleRevEntity = (ExampleRevEntity) revisionEntity;
|
||||
Identity identity = (Identity) Component.getInstance("org.jboss.seam.security.identity");
|
||||
|
||||
exampleRevEntity.setUsername(identity.getUsername());
|
||||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<para>
|
||||
Having an "empty" revision entity - that is, with no additional properties except the
|
||||
two mandatory ones - is also an easy way to change the names of the table and of the
|
||||
properties in the revisions table automatically generated by Envers.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In case there is no entity annotated with <literal>@RevisionEntity</literal>, a default
|
||||
table will be generated, with the name <literal>REVINFO</literal>.
|
||||
</para>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,631 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="toolsetguide" revision="2">
|
||||
<title>Toolset Guide</title>
|
||||
|
||||
<para>
|
||||
Roundtrip engineering with Hibernate is possible using a set of Eclipse plugins,
|
||||
commandline tools, as well as Ant tasks.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <emphasis>Hibernate Tools</emphasis> currently include plugins for the Eclipse
|
||||
IDE as well as Ant tasks for reverse engineering of existing databases:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
<emphasis>Mapping Editor:</emphasis> An editor for Hibernate XML mapping files,
|
||||
supporting auto-completion and syntax highlighting. It also supports semantic
|
||||
auto-completion for class names and property/field names, making it much more versatile than a normal XML editor.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Console:</emphasis> The console is a new view in Eclipse. In addition to
|
||||
a tree overview of your console configurations, you also get an interactive view
|
||||
of your persistent classes and their relationships. The console allows you to
|
||||
execute HQL queries against your database and browse the result directly in
|
||||
Eclipse.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Development Wizards:</emphasis> Several wizards are provided with the
|
||||
Hibernate Eclipse tools; you can use a wizard to quickly generate Hibernate configuration
|
||||
(cfg.xml) files, or you may even completely reverse engineer an existing database schema
|
||||
into POJO source files and Hibernate mapping files. The reverse engineering wizard
|
||||
supports customizable templates.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Ant Tasks:</emphasis>
|
||||
</para></listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Please refer to the <emphasis>Hibernate Tools</emphasis> package and it's documentation
|
||||
for more information.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
However, the Hibernate main package comes bundled with an integrated tool (it can even
|
||||
be used from "inside" Hibernate on-the-fly): <emphasis>SchemaExport</emphasis> aka
|
||||
<literal>hbm2ddl</literal>.
|
||||
</para>
|
||||
|
||||
<sect1 id="toolsetguide-s1" revision="2">
|
||||
<title>Automatic schema generation</title>
|
||||
|
||||
<para>
|
||||
DDL may be generated from your mapping files by a Hibernate utility. The generated
|
||||
schema includes referential integrity constraints (primary and foreign keys) for
|
||||
entity and collection tables. Tables and sequences are also created for mapped
|
||||
identifier generators.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You <emphasis>must</emphasis> specify a SQL <literal>Dialect</literal> via the
|
||||
<literal>hibernate.dialect</literal> property when using this tool, as DDL
|
||||
is highly vendor specific.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
First, customize your mapping files to improve the generated schema.
|
||||
</para>
|
||||
|
||||
<sect2 id="toolsetguide-s1-2" revision="3">
|
||||
<title>Customizing the schema</title>
|
||||
|
||||
<para>
|
||||
Many Hibernate mapping elements define optional attributes named <literal>length</literal>,
|
||||
<literal>precision</literal> and <literal>scale</literal>. You may set the length, precision
|
||||
and scale of a column with this attribute.
|
||||
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<property name="zip" length="5"/>]]></programlisting>
|
||||
<programlisting><![CDATA[<property name="balance" precision="12" scale="2"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Some tags also accept a <literal>not-null</literal> attribute (for generating a
|
||||
<literal>NOT NULL</literal> constraint on table columns) and a <literal>unique</literal>
|
||||
attribute (for generating <literal>UNIQUE</literal> constraint on table columns).
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<many-to-one name="bar" column="barId" not-null="true"/>]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[<element column="serialNumber" type="long" not-null="true" unique="true"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
A <literal>unique-key</literal> attribute may be used to group columns in
|
||||
a single unique key constraint. Currently, the specified value of the
|
||||
<literal>unique-key</literal> attribute is <emphasis>not</emphasis> used
|
||||
to name the constraint in the generated DDL, only to group the columns in
|
||||
the mapping file.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<many-to-one name="org" column="orgId" unique-key="OrgEmployeeId"/>
|
||||
<property name="employeeId" unique-key="OrgEmployee"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
An <literal>index</literal> attribute specifies the name of an index that
|
||||
will be created using the mapped column or columns. Multiple columns may be
|
||||
grouped into the same index, simply by specifying the same index name.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<property name="lastName" index="CustName"/>
|
||||
<property name="firstName" index="CustName"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
A <literal>foreign-key</literal> attribute may be used to override the name
|
||||
of any generated foreign key constraint.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<many-to-one name="bar" column="barId" foreign-key="FKFooBar"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Many mapping elements also accept a child <literal><column></literal> element.
|
||||
This is particularly useful for mapping multi-column types:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<property name="name" type="my.customtypes.Name"/>
|
||||
<column name="last" not-null="true" index="bar_idx" length="30"/>
|
||||
<column name="first" not-null="true" index="bar_idx" length="20"/>
|
||||
<column name="initial"/>
|
||||
</property>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>default</literal> attribute lets you specify a default value for
|
||||
a column (you should assign the same value to the mapped property before
|
||||
saving a new instance of the mapped class).
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<property name="credits" type="integer" insert="false">
|
||||
<column name="credits" default="10"/>
|
||||
</property>]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[<version name="version" type="integer" insert="false">
|
||||
<column name="version" default="0"/>
|
||||
</property>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>sql-type</literal> attribute allows the user to override the default
|
||||
mapping of a Hibernate type to SQL datatype.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<property name="balance" type="float">
|
||||
<column name="balance" sql-type="decimal(13,3)"/>
|
||||
</property>]]></programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>check</literal> attribute allows you to specify a check constraint.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<property name="foo" type="integer">
|
||||
<column name="foo" check="foo > 10"/>
|
||||
</property>]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[<class name="Foo" table="foos" check="bar < 100.0">
|
||||
...
|
||||
<property name="bar" type="float"/>
|
||||
</class>]]></programlisting>
|
||||
|
||||
|
||||
<table frame="topbot" id="schemattributes-summary" revision="2">
|
||||
<title>Summary</title>
|
||||
<tgroup cols="3">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="2.5*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute</entry>
|
||||
<entry>Values</entry>
|
||||
<entry>Interpretation</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><literal>length</literal></entry>
|
||||
<entry>number</entry>
|
||||
<entry>column length</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>precision</literal></entry>
|
||||
<entry>number</entry>
|
||||
<entry>column decimal precision</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>scale</literal></entry>
|
||||
<entry>number</entry>
|
||||
<entry>column decimal scale</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>not-null</literal></entry>
|
||||
<entry><literal>true|false</literal></entry>
|
||||
<entry>specfies that the column should be non-nullable</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>unique</literal></entry>
|
||||
<entry><literal>true|false</literal></entry>
|
||||
<entry>specifies that the column should have a unique constraint</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>index</literal></entry>
|
||||
<entry><literal>index_name</literal></entry>
|
||||
<entry>specifies the name of a (multi-column) index</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>unique-key</literal></entry>
|
||||
<entry><literal>unique_key_name</literal></entry>
|
||||
<entry>specifies the name of a multi-column unique constraint</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>foreign-key</literal></entry>
|
||||
<entry><literal>foreign_key_name</literal></entry>
|
||||
<entry>
|
||||
specifies the name of the foreign key constraint generated
|
||||
for an association, for a <literal><one-to-one></literal>,
|
||||
<literal><many-to-one></literal>, <literal><key></literal>,
|
||||
or <literal><many-to-many></literal> mapping element. Note that
|
||||
<literal>inverse="true"</literal> sides will not be considered
|
||||
by <literal>SchemaExport</literal>.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>sql-type</literal></entry>
|
||||
<entry><literal>SQL column type</literal></entry>
|
||||
<entry>
|
||||
overrides the default column type (attribute of
|
||||
<literal><column></literal> element only)
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>default</literal></entry>
|
||||
<entry>SQL expression</entry>
|
||||
<entry>
|
||||
specify a default value for the column
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>check</literal></entry>
|
||||
<entry>SQL expression</entry>
|
||||
<entry>
|
||||
create an SQL check constraint on either column or table
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
The <literal><comment></literal> element allows you to specify comments
|
||||
for the generated schema.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Customer" table="CurCust">
|
||||
<comment>Current customers only</comment>
|
||||
...
|
||||
</class>]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[<property name="balance">
|
||||
<column name="bal">
|
||||
<comment>Balance in USD</comment>
|
||||
</column>
|
||||
</property>]]></programlisting>
|
||||
|
||||
<para>
|
||||
This results in a <literal>comment on table</literal> or
|
||||
<literal>comment on column</literal> statement in the generated
|
||||
DDL (where supported).
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="toolsetguide-s1-3" revision="2">
|
||||
<title>Running the tool</title>
|
||||
|
||||
<para>
|
||||
The <literal>SchemaExport</literal> tool writes a DDL script to standard out and/or
|
||||
executes the DDL statements.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis>
|
||||
<literal>org.hibernate.tool.hbm2ddl.SchemaExport</literal> <emphasis>options mapping_files</emphasis>
|
||||
</para>
|
||||
|
||||
<table frame="topbot">
|
||||
<title><literal>SchemaExport</literal> Command Line Options</title>
|
||||
<tgroup cols="2">
|
||||
<colspec colwidth="1.5*"/>
|
||||
<colspec colwidth="2*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Option</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><literal>--quiet</literal></entry>
|
||||
<entry>don't output the script to stdout</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--drop</literal></entry>
|
||||
<entry>only drop the tables</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--create</literal></entry>
|
||||
<entry>only create the tables</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--text</literal></entry>
|
||||
<entry>don't export to the database</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--output=my_schema.ddl</literal></entry>
|
||||
<entry>output the ddl script to a file</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--naming=eg.MyNamingStrategy</literal></entry>
|
||||
<entry>select a <literal>NamingStrategy</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--config=hibernate.cfg.xml</literal></entry>
|
||||
<entry>read Hibernate configuration from an XML file</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--properties=hibernate.properties</literal></entry>
|
||||
<entry>read database properties from a file</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--format</literal></entry>
|
||||
<entry>format the generated SQL nicely in the script</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--delimiter=;</literal></entry>
|
||||
<entry>set an end of line delimiter for the script</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
You may even embed <literal>SchemaExport</literal> in your application:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Configuration cfg = ....;
|
||||
new SchemaExport(cfg).create(false, true);]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="toolsetguide-s1-4">
|
||||
<title>Properties</title>
|
||||
|
||||
<para>
|
||||
Database properties may be specified
|
||||
</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>as system properties with <literal>-D</literal><emphasis><property></emphasis></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>in <literal>hibernate.properties</literal></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>in a named properties file with <literal>--properties</literal></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
The needed properties are:
|
||||
</para>
|
||||
|
||||
<table frame="topbot">
|
||||
<title>SchemaExport Connection Properties</title>
|
||||
<tgroup cols="2">
|
||||
<colspec colwidth="1.5*"/>
|
||||
<colspec colwidth="2*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Property Name</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><literal>hibernate.connection.driver_class</literal></entry>
|
||||
<entry>jdbc driver class</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>hibernate.connection.url</literal></entry>
|
||||
<entry>jdbc url</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>hibernate.connection.username</literal></entry>
|
||||
<entry>database user</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>hibernate.connection.password</literal></entry>
|
||||
<entry>user password</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>hibernate.dialect</literal></entry>
|
||||
<entry>dialect</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="toolsetguide-s1-5">
|
||||
<title>Using Ant</title>
|
||||
|
||||
<para>
|
||||
You can call <literal>SchemaExport</literal> from your Ant build script:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<target name="schemaexport">
|
||||
<taskdef name="schemaexport"
|
||||
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
|
||||
classpathref="class.path"/>
|
||||
|
||||
<schemaexport
|
||||
properties="hibernate.properties"
|
||||
quiet="no"
|
||||
text="no"
|
||||
drop="no"
|
||||
delimiter=";"
|
||||
output="schema-export.sql">
|
||||
<fileset dir="src">
|
||||
<include name="**/*.hbm.xml"/>
|
||||
</fileset>
|
||||
</schemaexport>
|
||||
</target>]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="toolsetguide-s1-6" revision="2">
|
||||
<title>Incremental schema updates</title>
|
||||
|
||||
<para>
|
||||
The <literal>SchemaUpdate</literal> tool will update an existing schema with "incremental" changes.
|
||||
Note that <literal>SchemaUpdate</literal> depends heavily upon the JDBC metadata API, so it will
|
||||
not work with all JDBC drivers.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis>
|
||||
<literal>org.hibernate.tool.hbm2ddl.SchemaUpdate</literal> <emphasis>options mapping_files</emphasis>
|
||||
</para>
|
||||
|
||||
<table frame="topbot">
|
||||
<title><literal>SchemaUpdate</literal> Command Line Options</title>
|
||||
<tgroup cols="2">
|
||||
<colspec colwidth="1.5*"/>
|
||||
<colspec colwidth="2*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Option</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><literal>--quiet</literal></entry>
|
||||
<entry>don't output the script to stdout</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--text</literal></entry>
|
||||
<entry>don't export the script to the database</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--naming=eg.MyNamingStrategy</literal></entry>
|
||||
<entry>select a <literal>NamingStrategy</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--properties=hibernate.properties</literal></entry>
|
||||
<entry>read database properties from a file</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--config=hibernate.cfg.xml</literal></entry>
|
||||
<entry>specify a <literal>.cfg.xml</literal> file</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
You may embed <literal>SchemaUpdate</literal> in your application:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Configuration cfg = ....;
|
||||
new SchemaUpdate(cfg).execute(false);]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="toolsetguide-s1-7">
|
||||
<title>Using Ant for incremental schema updates</title>
|
||||
|
||||
<para>
|
||||
You can call <literal>SchemaUpdate</literal> from the Ant script:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<target name="schemaupdate">
|
||||
<taskdef name="schemaupdate"
|
||||
classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
|
||||
classpathref="class.path"/>
|
||||
|
||||
<schemaupdate
|
||||
properties="hibernate.properties"
|
||||
quiet="no">
|
||||
<fileset dir="src">
|
||||
<include name="**/*.hbm.xml"/>
|
||||
</fileset>
|
||||
</schemaupdate>
|
||||
</target>]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="toolsetguide-s1-8" revision="1">
|
||||
<title>Schema validation</title>
|
||||
|
||||
<para>
|
||||
The <literal>SchemaValidator</literal> tool will validate that the existing database schema "matches"
|
||||
your mapping documents. Note that <literal>SchemaValidator</literal> depends heavily upon the JDBC
|
||||
metadata API, so it will not work with all JDBC drivers. This tool is extremely useful for testing.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis>
|
||||
<literal>org.hibernate.tool.hbm2ddl.SchemaValidator</literal> <emphasis>options mapping_files</emphasis>
|
||||
</para>
|
||||
|
||||
<table frame="topbot">
|
||||
<title><literal>SchemaValidator</literal> Command Line Options</title>
|
||||
<tgroup cols="2">
|
||||
<colspec colwidth="1.5*"/>
|
||||
<colspec colwidth="2*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Option</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><literal>--naming=eg.MyNamingStrategy</literal></entry>
|
||||
<entry>select a <literal>NamingStrategy</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--properties=hibernate.properties</literal></entry>
|
||||
<entry>read database properties from a file</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>--config=hibernate.cfg.xml</literal></entry>
|
||||
<entry>specify a <literal>.cfg.xml</literal> file</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
You may embed <literal>SchemaValidator</literal> in your application:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Configuration cfg = ....;
|
||||
new SchemaValidator(cfg).validate();]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="toolsetguide-s1-9">
|
||||
<title>Using Ant for schema validation</title>
|
||||
|
||||
<para>
|
||||
You can call <literal>SchemaValidator</literal> from the Ant script:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<target name="schemavalidate">
|
||||
<taskdef name="schemavalidator"
|
||||
classname="org.hibernate.tool.hbm2ddl.SchemaValidatorTask"
|
||||
classpathref="class.path"/>
|
||||
|
||||
<schemavalidator
|
||||
properties="hibernate.properties">
|
||||
<fileset dir="src">
|
||||
<include name="**/*.hbm.xml"/>
|
||||
</fileset>
|
||||
</schemavalidator>
|
||||
</target>]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
@ -0,0 +1,313 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<chapter id="xml">
|
||||
<title>XML Mapping</title>
|
||||
|
||||
<para><emphasis>
|
||||
Note that this is an experimental feature in Hibernate 3.0 and is under
|
||||
extremely active development.
|
||||
</emphasis></para>
|
||||
|
||||
<sect1 id="xml-intro" revision="1">
|
||||
<title>Working with XML data</title>
|
||||
|
||||
<para>
|
||||
Hibernate lets you work with persistent XML data in much the same way
|
||||
you work with persistent POJOs. A parsed XML tree can be thought of
|
||||
as just another way to represent the relational data at the object level,
|
||||
instead of POJOs.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Hibernate supports dom4j as API for manipulating XML trees. You can write
|
||||
queries that retrieve dom4j trees from the database and have any
|
||||
modification you make to the tree automatically synchronized to the
|
||||
database. You can even take an XML document, parse it using dom4j, and
|
||||
write it to the database with any of Hibernate's basic operations:
|
||||
<literal>persist(), saveOrUpdate(), merge(), delete(), replicate()</literal>
|
||||
(merging is not yet supported).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This feature has many applications including data import/export,
|
||||
externalization of entity data via JMS or SOAP and XSLT-based reporting.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A single mapping may be used to simultaneously map properties of a class
|
||||
and nodes of an XML document to the database, or, if there is no class to map,
|
||||
it may be used to map just the XML.
|
||||
</para>
|
||||
|
||||
<sect2 id="xml-intro-mapping">
|
||||
<title>Specifying XML and class mapping together</title>
|
||||
|
||||
<para>
|
||||
Here is an example of mapping a POJO and XML simultaneously:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Account"
|
||||
table="ACCOUNTS"
|
||||
node="account">
|
||||
|
||||
<id name="accountId"
|
||||
column="ACCOUNT_ID"
|
||||
node="@id"/>
|
||||
|
||||
<many-to-one name="customer"
|
||||
column="CUSTOMER_ID"
|
||||
node="customer/@id"
|
||||
embed-xml="false"/>
|
||||
|
||||
<property name="balance"
|
||||
column="BALANCE"
|
||||
node="balance"/>
|
||||
|
||||
...
|
||||
|
||||
</class>]]></programlisting>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="xml-onlyxml">
|
||||
<title>Specifying only an XML mapping</title>
|
||||
|
||||
<para>
|
||||
Here is an example where there is no POJO class:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class entity-name="Account"
|
||||
table="ACCOUNTS"
|
||||
node="account">
|
||||
|
||||
<id name="id"
|
||||
column="ACCOUNT_ID"
|
||||
node="@id"
|
||||
type="string"/>
|
||||
|
||||
<many-to-one name="customerId"
|
||||
column="CUSTOMER_ID"
|
||||
node="customer/@id"
|
||||
embed-xml="false"
|
||||
entity-name="Customer"/>
|
||||
|
||||
<property name="balance"
|
||||
column="BALANCE"
|
||||
node="balance"
|
||||
type="big_decimal"/>
|
||||
|
||||
...
|
||||
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
This mapping allows you to access the data as a dom4j tree, or as a graph of
|
||||
property name/value pairs (java <literal>Map</literal>s). The property names
|
||||
are purely logical constructs that may be referred to in HQL queries.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="xml-mapping" revision="1">
|
||||
<title>XML mapping metadata</title>
|
||||
|
||||
<para>
|
||||
Many Hibernate mapping elements accept the <literal>node</literal> attribute.
|
||||
This let's you specify the name of an XML attribute or element that holds the
|
||||
property or entity data. The format of the <literal>node</literal> attribute
|
||||
must be one of the following:
|
||||
</para>
|
||||
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para><literal>"element-name"</literal> - map to the named XML element</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><literal>"@attribute-name"</literal> - map to the named XML attribute</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><literal>"."</literal> - map to the parent element</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>"element-name/@attribute-name"</literal> -
|
||||
map to the named attribute of the named element
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
For collections and single valued associations, there is an additional
|
||||
<literal>embed-xml</literal> attribute. If <literal>embed-xml="true"</literal>,
|
||||
the default, the XML tree for the associated entity (or collection of value type)
|
||||
will be embedded directly in the XML tree for the entity that owns the association.
|
||||
Otherwise, if <literal>embed-xml="false"</literal>, then only the referenced
|
||||
identifier value will appear in the XML for single point associations and
|
||||
collections will simply not appear at all.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You should be careful not to leave <literal>embed-xml="true"</literal> for
|
||||
too many associations, since XML does not deal well with circularity!
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<class name="Customer"
|
||||
table="CUSTOMER"
|
||||
node="customer">
|
||||
|
||||
<id name="id"
|
||||
column="CUST_ID"
|
||||
node="@id"/>
|
||||
|
||||
<map name="accounts"
|
||||
node="."
|
||||
embed-xml="true">
|
||||
<key column="CUSTOMER_ID"
|
||||
not-null="true"/>
|
||||
<map-key column="SHORT_DESC"
|
||||
node="@short-desc"
|
||||
type="string"/>
|
||||
<one-to-many entity-name="Account"
|
||||
embed-xml="false"
|
||||
node="account"/>
|
||||
</map>
|
||||
|
||||
<component name="name"
|
||||
node="name">
|
||||
<property name="firstName"
|
||||
node="first-name"/>
|
||||
<property name="initial"
|
||||
node="initial"/>
|
||||
<property name="lastName"
|
||||
node="last-name"/>
|
||||
</component>
|
||||
|
||||
...
|
||||
|
||||
</class>]]></programlisting>
|
||||
|
||||
<para>
|
||||
in this case, we have decided to embed the collection of account ids, but not
|
||||
the actual account data. The following HQL query:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[from Customer c left join fetch c.accounts where c.lastName like :lastName]]></programlisting>
|
||||
|
||||
<para>
|
||||
Would return datasets such as this:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<customer id="123456789">
|
||||
<account short-desc="Savings">987632567</account>
|
||||
<account short-desc="Credit Card">985612323</account>
|
||||
<name>
|
||||
<first-name>Gavin</first-name>
|
||||
<initial>A</initial>
|
||||
<last-name>King</last-name>
|
||||
</name>
|
||||
...
|
||||
</customer>]]></programlisting>
|
||||
|
||||
<para>
|
||||
If you set <literal>embed-xml="true"</literal> on the <literal><one-to-many></literal>
|
||||
mapping, the data might look more like this:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<customer id="123456789">
|
||||
<account id="987632567" short-desc="Savings">
|
||||
<customer id="123456789"/>
|
||||
<balance>100.29</balance>
|
||||
</account>
|
||||
<account id="985612323" short-desc="Credit Card">
|
||||
<customer id="123456789"/>
|
||||
<balance>-2370.34</balance>
|
||||
</account>
|
||||
<name>
|
||||
<first-name>Gavin</first-name>
|
||||
<initial>A</initial>
|
||||
<last-name>King</last-name>
|
||||
</name>
|
||||
...
|
||||
</customer>]]></programlisting>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1 id="xml-manipulation" revision="1">
|
||||
<title>Manipulating XML data</title>
|
||||
|
||||
<para>
|
||||
Let's rearead and update XML documents in the application. We do this by
|
||||
obtaining a dom4j session:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[Document doc = ....;
|
||||
|
||||
Session session = factory.openSession();
|
||||
Session dom4jSession = session.getSession(EntityMode.DOM4J);
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
List results = dom4jSession
|
||||
.createQuery("from Customer c left join fetch c.accounts where c.lastName like :lastName")
|
||||
.list();
|
||||
for ( int i=0; i<results.size(); i++ ) {
|
||||
//add the customer data to the XML document
|
||||
Element customer = (Element) results.get(i);
|
||||
doc.add(customer);
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[Session session = factory.openSession();
|
||||
Session dom4jSession = session.getSession(EntityMode.DOM4J);
|
||||
Transaction tx = session.beginTransaction();
|
||||
|
||||
Element cust = (Element) dom4jSession.get("Customer", customerId);
|
||||
for ( int i=0; i<results.size(); i++ ) {
|
||||
Element customer = (Element) results.get(i);
|
||||
//change the customer name in the XML and database
|
||||
Element name = customer.element("name");
|
||||
name.element("first-name").setText(firstName);
|
||||
name.element("initial").setText(initial);
|
||||
name.element("last-name").setText(lastName);
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
session.close();]]></programlisting>
|
||||
|
||||
<para>
|
||||
It is extremely useful to combine this feature with Hibernate's <literal>replicate()</literal>
|
||||
operation to implement XML-based data import/export.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 9.1 KiB |
|
@ -0,0 +1,429 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
|
||||
[
|
||||
<!ATTLIST svg
|
||||
xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
|
||||
]>
|
||||
<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="354.331"
|
||||
height="336.614"
|
||||
id="svg1">
|
||||
<defs
|
||||
id="defs3">
|
||||
<linearGradient
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="1"
|
||||
y2="0"
|
||||
id="linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop128" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop129" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="1"
|
||||
y2="0"
|
||||
id="linearGradient130"
|
||||
xlink:href="#linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad" />
|
||||
<radialGradient
|
||||
cx="0.5"
|
||||
cy="0.5"
|
||||
fx="0.5"
|
||||
fy="0.5"
|
||||
r="0.5"
|
||||
id="radialGradient131"
|
||||
xlink:href="#linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad" />
|
||||
</defs>
|
||||
<g
|
||||
transform="matrix(0.823795,0,0,0.823795,0.120302,5.25349)"
|
||||
style="font-size:12;"
|
||||
id="g659">
|
||||
<rect
|
||||
width="212.257"
|
||||
height="57.2441"
|
||||
x="17.9576"
|
||||
y="100.132"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect137" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
transform="matrix(0.743454,0,0,0.482981,6.46949,52.2178)"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect132" />
|
||||
</g>
|
||||
<rect
|
||||
width="325.86"
|
||||
height="63.6537"
|
||||
x="17.4083"
|
||||
y="15.194"
|
||||
style="font-size:12;fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect136" />
|
||||
<rect
|
||||
width="325.86"
|
||||
height="63.6537"
|
||||
x="13.6713"
|
||||
y="12.4966"
|
||||
style="font-size:12;fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect126" />
|
||||
<g
|
||||
transform="matrix(1.14345,0,0,0.729078,-1.67818,105.325)"
|
||||
style="font-size:12;"
|
||||
id="g164">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="16.6979"
|
||||
y="222.966"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect138" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="14.7335"
|
||||
y="221.002"
|
||||
transform="translate(-1.30962,-1.30992)"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect133" />
|
||||
</g>
|
||||
<text
|
||||
x="170.824753"
|
||||
y="58.402939"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:18;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text183">
|
||||
<tspan
|
||||
x="170.824997"
|
||||
y="58.402901"
|
||||
id="tspan360">
|
||||
Application</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="178.076340"
|
||||
y="364.281433"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:18;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text197">
|
||||
<tspan
|
||||
x="178.076004"
|
||||
y="364.281006"
|
||||
id="tspan421">
|
||||
Database</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="68.605331"
|
||||
y="138.524582"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text216">
|
||||
<tspan
|
||||
x="68.605301"
|
||||
y="138.524994"
|
||||
id="tspan384">
|
||||
SessionFactory</tspan>
|
||||
</text>
|
||||
<rect
|
||||
width="67.0014"
|
||||
height="101.35"
|
||||
x="196.927"
|
||||
y="89.2389"
|
||||
style="font-size:12;fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect387" />
|
||||
<rect
|
||||
width="67.0014"
|
||||
height="101.35"
|
||||
x="194.633"
|
||||
y="86.4389"
|
||||
style="font-size:12;fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect388" />
|
||||
<text
|
||||
x="249.108841"
|
||||
y="173.885559"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text389">
|
||||
<tspan
|
||||
x="249.108994"
|
||||
y="173.886002"
|
||||
id="tspan392">
|
||||
Session</tspan>
|
||||
</text>
|
||||
<rect
|
||||
width="73.0355"
|
||||
height="101.35"
|
||||
x="270.995"
|
||||
y="90.0018"
|
||||
style="font-size:12;fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect395" />
|
||||
<rect
|
||||
width="73.0355"
|
||||
height="101.35"
|
||||
x="267.869"
|
||||
y="87.2018"
|
||||
style="font-size:12;fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect396" />
|
||||
<text
|
||||
x="328.593658"
|
||||
y="174.715622"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text397">
|
||||
<tspan
|
||||
x="328.593994"
|
||||
y="174.716003"
|
||||
id="tspan563">
|
||||
Transaction</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.29544,0,0,0.397877,9.70533,103.96)"
|
||||
style="font-size:12;"
|
||||
id="g565">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect566" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect567" />
|
||||
</g>
|
||||
<text
|
||||
x="25.592752"
|
||||
y="204.497803"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:10;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text568">
|
||||
<tspan
|
||||
x="25.592800"
|
||||
y="204.498001"
|
||||
id="tspan662">
|
||||
TransactionFactory</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.298082,0,0,0.397877,99.6898,103.96)"
|
||||
style="font-size:12;"
|
||||
id="g573">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect574" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect575" />
|
||||
</g>
|
||||
<text
|
||||
x="134.030670"
|
||||
y="205.532791"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:10;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text576">
|
||||
<tspan
|
||||
x="134.031006"
|
||||
y="205.533005"
|
||||
id="tspan664">
|
||||
ConnectionProvider</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(1.14345,0,0,0.729078,-1.67818,38.9539)"
|
||||
style="font-size:12;"
|
||||
id="g587">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="16.6979"
|
||||
y="222.966"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect588" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="14.7335"
|
||||
y="221.002"
|
||||
transform="translate(-1.30962,-1.30992)"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect589" />
|
||||
</g>
|
||||
<rect
|
||||
width="90.951"
|
||||
height="44.4829"
|
||||
x="25.6196"
|
||||
y="206.028"
|
||||
style="font-size:12;fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect594" />
|
||||
<rect
|
||||
width="90.951"
|
||||
height="44.4829"
|
||||
x="24.4229"
|
||||
y="204.135"
|
||||
style="font-size:12;fill:#b3b3b3;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect595" />
|
||||
<text
|
||||
x="85.575645"
|
||||
y="282.300354"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:18;font-weight:normal;stroke-width:1pt;font-family:Helvetica;text-anchor:middle;"
|
||||
id="text596">
|
||||
<tspan
|
||||
x="85.575600"
|
||||
y="282.299988"
|
||||
id="tspan607">
|
||||
JNDI</tspan>
|
||||
</text>
|
||||
<rect
|
||||
width="90.951"
|
||||
height="44.4829"
|
||||
x="236.937"
|
||||
y="206.791"
|
||||
style="font-size:12;fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect610" />
|
||||
<rect
|
||||
width="90.951"
|
||||
height="44.4829"
|
||||
x="235.741"
|
||||
y="204.898"
|
||||
style="font-size:12;fill:#b3b3b3;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect611" />
|
||||
<text
|
||||
x="342.093201"
|
||||
y="283.226410"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:18;font-weight:normal;stroke-width:1pt;font-family:Helvetica;text-anchor:middle;"
|
||||
id="text612">
|
||||
<tspan
|
||||
x="342.092987"
|
||||
y="283.226013"
|
||||
id="tspan621">
|
||||
JTA</tspan>
|
||||
</text>
|
||||
<rect
|
||||
width="90.951"
|
||||
height="44.4829"
|
||||
x="130.134"
|
||||
y="206.791"
|
||||
style="font-size:12;fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect616" />
|
||||
<rect
|
||||
width="90.951"
|
||||
height="44.4829"
|
||||
x="128.937"
|
||||
y="204.898"
|
||||
style="font-size:12;fill:#b3b3b3;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect617" />
|
||||
<text
|
||||
x="212.445343"
|
||||
y="283.226410"
|
||||
transform="scale(0.823795,0.823795)"
|
||||
style="font-size:18;font-weight:normal;stroke-width:1pt;font-family:Helvetica;text-anchor:middle;"
|
||||
id="text618">
|
||||
<tspan
|
||||
x="212.445007"
|
||||
y="283.226013"
|
||||
id="tspan623">
|
||||
JDBC</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.823795,0,0,0.823795,0.120302,6.19341)"
|
||||
style="font-size:12;"
|
||||
id="g637">
|
||||
<g
|
||||
transform="matrix(0.499515,0,0,0.415467,-0.237339,5.61339)"
|
||||
id="g167">
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="61.8805"
|
||||
y="68.4288"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect134" />
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="59.2613"
|
||||
y="65.8095"
|
||||
style="fill:#e0e0e0;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect135" />
|
||||
</g>
|
||||
<text
|
||||
x="33.749969"
|
||||
y="50.589706"
|
||||
style="font-size:11;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text188">
|
||||
<tspan
|
||||
x="33.750000"
|
||||
y="50.589699"
|
||||
id="tspan635">
|
||||
Transient Objects</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.823795,0,0,0.823795,0.120302,5.25349)"
|
||||
style="font-size:12;"
|
||||
id="g644">
|
||||
<g
|
||||
transform="matrix(0.297486,0,0,0.516482,230.251,36.9178)"
|
||||
id="g364">
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="61.8805"
|
||||
y="68.4288"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect365" />
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="59.2613"
|
||||
y="65.8095"
|
||||
style="fill:#e0e0e0;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect366" />
|
||||
</g>
|
||||
<text
|
||||
x="277.123230"
|
||||
y="85.155571"
|
||||
style="font-size:11;font-weight:normal;stroke-width:1pt;font-family:Helvetica;text-anchor:middle;"
|
||||
id="text367">
|
||||
<tspan
|
||||
x="277.122986"
|
||||
y="85.155602"
|
||||
id="tspan631">
|
||||
Persistent</tspan>
|
||||
<tspan
|
||||
x="277.122986"
|
||||
y="96.155602"
|
||||
id="tspan633">
|
||||
Objects</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 6.7 KiB |
|
@ -0,0 +1,334 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
|
||||
[
|
||||
<!ATTLIST svg
|
||||
xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
|
||||
]>
|
||||
<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="318.898"
|
||||
height="248.031"
|
||||
id="svg1">
|
||||
<defs
|
||||
id="defs3">
|
||||
<linearGradient
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="1"
|
||||
y2="0"
|
||||
id="linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop128" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop129" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="1"
|
||||
y2="0"
|
||||
id="linearGradient130"
|
||||
xlink:href="#linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad" />
|
||||
<radialGradient
|
||||
cx="0.5"
|
||||
cy="0.5"
|
||||
fx="0.5"
|
||||
fy="0.5"
|
||||
r="0.5"
|
||||
id="radialGradient131"
|
||||
xlink:href="#linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad" />
|
||||
</defs>
|
||||
<rect
|
||||
width="291.837"
|
||||
height="57.0074"
|
||||
x="17.3169"
|
||||
y="18.646"
|
||||
style="font-size:12;fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect136" />
|
||||
<rect
|
||||
width="291.837"
|
||||
height="57.0074"
|
||||
x="13.9703"
|
||||
y="16.2302"
|
||||
style="font-size:12;fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect126" />
|
||||
<g
|
||||
transform="matrix(0.326107,0,0,0.765831,9.59261,8.98517)"
|
||||
style="font-size:12;"
|
||||
id="g161">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect137" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect132" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(1.02406,0,0,0.652953,0.223384,39.9254)"
|
||||
style="font-size:12;"
|
||||
id="g164">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="16.6979"
|
||||
y="222.966"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect138" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="14.7335"
|
||||
y="221.002"
|
||||
transform="translate(-1.30962,-1.30992)"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect133" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.449834,0,0,0.338463,-3.15909,9.73319)"
|
||||
style="font-size:12;"
|
||||
id="g167">
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="61.8805"
|
||||
y="68.4288"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect134" />
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="59.2613"
|
||||
y="65.8095"
|
||||
style="fill:#e0e0e0;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect135" />
|
||||
</g>
|
||||
<text
|
||||
x="302.277679"
|
||||
y="65.943230"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:18;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text183">
|
||||
<tspan
|
||||
x="302.277954"
|
||||
y="65.943184"
|
||||
id="tspan360">
|
||||
Application</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="36.235924"
|
||||
y="63.796055"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:14;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text188">
|
||||
<tspan
|
||||
x="36.235950"
|
||||
y="63.796051"
|
||||
id="tspan427">
|
||||
Transient Objects</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="180.416245"
|
||||
y="290.543701"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:18;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text197">
|
||||
<tspan
|
||||
x="180.415939"
|
||||
y="290.543549"
|
||||
id="tspan421">
|
||||
Database</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="25.037701"
|
||||
y="179.154755"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text216">
|
||||
<tspan
|
||||
x="25.037655"
|
||||
y="179.154648"
|
||||
id="tspan384">
|
||||
SessionFactory</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.252763,0,0,0.765831,109.104,8.98517)"
|
||||
style="font-size:12;"
|
||||
id="g386">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect387" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect388" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.297394,0,0,0.572692,101.502,21.6359)"
|
||||
style="font-size:12;"
|
||||
id="g364">
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="61.8805"
|
||||
y="68.4288"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect365" />
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="59.2613"
|
||||
y="65.8095"
|
||||
style="fill:#e0e0e0;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect366" />
|
||||
</g>
|
||||
<text
|
||||
x="202.746506"
|
||||
y="102.992203"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:14;font-weight:normal;stroke-width:1pt;font-family:Helvetica;text-anchor:middle;"
|
||||
id="text367">
|
||||
<tspan
|
||||
x="202.746948"
|
||||
y="102.992249"
|
||||
id="tspan423">
|
||||
Persistent</tspan>
|
||||
<tspan
|
||||
x="202.746948"
|
||||
y="116.992355"
|
||||
id="tspan425">
|
||||
Objects</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="174.458496"
|
||||
y="180.080795"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text389">
|
||||
<tspan
|
||||
x="174.458618"
|
||||
y="180.080338"
|
||||
id="tspan392">
|
||||
Session</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.127369,0,0,0.765831,188.675,8.98517)"
|
||||
style="font-size:12;"
|
||||
id="g394">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect395" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect396" />
|
||||
</g>
|
||||
<text
|
||||
x="260.413269"
|
||||
y="179.154739"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text397">
|
||||
<tspan
|
||||
x="260.412964"
|
||||
y="179.154343"
|
||||
id="tspan400">
|
||||
JDBC</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.127369,0,0,0.765831,229.156,8.98517)"
|
||||
style="font-size:12;"
|
||||
id="g405">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect406" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect407" />
|
||||
</g>
|
||||
<text
|
||||
x="320.606903"
|
||||
y="179.154739"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text408">
|
||||
<tspan
|
||||
x="320.606964"
|
||||
y="179.154343"
|
||||
id="tspan417">
|
||||
JNDI</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.127369,0,0,0.765831,269.281,8.98517)"
|
||||
style="font-size:12;"
|
||||
id="g411">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect412" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect413" />
|
||||
</g>
|
||||
<text
|
||||
x="377.096313"
|
||||
y="179.154739"
|
||||
transform="scale(0.73778,0.73778)"
|
||||
style="font-size:16;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text414">
|
||||
<tspan
|
||||
x="377.096008"
|
||||
y="179.154999"
|
||||
id="tspan145">
|
||||
JTA</tspan>
|
||||
</text>
|
||||
</svg>
|
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 8.2 KiB |
|
@ -0,0 +1,250 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
|
||||
[
|
||||
<!ATTLIST svg
|
||||
xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
|
||||
]>
|
||||
<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="248.031"
|
||||
height="248.031"
|
||||
id="svg1">
|
||||
<defs
|
||||
id="defs3">
|
||||
<linearGradient
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="1"
|
||||
y2="0"
|
||||
id="linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop128" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop129" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="1"
|
||||
y2="0"
|
||||
id="linearGradient130"
|
||||
xlink:href="#linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad" />
|
||||
<radialGradient
|
||||
cx="0.5"
|
||||
cy="0.5"
|
||||
fx="0.5"
|
||||
fy="0.5"
|
||||
r="0.5"
|
||||
id="radialGradient131"
|
||||
xlink:href="#linearGradient127"
|
||||
gradientUnits="objectBoundingBox"
|
||||
spreadMethod="pad" />
|
||||
</defs>
|
||||
<g
|
||||
transform="matrix(0.771934,0,0,0.771934,4.36019,-3.02123)"
|
||||
style="font-size:12;"
|
||||
id="g158">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="16.6979"
|
||||
y="17.3527"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect136" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="14.7335"
|
||||
y="15.3883"
|
||||
transform="translate(-1.30962,-1.30992)"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect126" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.771934,0,0,0.771934,4.36019,3.04452)"
|
||||
style="font-size:12;"
|
||||
id="g161">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="16.6979"
|
||||
y="99.2053"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect137" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="118.523"
|
||||
x="13.4238"
|
||||
y="95.9309"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect132" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.771934,0,0,0.771934,4.36019,8.0993)"
|
||||
style="font-size:12;"
|
||||
id="g164">
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="16.6979"
|
||||
y="222.966"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect138" />
|
||||
<rect
|
||||
width="285.502"
|
||||
height="77.2688"
|
||||
x="14.7335"
|
||||
y="221.002"
|
||||
transform="translate(-1.30962,-1.30992)"
|
||||
style="fill:#d2d2d2;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect133" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.771934,0,0,0.543505,2.59104,21.1103)"
|
||||
style="font-size:12;"
|
||||
id="g167">
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="61.8805"
|
||||
y="68.4288"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect134" />
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="59.2613"
|
||||
y="65.8095"
|
||||
style="fill:#e0e0e0;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect135" />
|
||||
</g>
|
||||
<text
|
||||
x="105.392174"
|
||||
y="56.568123"
|
||||
transform="scale(0.771934,0.771934)"
|
||||
style="font-size:24;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text183">
|
||||
<tspan
|
||||
x="105.392273"
|
||||
y="56.568146"
|
||||
id="tspan186">
|
||||
Application</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="81.820183"
|
||||
y="103.149330"
|
||||
transform="scale(0.771934,0.771934)"
|
||||
style="font-size:20;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text188">
|
||||
<tspan
|
||||
x="81.820213"
|
||||
y="103.149727"
|
||||
id="tspan206">
|
||||
Persistent Objects</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="111.548180"
|
||||
y="278.927887"
|
||||
transform="scale(0.771934,0.771934)"
|
||||
style="font-size:24;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text197">
|
||||
<tspan
|
||||
x="111.547874"
|
||||
y="278.927551"
|
||||
id="tspan200">
|
||||
Database</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="94.436180"
|
||||
y="153.805740"
|
||||
transform="scale(0.771934,0.771934)"
|
||||
style="font-size:24;font-weight:normal;stroke-width:1pt;font-family:Helvetica;"
|
||||
id="text216">
|
||||
<tspan
|
||||
x="94.436180"
|
||||
y="153.805740"
|
||||
id="tspan221">
|
||||
HIBERNATE</tspan>
|
||||
</text>
|
||||
<g
|
||||
transform="matrix(0.771934,0,0,0.771934,2.59083,1.02261)"
|
||||
style="font-size:12;"
|
||||
id="g254">
|
||||
<g
|
||||
transform="translate(4.58374,2.61928)"
|
||||
id="g176">
|
||||
<g
|
||||
transform="matrix(0.571429,0,0,0.67347,-10.6174,117.093)"
|
||||
id="g170">
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="61.8805"
|
||||
y="68.4288"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect171" />
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="59.2613"
|
||||
y="65.8095"
|
||||
style="fill:#e0e0e0;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect172" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.571429,0,0,0.67347,138.682,117.093)"
|
||||
id="g173">
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="61.8805"
|
||||
y="68.4288"
|
||||
style="fill:#757575;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect174" />
|
||||
<rect
|
||||
width="199.065"
|
||||
height="61.5532"
|
||||
x="59.2613"
|
||||
y="65.8095"
|
||||
style="fill:#e0e0e0;fill-rule:evenodd;stroke-width:1pt;"
|
||||
id="rect175" />
|
||||
</g>
|
||||
</g>
|
||||
<text
|
||||
x="47.259438"
|
||||
y="182.367538"
|
||||
style="font-weight:bold;stroke-width:1pt;font-family:Courier;"
|
||||
id="text191">
|
||||
<tspan
|
||||
x="47.259399"
|
||||
y="182.367996"
|
||||
id="tspan212">
|
||||
hibernate.</tspan>
|
||||
<tspan
|
||||
x="47.259399"
|
||||
y="194.367996"
|
||||
id="tspan214">
|
||||
properties</tspan>
|
||||
</text>
|
||||
<text
|
||||
x="198.523010"
|
||||
y="188.260941"
|
||||
style="font-weight:normal;stroke-width:1pt;font-family:helvetica;"
|
||||
id="text194">
|
||||
<tspan
|
||||
id="tspan195">
|
||||
XML Mapping</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.5 KiB |
|
@ -0,0 +1,154 @@
|
|||
<?xml version='1.0' encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||
~
|
||||
~ 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
|
||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
~ for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public License
|
||||
~ along with this distribution; if not, write to:
|
||||
~ Free Software Foundation, Inc.
|
||||
~ 51 Franklin Street, Fifth Floor
|
||||
~ Boston, MA 02110-1301 USA
|
||||
-->
|
||||
|
||||
<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
||||
|
||||
<authorgroup id="AuthorGroup">
|
||||
|
||||
<!--
|
||||
#######################################################################
|
||||
# Spanish
|
||||
#######################################################################
|
||||
-->
|
||||
<othercredit class="translator" lang="es-ES">
|
||||
<othername><![CDATA[Bernardo Antonio Buffa Colomé]]></othername>
|
||||
<email>kreimer@bbs.frc.utn.edu.ar</email>
|
||||
</othercredit>
|
||||
|
||||
<!--
|
||||
#######################################################################
|
||||
# French
|
||||
#######################################################################
|
||||
-->
|
||||
<othercredit class="translator" lang="fr-FR">
|
||||
<firstname>Vincent</firstname>
|
||||
<surname>Ricard</surname>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="fr-FR">
|
||||
<firstname>Sebastien</firstname>
|
||||
<surname>Cesbron</surname>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="fr-FR">
|
||||
<firstname>Michael</firstname>
|
||||
<surname>Courcy</surname>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="fr-FR">
|
||||
<firstname>Vincent</firstname>
|
||||
<surname>Giguère</surname>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="fr-FR">
|
||||
<firstname>Baptiste</firstname>
|
||||
<surname>Mathus</surname>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="fr-FR">
|
||||
<firstname>Emmanuel</firstname>
|
||||
<surname>Bernard</surname>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="fr-FR">
|
||||
<firstname>Anthony</firstname>
|
||||
<surname>Patricio</surname>
|
||||
</othercredit>
|
||||
|
||||
<!--
|
||||
#######################################################################
|
||||
# Portugese
|
||||
#######################################################################
|
||||
-->
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Alvaro</firstname>
|
||||
<surname>Netto</surname>
|
||||
<email>alvaronetto@cetip.com.br</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Anderson</firstname>
|
||||
<surname>Braulio</surname>
|
||||
<email>andersonbraulio@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Daniel Vieira</firstname>
|
||||
<surname>Costa</surname>
|
||||
<email>danielvc@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Francisco</firstname>
|
||||
<surname>gamarra</surname>
|
||||
<email>francisco.gamarra@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Gamarra</firstname>
|
||||
<email>mauricio.gamarra@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Luiz Carlos</firstname>
|
||||
<surname>Rodrigues</surname>
|
||||
<email>luizcarlos_rodrigues@yahoo.com.br</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Marcel</firstname>
|
||||
<surname>Castelo</surname>
|
||||
<email>marcel.castelo@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Paulo</firstname>
|
||||
<surname>César</surname>
|
||||
<email>paulocol@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Pablo L.</firstname>
|
||||
<surname>de Miranda</surname>
|
||||
<email>pablolmiranda@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Renato</firstname>
|
||||
<surname>Deggau</surname>
|
||||
<email>rdeggau@gmail.com</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Rogério</firstname>
|
||||
<surname>Araújo</surname>
|
||||
<email>rgildoaraujo@yahoo.com.br</email>
|
||||
</othercredit>
|
||||
<othercredit class="translator" lang="pt-BR">
|
||||
<firstname>Wanderson</firstname>
|
||||
<surname>Siqueira</surname>
|
||||
<email>wandersonxs@gmail.com</email>
|
||||
</othercredit>
|
||||
|
||||
<!--
|
||||
#######################################################################
|
||||
# Chinese
|
||||
#######################################################################
|
||||
-->
|
||||
<othercredit class="translator" lang="zh-CN">
|
||||
<firstname>Cao</firstname>
|
||||
<surname>Xiaogang</surname>
|
||||
<affiliation>
|
||||
<orgname>RedSaga</orgname>
|
||||
</affiliation>
|
||||
<contrib>Translation Lead</contrib>
|
||||
<email>caoxg@yahoo.com</email>
|
||||
</othercredit>
|
||||
|
||||
</authorgroup>
|
|
@ -0,0 +1,24 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
#: index.docbook:26
|
||||
msgid "HIBERNATE - Relational Persistence for Idiomatic Java"
|
||||
msgstr "HIBERNATE - Persistencia Relacional para Java Idiomático"
|
||||
|
||||
#: index.docbook:27
|
||||
msgid "Hibernate Reference Documentation"
|
||||
msgstr "Documentación de Referencia de Hibernate"
|
||||
|
||||
#: index.docbook:41
|
||||
msgid "©rightHolder;"
|
||||
msgstr "©rightHolder;"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,549 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "Architecture"
|
||||
msgstr "Arquitectura"
|
||||
|
||||
#: index.docbook:24
|
||||
msgid "Overview"
|
||||
msgstr "Visión General"
|
||||
|
||||
#: index.docbook:26
|
||||
msgid "A (very) high-level view of the Hibernate architecture:"
|
||||
msgstr "Una visión a (muy) alto nivel de la arquitectura de Hibernate:"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid ""
|
||||
"This diagram shows Hibernate using the database and configuration data to "
|
||||
"provide persistence services (and persistent objects) to the application."
|
||||
msgstr ""
|
||||
"Este diagrama muestra a Hibernate usando la base de datos y los datos de "
|
||||
"configuración para proveer servicios de persistencia (y objetos "
|
||||
"persistentes) a la aplicación."
|
||||
|
||||
#: index.docbook:44
|
||||
msgid ""
|
||||
"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:"
|
||||
msgstr ""
|
||||
"Nos gustaría mostrar una vista más detallada de la "
|
||||
"arquitectura de tiempo de ejecución. Desafortunadamente, Hibernate es "
|
||||
"flexible y soporta diferentes enfoques. Mostraremos los dos extremos. En la "
|
||||
"arquitectura \"sencilla\", es la aplicación la que provee su propias "
|
||||
"conexiones JDBC y gestiona sus propias transacciones. Este enfoque usa un "
|
||||
"mínimo subconjunto de la API de Hibernate:"
|
||||
|
||||
#: index.docbook:61
|
||||
msgid ""
|
||||
"The \"full cream\" architecture abstracts the application away from the "
|
||||
"underlying JDBC/JTA APIs and lets Hibernate take care of the details."
|
||||
msgstr ""
|
||||
"La arquitectura \"full cream\" abstrae a la aplicación de las APIs de "
|
||||
"JDBC/JTA y deja que Hibernate se encargue de los detalles."
|
||||
|
||||
#: index.docbook:75
|
||||
msgid "Heres some definitions of the objects in the diagrams:"
|
||||
msgstr "He aquí algunas definiciones de los objetos en los diagramas:"
|
||||
|
||||
#: index.docbook:80
|
||||
msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
|
||||
msgstr "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
|
||||
|
||||
#: index.docbook:82
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Caché threadsafe (inmutable) de mapeos compilados para una sola base "
|
||||
"de datos. Es una fábrica de <literal>Session</literal> y un cliente "
|
||||
"de <literal>ConnectionProvider</literal>. Opcionalmente, puede mantener una "
|
||||
"caché (de segundo nivel) de datos reusables entre transacciones, a un "
|
||||
"nivel de proceso o de cluster."
|
||||
|
||||
#: index.docbook:92
|
||||
msgid "Session (<literal>org.hibernate.Session</literal>)"
|
||||
msgstr "Session (<literal>org.hibernate.Session</literal>)"
|
||||
|
||||
#: index.docbook:94
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Objeto mono-hebra, de corta vida que representa una conversación "
|
||||
"entre la aplicación y el almacenamiento persistente. Envuelve una "
|
||||
"conexión JDBC. Es una fábrica de <literal>Transaction</"
|
||||
"literal>. Mantiene una caché requerida (de primer nivel) de objetos "
|
||||
"persistentes, usada mientras se navega el grafo de objetos o se recuperen "
|
||||
"objetos por identificador."
|
||||
|
||||
#: index.docbook:104
|
||||
msgid "Persistent objects and collections"
|
||||
msgstr "Objetos y colecciones persistentes"
|
||||
|
||||
#: index.docbook:106
|
||||
msgid ""
|
||||
"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)."
|
||||
msgstr ""
|
||||
"Objetos de corta vida, mono-hebra conteniendo estado persistente y "
|
||||
"funciónalidad de negocio. Estos pueden ser JavaBeans/POJOs (Plain Old "
|
||||
"Java Objects, o sea, cualquier objeto Java), la única cosa especial "
|
||||
"en ellos es que estan asociados actualmente con una (y sólo una) "
|
||||
"<literal>Session</literal>. Tan pronto como la <literal>Session</literal> "
|
||||
"sea cerrada, serán separados y estarán libres para ser usados "
|
||||
"en cualquier capa de aplicación. (por ejemplo, directamente como "
|
||||
"objetos de transferencia de datos hacia y desde la capa de presentació"
|
||||
"n)."
|
||||
|
||||
#: index.docbook:117
|
||||
msgid "Transient and detached objects and collections"
|
||||
msgstr "Objetos y colecciones transitorios y separados"
|
||||
|
||||
#: index.docbook:119
|
||||
msgid ""
|
||||
"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>."
|
||||
msgstr ""
|
||||
"Instancias de clases persistentes que no estan acutualmente asociadas con "
|
||||
"una <literal>Session</literal>. Pueden haber sido instanciadas por la "
|
||||
"aplicación y (aún) no haber sido hechas persistentes, o pueden "
|
||||
"haber sido instanciadas por una <literal>Session</literal> cerrada."
|
||||
|
||||
#: index.docbook:128
|
||||
msgid "Transaction (<literal>org.hibernate.Transaction</literal>)"
|
||||
msgstr "Transaction (<literal>org.hibernate.Transaction</literal>)"
|
||||
|
||||
#: index.docbook:130
|
||||
msgid ""
|
||||
"(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!"
|
||||
msgstr ""
|
||||
"(Opcional) Un objeto de corta vida, mono-hebra, usado por la aplicació"
|
||||
"n para especificar unidades atómicas de trabajo. Abstrae a la "
|
||||
"aplicación de las subyacentes transacciones JDBC, JTA o CORBA. En "
|
||||
"algunos casos, una <literal>Session</literal> puede extenderse sobre varias "
|
||||
"<literal>Transaction</literal>s. Sin embargo, la demarcación de la "
|
||||
"transacción, ya sea usando la API subyacente o <literal>Transaction</"
|
||||
"literal>, nunca es opcional!"
|
||||
|
||||
#: index.docbook:141
|
||||
msgid ""
|
||||
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
|
||||
"literal>)"
|
||||
msgstr ""
|
||||
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
|
||||
"literal>)"
|
||||
|
||||
#: index.docbook:143
|
||||
msgid ""
|
||||
"(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."
|
||||
msgstr ""
|
||||
"(Opcional) Una fábrica (y pool) de conexiones JDBC. Abstrae a la "
|
||||
"aplicación del <literal>Datasource</literal> o "
|
||||
"<literal>DriverManager</literal> subyacente. No se expone a la "
|
||||
"aplicación, pero puede ser extendido/implementado por el "
|
||||
"desarrollador."
|
||||
|
||||
#: index.docbook:151
|
||||
msgid ""
|
||||
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
|
||||
msgstr ""
|
||||
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
|
||||
|
||||
#: index.docbook:153
|
||||
msgid ""
|
||||
"(Optional) A factory for <literal>Transaction</literal> instances. Not "
|
||||
"exposed to the application, but can be extended/implemented by the developer."
|
||||
msgstr ""
|
||||
"(Opcional) Una fábrica de instancias de <literal>Transaction</"
|
||||
"literal>. No se expone a la aplicación, pero puede ser extendido/"
|
||||
"implementado por el desarrollador."
|
||||
|
||||
#: index.docbook:160
|
||||
msgid "Extension Interfaces"
|
||||
msgstr "Interfaces de Extensión"
|
||||
|
||||
#: index.docbook:162
|
||||
msgid ""
|
||||
"Hibernate offers many optional extension interfaces you can implement to "
|
||||
"customize the behavior of your persistence layer. See the API documentation "
|
||||
"for details."
|
||||
msgstr ""
|
||||
"Hibernate ofrece muchas interfaces de extensión opcional que puedes "
|
||||
"implementar para modificar a medida el comportamiento de tu capa de "
|
||||
"persistencia. Para más detalles, mira la documentación de la "
|
||||
"API."
|
||||
|
||||
#: index.docbook:171
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Dada una arquitectura \"sencilla\", la aplicación pasa por alto las "
|
||||
"APIs de <literal>Transaction</literal>/<literal>TransactionFactory</literal> "
|
||||
"y/o <literal>ConnectionProvider</literal>, para hablar directamente a JTA o "
|
||||
"JDBC."
|
||||
|
||||
#: index.docbook:179
|
||||
msgid "Instance states"
|
||||
msgstr "Estados de instancia"
|
||||
|
||||
#: index.docbook:180
|
||||
msgid ""
|
||||
"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:"
|
||||
msgstr ""
|
||||
"Una instancia de una clase persistente puede estar en uno de tres estados "
|
||||
"diferentes, definidos respecto de su <emphasis>contexto de persistencia</"
|
||||
"emphasis>. El objeto <literal>Session</literal> de Hibernate es el contexto "
|
||||
"de persistencia:"
|
||||
|
||||
#: index.docbook:188
|
||||
msgid "transient"
|
||||
msgstr "transitorio"
|
||||
|
||||
#: index.docbook:190
|
||||
msgid ""
|
||||
"The instance is not, and has never been associated with any persistence "
|
||||
"context. It has no persistent identity (primary key value)."
|
||||
msgstr ""
|
||||
"La instancia no está y nunca estuvo asociada con un contexto de "
|
||||
"persistencia. No tiene identidad persistente (valor de clave primaria)."
|
||||
|
||||
#: index.docbook:198
|
||||
msgid "persistent"
|
||||
msgstr "persistente"
|
||||
|
||||
#: index.docbook:200
|
||||
msgid ""
|
||||
"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)."
|
||||
msgstr ""
|
||||
"La instancia está actualmente asociada con un contexto de "
|
||||
"persistencia. Tiene una identidad persistente (valor de clave primaria) y, "
|
||||
"quizás, una fila correspondiente en la base de datos. Para un "
|
||||
"contexto de persistencia en particular, Hibernate <emphasis>garantiza</"
|
||||
"emphasis> que la identidad persistente es equivalente a la identidad Java "
|
||||
"(localización en memoria del objeto)."
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "detached"
|
||||
msgstr "separado"
|
||||
|
||||
#: index.docbook:214
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"La instancia estuvo una vez asociada con un contexto de persistencia, pero "
|
||||
"ese contexto fue cerrado, o la instancia fue serializada a otro proceso. "
|
||||
"Tiene una identidad persistente y, quizás, una fila correspondiente "
|
||||
"en la base de datos. Para las instancias separadas, Hibernate no establece "
|
||||
"ninguna garantía sobre la relación entre identidad persistente "
|
||||
"e identidad Java."
|
||||
|
||||
#: index.docbook:229
|
||||
msgid "JMX Integration"
|
||||
msgstr "Integración JMX"
|
||||
|
||||
#: index.docbook:231
|
||||
msgid ""
|
||||
"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>."
|
||||
msgstr ""
|
||||
"JMX es el estándar J2EE para la gestión de componentes Java. "
|
||||
"Hibernate puede ser gestionado por medio de un servicio estándar JMX. "
|
||||
"Proveemos una implementación de MBean en la distribución, "
|
||||
"<literal>org.hibernate.jmx.HibernateService</literal>."
|
||||
|
||||
#: index.docbook:237
|
||||
msgid ""
|
||||
"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:"
|
||||
msgstr ""
|
||||
"Para ejemplo de cómo desplegar Hibernate como un servicio JMX en un "
|
||||
"Servidor de Aplicaciones JBoss, por favor, mira la Guía del Usuario "
|
||||
"de JBoss. En JBoss AS, tienes además estos beneficios si despliegas "
|
||||
"usando JMX:"
|
||||
|
||||
#: index.docbook:245
|
||||
msgid ""
|
||||
"<emphasis>Session Management:</emphasis> The Hibernate <literal>Session</"
|
||||
"literal>'s life cycle 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>."
|
||||
msgstr ""
|
||||
"<emphasis>Gestión de Sesión:</emphasis> El ciclo de vida de la "
|
||||
"<literal>Session</literal> de Hibernate puede estar automáticamente "
|
||||
"ligado al ámbito de una transacción JTA. Esto significa que ya "
|
||||
"no tienes que abrir ni cerrar la <literal>Session</literal> manualmente, "
|
||||
"esto pasa a ser trabajo de un interceptor EJB de JBoss. Además "
|
||||
"tampoco tienes que preocuparte más de la demarcación de la "
|
||||
"transacción (a menos que que quieras escribir una capa de persitencia "
|
||||
"portable, por supuesto, usa la API de <literal>Transaction</literal> de "
|
||||
"Hibernate para esto). Para acceder a una <literal>Session</literal> llama al "
|
||||
"<literal>HibernateContext</literal>."
|
||||
|
||||
#: index.docbook:257
|
||||
msgid ""
|
||||
"<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."
|
||||
msgstr ""
|
||||
"<emphasis>Despliegue de HAR:</emphasis> Usualmente despliegas el servicio "
|
||||
"JMX de Hibernate usando un descriptor de despliegue de servicio de JBoss (en "
|
||||
"un fichero EAR y/o SAR), que soporta todas las opciones de "
|
||||
"configuración usuales de una <literal>SessionFactory</literal> de "
|
||||
"Hibernate. Sin embargo, todavía tienes que nombrar todos tus ficheros "
|
||||
"de mapeo en el descriptor de despliegue. Si decides usar el depliegue de HAR "
|
||||
"opcional, JBoss detectará automáticamente todos los ficheros "
|
||||
"de mapeo en tu fichero HAR."
|
||||
|
||||
#: index.docbook:268
|
||||
msgid ""
|
||||
"Consult the JBoss AS user guide for more information about these options."
|
||||
msgstr ""
|
||||
"Para más información sobre estas opciones, consulta la "
|
||||
"Guía de Usuario del JBoss AS."
|
||||
|
||||
#: index.docbook:272
|
||||
msgid ""
|
||||
"Another feature available as a JMX service are runtime Hibernate statistics. "
|
||||
"See <xref linkend=\"configuration-optional-statistics\"/>."
|
||||
msgstr ""
|
||||
"Otra funcionalidad disponible como un servicio JMX son las estadí"
|
||||
"sticas en tiempo de ejecución de Hibernate. Mira <xref linkend="
|
||||
"\"configuration-optional-statistics\"/>."
|
||||
|
||||
#: index.docbook:279
|
||||
msgid "JCA Support"
|
||||
msgstr "Soporte JCA:"
|
||||
|
||||
#: index.docbook:280
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Hiberate puede además ser configurado como un conector JCA. Por favor "
|
||||
"mira el sitio web para más detalles. Por favor ten en cuenta que el "
|
||||
"soporte de JCA de Hibernate está aún considerado experimental."
|
||||
|
||||
#: index.docbook:287
|
||||
msgid "Contextual Sessions"
|
||||
msgstr "UNTRANSLATED! Contextual Sessions"
|
||||
|
||||
#: index.docbook:288
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"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."
|
||||
|
||||
#: index.docbook:297
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"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."
|
||||
|
||||
#: index.docbook:307
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"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."
|
||||
|
||||
#: index.docbook:314
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"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."
|
||||
|
||||
#: index.docbook:324
|
||||
msgid ""
|
||||
"<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."
|
||||
msgstr ""
|
||||
"<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."
|
||||
|
||||
#: index.docbook:332
|
||||
msgid ""
|
||||
"<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current "
|
||||
"sessions are tracked by thread of execution. Again, see the Javadocs for "
|
||||
"details."
|
||||
msgstr ""
|
||||
"<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current "
|
||||
"sessions are tracked by thread of execution. Again, see the Javadocs for "
|
||||
"details."
|
||||
|
||||
#: index.docbook:338
|
||||
msgid ""
|
||||
"<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>."
|
||||
msgstr ""
|
||||
"<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>."
|
||||
|
||||
#: index.docbook:347
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"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."
|
||||
|
||||
#: index.docbook:359
|
||||
msgid ""
|
||||
"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 three corresponding short names, \"jta\", \"thread\", and "
|
||||
"\"managed\"."
|
||||
msgstr ""
|
||||
"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 three corresponding short names, \"jta\", \"thread\", and "
|
||||
"\"managed\"."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,617 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Batch processing"
|
||||
msgstr "Procesamiento por lotes"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"A naive approach to inserting 100 000 rows in the database using Hibernate "
|
||||
"might look like this:"
|
||||
msgstr ""
|
||||
"Un enfoque ingenuo para insertar 100.000 filas en la base de datos usando "
|
||||
"Hibernate podría verse así:"
|
||||
|
||||
#: index.docbook:12
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"for ( int i=0; i<100000; i++ ) {\n"
|
||||
" Customer customer = new Customer(.....);\n"
|
||||
" session.save(customer);\n"
|
||||
"}\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"for ( int i=0; i<100000; i++ ) {\n"
|
||||
" Customer customer = new Customer(.....);\n"
|
||||
" session.save(customer);\n"
|
||||
"}\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:14
|
||||
msgid ""
|
||||
"This would fall over with an <literal>OutOfMemoryException</literal> "
|
||||
"somewhere around the 50 000th row. That's because Hibernate caches all the "
|
||||
"newly inserted <literal>Customer</literal> instances in the session-level "
|
||||
"cache."
|
||||
msgstr ""
|
||||
"Esto podría caer sobre una <literal>OutOfMemoryException</literal> en algún "
|
||||
"sitio cerca de la fila 50.000. Esto es porque Hibernate tiene en caché todas "
|
||||
"las instancias de <literal>Customer</literal> recién instanciadas en el "
|
||||
"caché de nivel de sesión."
|
||||
|
||||
#: index.docbook:20
|
||||
msgid ""
|
||||
"In this chapter we'll show you how to avoid this problem. First, however, if "
|
||||
"you are doing batch processing, it is absolutely critical that you enable "
|
||||
"the use of JDBC batching, if you intend to achieve reasonable performance. "
|
||||
"Set the JDBC batch size to a reasonable number (say, 10-50):"
|
||||
msgstr ""
|
||||
"En este capítulo te mostraremos cómo evitar este problema. Primero, sin "
|
||||
"embargo, si estás haciendo procesamiento por lotes (batch processing), es "
|
||||
"absolutamente crítico que habilites el uso de loteo JDBC, si pretendes "
|
||||
"lograr un rendimiento razonable. Establece el tamaño de lote JDBC a un "
|
||||
"número razonable (digamos 10-50):"
|
||||
|
||||
#: index.docbook:27
|
||||
msgid "<![CDATA[hibernate.jdbc.batch_size 20]]>"
|
||||
msgstr "<![CDATA[hibernate.jdbc.batch_size 20]]>"
|
||||
|
||||
#: index.docbook:29
|
||||
msgid ""
|
||||
"Note that Hibernate disables insert batching at the JDBC level transparently "
|
||||
"if you use an <literal>identiy</literal> identifier generator."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! Note that Hibernate disables insert batching at the JDBC level "
|
||||
"transparently if you use an <literal>identiy</literal> identifier generator."
|
||||
|
||||
#: index.docbook:34
|
||||
msgid ""
|
||||
"You also might like to do this kind of work in a process where interaction "
|
||||
"with the second-level cache is completely disabled:"
|
||||
msgstr ""
|
||||
"Podrías además querer hacer este tipo de trabajo en un proceso donde la "
|
||||
"interacción con el caché de segundo nivel esté completamente deshabilitado:"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
msgstr "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
|
||||
#: index.docbook:41
|
||||
msgid ""
|
||||
"However, this is not absolutely necessary, since we can explicitly set the "
|
||||
"<literal>CacheMode</literal> to disable interaction with the second-level "
|
||||
"cache."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! However, this is not absolutely necessary, since we can "
|
||||
"explicitly set the <literal>CacheMode</literal> to disable interaction with "
|
||||
"the second-level cache."
|
||||
|
||||
#: index.docbook:47
|
||||
msgid "Batch inserts"
|
||||
msgstr "Inserciones en lote"
|
||||
|
||||
#: index.docbook:49
|
||||
msgid ""
|
||||
"When making new objects persistent, you must <literal>flush()</literal> and "
|
||||
"then <literal>clear()</literal> the session regularly, to control the size "
|
||||
"of the first-level cache."
|
||||
msgstr ""
|
||||
"Al hacer persistentes objetos nuevos, debes limpiar con <literal>flush()</"
|
||||
"literal> y llamar a <literal>clear()</literal> en la sesión regularmente, "
|
||||
"para controlar el tamaño del caché de primer nivel."
|
||||
|
||||
#: index.docbook:55
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"for ( int i=0; i<100000; i++ ) {\n"
|
||||
" Customer customer = new Customer(.....);\n"
|
||||
" session.save(customer);\n"
|
||||
" if ( i % 20 == 0 ) { //20, same as the JDBC batch size\n"
|
||||
" //flush a batch of inserts and release memory:\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"for ( int i=0; i<100000; i++ ) {\n"
|
||||
" Customer customer = new Customer(.....);\n"
|
||||
" session.save(customer);\n"
|
||||
" if ( i % 20 == 0 ) { //20, same as the JDBC batch size\n"
|
||||
" //flush a batch of inserts and release memory:\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:60
|
||||
msgid "Batch updates"
|
||||
msgstr "Actualizaciones en lote"
|
||||
|
||||
#: index.docbook:62
|
||||
msgid ""
|
||||
"For retrieving and updating data the same ideas apply. In addition, you need "
|
||||
"to use <literal>scroll()</literal> to take advantage of server-side cursors "
|
||||
"for queries that return many rows of data."
|
||||
msgstr ""
|
||||
"Para recuperar y actualizar datos se aplican las mismas ideas. "
|
||||
"Adicionalmente, necesitas usar <literal>scroll()</literal> para sacar "
|
||||
"ventaja de los cursores del lado del servidor en consultas que devuelvan "
|
||||
"muchas filas de datos."
|
||||
|
||||
#: index.docbook:68
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
|
||||
" .setCacheMode(CacheMode.IGNORE)\n"
|
||||
" .scroll(ScrollMode.FORWARD_ONLY);\n"
|
||||
"int count=0;\n"
|
||||
"while ( customers.next() ) {\n"
|
||||
" Customer customer = (Customer) customers.get(0);\n"
|
||||
" customer.updateStuff(...);\n"
|
||||
" if ( ++count % 20 == 0 ) {\n"
|
||||
" //flush a batch of updates and release memory:\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
|
||||
" .setCacheMode(CacheMode.IGNORE)\n"
|
||||
" .scroll(ScrollMode.FORWARD_ONLY);\n"
|
||||
"int count=0;\n"
|
||||
"while ( customers.next() ) {\n"
|
||||
" Customer customer = (Customer) customers.get(0);\n"
|
||||
" customer.updateStuff(...);\n"
|
||||
" if ( ++count % 20 == 0 ) {\n"
|
||||
" //flush a batch of updates and release memory:\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:73
|
||||
msgid "The StatelessSession interface"
|
||||
msgstr "UNTRANSLATED! The StatelessSession interface"
|
||||
|
||||
#: index.docbook:74
|
||||
msgid ""
|
||||
"Alternatively, Hibernate provides a command-oriented API that may be used "
|
||||
"for streaming data to and from the database in the form of detached objects. "
|
||||
"A <literal>StatelessSession</literal> has no persistence context associated "
|
||||
"with it and does not provide many of the higher-level life cycle semantics. "
|
||||
"In particular, a stateless session does not implement a first-level cache "
|
||||
"nor interact with any second-level or query cache. It does not implement "
|
||||
"transactional write-behind or automatic dirty checking. Operations performed "
|
||||
"using a stateless session do not ever cascade to associated instances. "
|
||||
"Collections are ignored by a stateless session. Operations performed via a "
|
||||
"stateless session bypass Hibernate's event model and interceptors. Stateless "
|
||||
"sessions are vulnerable to data aliasing effects, due to the lack of a first-"
|
||||
"level cache. A stateless session is a lower-level abstraction, much closer "
|
||||
"to the underlying JDBC."
|
||||
msgstr ""
|
||||
"Alternatively, Hibernate provides a command-oriented API that may be used "
|
||||
"for streaming data to and from the database in the form of detached objects. "
|
||||
"A <literal>StatelessSession</literal> has no persistence context associated "
|
||||
"with it and does not provide many of the higher-level life cycle semantics. "
|
||||
"In particular, a stateless session does not implement a first-level cache "
|
||||
"nor interact with any second-level or query cache. It does not implement "
|
||||
"transactional write-behind or automatic dirty checking. Operations performed "
|
||||
"using a stateless session do not ever cascade to associated instances. "
|
||||
"Collections are ignored by a stateless session. Operations performed via a "
|
||||
"stateless session bypass Hibernate's event model and interceptors. Stateless "
|
||||
"sessions are vulnerable to data aliasing effects, due to the lack of a first-"
|
||||
"level cache. A stateless session is a lower-level abstraction, much closer "
|
||||
"to the underlying JDBC."
|
||||
|
||||
#: index.docbook:89
|
||||
msgid ""
|
||||
"<![CDATA[StatelessSession session = sessionFactory.openStatelessSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
|
||||
" .scroll(ScrollMode.FORWARD_ONLY);\n"
|
||||
"while ( customers.next() ) {\n"
|
||||
" Customer customer = (Customer) customers.get(0);\n"
|
||||
" customer.updateStuff(...);\n"
|
||||
" session.update(customer);\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[StatelessSession session = sessionFactory.openStatelessSession();\n"
|
||||
" Transaction tx = "
|
||||
"session.beginTransaction();\n"
|
||||
" \n"
|
||||
" ScrollableResults "
|
||||
"customers = session.getNamedQuery(\"GetCustomers\")\n"
|
||||
" .scroll(ScrollMode."
|
||||
"FORWARD_ONLY);\n"
|
||||
" while ( customers.next"
|
||||
"() ) {\n"
|
||||
" Customer customer = "
|
||||
"(Customer) customers.get(0);\n"
|
||||
" customer.updateStuff"
|
||||
"(...);\n"
|
||||
" session.update"
|
||||
"(customer);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" tx.commit();\n"
|
||||
" session.close();]]>"
|
||||
|
||||
#: index.docbook:91
|
||||
msgid ""
|
||||
"Note that in this code example, the <literal>Customer</literal> instances "
|
||||
"returned by the query are immediately detached. They are never associated "
|
||||
"with any persistence context."
|
||||
msgstr ""
|
||||
"Note that in this code example, the <literal>Customer</literal> instances "
|
||||
"returned by the query are immediately detached. They are never associated "
|
||||
"with any persistence context."
|
||||
|
||||
#: index.docbook:97
|
||||
msgid ""
|
||||
"The <literal>insert(), update()</literal> and <literal>delete()</literal> "
|
||||
"operations defined by the <literal>StatelessSession</literal> interface are "
|
||||
"considered to be direct database row-level operations, which result in "
|
||||
"immediate execution of a SQL <literal>INSERT, UPDATE</literal> or "
|
||||
"<literal>DELETE</literal> respectively. Thus, they have very different "
|
||||
"semantics to the <literal>save(), saveOrUpdate()</literal> and "
|
||||
"<literal>delete()</literal> operations defined by the <literal>Session</"
|
||||
"literal> interface."
|
||||
msgstr ""
|
||||
"The <literal>insert(), update()</literal> and <literal>delete()</literal> "
|
||||
"operations defined by the <literal>StatelessSession</literal> interface are "
|
||||
"considered to be direct database row-level operations, which result in "
|
||||
"immediate execution of a SQL <literal>INSERT, UPDATE</literal> or "
|
||||
"<literal>DELETE</literal> respectively. Thus, they have very different "
|
||||
"semantics to the <literal>save(), saveOrUpdate()</literal> and "
|
||||
"<literal>delete()</literal> operations defined by the <literal>Session</"
|
||||
"literal> interface."
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "DML-style operations"
|
||||
msgstr "update/delete en masa"
|
||||
|
||||
#: index.docbook:112
|
||||
msgid ""
|
||||
"As already discussed, automatic and transparent object/relational mapping is "
|
||||
"concerned with the management of object state. This implies that the object "
|
||||
"state is available in memory, hence manipulating (using the SQL "
|
||||
"<literal>Data Manipulation Language</literal> (DML) statements: "
|
||||
"<literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</"
|
||||
"literal>) data directly in the database will not affect in-memory state. "
|
||||
"However, Hibernate provides methods for bulk SQL-style DML statement "
|
||||
"execution which are performed through the Hibernate Query Language (<link "
|
||||
"linkend=\"queryhql\">HQL</link>)."
|
||||
msgstr ""
|
||||
"Como ya se ha discutido, el mapeo objeto/relacional automático y "
|
||||
"transparente se refiere al manejo de estado de objetos. Esto implica que el "
|
||||
"estado del objeto está disponible en memoria, por lo tanto actualizar o "
|
||||
"borrar (usando <literal>UPDATE</literal> y <literal>DELETE</literal> de SQL) "
|
||||
"datos directamente en la base de datos no afectará el estado en memoria. Sin "
|
||||
"embargo, Hibernate provee métodos para la ejecución de sentencias del estilo "
|
||||
"de <literal>UPDATE</literal> y <literal>DELETE</literal> de SQL que se "
|
||||
"realizan a través del Lenguaje de Consulta de Hibernate (Hibernate Query "
|
||||
"Language o <xref linkend=\"queryhql\"/>HQL)."
|
||||
|
||||
#: index.docbook:122
|
||||
msgid ""
|
||||
"The pseudo-syntax for <literal>UPDATE</literal> and <literal>DELETE</"
|
||||
"literal> statements is: <literal>( UPDATE | DELETE ) FROM? EntityName (WHERE "
|
||||
"where_conditions)?</literal>. Some points to note:"
|
||||
msgstr ""
|
||||
"La pseudo-sintáxis para sentencias <literal>UPDATE</literal> y "
|
||||
"<literal>DELETE</literal> es: <literal>( UPDATE | DELETE ) FROM? ClassName "
|
||||
"(WHERE WHERE_CONDITIONS)?</literal>. Algunos puntos a tener en cuenta:"
|
||||
|
||||
#: index.docbook:130
|
||||
msgid "In the from-clause, the FROM keyword is optional"
|
||||
msgstr "En la cláusula-from, la palabra clave FROM es opcional"
|
||||
|
||||
#: index.docbook:135
|
||||
msgid ""
|
||||
"There can only be a single entity named in the from-clause; it can "
|
||||
"optionally be aliased. If the entity name is aliased, then any property "
|
||||
"references must be qualified using that alias; if the entity name is not "
|
||||
"aliased, then it is illegal for any property references to be qualified."
|
||||
msgstr ""
|
||||
"There can only be a single entity named in the from-clause; it can "
|
||||
"optionally be aliased. If the entity name is aliased, then any property "
|
||||
"references must be qualified using that alias; if the entity name is not "
|
||||
"aliased, then it is illegal for any property references to be qualified."
|
||||
|
||||
#: index.docbook:143
|
||||
msgid ""
|
||||
"No <link linkend=\"queryhql-joins-forms\">joins</link> (either implicit or "
|
||||
"explicit) can be specified in a bulk HQL query. Sub-queries may be used in "
|
||||
"the where-clause; the subqueries, themselves, may contain joins."
|
||||
msgstr ""
|
||||
"No <link linkend=\"queryhql-joins-forms\">joins</link> (either implicit or "
|
||||
"explicit) can be specified in a bulk HQL query. Sub-queries may be used in "
|
||||
"the where-clause; the subqueries, themselves, may contain joins."
|
||||
|
||||
#: index.docbook:150
|
||||
msgid "The where-clause is also optional."
|
||||
msgstr "La cláusula-where es también opcional."
|
||||
|
||||
#: index.docbook:156
|
||||
msgid ""
|
||||
"As an example, to execute an HQL <literal>UPDATE</literal>, use the "
|
||||
"<literal>Query.executeUpdate()</literal> method (the method is named for "
|
||||
"those familiar with JDBC's <literal>PreparedStatement.executeUpdate()</"
|
||||
"literal>):"
|
||||
msgstr ""
|
||||
"Como un ejemplo, para ejecutar un <literal>UPDATE</literal> HQL, usa el "
|
||||
"método <literal>Query.executeUpdate()</literal>(the method is named for "
|
||||
"those familiar with JDBC's <literal>PreparedStatement.executeUpdate()</"
|
||||
"literal>):"
|
||||
|
||||
#: index.docbook:162
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"String hqlUpdate = \"update Customer c set c.name = :newName where c.name = :"
|
||||
"oldName\";\n"
|
||||
"// or String hqlUpdate = \"update Customer set name = :newName where name = :"
|
||||
"oldName\";\n"
|
||||
"int updatedEntities = s.createQuery( hqlUpdate )\n"
|
||||
" .setString( \"newName\", newName )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
" Transaction tx = session."
|
||||
"beginTransaction();\n"
|
||||
" \n"
|
||||
" String hqlUpdate = \"update "
|
||||
"Customer c set c.name = :newName where c.name = :oldName\";\n"
|
||||
" // or String hqlUpdate = \"update "
|
||||
"Customer set name = :newName where name = :oldName\";\n"
|
||||
" int updatedEntities = s.createQuery"
|
||||
"( hqlUpdate )\n"
|
||||
" .setString( \"newName\", newName )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
" tx.commit();\n"
|
||||
" session.close();]]>"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid ""
|
||||
"HQL <literal>UPDATE</literal> statements, by default do not effect the <link "
|
||||
"linkend=\"mapping-declaration-version\">version</link> or the <link linkend="
|
||||
"\"mapping-declaration-timestamp\">timestamp</link> property values for the "
|
||||
"affected entities; this is in keeping with the EJB3 specification. However, "
|
||||
"you can force Hibernate to properly reset the <literal>version</literal> or "
|
||||
"<literal>timestamp</literal> property values through the use of a "
|
||||
"<literal>versioned update</literal>. This is achieved by adding the "
|
||||
"<literal>VERSIONED</literal> keyword after the <literal>UPDATE</literal> "
|
||||
"keyword."
|
||||
msgstr ""
|
||||
"HQL <literal>UPDATE</literal> statements, by default do not effect the <link "
|
||||
"linkend=\"mapping-declaration-version\">version</link> or the <link linkend="
|
||||
"\"mapping-declaration-timestamp\">timestamp</link> property values for the "
|
||||
"affected entities; this is in keeping with the EJB3 specification. However, "
|
||||
"you can force Hibernate to properly reset the <literal>version</literal> or "
|
||||
"<literal>timestamp</literal> property values through the use of a "
|
||||
"<literal>versioned update</literal>. This is achieved by adding the "
|
||||
"<literal>VERSIONED</literal> keyword after the <literal>UPDATE</literal> "
|
||||
"keyword."
|
||||
|
||||
#: index.docbook:174
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"String hqlVersionedUpdate = \"update versioned Customer set name = :newName "
|
||||
"where name = :oldName\";\n"
|
||||
"int updatedEntities = s.createQuery( hqlUpdate )\n"
|
||||
" .setString( \"newName\", newName )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
" Transaction tx = session."
|
||||
"beginTransaction();\n"
|
||||
" String hqlVersionedUpdate = "
|
||||
"\"update versioned Customer set name = :newName where name = :oldName\";\n"
|
||||
" int updatedEntities = s.createQuery"
|
||||
"( hqlUpdate )\n"
|
||||
" .setString( \"newName\", newName )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
" tx.commit();\n"
|
||||
" session.close();]]>"
|
||||
|
||||
#: index.docbook:176
|
||||
msgid ""
|
||||
"Note that custom version types (<literal>org.hibernate.usertype."
|
||||
"UserVersionType</literal>) are not allowed in conjunction with a "
|
||||
"<literal>update versioned</literal> statement."
|
||||
msgstr ""
|
||||
"Note that custom version types (<literal>org.hibernate.usertype."
|
||||
"UserVersionType</literal>) are not allowed in conjunction with a "
|
||||
"<literal>update versioned</literal> statement."
|
||||
|
||||
#: index.docbook:181
|
||||
msgid ""
|
||||
"To execute an HQL <literal>DELETE</literal>, use the same <literal>Query."
|
||||
"executeUpdate()</literal> method:"
|
||||
msgstr ""
|
||||
"Para ejecutar un <literal>DELETE</literal> HQL, usa el mismo método "
|
||||
"<literal>Query.executeUpdate()</literal>:"
|
||||
|
||||
#: index.docbook:186
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"String hqlDelete = \"delete Customer c where c.name = :oldName\";\n"
|
||||
"// or String hqlDelete = \"delete Customer where name = :oldName\";\n"
|
||||
"int deletedEntities = s.createQuery( hqlDelete )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
" Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
" String hqlDelete = \"delete Customer where name = :oldName\";\n"
|
||||
" int deletedEntities = s.createQuery( hqlDelete )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
" tx.commit();\n"
|
||||
" session.close();]]>"
|
||||
|
||||
#: index.docbook:188
|
||||
msgid ""
|
||||
"The <literal>int</literal> value returned by the <literal>Query.executeUpdate"
|
||||
"()</literal> method indicate the number of entities effected by the "
|
||||
"operation. Consider this may or may not correlate to the number of rows "
|
||||
"effected in the database. An HQL bulk operation might result in multiple "
|
||||
"actual SQL statements being executed, for joined-subclass, for example. The "
|
||||
"returned number indicates the number of actual entities affected by the "
|
||||
"statement. Going back to the example of joined-subclass, a delete against "
|
||||
"one of the subclasses may actually result in deletes against not just the "
|
||||
"table to which that subclass is mapped, but also the \"root\" table and "
|
||||
"potentially joined-subclass tables further down the inheritence hierarchy."
|
||||
msgstr ""
|
||||
"El valor <literal>int</literal> devuelto por el método <literal>Query."
|
||||
"executeUpdate()</literal> indica el número de entidades afectadas por la "
|
||||
"operación. Considera que esto puede o no correlacionarse al número de filas "
|
||||
"afectadas en la base de datos. Una operación masiva HQL podría resultar en "
|
||||
"que se ejecuten múltiples sentencias de SQL reales, para joined-subclass, "
|
||||
"por ejemplo. El número devuelto indica el número de entidades reales "
|
||||
"afectadas por la sentencia. Volviendo al ejemplo de joined-subclass, un "
|
||||
"borrado contra una de las subclases puede resultar realmente en borrados "
|
||||
"contra no sólo la tabla a la que está mapeada esa subclase, sino también la "
|
||||
"tabla \"raíz\" y potencialmente tablas de joined-subclass más debajo en la "
|
||||
"jerarquía de herencia."
|
||||
|
||||
#: index.docbook:199
|
||||
msgid ""
|
||||
"The pseudo-syntax for <literal>INSERT</literal> statements is: "
|
||||
"<literal>INSERT INTO EntityName properties_list select_statement</literal>. "
|
||||
"Some points to note:"
|
||||
msgstr ""
|
||||
"Ten en cuenta que existen actualmente unas pocas limitaciones con las "
|
||||
"operaciones HQL masivas, que serán atendidas en lanzamientos futuros; "
|
||||
"consulta la hoja de ruta de JIRA para más detalles."
|
||||
|
||||
#: index.docbook:207
|
||||
msgid ""
|
||||
"Only the INSERT INTO ... SELECT ... form is supported; not the INSERT "
|
||||
"INTO ... VALUES ... form."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:210
|
||||
msgid ""
|
||||
"The properties_list is analogous to the <literal>column speficiation</"
|
||||
"literal> in the SQL <literal>INSERT</literal> statement. For entities "
|
||||
"involved in mapped inheritence, only properties directly defined on that "
|
||||
"given class-level can be used in the properties_list. Superclass properties "
|
||||
"are not allowed; and subclass properties do not make sense. In other words, "
|
||||
"<literal>INSERT</literal> statements are inherently non-polymorphic."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:220
|
||||
msgid ""
|
||||
"select_statement can be any valid HQL select query, with the caveat that the "
|
||||
"return types must match the types expected by the insert. Currently, this is "
|
||||
"checked during query compilation rather than allowing the check to relegate "
|
||||
"to the database. Note however that this might cause problems between "
|
||||
"Hibernate <literal>Type</literal>s which are <emphasis>equivalent</emphasis> "
|
||||
"as opposed to <emphasis>equal</emphasis>. This might cause issues with "
|
||||
"mismatches between a property defined as a <literal>org.hibernate.type."
|
||||
"DateType</literal> and a property defined as a <literal>org.hibernate.type."
|
||||
"TimestampType</literal>, even though the database might not make a "
|
||||
"distinction or might be able to handle the conversion."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:232
|
||||
msgid ""
|
||||
"For the id property, the insert statement gives you two options. You can "
|
||||
"either explicitly specify the id property in the properties_list (in which "
|
||||
"case its value is taken from the corresponding select expression) or omit it "
|
||||
"from the properties_list (in which case a generated value is used). This "
|
||||
"later option is only available when using id generators that operate in the "
|
||||
"database; attempting to use this option with any \"in memory\" type "
|
||||
"generators will cause an exception during parsing. Note that for the "
|
||||
"purposes of this discussion, in-database generators are considered to be "
|
||||
"<literal>org.hibernate.id.SequenceGenerator</literal> (and its subclasses) "
|
||||
"and any implementors of <literal>org.hibernate.id."
|
||||
"PostInsertIdentifierGenerator</literal>. The most notable exception here is "
|
||||
"<literal>org.hibernate.id.TableHiLoGenerator</literal>, which cannot be used "
|
||||
"because it does not expose a selectable way to get its values."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:247
|
||||
msgid ""
|
||||
"For properties mapped as either <literal>version</literal> or "
|
||||
"<literal>timestamp</literal>, the insert statement gives you two options. "
|
||||
"You can either specify the property in the properties_list (in which case "
|
||||
"its value is taken from the corresponding select expressions) or omit it "
|
||||
"from the properties_list (in which case the <literal>seed value</literal> "
|
||||
"defined by the <literal>org.hibernate.type.VersionType</literal> is used)."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:257
|
||||
msgid "An example HQL <literal>INSERT</literal> statement execution:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:261
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"String hqlInsert = \"insert into DelinquentAccount (id, name) select c.id, c."
|
||||
"name from Customer c where ...\";\n"
|
||||
"int createdEntities = s.createQuery( hqlInsert )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,394 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Best Practices"
|
||||
msgstr "Mejores Prácticas"
|
||||
|
||||
#: index.docbook:9
|
||||
msgid ""
|
||||
"Write fine-grained classes and map them using <literal><component></"
|
||||
"literal>."
|
||||
msgstr ""
|
||||
"Escribe clase finamente granularizadas y mapealas usando <literal><"
|
||||
"component></literal>."
|
||||
|
||||
#: index.docbook:11
|
||||
msgid ""
|
||||
"Use an <literal>Address</literal> class to encapsulate <literal>street</"
|
||||
"literal>, <literal>suburb</literal>, <literal>state</literal>, "
|
||||
"<literal>postcode</literal>. This encourages code reuse and simplifies "
|
||||
"refactoring."
|
||||
msgstr ""
|
||||
"Usa una clase <literal>Dirección</literal> para encapsular "
|
||||
"<literal>calle</literal>, <literal>distrito</literal>, <literal>estado</"
|
||||
"literal>, <literal>código postal</literal>. Esto alienta la "
|
||||
"reutilización de código y simplifica el refactoring."
|
||||
|
||||
#: index.docbook:19
|
||||
msgid "Declare identifier properties on persistent classes."
|
||||
msgstr "Declara las propiedades identificadoras en clases persistentes."
|
||||
|
||||
#: index.docbook:21
|
||||
msgid ""
|
||||
"Hibernate makes identifier properties optional. There are all sorts of "
|
||||
"reasons why you should use them. We recommend that identifiers be "
|
||||
"'synthetic' (generated, with no business meaning)."
|
||||
msgstr ""
|
||||
"Hibernate hace opcionales las propiedades identificadoras. Existen todo tipo "
|
||||
"de razones por las que debes usarlas. Recomendamos que los identificadores "
|
||||
"sean 'sintéticos' (generados, sin ningún significado de "
|
||||
"negocio)."
|
||||
|
||||
#: index.docbook:29
|
||||
msgid "Identify natural keys."
|
||||
msgstr "Identifica las claves naturales."
|
||||
|
||||
#: index.docbook:31
|
||||
msgid ""
|
||||
"Identify natural keys for all entities, and map them using <literal><"
|
||||
"natural-id></literal>. Implement <literal>equals()</literal> and "
|
||||
"<literal>hashCode()</literal> to compare the properties that make up the "
|
||||
"natural key."
|
||||
msgstr ""
|
||||
"Identifica las claves naturales de todas las entidades, y mapealas usando "
|
||||
"<literal><natural-id></literal>. Implementa <literal>equals()</"
|
||||
"literal> y <literal>hashCode()</literal> para comparar las propiedades que "
|
||||
"componen la clave natural."
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "Place each class mapping in its own file."
|
||||
msgstr "Coloca cada mapeo de clase en su propio fichero."
|
||||
|
||||
#: index.docbook:41
|
||||
msgid ""
|
||||
"Don't use a single monolithic mapping document. Map <literal>com.eg.Foo</"
|
||||
"literal> in the file <literal>com/eg/Foo.hbm.xml</literal>. This makes "
|
||||
"particularly good sense in a team environment."
|
||||
msgstr ""
|
||||
"No uses un solo documento monolítico de mapeo. Mapea <literal>com.eg."
|
||||
"Foo</literal> en el fichero <literal>com/eg/Foo.hbm.xml</literal>. Esto "
|
||||
"tiene sentido particularmente en un ambiente de equipo."
|
||||
|
||||
#: index.docbook:49
|
||||
msgid "Load mappings as resources."
|
||||
msgstr "Carga los mapeos como recursos."
|
||||
|
||||
#: index.docbook:51
|
||||
msgid "Deploy the mappings along with the classes they map."
|
||||
msgstr "Despliega los mapeos junto a las clases que mapean."
|
||||
|
||||
#: index.docbook:57
|
||||
msgid "Consider externalising query strings."
|
||||
msgstr "Considera externalizar las cadenas de consulta."
|
||||
|
||||
#: index.docbook:59
|
||||
msgid ""
|
||||
"This is a good practice if your queries call non-ANSI-standard SQL "
|
||||
"functions. Externalising the query strings to mapping files will make the "
|
||||
"application more portable."
|
||||
msgstr ""
|
||||
"Esta es una buena práctica si tus consultas llaman a funciones SQL "
|
||||
"que no son del estándar ANSI. Externalizar las cadenas de consulta a "
|
||||
"ficheros de mapeo hará la aplicación más portable."
|
||||
|
||||
#: index.docbook:67
|
||||
msgid "Use bind variables."
|
||||
msgstr "Usa variables de ligado."
|
||||
|
||||
#: index.docbook:69
|
||||
msgid ""
|
||||
"As in JDBC, always replace non-constant values by \"?\". Never use string "
|
||||
"manipulation to bind a non-constant value in a query! Even better, consider "
|
||||
"using named parameters in queries."
|
||||
msgstr ""
|
||||
"Igual que en JDBC, siempre remplaza valores no constantes con \"?\". ¡"
|
||||
"Nunca uses manipulación de cadenas para ligar un valor no constante "
|
||||
"en una consulta! Incluso mejor, considera usar parámetros con nombre "
|
||||
"en las consultas."
|
||||
|
||||
#: index.docbook:77
|
||||
msgid "Don't manage your own JDBC connections."
|
||||
msgstr "No manejes tus propias conexiones JDBC."
|
||||
|
||||
#: index.docbook:79
|
||||
msgid ""
|
||||
"Hibernate lets the application manage JDBC connections. This approach should "
|
||||
"be considered a last-resort. If you can't use the built-in connections "
|
||||
"providers, consider providing your own implementation of <literal>org."
|
||||
"hibernate.connection.ConnectionProvider</literal>."
|
||||
msgstr ""
|
||||
"Hibernate deja a la aplicación administre las conexiones JDBC. Este "
|
||||
"enfoque debe considerarse como último recurso. Si no puedes usar los "
|
||||
"provedores de conexión prefabricados, considera prover tu propia "
|
||||
"implementación de <literal>org.hibernate.connection."
|
||||
"ConnectionProvider</literal>."
|
||||
|
||||
#: index.docbook:87
|
||||
msgid "Consider using a custom type."
|
||||
msgstr "Considera usar un tipo personalizado."
|
||||
|
||||
#: index.docbook:89
|
||||
msgid ""
|
||||
"Suppose you have a Java type, say from some library, that needs to be "
|
||||
"persisted but doesn't provide the accessors needed to map it as a component. "
|
||||
"You should consider implementing <literal>org.hibernate.UserType</literal>. "
|
||||
"This approach frees the application code from implementing transformations "
|
||||
"to / from a Hibernate type."
|
||||
msgstr ""
|
||||
"Supón que tienes un tipo Java, digamos de alguna biblioteca, que "
|
||||
"necesita hacerse persistente pero no provee los métodos de acceso "
|
||||
"necesarios para mapearlo como un componente. Debes considerar implementar "
|
||||
"<literal>org.hibernate.UserType</literal>. Este enfoque libera al có"
|
||||
"digo de aplicación de implementar transformaciones a / desde un tipo "
|
||||
"Hibernate."
|
||||
|
||||
#: index.docbook:98
|
||||
msgid "Use hand-coded JDBC in bottlenecks."
|
||||
msgstr "Usa JDBC codificado a mano en cuellos de botella."
|
||||
|
||||
#: index.docbook:100
|
||||
msgid ""
|
||||
"In performance-critical areas of the system, some kinds of operations might "
|
||||
"benefit from direct JDBC. But please, wait until you <emphasis>know</"
|
||||
"emphasis> something is a bottleneck. And don't assume that direct JDBC is "
|
||||
"necessarily faster. If you need to use direct JDBC, it might be worth "
|
||||
"opening a Hibernate <literal>Session</literal> and using that JDBC "
|
||||
"connection. That way you can still use the same transaction strategy and "
|
||||
"underlying connection provider."
|
||||
msgstr ""
|
||||
"En áreas del sistema de rendimiento crítico, algunos tipos de "
|
||||
"operaciones podrían beneficiarse del JDBC directo. Pero por favor, "
|
||||
"espero hasta que <emphasis>sepas</emphasis> que algo es un cuello de "
|
||||
"botella. Y no asumas que el JDBC directo es necesariamente más "
|
||||
"rápido. Si necesitas usar JDBC directo, podría ser valioso "
|
||||
"abrir una <literal>Session</literal> de Hibernate y usar esa conexión "
|
||||
"JDBC. De esta forma puedes usar aún la misma estrategia de "
|
||||
"transacción y el mismo proveedor de conexiones subyacente."
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "Understand <literal>Session</literal> flushing."
|
||||
msgstr "Comprende la limpieza (flushing) de <literal>Session</literal>."
|
||||
|
||||
#: index.docbook:112
|
||||
msgid ""
|
||||
"From time to time the Session synchronizes its persistent state with the "
|
||||
"database. Performance will be affected if this process occurs too often. You "
|
||||
"may sometimes minimize unnecessary flushing by disabling automatic flushing "
|
||||
"or even by changing the order of queries and other operations within a "
|
||||
"particular transaction."
|
||||
msgstr ""
|
||||
"De vez en cuando la sesión sincroniza su estado persistente con la "
|
||||
"base de datos. El rendimiento se verá afectado si este proceso ocurre "
|
||||
"demasiado frecuentemente. A veces puedes minimizar limpieza innecesaria "
|
||||
"deshabilitando la limpieza automática o incluso cambiando el orden de "
|
||||
"las consultas u otras operaciones en una transacción en particular."
|
||||
|
||||
#: index.docbook:121
|
||||
msgid "In a three tiered architecture, consider using detached objects."
|
||||
msgstr ""
|
||||
"En una aplicación en tres gradas, considera usar objetos separados."
|
||||
|
||||
#: index.docbook:123
|
||||
msgid ""
|
||||
"When using a servlet / session bean architecture, you could pass persistent "
|
||||
"objects loaded in the session bean to and from the servlet / JSP layer. Use "
|
||||
"a new session to service each request. Use <literal>Session.merge()</"
|
||||
"literal> or <literal>Session.saveOrUpdate()</literal> to synchronize objects "
|
||||
"with the database."
|
||||
msgstr ""
|
||||
"Al usar una arquitectura de servlet / sesión, puedes pasar objetos "
|
||||
"persistentes en el bean de sesión hacia y desde la capa de servlet / "
|
||||
"JSP. Usa una sesión nueva para atender el servicio de cada "
|
||||
"petición. Usa <literal>Session.merge()</literal> o <literal>Session."
|
||||
"saveOrUpdate()</literal> para sincronizar los objetos con la base de datos."
|
||||
|
||||
#: index.docbook:132
|
||||
msgid "In a two tiered architecture, consider using long persistence contexts."
|
||||
msgstr ""
|
||||
"En una arquitectura en dos gradas, considera usar contexto de persistencia "
|
||||
"largos."
|
||||
|
||||
#: index.docbook:134
|
||||
msgid ""
|
||||
"Database Transactions have to be as short as possible for best scalability. "
|
||||
"However, it is often neccessary to implement long running "
|
||||
"<emphasis>application transactions</emphasis>, a single unit-of-work from "
|
||||
"the point of view of a user. An application transaction might span several "
|
||||
"client request/response cycles. It is common to use detached objects to "
|
||||
"implement application transactions. An alternative, extremely appropriate in "
|
||||
"two tiered architecture, is to maintain a single open persistence contact "
|
||||
"(session) for the whole life cycle of the application transaction and simply "
|
||||
"disconnect from the JDBC connection at the end of each request and reconnect "
|
||||
"at the beginning of the subsequent request. Never share a single session "
|
||||
"across more than one application transaction, or you will be working with "
|
||||
"stale data."
|
||||
msgstr ""
|
||||
"Las transacciones de base de datos tienen que ser tan cortas como sea "
|
||||
"posible. Sin embargo, frecuentemente es necesario implementar "
|
||||
"<emphasis>transacciones de aplicación</emphasis> ejecutándose "
|
||||
"en largo, una sola unidad de trabajo desde el punto de vista de un usuario. "
|
||||
"Una transacción de aplicación puede abarcar muchos ciclos "
|
||||
"petición/respuesta del cliente. Es común usar objetos "
|
||||
"separados para implementar transacciones de aplicación. Una "
|
||||
"alternativa, extremadamente apropiada en arquitecturas en dos gradas, es "
|
||||
"mantener un solo contacto de persistencia abierto (sesión) para todo "
|
||||
"el ciclo de vida de la transacción de aplicación y simplemente "
|
||||
"desconectar de la conexión JDBC al final de cada petición, y "
|
||||
"reconectar al comienzo de la petición subsecuente. Nunca compartas "
|
||||
"una única sesión a través de más de una "
|
||||
"transacción de aplicación, o estarás trabajando con "
|
||||
"datos añejos."
|
||||
|
||||
#: index.docbook:148
|
||||
msgid "Don't treat exceptions as recoverable."
|
||||
msgstr "No trates la excepciones como recuperables."
|
||||
|
||||
#: index.docbook:150
|
||||
msgid ""
|
||||
"This is more of a necessary practice than a \"best\" practice. When an "
|
||||
"exception occurs, roll back the <literal>Transaction</literal> and close the "
|
||||
"<literal>Session</literal>. If you don't, Hibernate can't guarantee that in-"
|
||||
"memory state accurately represents persistent state. As a special case of "
|
||||
"this, do not use <literal>Session.load()</literal> to determine if an "
|
||||
"instance with the given identifier exists on the database; use "
|
||||
"<literal>Session.get()</literal> or a query instead."
|
||||
msgstr ""
|
||||
"Esto es más una práctica necesaria que una \"mejor\" prá"
|
||||
"ctica. Cuando ocurra una excepción, deshaz (rollback) la "
|
||||
"<literal>Transaction</literal> y cierra la <literal>Session</literal>. Si no "
|
||||
"lo haces, Hibernate no puede garantizar que el estado en memoria representa "
|
||||
"con exactitud el estado persistente. Como un caso especial de esto, no uses "
|
||||
"<literal>Session.load()</literal> para determinar si una instancia con el "
|
||||
"identificador dado existe en la base de datos. En cambio, usa "
|
||||
"<literal>Session.get()</literal> o una consulta."
|
||||
|
||||
#: index.docbook:160
|
||||
msgid "Prefer lazy fetching for associations."
|
||||
msgstr "Prefiere la recuperación perezosa para las asociaciones."
|
||||
|
||||
#: index.docbook:162
|
||||
msgid ""
|
||||
"Use eager fetching sparingly. Use proxies and lazy collections for most "
|
||||
"associations to classes that are not likely to be completely held in the "
|
||||
"second-level cache. For associations to cached classes, where there is an a "
|
||||
"extremely high probability of a cache hit, explicitly disable eager fetching "
|
||||
"using <literal>lazy=\"false\"</literal>. When an join fetching is "
|
||||
"appropriate to a particular use case, use a query with a <literal>left join "
|
||||
"fetch</literal>."
|
||||
msgstr ""
|
||||
"Usa escasamente la recuperación temprana. Usa proxies y colecciones "
|
||||
"perezosas para la mayoría de asociaciones a clases probablemente no "
|
||||
"estén mantenidas en el caché de segundo nivel. Para las "
|
||||
"asociaciones a clases en caché, donde hay una probabilidad de acceso "
|
||||
"a caché extremadamente alta, deshabilita explícitamente la "
|
||||
"recuperación temprana usando <literal>lazy=\"false\"</literal>. "
|
||||
"Cuando sea apropiada la recuperación por unión (join fetching) "
|
||||
"para un caso de uso en particular, usa una consulta con un <literal>left "
|
||||
"join fetch</literal>."
|
||||
|
||||
#: index.docbook:172
|
||||
msgid ""
|
||||
"Use the <emphasis>open session in view</emphasis> pattern, or a disciplined "
|
||||
"<emphasis>assembly phase</emphasis> to avoid problems with unfetched data."
|
||||
msgstr ""
|
||||
"Usa el patrón <emphasis>sesión abierta en vista</emphasis>, o "
|
||||
"una <emphasis>fase de ensamblado</emphasis> disciplinada para evitar "
|
||||
"problemas con datos no recuperados."
|
||||
|
||||
#: index.docbook:177
|
||||
msgid ""
|
||||
"Hibernate frees the developer from writing tedious <emphasis>Data Transfer "
|
||||
"Objects</emphasis> (DTO). In a traditional EJB architecture, DTOs serve dual "
|
||||
"purposes: first, they work around the problem that entity beans are not "
|
||||
"serializable; second, they implicitly define an assembly phase where all "
|
||||
"data to be used by the view is fetched and marshalled into the DTOs before "
|
||||
"returning control to the presentation tier. Hibernate eliminates the first "
|
||||
"purpose. However, you will still need an assembly phase (think of your "
|
||||
"business methods as having a strict contract with the presentation tier "
|
||||
"about what data is available in the detached objects) unless you are "
|
||||
"prepared to hold the persistence context (the session) open across the view "
|
||||
"rendering process. This is not a limitation of Hibernate! It is a "
|
||||
"fundamental requirement of safe transactional data access."
|
||||
msgstr ""
|
||||
"Hibernate liberal al desarrollador de escribir <emphasis>Objetos de "
|
||||
"Transferencia de Datos (Data Transfer Objects)</emphasis> (DTO). En una "
|
||||
"arquitectura tradicional de EJB, los DTOs tienen un propósito doble: "
|
||||
"primero, atacan el problema que los beans de entidad no son serializables. "
|
||||
"Segundo, definen implícitamente una fase de ensamblado cuando se "
|
||||
"recuperan y se forman (marshalling) todos los datos a usar por la vista en "
|
||||
"los DTOs antes de devolver el control a la grada de presentación. "
|
||||
"Hibernate elimina el primer propósito. Sin embargo, aún "
|
||||
"necesitas una fase de ensamblado (piensa en tus métodos de negocio "
|
||||
"como si tuviesen un contrato estricto con la grada de presentación "
|
||||
"sobre qué datos están disponibles en los objetos separados) a "
|
||||
"menos que estés preparado para tener el contexto de persistencia (la "
|
||||
"sesión) abierto a través del proceso de renderización "
|
||||
"de la vista. ¡Esta no es una limitación de Hibernate! Es un "
|
||||
"requerimiento fundamental de acceso seguro a datos transaccionales."
|
||||
|
||||
#: index.docbook:191
|
||||
msgid "Consider abstracting your business logic from Hibernate."
|
||||
msgstr "Considera abstraer tu lógica de negocio de Hibernate"
|
||||
|
||||
#: index.docbook:193
|
||||
msgid ""
|
||||
"Hide (Hibernate) data-access code behind an interface. Combine the "
|
||||
"<emphasis>DAO</emphasis> and <emphasis>Thread Local Session</emphasis> "
|
||||
"patterns. You can even have some classes persisted by handcoded JDBC, "
|
||||
"associated to Hibernate via a <literal>UserType</literal>. (This advice is "
|
||||
"intended for \"sufficiently large\" applications; it is not appropriate for "
|
||||
"an application with five tables!)"
|
||||
msgstr ""
|
||||
"Oculta el código de acceso a datos (Hibernate) detrás de una "
|
||||
"interface. Combina los patrones <emphasis>DAO</emphasis> y "
|
||||
"<emphasis>Sesión de Hebra Local</emphasis>. Incluso puedes tener "
|
||||
"algunas clases hechas persistentes por JDBC escrito a mano, asociadas a "
|
||||
"Hibernate por medio de un <literal>UserType</literal>. (Este consejo "
|
||||
"está pensado para aplicaciones \"suficientemente grandes\"; ¡"
|
||||
"no es apropiado para una aplicación con cinco tablas!)"
|
||||
|
||||
#: index.docbook:203
|
||||
msgid "Don't use exotic association mappings."
|
||||
msgstr "No uses mapeos de asociación exóticos."
|
||||
|
||||
#: index.docbook:205
|
||||
msgid ""
|
||||
"Good usecases for a real many-to-many associations are rare. Most of the "
|
||||
"time you need additional information stored in the \"link table\". In this "
|
||||
"case, it is much better to use two one-to-many associations to an "
|
||||
"intermediate link class. In fact, we think that most associations are one-to-"
|
||||
"many and many-to-one, you should be careful when using any other association "
|
||||
"style and ask yourself if it is really neccessary."
|
||||
msgstr ""
|
||||
"Son raros los casos de uso de asociaciones reales muchos-a-muchos. La mayor "
|
||||
"parte del tiempo necesitas información adicional almacenada en una "
|
||||
"\"tabla de enlace\". En este caso, es mucho mejor usar dos asociaciones uno-"
|
||||
"a-muchos a una clase de enlace intermedia. De hecho, pensamos que la "
|
||||
"mayoría de asociaciones son uno-a-muchos y muchos-a-uno, debes ser "
|
||||
"cuidadoso al usr cualquier otro estilo de asociación y preguntarte si "
|
||||
"es realmente necesario."
|
||||
|
||||
#: index.docbook:215
|
||||
msgid "Prefer bidirectional associations."
|
||||
msgstr "Prefiere las asociaciones bidireccionales."
|
||||
|
||||
#: index.docbook:217
|
||||
msgid ""
|
||||
"Unidirectional associations are more difficult to query. In a large "
|
||||
"application, almost all associations must be navigable in both directions in "
|
||||
"queries."
|
||||
msgstr ""
|
||||
"Las asociaciones unidireccionales son más difíciles de "
|
||||
"consultar. En una aplicación grande, casi todas las asociaciones "
|
||||
"deben ser navegables en ambas direcciones en consultas."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,753 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Component Mapping"
|
||||
msgstr "Mapeo de Componentes"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"The notion of a <emphasis>component</emphasis> is re-used in several "
|
||||
"different contexts, for different purposes, throughout Hibernate."
|
||||
msgstr ""
|
||||
"La noción de un <emphasis>componente</emphasis> es reusada en muchos "
|
||||
"contextos diferentes, para propósitos diferentes, a través de "
|
||||
"Hibernate."
|
||||
|
||||
#: index.docbook:13
|
||||
msgid "Dependent objects"
|
||||
msgstr "Objetos dependientes"
|
||||
|
||||
#: index.docbook:15
|
||||
msgid ""
|
||||
"A component is a contained object that is persisted as a value type, not an "
|
||||
"entity reference. The term \"component\" refers to the object-oriented "
|
||||
"notion of composition (not to architecture-level components). For example, "
|
||||
"you might model a person like this:"
|
||||
msgstr ""
|
||||
"Un componente es un objeto contenido que es persistido como un tipo de "
|
||||
"valor, no una referencia de entidad. El término \"componente\" hace "
|
||||
"referencia a la noción orientada a objetos de composición (no "
|
||||
"a componentes a nivel de arquitectura). Por ejemplo, podrías modelar "
|
||||
"una persona como:"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid ""
|
||||
"<![CDATA[public class Person {\n"
|
||||
" private java.util.Date birthday;\n"
|
||||
" private Name name;\n"
|
||||
" private String key;\n"
|
||||
" public String getKey() {\n"
|
||||
" return key;\n"
|
||||
" }\n"
|
||||
" private void setKey(String key) {\n"
|
||||
" this.key=key;\n"
|
||||
" }\n"
|
||||
" public java.util.Date getBirthday() {\n"
|
||||
" return birthday;\n"
|
||||
" }\n"
|
||||
" public void setBirthday(java.util.Date birthday) {\n"
|
||||
" this.birthday = birthday;\n"
|
||||
" }\n"
|
||||
" public Name getName() {\n"
|
||||
" return name;\n"
|
||||
" }\n"
|
||||
" public void setName(Name name) {\n"
|
||||
" this.name = name;\n"
|
||||
" }\n"
|
||||
" ......\n"
|
||||
" ......\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[public class Person {\n"
|
||||
" private java.util.Date birthday;\n"
|
||||
" private Name name;\n"
|
||||
" private String key;\n"
|
||||
" public String getKey() {\n"
|
||||
" return key;\n"
|
||||
" }\n"
|
||||
" private void setKey(String key) {\n"
|
||||
" this.key=key;\n"
|
||||
" }\n"
|
||||
" public java.util.Date getBirthday() {\n"
|
||||
" return birthday;\n"
|
||||
" }\n"
|
||||
" public void setBirthday(java.util.Date birthday) {\n"
|
||||
" this.birthday = birthday;\n"
|
||||
" }\n"
|
||||
" public Name getName() {\n"
|
||||
" return name;\n"
|
||||
" }\n"
|
||||
" public void setName(Name name) {\n"
|
||||
" this.name = name;\n"
|
||||
" }\n"
|
||||
" ......\n"
|
||||
" ......\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:23
|
||||
msgid ""
|
||||
"<![CDATA[public class Name {\n"
|
||||
" char initial;\n"
|
||||
" String first;\n"
|
||||
" String last;\n"
|
||||
" public String getFirst() {\n"
|
||||
" return first;\n"
|
||||
" }\n"
|
||||
" void setFirst(String first) {\n"
|
||||
" this.first = first;\n"
|
||||
" }\n"
|
||||
" public String getLast() {\n"
|
||||
" return last;\n"
|
||||
" }\n"
|
||||
" void setLast(String last) {\n"
|
||||
" this.last = last;\n"
|
||||
" }\n"
|
||||
" public char getInitial() {\n"
|
||||
" return initial;\n"
|
||||
" }\n"
|
||||
" void setInitial(char initial) {\n"
|
||||
" this.initial = initial;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[public class Name {\n"
|
||||
" char initial;\n"
|
||||
" String first;\n"
|
||||
" String last;\n"
|
||||
" public String getFirst() {\n"
|
||||
" return first;\n"
|
||||
" }\n"
|
||||
" void setFirst(String first) {\n"
|
||||
" this.first = first;\n"
|
||||
" }\n"
|
||||
" public String getLast() {\n"
|
||||
" return last;\n"
|
||||
" }\n"
|
||||
" void setLast(String last) {\n"
|
||||
" this.last = last;\n"
|
||||
" }\n"
|
||||
" public char getInitial() {\n"
|
||||
" return initial;\n"
|
||||
" }\n"
|
||||
" void setInitial(char initial) {\n"
|
||||
" this.initial = initial;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:25
|
||||
msgid ""
|
||||
"Now <literal>Name</literal> may be persisted as a component of "
|
||||
"<literal>Person</literal>. Notice that <literal>Name</literal> defines "
|
||||
"getter and setter methods for its persistent properties, but doesn't need to "
|
||||
"declare any interfaces or identifier properties."
|
||||
msgstr ""
|
||||
"Ahora <literal>Name</literal> puede ser persistido como un componente de "
|
||||
"<literal>Person</literal>. Observa que <literal>Name</literal> define "
|
||||
"métodos getter y setter para sus propiedades persistentes, pero no "
|
||||
"necesita declarar ninguna interface ni propiedades identificadoras."
|
||||
|
||||
#: index.docbook:32
|
||||
msgid "Our Hibernate mapping would look like:"
|
||||
msgstr "Nuestro mapeo de Hibernate se vería así:"
|
||||
|
||||
#: index.docbook:36
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
|
||||
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
|
||||
" <generator class=\"uuid\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"birthday\" type=\"date\"/>\n"
|
||||
" <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute "
|
||||
"optional -->\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </component>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
|
||||
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
|
||||
" <generator class=\"uuid.hex\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"birthday\" type=\"date\"/>\n"
|
||||
" <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute "
|
||||
"optional -->\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </component>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:38
|
||||
msgid ""
|
||||
"The person table would have the columns <literal>pid</literal>, "
|
||||
"<literal>birthday</literal>, <literal>initial</literal>, <literal>first</"
|
||||
"literal> and <literal>last</literal>."
|
||||
msgstr ""
|
||||
"La tabla person tendría las columnas <literal>pid</literal>, "
|
||||
"<literal>birthday</literal>, <literal>initial</literal>, <literal>first</"
|
||||
"literal> y <literal>last</literal>."
|
||||
|
||||
#: index.docbook:46
|
||||
msgid ""
|
||||
"Like all value types, components do not support shared references. In other "
|
||||
"words, two persons could have the same name, but the two person objects "
|
||||
"would contain two independent name ojects, only \"the same\" by value. The "
|
||||
"null value semantics of a component are <emphasis>ad hoc</emphasis>. When "
|
||||
"reloading the containing object, Hibernate will assume that if all component "
|
||||
"columns are null, then the entire component is null. This should be okay for "
|
||||
"most purposes."
|
||||
msgstr ""
|
||||
"Como todos los tipos de valor, los componentes no soportan referencias "
|
||||
"compartidas. En otras palabras, dos personas pueden tener el mismo nombre, "
|
||||
"pero los dos objetos persona contendrían dos objetos nombre "
|
||||
"independientes, sólo \"iguales\" en valor. La semántica de "
|
||||
"valor nulo de un componente es <emphasis>ad hoc</emphasis>. Cuando se "
|
||||
"recargue el objeto contenedor, Hibernate asumirá que si todas las "
|
||||
"columnas del componente son nulas, el componente entero es nulo. Esto debe "
|
||||
"estar bien para la mayoría de propósitos."
|
||||
|
||||
#: index.docbook:55
|
||||
msgid ""
|
||||
"The properties of a component may be of any Hibernate type (collections, "
|
||||
"many-to-one associations, other components, etc). Nested components should "
|
||||
"<emphasis>not</emphasis> be considered an exotic usage. Hibernate is "
|
||||
"intended to support a very fine-grained object model."
|
||||
msgstr ""
|
||||
"Las propiedades de un componentes pueden ser de cualquier tipo de Hibernate "
|
||||
"(colecciones, muchos-a-uno, asociaciones, otros componentes, etc). Los "
|
||||
"componentes anidados <emphasis>no</emphasis> deben ser considerados un uso "
|
||||
"exótico. Hibernate está concebido para soportar un modelo de "
|
||||
"objetos granularizado en fino."
|
||||
|
||||
#: index.docbook:62
|
||||
msgid ""
|
||||
"The <literal><component></literal> element allows a <literal><"
|
||||
"parent></literal> subelement that maps a property of the component class "
|
||||
"as a reference back to the containing entity."
|
||||
msgstr ""
|
||||
"El elemento <literal><component></literal> permite un subelemento "
|
||||
"<literal><parent></literal> que mapee una propiedad de la clase del "
|
||||
"componente como una referencia de regreso a la entidad contenedora."
|
||||
|
||||
#: index.docbook:68
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
|
||||
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
|
||||
" <generator class=\"uuid\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"birthday\" type=\"date\"/>\n"
|
||||
" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"
|
||||
" <parent name=\"namedPerson\"/> <!-- reference back to the Person --"
|
||||
">\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </component>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
|
||||
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
|
||||
" <generator class=\"uuid.hex\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"birthday\" type=\"date\"/>\n"
|
||||
" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"
|
||||
" <parent name=\"namedPerson\"/> <!-- reference back to the Person --"
|
||||
">\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </component>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:73
|
||||
msgid "Collections of dependent objects"
|
||||
msgstr "Colecciones de objetos dependientes"
|
||||
|
||||
#: index.docbook:75
|
||||
msgid ""
|
||||
"Collections of components are supported (eg. an array of type <literal>Name</"
|
||||
"literal>). Declare your component collection by replacing the <literal><"
|
||||
"element></literal> tag with a <literal><composite-element></"
|
||||
"literal> tag."
|
||||
msgstr ""
|
||||
"Las colecciones de componentes están soportadas (por ejemplo, un "
|
||||
"array de tipo <literal>Name</literal>). Declara tu colección de "
|
||||
"componentes remplazando la etiqueta <literal><element></literal> por "
|
||||
"una etiqueta <literal><composite-element></literal>."
|
||||
|
||||
#: index.docbook:82
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"
|
||||
" <key column=\"id\"/>\n"
|
||||
" <composite-element class=\"eg.Name\"> <!-- class attribute required -->\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </composite-element>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"
|
||||
" <key column=\"id\"/>\n"
|
||||
" <composite-element class=\"eg.Name\"> <!-- class attribute required -->\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </composite-element>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:84
|
||||
msgid ""
|
||||
"Note: if you define a <literal>Set</literal> of composite elements, it is "
|
||||
"very important to implement <literal>equals()</literal> and <literal>hashCode"
|
||||
"()</literal> correctly."
|
||||
msgstr ""
|
||||
"Nota: si defines un <literal>Set</literal> de elementos compuestos, es muy "
|
||||
"importante implementar <literal>equals()</literal> y <literal>hashCode()</"
|
||||
"literal> correctamente."
|
||||
|
||||
#: index.docbook:90
|
||||
msgid ""
|
||||
"Composite elements may contain components but not collections. If your "
|
||||
"composite element itself contains components, use the <literal><nested-"
|
||||
"composite-element></literal> tag. This is a pretty exotic case - a "
|
||||
"collection of components which themselves have components. By this stage you "
|
||||
"should be asking yourself if a one-to-many association is more appropriate. "
|
||||
"Try remodelling the composite element as an entity - but note that even "
|
||||
"though the Java model is the same, the relational model and persistence "
|
||||
"semantics are still slightly different."
|
||||
msgstr ""
|
||||
"Los elementos compuestos pueden contener componentes pero no colecciones. Si "
|
||||
"tu elemento compuesto contiene a su vez componentes, usa la etiqueta "
|
||||
"<literal><nested-composite-element></literal>. Este es un caso "
|
||||
"bastante exótico - una colección de componentes que a su vez "
|
||||
"tienen componentes. A esta altura debes estar preguntándote si una "
|
||||
"asociación uno-a-muchos es más apropiada. Intenta remodelar el "
|
||||
"elemento compuesto como una entidad - pero observa que aunque el modelo Java "
|
||||
"es el mismo, el modelo relacional y la semántica de persistencia "
|
||||
"siguen siendo ligeramente diferentes."
|
||||
|
||||
#: index.docbook:102
|
||||
msgid ""
|
||||
"Please note that a composite element mapping doesn't support null-able "
|
||||
"properties if you're using a <literal><set></literal>. Hibernate has "
|
||||
"to use each columns value to identify a record when deleting objects (there "
|
||||
"is no separate primary key column in the composite element table), which is "
|
||||
"not possible with null values. You have to either use only not-null "
|
||||
"properties in a composite-element or choose a <literal><list></"
|
||||
"literal>, <literal><map></literal>, <literal><bag></literal> or "
|
||||
"<literal><idbag></literal>."
|
||||
msgstr ""
|
||||
"Por favor observa que un mapeo de elemento compuesto no soporta propiedades "
|
||||
"nulables si estás usando un <literal><set></literal>. Hibernate "
|
||||
"tiene que usar cada columna para identificar un registro al borrar objetos "
|
||||
"(no hay una columna clave primaria separada en la tabla del elemento "
|
||||
"compuesto), lo que es imposible con valores nulos. Tienes que, o bien usar "
|
||||
"sólo propiedades no nulas en un elemento compuesto o elegir un "
|
||||
"<literal><list></literal>, <literal><map></literal>, "
|
||||
"<literal><bag></literal> o <literal><idbag></literal>."
|
||||
|
||||
#: index.docbook:113
|
||||
msgid ""
|
||||
"A special case of a composite element is a composite element with a nested "
|
||||
"<literal><many-to-one></literal> element. A mapping like this allows "
|
||||
"you to map extra columns of a many-to-many association table to the "
|
||||
"composite element class. The following is a many-to-many association from "
|
||||
"<literal>Order</literal> to <literal>Item</literal> where "
|
||||
"<literal>purchaseDate</literal>, <literal>price</literal> and "
|
||||
"<literal>quantity</literal> are properties of the association:"
|
||||
msgstr ""
|
||||
"Un caso especial de un elemento compuesto es un elemento compuesto con un "
|
||||
"elemento anidado <literal><many-to-one></literal>. Un mapeo como este "
|
||||
"te permite mapear columnas extra de una tabla de asociación muchos-a-"
|
||||
"muchos a la clase del elemento compuesto. La siguiente es una "
|
||||
"asociación muchos-a-muchos de <literal>Order</literal> a "
|
||||
"<literal>Item</literal> donde <literal>purchaseDate</literal>, "
|
||||
"<literal>price</literal> y <literal>quantity</literal> son propiedades de la "
|
||||
"asociación:"
|
||||
|
||||
#: index.docbook:123
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Order\" .... >\n"
|
||||
" ....\n"
|
||||
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
|
||||
" <key column=\"order_id\">\n"
|
||||
" <composite-element class=\"eg.Purchase\">\n"
|
||||
" <property name=\"purchaseDate\"/>\n"
|
||||
" <property name=\"price\"/>\n"
|
||||
" <property name=\"quantity\"/>\n"
|
||||
" <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class "
|
||||
"attribute is optional -->\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"eg.Order\" .... >\n"
|
||||
" ....\n"
|
||||
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
|
||||
" <key column=\"order_id\">\n"
|
||||
" <composite-element class=\"eg.Purchase\">\n"
|
||||
" <property name=\"purchaseDate\"/>\n"
|
||||
" <property name=\"price\"/>\n"
|
||||
" <property name=\"quantity\"/>\n"
|
||||
" <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class "
|
||||
"attribute is optional -->\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:125
|
||||
msgid ""
|
||||
"Of course, there can't be a reference to the purchae on the other side, for "
|
||||
"bidirectional association navigation. Remember that components are value "
|
||||
"types and don't allow shared references. A single <literal>Purchase</"
|
||||
"literal> can be in the set of an <literal>Order</literal>, but it can't be "
|
||||
"referenced by the <literal>Item</literal> at the same time."
|
||||
msgstr ""
|
||||
"Por supuesto, no puede haber una referencia a la compra del otro lado para "
|
||||
"la navegación bidireccional de la asociación. Recuerda que los "
|
||||
"componentes son tipos de valor no permiten referencias compartidas. Una sola "
|
||||
"<literal>Purchase</literal> puede estar en el conjunto de una "
|
||||
"<literal>Order</literal>, pero no puede ser referenciada por el "
|
||||
"<literal>Item</literal> al mismo tiempo."
|
||||
|
||||
#: index.docbook:133
|
||||
msgid "Even ternary (or quaternary, etc) associations are possible:"
|
||||
msgstr "Incluso son posibles las asociaciones ternarias (o cuaternarias, etc):"
|
||||
|
||||
#: index.docbook:135
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Order\" .... >\n"
|
||||
" ....\n"
|
||||
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
|
||||
" <key column=\"order_id\">\n"
|
||||
" <composite-element class=\"eg.OrderLine\">\n"
|
||||
" <many-to-one name=\"purchaseDetails class=\"eg.Purchase\"/>\n"
|
||||
" <many-to-one name=\"item\" class=\"eg.Item\"/>\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"eg.Order\" .... >\n"
|
||||
" ....\n"
|
||||
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
|
||||
" <key column=\"order_id\">\n"
|
||||
" <composite-element class=\"eg.OrderLine\">\n"
|
||||
" <many-to-one name=\"purchaseDetails class=\"eg.Purchase\"/>\n"
|
||||
" <many-to-one name=\"item\" class=\"eg.Item\"/>\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:137
|
||||
msgid ""
|
||||
"Composite elements may appear in queries using the same syntax as "
|
||||
"associations to other entities."
|
||||
msgstr ""
|
||||
"Los elementos compuestos pueden aparecer en consultas usando la misma "
|
||||
"sintáxis que las asociaciones a otras entidades."
|
||||
|
||||
#: index.docbook:145
|
||||
msgid "Components as Map indices"
|
||||
msgstr "Componentes como índices de Map"
|
||||
|
||||
#: index.docbook:147
|
||||
msgid ""
|
||||
"The <literal><composite-map-key></literal> element lets you map a "
|
||||
"component class as the key of a <literal>Map</literal>. Make sure you "
|
||||
"override <literal>hashCode()</literal> and <literal>equals()</literal> "
|
||||
"correctly on the component class."
|
||||
msgstr ""
|
||||
"El elemento <literal><composite-map-key></literal> te permite mapear "
|
||||
"una clase componente como la clave de un <literal>Map</literal>. Asegú"
|
||||
"rate que sobrescribes <literal>hashCode()</literal> y <literal>equals()</"
|
||||
"literal> correctamente en la clase componente."
|
||||
|
||||
#: index.docbook:156
|
||||
msgid "Components as composite identifiers"
|
||||
msgstr "Componentes como identificadores compuestos"
|
||||
|
||||
#: index.docbook:158
|
||||
msgid ""
|
||||
"You may use a component as an identifier of an entity class. Your component "
|
||||
"class must satisfy certain requirements:"
|
||||
msgstr ""
|
||||
"Puedes usar un componente como un identidicador de una clase entidad. Tu "
|
||||
"clase componente debe satisfacer ciertos requerimientos:"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "It must implement <literal>java.io.Serializable</literal>."
|
||||
msgstr "Debe implementar <literal>java.io.Serializable</literal>."
|
||||
|
||||
#: index.docbook:170
|
||||
msgid ""
|
||||
"It must re-implement <literal>equals()</literal> and <literal>hashCode()</"
|
||||
"literal>, consistently with the database's notion of composite key equality."
|
||||
msgstr ""
|
||||
"Debe re-implementar <literal>equals()</literal> y <literal>hashCode()</"
|
||||
"literal>, consistentemente con la noción de base de datos de igualdad "
|
||||
"de clave compuesta."
|
||||
|
||||
#: index.docbook:179
|
||||
msgid ""
|
||||
"Note: in Hibernate3, the second requirement is not an absolutely hard "
|
||||
"requirement of Hibernate. But do it anyway."
|
||||
msgstr ""
|
||||
"Nota: en Hibernat3, el segundo requerimiento no es absolutamente un "
|
||||
"requerimiento rígido de Hibernate. Pero de todas formas, házlo."
|
||||
|
||||
#: index.docbook:183
|
||||
msgid ""
|
||||
"You can't use an <literal>IdentifierGenerator</literal> to generate "
|
||||
"composite keys. Instead the application must assign its own identifiers."
|
||||
msgstr ""
|
||||
"No puedes usar un <literal>IdentifierGenerator</literal> para generar claves "
|
||||
"compuestas. La aplicación debe, en cambio, asignar sus propios "
|
||||
"identificadores."
|
||||
|
||||
#: index.docbook:188
|
||||
msgid ""
|
||||
"Use the <literal><composite-id></literal> tag (with nested "
|
||||
"<literal><key-property></literal> elements) in place of the usual "
|
||||
"<literal><id></literal> declaration. For example, the "
|
||||
"<literal>OrderLine</literal> class has a primary key that depends upon the "
|
||||
"(composite) primary key of <literal>Order</literal>."
|
||||
msgstr ""
|
||||
"Usa la etiqueta <literal><composite-id></literal> (con elementos "
|
||||
"anidados <literal><key-property></literal>) en lugar de la usual "
|
||||
"declaración <literal><id></literal>. Por ejemplo, la clase "
|
||||
"<literal>OrderLine</literal> tiene una clave primaria que depende de la "
|
||||
"clave primaria (compuesta) de <literal>Order</literal>."
|
||||
|
||||
#: index.docbook:196
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"OrderLine\">\n"
|
||||
" \n"
|
||||
" <composite-id name=\"id\" class=\"OrderLineId\">\n"
|
||||
" <key-property name=\"lineId\"/>\n"
|
||||
" <key-property name=\"orderId\"/>\n"
|
||||
" <key-property name=\"customerId\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" \n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"order\" class=\"Order\"\n"
|
||||
" insert=\"false\" update=\"false\">\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </many-to-one>\n"
|
||||
" ....\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"OrderLine\">\n"
|
||||
" \n"
|
||||
" <composite-id name=\"id\" class=\"OrderLineId\">\n"
|
||||
" <key-property name=\"lineId\"/>\n"
|
||||
" <key-property name=\"orderId\"/>\n"
|
||||
" <key-property name=\"customerId\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" \n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"order\" class=\"Order\"\n"
|
||||
" insert=\"false\" update=\"false\">\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </many-to-one>\n"
|
||||
" ....\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:198
|
||||
msgid ""
|
||||
"Now, any foreign keys referencing the <literal>OrderLine</literal> table are "
|
||||
"also composite. You must declare this in your mappings for other classes. An "
|
||||
"association to <literal>OrderLine</literal> would be mapped like this:"
|
||||
msgstr ""
|
||||
"Ahora, cualquier clave foránea que referencie la tabla de "
|
||||
"<literal>OrderLine</literal> es también compuesta. Debes declarar "
|
||||
"esto en tus mapeos de otras clases. Una asociación a "
|
||||
"<literal>OrderLine</literal> sería mapeado así:"
|
||||
|
||||
#: index.docbook:204
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"orderLine\" class=\"OrderLine\">\n"
|
||||
"<!-- the \"class\" attribute is optional, as usual -->\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
"</many-to-one>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<many-to-one name=\"orderLine\" class=\"OrderLine\">\n"
|
||||
"<!-- the \"class\" attribute is optional, as usual -->\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
"</many-to-one>]]>"
|
||||
|
||||
#: index.docbook:206
|
||||
msgid ""
|
||||
"(Note that the <literal><column></literal> tag is an alternative to "
|
||||
"the <literal>column</literal> attribute everywhere.)"
|
||||
msgstr ""
|
||||
"(Nota que la etiqueta <literal><column></literal> es una alternativa "
|
||||
"al atributo <literal>column</literal> en cualquier sitio.)"
|
||||
|
||||
#: index.docbook:211
|
||||
msgid ""
|
||||
"A <literal>many-to-many</literal> association to <literal>OrderLine</"
|
||||
"literal> also uses the composite foreign key:"
|
||||
msgstr ""
|
||||
"Una asociación <literal>muchos-a-muchos</literal> a "
|
||||
"<literal>OrderLine</literal> también usa la clave foránea "
|
||||
"compuesta:"
|
||||
|
||||
#: index.docbook:216
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"undeliveredOrderLines\">\n"
|
||||
" <key column name=\"warehouseId\"/>\n"
|
||||
" <many-to-many class=\"OrderLine\">\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </many-to-many>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"undeliveredOrderLines\">\n"
|
||||
" <key column name=\"warehouseId\"/>\n"
|
||||
" <many-to-many class=\"OrderLine\">\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </many-to-many>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:218
|
||||
msgid ""
|
||||
"The collection of <literal>OrderLine</literal>s in <literal>Order</literal> "
|
||||
"would use:"
|
||||
msgstr ""
|
||||
"La colección de <literal>OrderLine</literal>s en <literal>Order</"
|
||||
"literal> usaría:"
|
||||
|
||||
#: index.docbook:223
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"orderLines\" inverse=\"true\">\n"
|
||||
" <key>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </key>\n"
|
||||
" <one-to-many class=\"OrderLine\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"orderLines\" inverse=\"true\">\n"
|
||||
" <key>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </key>\n"
|
||||
" <one-to-many class=\"OrderLine\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:225
|
||||
msgid ""
|
||||
"(The <literal><one-to-many></literal> element, as usual, declares no "
|
||||
"columns.)"
|
||||
msgstr ""
|
||||
"(El elemento <literal><one-to-many></literal>, como es usual, no "
|
||||
"declara columnas.)"
|
||||
|
||||
#: index.docbook:229
|
||||
msgid ""
|
||||
"If <literal>OrderLine</literal> itself owns a collection, it also has a "
|
||||
"composite foreign key."
|
||||
msgstr ""
|
||||
"Si <literal>OrderLine</literal> posee una colección por sí "
|
||||
"misma, tiene también una clave foránea compuesta."
|
||||
|
||||
#: index.docbook:234
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"OrderLine\">\n"
|
||||
" ....\n"
|
||||
" ....\n"
|
||||
" <list name=\"deliveryAttempts\">\n"
|
||||
" <key> <!-- a collection inherits the composite key type -->\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </key>\n"
|
||||
" <list-index column=\"attemptId\" base=\"1\"/>\n"
|
||||
" <composite-element class=\"DeliveryAttempt\">\n"
|
||||
" ...\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"OrderLine\">\n"
|
||||
" ....\n"
|
||||
" ....\n"
|
||||
" <list name=\"deliveryAttempts\">\n"
|
||||
" <key> <!-- a collection inherits the composite key type -->\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </key>\n"
|
||||
" <list-index column=\"attemptId\" base=\"1\"/>\n"
|
||||
" <composite-element class=\"DeliveryAttempt\">\n"
|
||||
" ...\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:239
|
||||
msgid "Dynamic components"
|
||||
msgstr "Componentes dinámicos"
|
||||
|
||||
#: index.docbook:241
|
||||
msgid "You may even map a property of type <literal>Map</literal>:"
|
||||
msgstr "Puedes incluso mapear una propiedad de tipo <literal>Map</literal>:"
|
||||
|
||||
#: index.docbook:245
|
||||
msgid ""
|
||||
"<![CDATA[<dynamic-component name=\"userAttributes\">\n"
|
||||
" <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n"
|
||||
" <property name=\"bar\" column=\"BAR\" type=\"integer\"/>\n"
|
||||
" <many-to-one name=\"baz\" class=\"Baz\" column=\"BAZ_ID\"/>\n"
|
||||
"</dynamic-component>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<dynamic-component name=\"userAttributes\">\n"
|
||||
" <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n"
|
||||
" <property name=\"bar\" column=\"BAR\" type=\"integer\"/>\n"
|
||||
" <many-to-one name=\"baz\" class=\"Baz\" column=\"BAZ_ID\"/>\n"
|
||||
"</dynamic-component>]]>"
|
||||
|
||||
#: index.docbook:247
|
||||
msgid ""
|
||||
"The semantics of a <literal><dynamic-component></literal> mapping are "
|
||||
"identical to <literal><component></literal>. The advantage of this "
|
||||
"kind of mapping is the ability to determine the actual properties of the "
|
||||
"bean at deployment time, just by editing the mapping document. Runtime "
|
||||
"manipulation of the mapping document is also possible, using a DOM parser. "
|
||||
"Even better, you can access (and change) Hibernate's configuration-time "
|
||||
"metamodel via the <literal>Configuration</literal> object."
|
||||
msgstr ""
|
||||
"La semántica de un mapeo <literal><dynamic-component></literal> "
|
||||
"es ídentica a la de <literal><component></literal>. La ventaja "
|
||||
"de este tipo de mapeos es la habilidad para determinar las propiedades "
|
||||
"reales del bean en tiempo de despliegue, sólo con editar el documento "
|
||||
"de mapeo. La manipulación del documento de mapeo en tiempo de "
|
||||
"ejecución es también posible, usando un analizador DOM. "
|
||||
"Incluso mejor, puedes acceder (y cambiar) el metamodelo de tiempo de "
|
||||
"configuración de Hibernate por medio del objeto "
|
||||
"<literal>Configuration</literal>."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,538 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Interceptors and events"
|
||||
msgstr "Interceptores y eventos"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"It is often useful for the application to react to certain events that occur "
|
||||
"inside Hibernate. This allows implementation of certain kinds of generic "
|
||||
"functionality, and extension of Hibernate functionality."
|
||||
msgstr ""
|
||||
"Frecuentemente es útil para la aplicación reaccionar a ciertos "
|
||||
"eventos que ocurran dentro de Hibernate. Esto permite la implementació"
|
||||
"n de ciertos tipos de funcionalidade genérica, y extensión de "
|
||||
"la funcionalidad de Hibernate."
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Interceptors"
|
||||
msgstr "Interceptores"
|
||||
|
||||
#: index.docbook:16
|
||||
msgid ""
|
||||
"The <literal>Interceptor</literal> interface provides callbacks from the "
|
||||
"session to the application allowing the application to inspect and/or "
|
||||
"manipulate properties of a persistent object before it is saved, updated, "
|
||||
"deleted or loaded. One possible use for this is to track auditing "
|
||||
"information. For example, the following <literal>Interceptor</literal> "
|
||||
"automatically sets the <literal>createTimestamp</literal> when an "
|
||||
"<literal>Auditable</literal> is created and updates the "
|
||||
"<literal>lastUpdateTimestamp</literal> property when an <literal>Auditable</"
|
||||
"literal> is updated."
|
||||
msgstr ""
|
||||
"La interface <literal>Interceptor</literal> provee callbacks desde la "
|
||||
"sesión a la aplicación permitiendo a ésta última "
|
||||
"inspeccionar y/o manipular las propiedades de un objeto persistente antes "
|
||||
"que sea salvado, actualizado, borrado o cargado. Un uso posible de esto es "
|
||||
"seguir la pista de información de auditoría. Por ejemplo, el "
|
||||
"siguiente <literal>Interceptor</literal> establece automáticamente el "
|
||||
"<literal>createTimestamp</literal> cuando un <literal>Auditable</literal> es "
|
||||
"creado y actualiza la propiedad <literal>lastUpdateTimestamp</literal> "
|
||||
"cuando un <literal>Auditable</literal> es acutalizado."
|
||||
|
||||
#: index.docbook:27
|
||||
msgid ""
|
||||
"You may either implement <literal>Interceptor</literal> directly or (better) "
|
||||
"extend <literal>EmptyInterceptor</literal>."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! You may either implement <literal>Interceptor</literal> "
|
||||
"directly or (better) extend <literal>EmptyInterceptor</literal>."
|
||||
|
||||
#: index.docbook:32
|
||||
msgid ""
|
||||
"<![CDATA[package org.hibernate.test;\n"
|
||||
"\n"
|
||||
"import java.io.Serializable;\n"
|
||||
"import java.util.Date;\n"
|
||||
"import java.util.Iterator;\n"
|
||||
"\n"
|
||||
"import org.hibernate.EmptyInterceptor;\n"
|
||||
"import org.hibernate.Transaction;\n"
|
||||
"import org.hibernate.type.Type;\n"
|
||||
"\n"
|
||||
"public class AuditInterceptor extends EmptyInterceptor {\n"
|
||||
"\n"
|
||||
" private int updates;\n"
|
||||
" private int creates;\n"
|
||||
" private int loads;\n"
|
||||
"\n"
|
||||
" public void onDelete(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
" // do nothing\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onFlushDirty(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] currentState,\n"
|
||||
" Object[] previousState,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
"\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" updates++;\n"
|
||||
" for ( int i=0; i < propertyNames.length; i++ ) {\n"
|
||||
" if ( \"lastUpdateTimestamp\".equals( propertyNames[i] ) ) {\n"
|
||||
" currentState[i] = new Date();\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onLoad(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" loads++;\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onSave(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
"\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" creates++;\n"
|
||||
" for ( int i=0; i<propertyNames.length; i++ ) {\n"
|
||||
" if ( \"createTimestamp\".equals( propertyNames[i] ) ) {\n"
|
||||
" state[i] = new Date();\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public void afterTransactionCompletion(Transaction tx) {\n"
|
||||
" if ( tx.wasCommitted() ) {\n"
|
||||
" System.out.println(\"Creations: \" + creates + \", Updates: \" + "
|
||||
"updates, \"Loads: \" + loads);\n"
|
||||
" }\n"
|
||||
" updates=0;\n"
|
||||
" creates=0;\n"
|
||||
" loads=0;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[package org.hibernate.test;\n"
|
||||
"\n"
|
||||
"import java.io.Serializable;\n"
|
||||
"import java.util.Date;\n"
|
||||
"import java.util.Iterator;\n"
|
||||
"\n"
|
||||
"import org.hibernate.Interceptor;\n"
|
||||
"import org.hibernate.type.Type;\n"
|
||||
"\n"
|
||||
"public class AuditInterceptor implements Interceptor, Serializable {\n"
|
||||
"\n"
|
||||
" private int updates;\n"
|
||||
" private int creates;\n"
|
||||
"\n"
|
||||
" public void onDelete(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
" // do nothing\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onFlushDirty(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] currentState,\n"
|
||||
" Object[] previousState,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
"\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" updates++;\n"
|
||||
" for ( int i=0; i < propertyNames.length; i++ ) {\n"
|
||||
" if ( \"lastUpdateTimestamp\".equals( propertyNames[i] ) ) {\n"
|
||||
" currentState[i] = new Date();\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onLoad(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onSave(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
"\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" creates++;\n"
|
||||
" for ( int i=0; i<propertyNames.length; i++ ) {\n"
|
||||
" if ( \"createTimestamp\".equals( propertyNames[i] ) ) {\n"
|
||||
" state[i] = new Date();\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public void postFlush(Iterator entities) {\n"
|
||||
" System.out.println(\"Creations: \" + creates + \", Updates: \" + "
|
||||
"updates);\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public void preFlush(Iterator entities) {\n"
|
||||
" updates=0;\n"
|
||||
" creates=0;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:34
|
||||
msgid ""
|
||||
"Interceptors come in two flavors: <literal>Session</literal>-scoped and "
|
||||
"<literal>SessionFactory</literal>-scoped."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! Interceptors come in two flavors: <literal>Session</literal>-"
|
||||
"scoped and <literal>SessionFactory</literal>-scoped."
|
||||
|
||||
#: index.docbook:39
|
||||
msgid ""
|
||||
"A <literal>Session</literal>-scoped interceptor is specified when a session "
|
||||
"is opened using one of the overloaded SessionFactory.openSession() methods "
|
||||
"accepting an <literal>Interceptor</literal>."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! A <literal>Session</literal>-scoped interceptor is specified "
|
||||
"when a session is opened using one of the overloaded SessionFactory."
|
||||
"openSession() methods accepting an <literal>Interceptor</literal>."
|
||||
|
||||
#: index.docbook:45
|
||||
msgid "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
|
||||
|
||||
#: index.docbook:47
|
||||
msgid ""
|
||||
"A <literal>SessionFactory</literal>-scoped interceptor is registered with "
|
||||
"the <literal>Configuration</literal> object prior to building the "
|
||||
"<literal>SessionFactory</literal>. In this case, the supplied interceptor "
|
||||
"will be applied to all sessions opened from that <literal>SessionFactory</"
|
||||
"literal>; this is true unless a session is opened explicitly specifying the "
|
||||
"interceptor to use. <literal>SessionFactory</literal>-scoped interceptors "
|
||||
"must be thread safe, taking care to not store session-specific state since "
|
||||
"multiple sessions will use this interceptor (potentially) concurrently."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! A <literal>SessionFactory</literal>-scoped interceptor is "
|
||||
"registered with the <literal>Configuration</literal> object prior to "
|
||||
"building the <literal>SessionFactory</literal>. In this case, the supplied "
|
||||
"interceptor will be applied to all sessions opened from that "
|
||||
"<literal>SessionFactory</literal>; this is true unless a session is opened "
|
||||
"explicitly specifying the interceptor to use. <literal>SessionFactory</"
|
||||
"literal>-scoped interceptors must be thread safe, taking care to not store "
|
||||
"session-specific state since multiple sessions will use this interceptor "
|
||||
"(potentially) concurrently."
|
||||
|
||||
#: index.docbook:56
|
||||
msgid ""
|
||||
"<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
|
||||
#: index.docbook:61
|
||||
msgid "Event system"
|
||||
msgstr "Sistema de eventos"
|
||||
|
||||
#: index.docbook:63
|
||||
msgid ""
|
||||
"If you have to react to particular events in your persistence layer, you may "
|
||||
"also use the Hibernate3 <emphasis>event</emphasis> architecture. The event "
|
||||
"system can be used in addition or as a replacement for interceptors."
|
||||
msgstr ""
|
||||
"Si tienes que reaccionar a eventos particulares en tu capa de persistencia, "
|
||||
"puedes también la arquitectura de <emphasis>eventos</emphasis> de "
|
||||
"Hibernate3. El sistema de eventos puede ser usado en adición o como "
|
||||
"un remplazo a los interceptores."
|
||||
|
||||
#: index.docbook:69
|
||||
msgid ""
|
||||
"Essentially all of the methods of the <literal>Session</literal> interface "
|
||||
"correlate to an event. You have a <literal>LoadEvent</literal>, a "
|
||||
"<literal>FlushEvent</literal>, etc (consult the XML configuration-file DTD "
|
||||
"or the <literal>org.hibernate.event</literal> package for the full list of "
|
||||
"defined event types). When a request is made of one of these methods, the "
|
||||
"Hibernate <literal>Session</literal> generates an appropriate event and "
|
||||
"passes it to the configured event listeners for that type. Out-of-the-box, "
|
||||
"these listeners implement the same processing in which those methods always "
|
||||
"resulted. However, you are free to implement a customization of one of the "
|
||||
"listener interfaces (i.e., the <literal>LoadEvent</literal> is processed by "
|
||||
"the registered implemenation of the <literal>LoadEventListener</literal> "
|
||||
"interface), in which case their implementation would be responsible for "
|
||||
"processing any <literal>load()</literal> requests made of the "
|
||||
"<literal>Session</literal>."
|
||||
msgstr ""
|
||||
"Esencialmente todos los métodos de la interface <literal>Session</"
|
||||
"literal> se correlacionan con un evento. Tienes un <literal>LoadEvent</"
|
||||
"literal>, un <literal>FlushEvent</literal>, etc (consulta el DTD del fichero "
|
||||
"de configuración XML o el paquete <literal>org.hibernate.event</"
|
||||
"literal> para la lista completa de tipos de evento definidos). Cuando se "
|
||||
"hace una petición de uno de estos métodos, la "
|
||||
"<literal>Session</literal> de Hibernate genera un evento apropiado y se lo "
|
||||
"pasa al oyente (listener) de eventos configurado para ese tipo. De fá"
|
||||
"brica, estos oyentes implementan el mismo procesamiento en los que siempre "
|
||||
"resultan aquellos métodos. Sin embargo, eres libre de implementar una "
|
||||
"personalización de una de las interfaces oyentes (es decir, el "
|
||||
"<literal>LoadEvent</literal> es procesado por la implementación "
|
||||
"registrada de la interface <literal>LoadEventListener</literal>), en cuyo "
|
||||
"caso su implementación sería responsable de procesar cualquier "
|
||||
"petición <literal>load()</literal> hecha a la <literal>Session</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:84
|
||||
msgid ""
|
||||
"The listeners should be considered effectively singletons; meaning, they are "
|
||||
"shared between requests, and thus should not save any state as instance "
|
||||
"variables."
|
||||
msgstr ""
|
||||
"Los oyentes deben ser considerados efectivamente singletons; quiere decir, "
|
||||
"que son compartidos entre las peticiones, y por lo tanto no guardan "
|
||||
"ningún estado en variables de instancia."
|
||||
|
||||
#: index.docbook:89
|
||||
msgid ""
|
||||
"A custom listener should implement the appropriate interface for the event "
|
||||
"it wants to process and/or extend one of the convenience base classes (or "
|
||||
"even the default event listeners used by Hibernate out-of-the-box as these "
|
||||
"are declared non-final for this purpose). Custom listeners can either be "
|
||||
"registered programmatically through the <literal>Configuration</literal> "
|
||||
"object, or specified in the Hibernate configuration XML (declarative "
|
||||
"configuration through the properties file is not supported). Here's an "
|
||||
"example of a custom load event listener:"
|
||||
msgstr ""
|
||||
"Un oyente personalizado debe implementar la interface apropiada para el "
|
||||
"evento que quiere procesar y/o extender una de las clases base de "
|
||||
"conveniencia (o incluso los oyentes de eventos por defecto usados por "
|
||||
"Hibernate de fábrica al ser éstos declarados non-final para "
|
||||
"este propósito). Los oyentes personalizados pueden ser registrados "
|
||||
"programáticamente a través del objeto <literal>Configuration</"
|
||||
"literal>, o especificados en el XML de configuración de Hibernate (la "
|
||||
"declaración declarativa a través del fichero de propiedades no "
|
||||
"está soportada). He aquí un ejemplo de un oyente personalizado "
|
||||
"de eventos load:"
|
||||
|
||||
#: index.docbook:99
|
||||
msgid ""
|
||||
"<![CDATA[public class MyLoadListener implements LoadEventListener {\n"
|
||||
" // this is the single method defined by the LoadEventListener interface\n"
|
||||
" public void onLoad(LoadEvent event, LoadEventListener.LoadType "
|
||||
"loadType)\n"
|
||||
" throws HibernateException {\n"
|
||||
" if ( !MySecurity.isAuthorized( event.getEntityClassName(), event."
|
||||
"getEntityId() ) ) {\n"
|
||||
" throw MySecurityException(\"Unauthorized access\");\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[public class MyLoadListener extends DefaultLoadEventListener {\n"
|
||||
" // this is the single method defined by the LoadEventListener interface\n"
|
||||
" public Object onLoad(LoadEvent event, LoadEventListener.LoadType "
|
||||
"loadType)\n"
|
||||
" throws HibernateException {\n"
|
||||
" if ( !MySecurity.isAuthorized( event.getEntityClassName(), event."
|
||||
"getEntityId() ) ) {\n"
|
||||
" throw MySecurityException(\"Unauthorized access\");\n"
|
||||
" }\n"
|
||||
" return super.onLoad(event, loadType);\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:101
|
||||
msgid ""
|
||||
"You also need a configuration entry telling Hibernate to use the listener in "
|
||||
"addition to the default listener:"
|
||||
msgstr ""
|
||||
"Necesitas además una entrada de configuración dicié"
|
||||
"ndole a Hibernate que use el oyente en vez del oyente por defecto:"
|
||||
|
||||
#: index.docbook:106
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-configuration>\n"
|
||||
" <session-factory>\n"
|
||||
" ...\n"
|
||||
" <event type=\"load\">\n"
|
||||
" <listener class=\"com.eg.MyLoadListener\"/>\n"
|
||||
" <listener class=\"org.hibernate.event.def."
|
||||
"DefaultLoadEventListener\"/>\n"
|
||||
" </event>\n"
|
||||
" </session-factory>\n"
|
||||
"</hibernate-configuration>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<hibernate-configuration>\n"
|
||||
" <session-factory>\n"
|
||||
" ...\n"
|
||||
" <listener type=\"load\" class=\"MyLoadListener\"/>\n"
|
||||
" </session-factory>\n"
|
||||
"</hibernate-configuration>]]>"
|
||||
|
||||
#: index.docbook:108
|
||||
msgid "Instead, you may register it programmatically:"
|
||||
msgstr "En cambio, puedes registrarlo programáticamente:"
|
||||
|
||||
#: index.docbook:112
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = new Configuration();\n"
|
||||
"LoadEventListener[] stack = { new MyLoadListener(), new "
|
||||
"DefaultLoadEventListener() };\n"
|
||||
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = new Configuration();\n"
|
||||
"cfg.getSessionEventListenerConfig().setLoadEventListener( new MyLoadListener"
|
||||
"() );]]>"
|
||||
|
||||
#: index.docbook:114
|
||||
msgid ""
|
||||
"Listeners registered declaratively cannot share instances. If the same class "
|
||||
"name is used in multiple <literal><listener/></literal> elements, each "
|
||||
"reference will result in a separate instance of that class. If you need the "
|
||||
"capability to share listener instances between listener types you must use "
|
||||
"the programmatic registration approach."
|
||||
msgstr ""
|
||||
"Los oyentes registrados declarativamente no pueden compartir instancias. Si "
|
||||
"el mismo nombre de clase es usado en múltiples elementos <literal><"
|
||||
"listener/></literal>, cada referencia resultará en una instancia "
|
||||
"separada de esa clase. Si necesitas la capacidad de compartir instancias de "
|
||||
"oyentes entre tipos de oyente debes usar el enfoque de registración "
|
||||
"programática."
|
||||
|
||||
#: index.docbook:122
|
||||
msgid ""
|
||||
"Why implement an interface and define the specific type during "
|
||||
"configuration? Well, a listener implementation could implement multiple "
|
||||
"event listener interfaces. Having the type additionally defined during "
|
||||
"registration makes it easier to turn custom listeners on or off during "
|
||||
"configuration."
|
||||
msgstr ""
|
||||
"¿Por qué implementar una interface y definir el tipo "
|
||||
"espcífico durante la configuración? Bueno, una "
|
||||
"implementación de oyente podría implementar múltiples "
|
||||
"interfaces de oyente de eventos. Teniendo el tipo definido adicionalmente "
|
||||
"durante la registración lo hace más fácil para activar "
|
||||
"o desactivar oyentes personalizados durante la configuración."
|
||||
|
||||
#: index.docbook:132
|
||||
msgid "Hibernate declarative security"
|
||||
msgstr "Seguridad declarativa de Hibernate"
|
||||
|
||||
#: index.docbook:133
|
||||
msgid ""
|
||||
"Usually, declarative security in Hibernate applications is managed in a "
|
||||
"session facade layer. Now, Hibernate3 allows certain actions to be "
|
||||
"permissioned via JACC, and authorized via JAAS. This is optional "
|
||||
"functionality built on top of the event architecture."
|
||||
msgstr ""
|
||||
"Usualmente, la seguridad declarativa en aplicaciones Hibernate es manejada "
|
||||
"en una capa de fachada de sesión. Ahora, Hibernate3 permite que "
|
||||
"ciertas acciones sean permitidas vía JACC, y autorizadas vía "
|
||||
"JAAS. Esta en una funcionalidad opcional construída encima de la "
|
||||
"arquitectura de eventos."
|
||||
|
||||
#: index.docbook:139
|
||||
msgid ""
|
||||
"First, you must configure the appropriate event listeners, to enable the use "
|
||||
"of JAAS authorization."
|
||||
msgstr ""
|
||||
"Primero, debes configurar los oyentes de eventos apropiados, para habilitar "
|
||||
"el uso de autorización JAAS."
|
||||
|
||||
#: index.docbook:144
|
||||
msgid ""
|
||||
"<![CDATA[<listener type=\"pre-delete\" class=\"org.hibernate.secure."
|
||||
"JACCPreDeleteEventListener\"/>\n"
|
||||
"<listener type=\"pre-update\" class=\"org.hibernate.secure."
|
||||
"JACCPreUpdateEventListener\"/>\n"
|
||||
"<listener type=\"pre-insert\" class=\"org.hibernate.secure."
|
||||
"JACCPreInsertEventListener\"/>\n"
|
||||
"<listener type=\"pre-load\" class=\"org.hibernate.secure."
|
||||
"JACCPreLoadEventListener\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<listener type=\"pre-delete\" class=\"org.hibernate.secure."
|
||||
"JACCPreDeleteEventListener\"/>\n"
|
||||
"<listener type=\"pre-update\" class=\"org.hibernate.secure."
|
||||
"JACCPreUpdateEventListener\"/>\n"
|
||||
"<listener type=\"pre-insert\" class=\"org.hibernate.secure."
|
||||
"JACCPreInsertEventListener\"/>\n"
|
||||
"<listener type=\"pre-load\" class=\"org.hibernate.secure."
|
||||
"JACCPreLoadEventListener\"/>]]>"
|
||||
|
||||
#: index.docbook:146
|
||||
msgid ""
|
||||
"Note that <literal><listener type=\"...\" class=\"...\"/></literal> is "
|
||||
"just a shorthand for <literal><event type=\"...\"><listener class="
|
||||
"\"...\"/></event></literal> when there is exactly one listener for "
|
||||
"a particular event type."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! Note that <literal><listener type=\"...\" class=\"...\"/>"
|
||||
"</literal> is just a shorthand for <literal><event type=\"...\"><"
|
||||
"listener class=\"...\"/></event></literal> when there is exactly "
|
||||
"one listener for a particular event type."
|
||||
|
||||
#: index.docbook:152
|
||||
msgid ""
|
||||
"Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to "
|
||||
"roles:"
|
||||
msgstr ""
|
||||
"Seguido, aún en <literal>hibernate.cfg.xml</literal>, liga los "
|
||||
"permisos a roles:"
|
||||
|
||||
#: index.docbook:156
|
||||
msgid ""
|
||||
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,"
|
||||
"read\"/>\n"
|
||||
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,"
|
||||
"read\"/>\n"
|
||||
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
|
||||
|
||||
#: index.docbook:158
|
||||
msgid "The role names are the roles understood by your JACC provider."
|
||||
msgstr "Los nombres de role son los roles entendidos por tu proveedor de JACC."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,586 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Example: Parent/Child"
|
||||
msgstr "Ejemplo: Padre/Hijo"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"One of the very first things that new users try to do with Hibernate is to "
|
||||
"model a parent / child type relationship. There are two different approaches "
|
||||
"to this. For various reasons the most convenient approach, especially for "
|
||||
"new users, is to model both <literal>Parent</literal> and <literal>Child</"
|
||||
"literal> as entity classes with a <literal><one-to-many></literal> "
|
||||
"association from <literal>Parent</literal> to <literal>Child</literal>. (The "
|
||||
"alternative approach is to declare the <literal>Child</literal> as a "
|
||||
"<literal><composite-element></literal>.) Now, it turns out that "
|
||||
"default semantics of a one to many association (in Hibernate) are much less "
|
||||
"close to the usual semantics of a parent / child relationship than those of "
|
||||
"a composite element mapping. We will explain how to use a "
|
||||
"<emphasis>bidirectional one to many association with cascades</emphasis> to "
|
||||
"model a parent / child relationship efficiently and elegantly. It's not at "
|
||||
"all difficult!"
|
||||
msgstr ""
|
||||
"Una de las primerísimas cosas que los usuarios nuevos intentan hacer "
|
||||
"con Hibernate es modelar una relación de tipo padre / hijo. Para esto "
|
||||
"hay dos enfoques diferentes. Por varias razones, el enfoque más "
|
||||
"conveniente, especialmente para usuarios nuevos, es modelar tanto "
|
||||
"<literal>Parent</literal> como <literal>Child</literal> como clases de "
|
||||
"entidad con una asociación <literal><one-to-many></literal> "
|
||||
"desde <literal>Parent</literal> a <literal>Child</literal>. (El enfoque "
|
||||
"alternativo es declarar el <literal>Child</literal> como un <literal><"
|
||||
"composite-element></literal>.) Ahora, resulta que la semántica por "
|
||||
"defecto de una asociación uno a muchos (en Hibernate) es mucho menos "
|
||||
"cercana a la semántica usual de una relación padre / hijo que "
|
||||
"aquellas de un mapeo de elementos compuestos. Explicaremos cómo usar "
|
||||
"una <emphasis>asociación uno a muchos bidireccional con tratamiento "
|
||||
"en cascada</emphasis> para modelar una relación padre / hijo "
|
||||
"eficiente y elegantemente. ¡No es para nada difícil!"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "A note about collections"
|
||||
msgstr "Una nota sobre las colecciones"
|
||||
|
||||
#: index.docbook:23
|
||||
msgid ""
|
||||
"Hibernate collections are considered to be a logical part of their owning "
|
||||
"entity; never of the contained entities. This is a crucial distinction! It "
|
||||
"has the following consequences:"
|
||||
msgstr ""
|
||||
"Se considera que las colecciones de Hibernate son una parte lógica de "
|
||||
"la entidad que las posee; nunca de las entidades contenidas. ¡Esta es "
|
||||
"una distinción crucial! Esto tiene las siguientes consecuencias:"
|
||||
|
||||
#: index.docbook:30
|
||||
msgid ""
|
||||
"When we remove / add an object from / to a collection, the version number of "
|
||||
"the collection owner is incremented."
|
||||
msgstr ""
|
||||
"Cuando se quita / añade un objeto desde / a una colección, se "
|
||||
"incrementa el número de versión del dueño de la "
|
||||
"colección."
|
||||
|
||||
#: index.docbook:36
|
||||
msgid ""
|
||||
"If an object that was removed from a collection is an instance of a value "
|
||||
"type (eg, a composite element), that object will cease to be persistent and "
|
||||
"its state will be completely removed from the database. Likewise, adding a "
|
||||
"value type instance to the collection will cause its state to be immediately "
|
||||
"persistent."
|
||||
msgstr ""
|
||||
"Si un objeto que fue quitado de una colección es una instancia de un "
|
||||
"tipo de valor (por ejemplo, un elemento compuesto), ese objeta cesará "
|
||||
"de ser persistente y su estado será completamente quitado de la base "
|
||||
"de datos. Asimismo, añadir una instancia de tipo de valor a la "
|
||||
"colección causará que su estado sea inmediatamente persistente."
|
||||
|
||||
#: index.docbook:44
|
||||
msgid ""
|
||||
"On the other hand, if an entity is removed from a collection (a one-to-many "
|
||||
"or many-to-many association), it will not be deleted, by default. This "
|
||||
"behaviour is completely consistent - a change to the internal state of "
|
||||
"another entity should not cause the associated entity to vanish! Likewise, "
|
||||
"adding an entity to a collection does not cause that entity to become "
|
||||
"persistent, by default."
|
||||
msgstr ""
|
||||
"Por otro lado, si se quita una entidad de una colección (una "
|
||||
"asociación uno-a-muchos o muchos-a-muchos), no será borrado, "
|
||||
"por defecto. Este comportamiento es completamente consistente. ¡Un "
|
||||
"cambio en el estado interno de otra entidad no hace desaparecer la entidad "
|
||||
"asociada! Asimismo, añadir una entidad a una colección no "
|
||||
"causa que la entidad se vuelva persistente, por defecto."
|
||||
|
||||
#: index.docbook:54
|
||||
msgid ""
|
||||
"Instead, the default behaviour is that adding an entity to a collection "
|
||||
"merely creates a link between the two entities, while removing it removes "
|
||||
"the link. This is very appropriate for all sorts of cases. Where it is not "
|
||||
"appropriate at all is the case of a parent / child relationship, where the "
|
||||
"life of the child is bound to the life cycle of the parent."
|
||||
msgstr ""
|
||||
"En cambio, el comportamiento por defecto es que al añadir una entidad "
|
||||
"a una colección se crea meramente un enlace entre las dos entidades, "
|
||||
"mientras que al quitarla se quita el enlace. Esto es muy apropiado para "
|
||||
"todos los tipos de casos. Donde no es para nada apropiado es en el caso de "
|
||||
"una relación padre / hijo. donde la vida del hijo está ligada "
|
||||
"al ciclo de vida del padre."
|
||||
|
||||
#: index.docbook:64
|
||||
msgid "Bidirectional one-to-many"
|
||||
msgstr "Uno-a-muchos bidirectional"
|
||||
|
||||
#: index.docbook:66
|
||||
msgid ""
|
||||
"Suppose we start with a simple <literal><one-to-many></literal> "
|
||||
"association from <literal>Parent</literal> to <literal>Child</literal>."
|
||||
msgstr ""
|
||||
"Supón que empezamos con una asociación simple <literal><one-"
|
||||
"to-many></literal> desde <literal>Parent</literal> a <literal>Child</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:71
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"children\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:73
|
||||
msgid "If we were to execute the following code"
|
||||
msgstr "Si ejecutásemos el siguiente código"
|
||||
|
||||
#: index.docbook:77
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = .....;\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.getChildren().add(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Parent p = .....;\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.getChildren().add(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:79
|
||||
msgid "Hibernate would issue two SQL statements:"
|
||||
msgstr "Hibernate publicaría dos sentencias SQL:"
|
||||
|
||||
#: index.docbook:85
|
||||
msgid ""
|
||||
"an <literal>INSERT</literal> to create the record for <literal>c</literal>"
|
||||
msgstr ""
|
||||
"un <literal>INSERT</literal> para crear el registro de <literal>c</literal>"
|
||||
|
||||
#: index.docbook:88
|
||||
msgid ""
|
||||
"an <literal>UPDATE</literal> to create the link from <literal>p</literal> to "
|
||||
"<literal>c</literal>"
|
||||
msgstr ""
|
||||
"un <literal>UPDATE</literal> para crear el enlace desde <literal>p</literal> "
|
||||
"a <literal>c</literal>"
|
||||
|
||||
#: index.docbook:95
|
||||
msgid ""
|
||||
"This is not only inefficient, but also violates any <literal>NOT NULL</"
|
||||
"literal> constraint on the <literal>parent_id</literal> column. We can fix "
|
||||
"the nullability constraint violation by specifying <literal>not-null=\"true"
|
||||
"\"</literal> in the collection mapping:"
|
||||
msgstr ""
|
||||
"Esto no es sólo ineficiente, sino que además viola cualquier "
|
||||
"restricción <literal>NOT NULL</literal> en la columna "
|
||||
"<literal>parent_id</literal>. Podemos reparar la violación de "
|
||||
"restricción de nulabilidad especificando <literal>not-null=\"true\"</"
|
||||
"literal> en el mapeo de la colección:"
|
||||
|
||||
#: index.docbook:101
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\">\n"
|
||||
" <key column=\"parent_id\" not-null=\"true\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"children\">\n"
|
||||
" <key column=\"parent_id\" not-null=\"true\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:103
|
||||
msgid "However, this is not the recommended solution."
|
||||
msgstr "Sin embargo, esta no es la solución recomendada."
|
||||
|
||||
#: index.docbook:106
|
||||
msgid ""
|
||||
"The underlying cause of this behaviour is that the link (the foreign key "
|
||||
"<literal>parent_id</literal>) from <literal>p</literal> to <literal>c</"
|
||||
"literal> is not considered part of the state of the <literal>Child</literal> "
|
||||
"object and is therefore not created in the <literal>INSERT</literal>. So the "
|
||||
"solution is to make the link part of the <literal>Child</literal> mapping."
|
||||
msgstr ""
|
||||
"El caso subyacente de este comportamiento es que el enlace (la clave "
|
||||
"foránea <literal>parent_id</literal>) de <literal>p</literal> a "
|
||||
"<literal>c</literal> no es considerado parte del estado del objeto "
|
||||
"<literal>Child</literal> y por lo tanto no es creada en el <literal>INSERT</"
|
||||
"literal>. De modo que la solución es hacer el enlace parte del mapeo "
|
||||
"del <literal>Child</literal>."
|
||||
|
||||
#: index.docbook:113
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"parent\" column=\"parent_id\" not-null=\"true\"/"
|
||||
">]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<many-to-one name=\"parent\" column=\"parent_id\" not-null=\"true\"/"
|
||||
">]]>"
|
||||
|
||||
#: index.docbook:115
|
||||
msgid ""
|
||||
"(We also need to add the <literal>parent</literal> property to the "
|
||||
"<literal>Child</literal> class.)"
|
||||
msgstr ""
|
||||
"(Necesitamos además añadir la propiedad <literal>parent</"
|
||||
"literal> a la clase <literal>Child</literal>.)"
|
||||
|
||||
#: index.docbook:119
|
||||
msgid ""
|
||||
"Now that the <literal>Child</literal> entity is managing the state of the "
|
||||
"link, we tell the collection not to update the link. We use the "
|
||||
"<literal>inverse</literal> attribute."
|
||||
msgstr ""
|
||||
"Ahora que la entidad <literal>Child</literal> está gestionando el "
|
||||
"estado del enlace, le decimos a la colección que no actualice el "
|
||||
"enlace. Usamos el atributo <literal>inverse</literal>."
|
||||
|
||||
#: index.docbook:124
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:126
|
||||
msgid "The following code would be used to add a new <literal>Child</literal>"
|
||||
msgstr ""
|
||||
"El siguiente código podría ser usado para añadir un "
|
||||
"nuevo <literal>Child</literal>"
|
||||
|
||||
#: index.docbook:130
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"c.setParent(p);\n"
|
||||
"p.getChildren().add(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"c.setParent(p);\n"
|
||||
"p.getChildren().add(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:132
|
||||
msgid "And now, only one SQL <literal>INSERT</literal> would be issued!"
|
||||
msgstr ""
|
||||
"Y ahora, ¡Sólo se publicaría un <literal>INSERT</"
|
||||
"literal> de SQL!"
|
||||
|
||||
#: index.docbook:136
|
||||
msgid ""
|
||||
"To tighten things up a bit, we could create an <literal>addChild()</literal> "
|
||||
"method of <literal>Parent</literal>."
|
||||
msgstr ""
|
||||
"Para ajustar un poco más las cosas, podríamos crear un "
|
||||
"método <literal>addChild()</literal> en <literal>Parent</literal>."
|
||||
|
||||
#: index.docbook:141
|
||||
msgid ""
|
||||
"<![CDATA[public void addChild(Child c) {\n"
|
||||
" c.setParent(this);\n"
|
||||
" children.add(c);\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[public void addChild(Child c) {\n"
|
||||
" c.setParent(this);\n"
|
||||
" children.add(c);\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:143
|
||||
msgid "Now, the code to add a <literal>Child</literal> looks like"
|
||||
msgstr ""
|
||||
"Ahora, el código para añadir un <literal>Child</literal> se ve "
|
||||
"así"
|
||||
|
||||
#: index.docbook:147
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.addChild(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.addChild(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:152
|
||||
msgid "Cascading life cycle"
|
||||
msgstr "Ciclo de vida en cascada"
|
||||
|
||||
#: index.docbook:154
|
||||
msgid ""
|
||||
"The explicit call to <literal>save()</literal> is still annoying. We will "
|
||||
"address this by using cascades."
|
||||
msgstr ""
|
||||
"La llamada explícita a <literal>save()</literal> es aún "
|
||||
"molesta. Apuntaremos a esto usando tratamientos en cascada."
|
||||
|
||||
#: index.docbook:159
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:161
|
||||
msgid "This simplifies the code above to"
|
||||
msgstr "Esto simplifica el código anterior a"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.addChild(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.addChild(c);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:167
|
||||
msgid ""
|
||||
"Similarly, we don't need to iterate over the children when saving or "
|
||||
"deleting a <literal>Parent</literal>. The following removes <literal>p</"
|
||||
"literal> and all its children from the database."
|
||||
msgstr ""
|
||||
"Similarmente, no necesitamos iterar los hijos al salvar o borrar un "
|
||||
"<literal>Parent</literal>. Lo siguiente quita <literal>p</literal> y todos "
|
||||
"sus hijos de la base de datos."
|
||||
|
||||
#: index.docbook:172
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"session.delete(p);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"session.delete(p);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:174
|
||||
msgid "However, this code"
|
||||
msgstr "Sin embargo, este código"
|
||||
|
||||
#: index.docbook:178
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = (Child) p.getChildren().iterator().next();\n"
|
||||
"p.getChildren().remove(c);\n"
|
||||
"c.setParent(null);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = (Child) p.getChildren().iterator().next();\n"
|
||||
"p.getChildren().remove(c);\n"
|
||||
"c.setParent(null);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:180
|
||||
msgid ""
|
||||
"will not remove <literal>c</literal> from the database; it will ony remove "
|
||||
"the link to <literal>p</literal> (and cause a <literal>NOT NULL</literal> "
|
||||
"constraint violation, in this case). You need to explicitly <literal>delete()"
|
||||
"</literal> the <literal>Child</literal>."
|
||||
msgstr ""
|
||||
"no quitará <literal>c</literal> de la base de datos; sólo "
|
||||
"quitará el enlace a <literal>p</literal> (y causará una "
|
||||
"violación a una restricción <literal>NOT NULL</literal>). "
|
||||
"Necesitas borrar el hijo explícitamente llamando a <literal>delete()</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:186
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = (Child) p.getChildren().iterator().next();\n"
|
||||
"p.getChildren().remove(c);\n"
|
||||
"session.delete(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = (Child) p.getChildren().iterator().next();\n"
|
||||
"p.getChildren().remove(c);\n"
|
||||
"session.delete(c);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:188
|
||||
msgid ""
|
||||
"Now, in our case, a <literal>Child</literal> can't really exist without its "
|
||||
"parent. So if we remove a <literal>Child</literal> from the collection, we "
|
||||
"really do want it to be deleted. For this, we must use <literal>cascade="
|
||||
"\"all-delete-orphan\"</literal>."
|
||||
msgstr ""
|
||||
"Ahora, en nuestro caso, un <literal>Child</literal> no puede existir "
|
||||
"realmente sin su padre. De modo que si quitamos un <literal>Child</literal> "
|
||||
"de la colección, realmente queremos que sea borrado. Para esto, "
|
||||
"debemos usar <literal>cascade=\"all-delete-orphan\"</literal>."
|
||||
|
||||
#: index.docbook:194
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all-delete-orphan"
|
||||
"\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all-delete-orphan"
|
||||
"\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:196
|
||||
msgid ""
|
||||
"Note: even though the collection mapping specifies <literal>inverse=\"true"
|
||||
"\"</literal>, cascades are still processed by iterating the collection "
|
||||
"elements. So if you require that an object be saved, deleted or updated by "
|
||||
"cascade, you must add it to the collection. It is not enough to simply call "
|
||||
"<literal>setParent()</literal>."
|
||||
msgstr ""
|
||||
"Nota: aunque el mapeo de la colección especifique <literal>inverse="
|
||||
"\"true\"</literal>, el tratamiento en cascada se procesa aún al "
|
||||
"iterar los elementos de colección. De modo que si requieres que un "
|
||||
"objeto sea salvado, borrado o actualizado en cascada, debes añadirlo "
|
||||
"a la colección. No es suficiente con simplemente llamar a "
|
||||
"<literal>setParent()</literal>."
|
||||
|
||||
#: index.docbook:206
|
||||
msgid "Cascades and <literal>unsaved-value</literal>"
|
||||
msgstr "Tratamiento en cascada y <literal>unsaved-value</literal>"
|
||||
|
||||
#: index.docbook:208
|
||||
msgid ""
|
||||
"Suppose we loaded up a <literal>Parent</literal> in one <literal>Session</"
|
||||
"literal>, made some changes in a UI action and wish to persist these changes "
|
||||
"in a new session by calling <literal>update()</literal>. The "
|
||||
"<literal>Parent</literal> will contain a collection of childen and, since "
|
||||
"cascading update is enabled, Hibernate needs to know which children are "
|
||||
"newly instantiated and which represent existing rows in the database. Lets "
|
||||
"assume that both <literal>Parent</literal> and <literal>Child</literal> have "
|
||||
"genenerated identifier properties of type <literal>Long</literal>. Hibernate "
|
||||
"will use the identifier and version/timestamp property value to determine "
|
||||
"which of the children are new. (See <xref linkend=\"objectstate-saveorupdate"
|
||||
"\"/>.) <emphasis>In Hibernate3, it is no longer necessary to specify an "
|
||||
"<literal>unsaved-value</literal> explicitly.</emphasis>"
|
||||
msgstr ""
|
||||
"Supón que hemos cargado un <literal>Parent</literal> en una "
|
||||
"<literal>Session</literal>, hemos hecho algunos cambios en una acción "
|
||||
"de UI y deseamos hacer persistentes estos cambios en una nueva sesión "
|
||||
"llamando a <literal>update()</literal>. El <literal>Parent</literal> "
|
||||
"contendrá una colección de hijos y, ya que está "
|
||||
"habilitado el tratamiento en cascada, Hibernate necesita saber qué "
|
||||
"hijos están recién instanciados y cuáles representan "
|
||||
"filas existentes en la base de datos. Asumamos que tanto <literal>Parent</"
|
||||
"literal> como <literal>Child</literal> tienen propiedades identificadoras "
|
||||
"generadas de tipo <literal>Long</literal>. Hibernate usará el "
|
||||
"identificador y el valor de la propiedad de versión/timestamp para "
|
||||
"determinar cuáles de los hijos son nuevos. (Ver <xref linkend="
|
||||
"\"objectstate-saveorupdate\"/>.) <emphasis>En Hibernate3, no es más "
|
||||
"necesario especificar un <literal>unsaved-value</literal> explí"
|
||||
"citamente.</emphasis>"
|
||||
|
||||
#: index.docbook:220
|
||||
msgid ""
|
||||
"The following code will update <literal>parent</literal> and <literal>child</"
|
||||
"literal> and insert <literal>newChild</literal>."
|
||||
msgstr ""
|
||||
"The following code will update <literal>parent</literal> and <literal>child</"
|
||||
"literal> and insert <literal>newChild</literal>."
|
||||
|
||||
#: index.docbook:225
|
||||
msgid ""
|
||||
"<![CDATA[//parent and child were both loaded in a previous session\n"
|
||||
"parent.addChild(child);\n"
|
||||
"Child newChild = new Child();\n"
|
||||
"parent.addChild(newChild);\n"
|
||||
"session.update(parent);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[//parent and child were both loaded in a previous session\n"
|
||||
"parent.addChild(child);\n"
|
||||
"Child newChild = new Child();\n"
|
||||
"parent.addChild(newChild);\n"
|
||||
"session.update(parent);\n"
|
||||
"session.flush();]]>"
|
||||
|
||||
#: index.docbook:227
|
||||
msgid ""
|
||||
"Well, that's all very well for the case of a generated identifier, but what "
|
||||
"about assigned identifiers and composite identifiers? This is more "
|
||||
"difficult, since Hibernate can't use the identifier property to distinguish "
|
||||
"between a newly instantiated object (with an identifier assigned by the "
|
||||
"user) and an object loaded in a previous session. In this case, Hibernate "
|
||||
"will either use the timestamp or version property, or will actually query "
|
||||
"the second-level cache or, worst case, the database, to see if the row "
|
||||
"exists."
|
||||
msgstr ""
|
||||
"Bueno, todo eso está muy bien para el caso de un identificador "
|
||||
"generado, pero ¿qué de los identificadores asignados y de los "
|
||||
"identificadores compuestos? Esto es más difícil, ya que "
|
||||
"Hibernate no puede usar la propiedad identificadora para distinguir entre un "
|
||||
"objeto recién instanciado (con un identificador asignado por el "
|
||||
"usuario) y un objeto cargado en una sesión previa. En este caso, "
|
||||
"Hibernate bien usará la propiedad de versión o timestamp, o "
|
||||
"bien consultará realmente el caché de segundo nivel, o bien, "
|
||||
"en el peor de los casos, la base de datos, para ver si existe la fila."
|
||||
|
||||
#: index.docbook:260
|
||||
msgid "Conclusion"
|
||||
msgstr "Conclusión"
|
||||
|
||||
#: index.docbook:262
|
||||
msgid ""
|
||||
"There is quite a bit to digest here and it might look confusing first time "
|
||||
"around. However, in practice, it all works out very nicely. Most Hibernate "
|
||||
"applications use the parent / child pattern in many places."
|
||||
msgstr ""
|
||||
"Hay que resumir un poco aquí y podría parecer confuso a la "
|
||||
"primera vez. Sin embargo, en la práctica, todo funciona muy "
|
||||
"agradablemente. La mayoría de las aplicaciones de Hibernate usan el "
|
||||
"patrón padre / hijo en muchos sitios."
|
||||
|
||||
#: index.docbook:267
|
||||
msgid ""
|
||||
"We mentioned an alternative in the first paragraph. None of the above issues "
|
||||
"exist in the case of <literal><composite-element></literal> mappings, "
|
||||
"which have exactly the semantics of a parent / child relationship. "
|
||||
"Unfortunately, there are two big limitations to composite element classes: "
|
||||
"composite elements may not own collections, and they should not be the child "
|
||||
"of any entity other than the unique parent."
|
||||
msgstr ""
|
||||
"Hemos mencionado una alternativa en el primer párrafo. Ninguno de los "
|
||||
"temas anteriores existe en el caso de los mapeos <literal><composite-"
|
||||
"element></literal>, que tienen exactamente la semántica de una "
|
||||
"relación padre / hijo. Desafortunadamente, hay dos grandes "
|
||||
"limitaciones para las clases de elementos compuestos: los elementos "
|
||||
"compuestos no pueden poseer sus propias colecciones, y no deben ser el hijo "
|
||||
"de cualquier otra entidad que no sea su padre único."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,852 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Example: Weblog Application"
|
||||
msgstr "Ejemplo: Aplicación de Weblog"
|
||||
|
||||
#: index.docbook:8
|
||||
msgid "Persistent Classes"
|
||||
msgstr "Clases Persistentes"
|
||||
|
||||
#: index.docbook:10
|
||||
msgid ""
|
||||
"The persistent classes represent a weblog, and an item posted in a weblog. "
|
||||
"They are to be modelled as a standard parent/child relationship, but we will "
|
||||
"use an ordered bag, instead of a set."
|
||||
msgstr ""
|
||||
"Las clases persistentes representan un weblog, y un ítem enviado a un "
|
||||
"weblog. Van a ser modelados como una relación padre/hijo estñ"
|
||||
"ndar, pero usaremos un bag ordenado, en vez de un conjunto (set)."
|
||||
|
||||
#: index.docbook:16
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.util.List;\n"
|
||||
"\n"
|
||||
"public class Blog {\n"
|
||||
" private Long _id;\n"
|
||||
" private String _name;\n"
|
||||
" private List _items;\n"
|
||||
"\n"
|
||||
" public Long getId() {\n"
|
||||
" return _id;\n"
|
||||
" }\n"
|
||||
" public List getItems() {\n"
|
||||
" return _items;\n"
|
||||
" }\n"
|
||||
" public String getName() {\n"
|
||||
" return _name;\n"
|
||||
" }\n"
|
||||
" public void setId(Long long1) {\n"
|
||||
" _id = long1;\n"
|
||||
" }\n"
|
||||
" public void setItems(List list) {\n"
|
||||
" _items = list;\n"
|
||||
" }\n"
|
||||
" public void setName(String string) {\n"
|
||||
" _name = string;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.util.List;\n"
|
||||
"\n"
|
||||
"public class Blog {\n"
|
||||
" private Long _id;\n"
|
||||
" private String _name;\n"
|
||||
" private List _items;\n"
|
||||
"\n"
|
||||
" public Long getId() {\n"
|
||||
" return _id;\n"
|
||||
" }\n"
|
||||
" public List getItems() {\n"
|
||||
" return _items;\n"
|
||||
" }\n"
|
||||
" public String getName() {\n"
|
||||
" return _name;\n"
|
||||
" }\n"
|
||||
" public void setId(Long long1) {\n"
|
||||
" _id = long1;\n"
|
||||
" }\n"
|
||||
" public void setItems(List list) {\n"
|
||||
" _items = list;\n"
|
||||
" }\n"
|
||||
" public void setName(String string) {\n"
|
||||
" _name = string;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:18
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.text.DateFormat;\n"
|
||||
"import java.util.Calendar;\n"
|
||||
"\n"
|
||||
"public class BlogItem {\n"
|
||||
" private Long _id;\n"
|
||||
" private Calendar _datetime;\n"
|
||||
" private String _text;\n"
|
||||
" private String _title;\n"
|
||||
" private Blog _blog;\n"
|
||||
"\n"
|
||||
" public Blog getBlog() {\n"
|
||||
" return _blog;\n"
|
||||
" }\n"
|
||||
" public Calendar getDatetime() {\n"
|
||||
" return _datetime;\n"
|
||||
" }\n"
|
||||
" public Long getId() {\n"
|
||||
" return _id;\n"
|
||||
" }\n"
|
||||
" public String getText() {\n"
|
||||
" return _text;\n"
|
||||
" }\n"
|
||||
" public String getTitle() {\n"
|
||||
" return _title;\n"
|
||||
" }\n"
|
||||
" public void setBlog(Blog blog) {\n"
|
||||
" _blog = blog;\n"
|
||||
" }\n"
|
||||
" public void setDatetime(Calendar calendar) {\n"
|
||||
" _datetime = calendar;\n"
|
||||
" }\n"
|
||||
" public void setId(Long long1) {\n"
|
||||
" _id = long1;\n"
|
||||
" }\n"
|
||||
" public void setText(String string) {\n"
|
||||
" _text = string;\n"
|
||||
" }\n"
|
||||
" public void setTitle(String string) {\n"
|
||||
" _title = string;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.text.DateFormat;\n"
|
||||
"import java.util.Calendar;\n"
|
||||
"\n"
|
||||
"public class BlogItem {\n"
|
||||
" private Long _id;\n"
|
||||
" private Calendar _datetime;\n"
|
||||
" private String _text;\n"
|
||||
" private String _title;\n"
|
||||
" private Blog _blog;\n"
|
||||
"\n"
|
||||
" public Blog getBlog() {\n"
|
||||
" return _blog;\n"
|
||||
" }\n"
|
||||
" public Calendar getDatetime() {\n"
|
||||
" return _datetime;\n"
|
||||
" }\n"
|
||||
" public Long getId() {\n"
|
||||
" return _id;\n"
|
||||
" }\n"
|
||||
" public String getText() {\n"
|
||||
" return _text;\n"
|
||||
" }\n"
|
||||
" public String getTitle() {\n"
|
||||
" return _title;\n"
|
||||
" }\n"
|
||||
" public void setBlog(Blog blog) {\n"
|
||||
" _blog = blog;\n"
|
||||
" }\n"
|
||||
" public void setDatetime(Calendar calendar) {\n"
|
||||
" _datetime = calendar;\n"
|
||||
" }\n"
|
||||
" public void setId(Long long1) {\n"
|
||||
" _id = long1;\n"
|
||||
" }\n"
|
||||
" public void setText(String string) {\n"
|
||||
" _text = string;\n"
|
||||
" }\n"
|
||||
" public void setTitle(String string) {\n"
|
||||
" _title = string;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:23
|
||||
msgid "Hibernate Mappings"
|
||||
msgstr "Mapeos de Hibernate"
|
||||
|
||||
#: index.docbook:25
|
||||
msgid "The XML mappings should now be quite straightforward."
|
||||
msgstr "Los mapeos XML ahora deben ser absolutamente directos."
|
||||
|
||||
#: index.docbook:29
|
||||
msgid ""
|
||||
"<![CDATA[<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE hibernate-mapping PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-mapping package=\"eg\">\n"
|
||||
"\n"
|
||||
" <class\n"
|
||||
" name=\"Blog\"\n"
|
||||
" table=\"BLOGS\">\n"
|
||||
"\n"
|
||||
" <id\n"
|
||||
" name=\"id\"\n"
|
||||
" column=\"BLOG_ID\">\n"
|
||||
"\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
"\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"name\"\n"
|
||||
" column=\"NAME\"\n"
|
||||
" not-null=\"true\"\n"
|
||||
" unique=\"true\"/>\n"
|
||||
"\n"
|
||||
" <bag\n"
|
||||
" name=\"items\"\n"
|
||||
" inverse=\"true\"\n"
|
||||
" order-by=\"DATE_TIME\"\n"
|
||||
" cascade=\"all\">\n"
|
||||
"\n"
|
||||
" <key column=\"BLOG_ID\"/>\n"
|
||||
" <one-to-many class=\"BlogItem\"/>\n"
|
||||
"\n"
|
||||
" </bag>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE hibernate-mapping PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-mapping package=\"eg\">\n"
|
||||
"\n"
|
||||
" <class\n"
|
||||
" name=\"Blog\"\n"
|
||||
" table=\"BLOGS\">\n"
|
||||
"\n"
|
||||
" <id\n"
|
||||
" name=\"id\"\n"
|
||||
" column=\"BLOG_ID\">\n"
|
||||
"\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
"\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"name\"\n"
|
||||
" column=\"NAME\"\n"
|
||||
" not-null=\"true\"\n"
|
||||
" unique=\"true\"/>\n"
|
||||
"\n"
|
||||
" <bag\n"
|
||||
" name=\"items\"\n"
|
||||
" inverse=\"true\"\n"
|
||||
" order-by=\"DATE_TIME\"\n"
|
||||
" cascade=\"all\">\n"
|
||||
"\n"
|
||||
" <key column=\"BLOG_ID\"/>\n"
|
||||
" <one-to-many class=\"BlogItem\"/>\n"
|
||||
"\n"
|
||||
" </bag>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
|
||||
#: index.docbook:31
|
||||
msgid ""
|
||||
"<![CDATA[<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE hibernate-mapping PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-mapping package=\"eg\">\n"
|
||||
"\n"
|
||||
" <class\n"
|
||||
" name=\"BlogItem\"\n"
|
||||
" table=\"BLOG_ITEMS\"\n"
|
||||
" dynamic-update=\"true\">\n"
|
||||
"\n"
|
||||
" <id\n"
|
||||
" name=\"id\"\n"
|
||||
" column=\"BLOG_ITEM_ID\">\n"
|
||||
"\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
"\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"title\"\n"
|
||||
" column=\"TITLE\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"text\"\n"
|
||||
" column=\"TEXT\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"datetime\"\n"
|
||||
" column=\"DATE_TIME\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <many-to-one\n"
|
||||
" name=\"blog\"\n"
|
||||
" column=\"BLOG_ID\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE hibernate-mapping PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-mapping package=\"eg\">\n"
|
||||
"\n"
|
||||
" <class\n"
|
||||
" name=\"BlogItem\"\n"
|
||||
" table=\"BLOG_ITEMS\"\n"
|
||||
" dynamic-update=\"true\">\n"
|
||||
"\n"
|
||||
" <id\n"
|
||||
" name=\"id\"\n"
|
||||
" column=\"BLOG_ITEM_ID\">\n"
|
||||
"\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
"\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"title\"\n"
|
||||
" column=\"TITLE\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"text\"\n"
|
||||
" column=\"TEXT\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"datetime\"\n"
|
||||
" column=\"DATE_TIME\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <many-to-one\n"
|
||||
" name=\"blog\"\n"
|
||||
" column=\"BLOG_ID\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
|
||||
#: index.docbook:36
|
||||
msgid "Hibernate Code"
|
||||
msgstr "Código Hibernate"
|
||||
|
||||
#: index.docbook:38
|
||||
msgid ""
|
||||
"The following class demonstrates some of the kinds of things we can do with "
|
||||
"these classes, using Hibernate."
|
||||
msgstr ""
|
||||
"La siguiente clase demuestra algunos de los tipos de cosas que podemos haces "
|
||||
"con estas clases, usando Hibernate."
|
||||
|
||||
#: index.docbook:43
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.util.ArrayList;\n"
|
||||
"import java.util.Calendar;\n"
|
||||
"import java.util.Iterator;\n"
|
||||
"import java.util.List;\n"
|
||||
"\n"
|
||||
"import org.hibernate.HibernateException;\n"
|
||||
"import org.hibernate.Query;\n"
|
||||
"import org.hibernate.Session;\n"
|
||||
"import org.hibernate.SessionFactory;\n"
|
||||
"import org.hibernate.Transaction;\n"
|
||||
"import org.hibernate.cfg.Configuration;\n"
|
||||
"import org.hibernate.tool.hbm2ddl.SchemaExport;\n"
|
||||
"\n"
|
||||
"public class BlogMain {\n"
|
||||
" \n"
|
||||
" private SessionFactory _sessions;\n"
|
||||
" \n"
|
||||
" public void configure() throws HibernateException {\n"
|
||||
" _sessions = new Configuration()\n"
|
||||
" .addClass(Blog.class)\n"
|
||||
" .addClass(BlogItem.class)\n"
|
||||
" .buildSessionFactory();\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void exportTables() throws HibernateException {\n"
|
||||
" Configuration cfg = new Configuration()\n"
|
||||
" .addClass(Blog.class)\n"
|
||||
" .addClass(BlogItem.class);\n"
|
||||
" new SchemaExport(cfg).create(true, true);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public Blog createBlog(String name) throws HibernateException {\n"
|
||||
" \n"
|
||||
" Blog blog = new Blog();\n"
|
||||
" blog.setName(name);\n"
|
||||
" blog.setItems( new ArrayList() );\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.persist(blog);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return blog;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public BlogItem createBlogItem(Blog blog, String title, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" BlogItem item = new BlogItem();\n"
|
||||
" item.setTitle(title);\n"
|
||||
" item.setText(text);\n"
|
||||
" item.setBlog(blog);\n"
|
||||
" item.setDatetime( Calendar.getInstance() );\n"
|
||||
" blog.getItems().add(item);\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.update(blog);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return item;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public BlogItem createBlogItem(Long blogid, String title, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" BlogItem item = new BlogItem();\n"
|
||||
" item.setTitle(title);\n"
|
||||
" item.setText(text);\n"
|
||||
" item.setDatetime( Calendar.getInstance() );\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Blog blog = (Blog) session.load(Blog.class, blogid);\n"
|
||||
" item.setBlog(blog);\n"
|
||||
" blog.getItems().add(item);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return item;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void updateBlogItem(BlogItem item, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" item.setText(text);\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.update(item);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void updateBlogItem(Long itemid, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" BlogItem item = (BlogItem) session.load(BlogItem.class, "
|
||||
"itemid);\n"
|
||||
" item.setText(text);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public List listAllBlogNamesAndItemCounts(int max)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" List result = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"select blog.id, blog.name, count(blogItem) \" +\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"left outer join blog.items as blogItem \" +\n"
|
||||
" \"group by blog.name, blog.id \" +\n"
|
||||
" \"order by max(blogItem.datetime)\"\n"
|
||||
" );\n"
|
||||
" q.setMaxResults(max);\n"
|
||||
" result = q.list();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public Blog getBlogAndAllItems(Long blogid)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" Blog blog = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"left outer join fetch blog.items \" +\n"
|
||||
" \"where blog.id = :blogid\"\n"
|
||||
" );\n"
|
||||
" q.setParameter(\"blogid\", blogid);\n"
|
||||
" blog = (Blog) q.uniqueResult();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return blog;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public List listBlogsAndRecentItems() throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" List result = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"inner join blog.items as blogItem \" +\n"
|
||||
" \"where blogItem.datetime > :minDate\"\n"
|
||||
" );\n"
|
||||
"\n"
|
||||
" Calendar cal = Calendar.getInstance();\n"
|
||||
" cal.roll(Calendar.MONTH, false);\n"
|
||||
" q.setCalendar(\"minDate\", cal);\n"
|
||||
" \n"
|
||||
" result = q.list();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.util.ArrayList;\n"
|
||||
"import java.util.Calendar;\n"
|
||||
"import java.util.Iterator;\n"
|
||||
"import java.util.List;\n"
|
||||
"\n"
|
||||
"import org.hibernate.HibernateException;\n"
|
||||
"import org.hibernate.Query;\n"
|
||||
"import org.hibernate.Session;\n"
|
||||
"import org.hibernate.SessionFactory;\n"
|
||||
"import org.hibernate.Transaction;\n"
|
||||
"import org.hibernate.cfg.Configuration;\n"
|
||||
"import org.hibernate.tool.hbm2ddl.SchemaExport;\n"
|
||||
"\n"
|
||||
"public class BlogMain {\n"
|
||||
" \n"
|
||||
" private SessionFactory _sessions;\n"
|
||||
" \n"
|
||||
" public void configure() throws HibernateException {\n"
|
||||
" _sessions = new Configuration()\n"
|
||||
" .addClass(Blog.class)\n"
|
||||
" .addClass(BlogItem.class)\n"
|
||||
" .buildSessionFactory();\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void exportTables() throws HibernateException {\n"
|
||||
" Configuration cfg = new Configuration()\n"
|
||||
" .addClass(Blog.class)\n"
|
||||
" .addClass(BlogItem.class);\n"
|
||||
" new SchemaExport(cfg).create(true, true);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public Blog createBlog(String name) throws HibernateException {\n"
|
||||
" \n"
|
||||
" Blog blog = new Blog();\n"
|
||||
" blog.setName(name);\n"
|
||||
" blog.setItems( new ArrayList() );\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.persist(blog);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return blog;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public BlogItem createBlogItem(Blog blog, String title, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" BlogItem item = new BlogItem();\n"
|
||||
" item.setTitle(title);\n"
|
||||
" item.setText(text);\n"
|
||||
" item.setBlog(blog);\n"
|
||||
" item.setDatetime( Calendar.getInstance() );\n"
|
||||
" blog.getItems().add(item);\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.update(blog);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return item;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public BlogItem createBlogItem(Long blogid, String title, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" BlogItem item = new BlogItem();\n"
|
||||
" item.setTitle(title);\n"
|
||||
" item.setText(text);\n"
|
||||
" item.setDatetime( Calendar.getInstance() );\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Blog blog = (Blog) session.load(Blog.class, blogid);\n"
|
||||
" item.setBlog(blog);\n"
|
||||
" blog.getItems().add(item);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return item;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void updateBlogItem(BlogItem item, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" item.setText(text);\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.update(item);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void updateBlogItem(Long itemid, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" BlogItem item = (BlogItem) session.load(BlogItem.class, "
|
||||
"itemid);\n"
|
||||
" item.setText(text);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public List listAllBlogNamesAndItemCounts(int max)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" List result = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"select blog.id, blog.name, count(blogItem) \" +\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"left outer join blog.items as blogItem \" +\n"
|
||||
" \"group by blog.name, blog.id \" +\n"
|
||||
" \"order by max(blogItem.datetime)\"\n"
|
||||
" );\n"
|
||||
" q.setMaxResults(max);\n"
|
||||
" result = q.list();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public Blog getBlogAndAllItems(Long blogid)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" Blog blog = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"left outer join fetch blog.items \" +\n"
|
||||
" \"where blog.id = :blogid\"\n"
|
||||
" );\n"
|
||||
" q.setParameter(\"blogid\", blogid);\n"
|
||||
" blog = (Blog) q.uniqueResult();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return blog;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public List listBlogsAndRecentItems() throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" List result = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"inner join blog.items as blogItem \" +\n"
|
||||
" \"where blogItem.datetime > :minDate\"\n"
|
||||
" );\n"
|
||||
"\n"
|
||||
" Calendar cal = Calendar.getInstance();\n"
|
||||
" cal.roll(Calendar.MONTH, false);\n"
|
||||
" q.setCalendar(\"minDate\", cal);\n"
|
||||
" \n"
|
||||
" result = q.list();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,303 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Filtering data"
|
||||
msgstr "Filtrando datos"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"Hibernate3 provides an innovative new approach to handling data with "
|
||||
"\"visibility\" rules. A <emphasis>Hibernate filter</emphasis> is a global, "
|
||||
"named, parameterized filter that may be enabled or disabled for a particular "
|
||||
"Hibernate session."
|
||||
msgstr ""
|
||||
"Hibernate3 provee un nuevo enfoque innovador para manejar datos con reglas "
|
||||
"de \"visibilidad\". Un <emphasis>filtro de Hibernate</emphasis> es un filtro "
|
||||
"global, con nombre y parametrizado que puede ser habilitado o deshabilitado "
|
||||
"para una sesión de Hibernate en particular."
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Hibernate filters"
|
||||
msgstr "Filtros de Hibernate"
|
||||
|
||||
#: index.docbook:16
|
||||
msgid ""
|
||||
"Hibernate3 adds the ability to pre-define filter criteria and attach those "
|
||||
"filters at both a class and a collection level. A filter criteria is the "
|
||||
"ability to define a restriction clause very similiar to the existing \"where"
|
||||
"\" attribute available on the class and various collection elements. Except "
|
||||
"these filter conditions can be parameterized. The application can then make "
|
||||
"the decision at runtime whether given filters should be enabled and what "
|
||||
"their parameter values should be. Filters can be used like database views, "
|
||||
"but parameterized inside the application."
|
||||
msgstr ""
|
||||
"Hibernate3 añade la habilidad de predefinir criterios de filtros y unir esos "
|
||||
"filtros tanto a nivel de una clase como de una colección. Un criterio de "
|
||||
"filtro es la habilidad de definir una cláusula de restricción muy similar al "
|
||||
"atributo existente \"where\" disponible en el elemento class y varios "
|
||||
"elementos de colección. Excepto en que estos filtros pueden ser "
|
||||
"parametrizados. La aplicación puede tomar la decisión en tiempo de ejecución "
|
||||
"de qué filtros deben estar habilitados y cuáles deben ser sus parámetros. "
|
||||
"Los filtros pueden ser usados como vistas de base de datos, pero "
|
||||
"parametrizados dentro de la aplicación."
|
||||
|
||||
#: index.docbook:26
|
||||
msgid ""
|
||||
"In order to use filters, they must first be defined and then attached to the "
|
||||
"appropriate mapping elements. To define a filter, use the <literal><"
|
||||
"filter-def/></literal> element within a <literal><hibernate-mapping/"
|
||||
"></literal> element:"
|
||||
msgstr ""
|
||||
"Para usar los filtros, éstos deben primero ser definidos y luego unidos a "
|
||||
"los elementos de mapeo apropiados. Para definir un filtro, usa el elemento "
|
||||
"<literal><filter-def/></literal> dentro de un elemento <literal><"
|
||||
"hibernate-mapping/></literal>:"
|
||||
|
||||
#: index.docbook:32
|
||||
msgid ""
|
||||
"<![CDATA[<filter-def name=\"myFilter\">\n"
|
||||
" <filter-param name=\"myFilterParam\" type=\"string\"/>\n"
|
||||
"</filter-def>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<filter-def name=\"myFilter\">\n"
|
||||
" <filter-param name=\"myFilterParam\" type=\"string\"/>\n"
|
||||
"</filter-def>]]>"
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Then, this filter can be attached to a class:"
|
||||
msgstr "Entonces este filtro puede ser unido a una clase:"
|
||||
|
||||
#: index.docbook:38
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"myClass\" ...>\n"
|
||||
" ...\n"
|
||||
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
|
||||
"\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"myClass\" ...>\n"
|
||||
" ...\n"
|
||||
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
|
||||
"\"/>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:40
|
||||
msgid "or, to a collection:"
|
||||
msgstr "o a una colección:"
|
||||
|
||||
#: index.docbook:44
|
||||
msgid ""
|
||||
"<![CDATA[<set ...>\n"
|
||||
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
|
||||
"\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<set ...>\n"
|
||||
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
|
||||
"\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:46
|
||||
msgid "or, even to both (or multiples of each) at the same time."
|
||||
msgstr "o incluso a ambos (o muchos de cada uno) al mismo tiempo."
|
||||
|
||||
#: index.docbook:50
|
||||
msgid ""
|
||||
"The methods on <literal>Session</literal> are: <literal>enableFilter(String "
|
||||
"filterName)</literal>, <literal>getEnabledFilter(String filterName)</"
|
||||
"literal>, and <literal>disableFilter(String filterName)</literal>. By "
|
||||
"default, filters are <emphasis>not</emphasis> enabled for a given session; "
|
||||
"they must be explcitly enabled through use of the <literal>Session."
|
||||
"enabledFilter()</literal> method, which returns an instance of the "
|
||||
"<literal>Filter</literal> interface. Using the simple filter defined above, "
|
||||
"this would look like:"
|
||||
msgstr ""
|
||||
"Los métodos en <literal>Session</literal> son: <literal>enableFilter(String "
|
||||
"filterName)</literal>, <literal>getEnabledFilter(String filterName)</"
|
||||
"literal>, y <literal>disableFilter(String filterName)</literal>. Por "
|
||||
"defecto, los filtros <emphasis>no</emphasis> están habilitados para una "
|
||||
"sesión dada; deben ser habilitados explícitamente por medio del uso del "
|
||||
"método <literal>Session.enableFilter()</literal>, que devuelve una instancia "
|
||||
"de la interface <literal>Filter</literal>. Usando el filtro simple definido "
|
||||
"arriba, esto se vería así:"
|
||||
|
||||
#: index.docbook:59
|
||||
msgid ""
|
||||
"<![CDATA[session.enableFilter(\"myFilter\").setParameter(\"myFilterParam\", "
|
||||
"\"some-value\");]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[session.enableFilter(\"myFilter\").setParameter(\"myFilterParam\", "
|
||||
"\"some-value\");]]>"
|
||||
|
||||
#: index.docbook:61
|
||||
msgid ""
|
||||
"Note that methods on the org.hibernate.Filter interface do allow the method-"
|
||||
"chaining common to much of Hibernate."
|
||||
msgstr ""
|
||||
"Nota que los métodos en la interface org.hibernate.Filter permiten el "
|
||||
"encadenamiento de métodos común en gran parte de Hibernate."
|
||||
|
||||
#: index.docbook:65
|
||||
msgid ""
|
||||
"A full example, using temporal data with an effective record date pattern:"
|
||||
msgstr ""
|
||||
"Un ejemplo completo, usando datos temporales con un patrón efectivo de "
|
||||
"fechas de registro:"
|
||||
|
||||
#: index.docbook:69
|
||||
msgid ""
|
||||
"<![CDATA[<filter-def name=\"effectiveDate\">\n"
|
||||
" <filter-param name=\"asOfDate\" type=\"date\"/>\n"
|
||||
"</filter-def>\n"
|
||||
"\n"
|
||||
"<class name=\"Employee\" ...>\n"
|
||||
"...\n"
|
||||
" <many-to-one name=\"department\" column=\"dept_id\" class=\"Department\"/"
|
||||
">\n"
|
||||
" <property name=\"effectiveStartDate\" type=\"date\" column=\"eff_start_dt"
|
||||
"\"/>\n"
|
||||
" <property name=\"effectiveEndDate\" type=\"date\" column=\"eff_end_dt\"/"
|
||||
">\n"
|
||||
"...\n"
|
||||
" <!--\n"
|
||||
" Note that this assumes non-terminal records have an eff_end_dt set "
|
||||
"to\n"
|
||||
" a max db date for simplicity-sake\n"
|
||||
" -->\n"
|
||||
" <filter name=\"effectiveDate\"\n"
|
||||
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Department\" ...>\n"
|
||||
"...\n"
|
||||
" <set name=\"employees\" lazy=\"true\">\n"
|
||||
" <key column=\"dept_id\"/>\n"
|
||||
" <one-to-many class=\"Employee\"/>\n"
|
||||
" <filter name=\"effectiveDate\"\n"
|
||||
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/"
|
||||
">\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<filter-def name=\"effectiveDate\">\n"
|
||||
" <filter-param name=\"asOfDate\" type=\"date\"/>\n"
|
||||
"</filter-def>\n"
|
||||
"\n"
|
||||
"<class name=\"Employee\" ...>\n"
|
||||
"...\n"
|
||||
" <many-to-one name=\"department\" column=\"dept_id\" class=\"Department\"/"
|
||||
">\n"
|
||||
" <property name=\"effectiveStartDate\" type=\"date\" column=\"eff_start_dt"
|
||||
"\"/>\n"
|
||||
" <property name=\"effectiveEndDate\" type=\"date\" column=\"eff_end_dt\"/"
|
||||
">\n"
|
||||
"...\n"
|
||||
" <!--\n"
|
||||
" Note that this assumes non-terminal records have an eff_end_dt set "
|
||||
"to\n"
|
||||
" a max db date for simplicity-sake\n"
|
||||
" -->\n"
|
||||
" <filter name=\"effectiveDate\"\n"
|
||||
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Department\" ...>\n"
|
||||
"...\n"
|
||||
" <set name=\"employees\" lazy=\"true\">\n"
|
||||
" <key column=\"dept_id\"/>\n"
|
||||
" <one-to-many class=\"Employee\"/>\n"
|
||||
" <filter name=\"effectiveDate\"\n"
|
||||
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/"
|
||||
">\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:71
|
||||
msgid ""
|
||||
"Then, in order to ensure that you always get back currently effective "
|
||||
"records, simply enable the filter on the session prior to retrieving "
|
||||
"employee data:"
|
||||
msgstr ""
|
||||
"Entonces, en orden de asegurar que siempre tendrás de vuelta registros "
|
||||
"actualmente efectivos, simplemente habilita el filtro en la sesión previo a "
|
||||
"recuperar los datos de empleados:"
|
||||
|
||||
#: index.docbook:76
|
||||
msgid ""
|
||||
"<![CDATA[Session session = ...;\n"
|
||||
"session.enableFilter(\"effectiveDate\").setParameter(\"asOfDate\", new Date"
|
||||
"());\n"
|
||||
"List results = session.createQuery(\"from Employee as e where e.salary > :"
|
||||
"targetSalary\")\n"
|
||||
" .setLong(\"targetSalary\", new Long(1000000))\n"
|
||||
" .list();\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = ...;\n"
|
||||
"session.enableFilter(\"effectiveDate\").setParameter(\"asOfDate\", new Date"
|
||||
"());\n"
|
||||
"List results = session.createQuery(\"from Employee as e where e.salary > :"
|
||||
"targetSalary\")\n"
|
||||
" .setLong(\"targetSalary\", new Long(1000000))\n"
|
||||
" .list();\n"
|
||||
"]]>"
|
||||
|
||||
#: index.docbook:78
|
||||
msgid ""
|
||||
"In the HQL above, even though we only explicitly mentioned a salary "
|
||||
"constraint on the results, because of the enabled filter the query will "
|
||||
"return only currently active employees who have a salary greater than a "
|
||||
"million dollars."
|
||||
msgstr ""
|
||||
"En el HQL de arriba, aunque sólo hemos mencionado explícitamente una "
|
||||
"restricción de salario en los resultados, debido al filtro habilitado la "
|
||||
"consulta sólo devolverá empleados actualmente activos que tengan un salario "
|
||||
"mayor que un millón de dólares."
|
||||
|
||||
#: index.docbook:84
|
||||
msgid ""
|
||||
"Note: if you plan on using filters with outer joining (either through HQL or "
|
||||
"load fetching) be careful of the direction of the condition expression. Its "
|
||||
"safest to set this up for left outer joining; in general, place the "
|
||||
"parameter first followed by the column name(s) after the operator."
|
||||
msgstr ""
|
||||
"Nota: si planeas usar filtros con unión externa (outer joining) (bien a "
|
||||
"través de HQL, o bien de recuperación de carga) sé cuidadoso en la dirección "
|
||||
"de expresión de la condición. Lo más seguro es establecer esto para unión "
|
||||
"externa izquierda (left outer joining). En general, coloca el primer "
|
||||
"parámetro seguido del nombre(s) de columna(s) después del operador."
|
||||
|
||||
#: index.docbook:91
|
||||
msgid ""
|
||||
"After being defined a filter might be attached to multiple entities and/or "
|
||||
"collections each with its own condition. That can be tedious when the "
|
||||
"conditions are the same each time. Thus <literal><filter-def/></"
|
||||
"literal> allows defining a default condition, either as an attribute or "
|
||||
"CDATA:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:98
|
||||
msgid ""
|
||||
"<![CDATA[<filter-def name=\"myFilter\" condition=\"abc > xyz\">...</filter-"
|
||||
"def>\n"
|
||||
"<filter-def name=\"myOtherFilter\">abc=xyz</filter-def>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:100
|
||||
msgid ""
|
||||
"This default condition will then be used whenever the filter is attached to "
|
||||
"something without specifying a condition. Note that this means you can give "
|
||||
"a specific condition as part of the attachment of the filter which overrides "
|
||||
"the default condition in that particular case."
|
||||
msgstr ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,844 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Inheritance Mapping"
|
||||
msgstr "Mapeo de Herencia"
|
||||
|
||||
#: index.docbook:8
|
||||
msgid "The Three Strategies"
|
||||
msgstr "Las Tres Estrategias"
|
||||
|
||||
#: index.docbook:10
|
||||
msgid "Hibernate supports the three basic inheritance mapping strategies:"
|
||||
msgstr ""
|
||||
"Hibernate soporta las tres estrategias básicas de mapeo de herencia:"
|
||||
|
||||
#: index.docbook:16
|
||||
msgid "table per class hierarchy"
|
||||
msgstr "<para>tabla por jerarquía de clases</para>"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "<para>table per subclass</para>"
|
||||
msgstr "<para>tabla por subclase</para>"
|
||||
|
||||
#: index.docbook:26
|
||||
msgid "table per concrete class"
|
||||
msgstr "tabla por clase concreta"
|
||||
|
||||
#: index.docbook:32
|
||||
msgid ""
|
||||
"In addition, Hibernate supports a fourth, slightly different kind of "
|
||||
"polymorphism:"
|
||||
msgstr ""
|
||||
"En adición, Hibernate soporta un cuarto, ligeramente diferente tipo "
|
||||
"de polimorfismo:"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "implicit polymorphism"
|
||||
msgstr "polimorfismo implícito"
|
||||
|
||||
#: index.docbook:45
|
||||
msgid ""
|
||||
"It is possible to use different mapping strategies for different branches of "
|
||||
"the same inheritance hierarchy, and then make use of implicit polymorphism "
|
||||
"to achieve polymorphism across the whole hierarchy. However, Hibernate does "
|
||||
"not support mixing <literal><subclass></literal>, and <literal><"
|
||||
"joined-subclass></literal> and <literal><union-subclass></literal> "
|
||||
"mappings under the same root <literal><class></literal> element. It is "
|
||||
"possible to mix together the table per hierarchy and table per subclass "
|
||||
"strategies, under the the same <literal><class></literal> element, by "
|
||||
"combining the <literal><subclass></literal> and <literal><join></"
|
||||
"literal> elements (see below)."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! It is possible to define <literal>subclass</literal>, "
|
||||
"<literal>union-subclass</literal>, and <literal>joined-subclass</literal> "
|
||||
"mappings in separate mapping documents, directly beneath <literal>hibernate-"
|
||||
"mapping</literal>. This allows you to extend a class hierachy just by adding "
|
||||
"a new mapping file. You must specify an <literal>extends</literal> attribute "
|
||||
"in the subclass mapping, naming a previously mapped superclass. Note: "
|
||||
"Previously this feature made the ordering of the mapping documents "
|
||||
"important. Since Hibernate3, the ordering of mapping files does not matter "
|
||||
"when using the extends keyword. The ordering inside a single mapping file "
|
||||
"still needs to be defined as superclasses before subclasses."
|
||||
|
||||
#: index.docbook:59
|
||||
msgid ""
|
||||
"It is possible to define <literal>subclass</literal>, <literal>union-"
|
||||
"subclass</literal>, and <literal>joined-subclass</literal> mappings in "
|
||||
"separate mapping documents, directly beneath <literal>hibernate-mapping</"
|
||||
"literal>. This allows you to extend a class hierachy just by adding a new "
|
||||
"mapping file. You must specify an <literal>extends</literal> attribute in "
|
||||
"the subclass mapping, naming a previously mapped superclass. Note: "
|
||||
"Previously this feature made the ordering of the mapping documents "
|
||||
"important. Since Hibernate3, the ordering of mapping files does not matter "
|
||||
"when using the extends keyword. The ordering inside a single mapping file "
|
||||
"still needs to be defined as superclasses before subclasses."
|
||||
msgstr ""
|
||||
"<![CDATA[\n"
|
||||
" <hibernate-mapping>\n"
|
||||
" <subclass name=\"DomesticCat\" "
|
||||
"extends=\"Cat\" discriminator-value=\"D\">\n"
|
||||
" <property name=\"name\" "
|
||||
"type=\"string\"/>\n"
|
||||
" </subclass>\n"
|
||||
" </hibernate-mapping>]]>"
|
||||
|
||||
#: index.docbook:70
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
" <hibernate-mapping>\n"
|
||||
" <subclass name=\"DomesticCat\" extends=\"Cat\" discriminator-value=\"D"
|
||||
"\">\n"
|
||||
" <property name=\"name\" type=\"string\"/>\n"
|
||||
" </subclass>\n"
|
||||
" </hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
"Es posible usar estrategias de mapeo diferentes para diferentes "
|
||||
"ramificaciones de la misma jerarquía de herencia, y entonces usar "
|
||||
"polimorfismo implícito para conseguir polimorfismo a través de "
|
||||
"toda la jerarquía. Sin embargo, Hibernate no soporta la mezcla de "
|
||||
"mapeos <literal><subclass></literal>, y <literal><joined-"
|
||||
"subclass></literal> y <literal><union-subclass></literal> bajo el "
|
||||
"mismo elemento <literal><class></literal> raíz. Es posible "
|
||||
"mezclar juntas las estrategias de tabla por jerarquía y tabla por "
|
||||
"subclase, bajo el mismo elemento <literal><class></literal>, "
|
||||
"combinando los elementos <literal><subclass></literal> y <literal><"
|
||||
"join></literal> (ver debajo)."
|
||||
|
||||
#: index.docbook:74
|
||||
msgid "Table per class hierarchy"
|
||||
msgstr "Tabla por jerarquía de clases"
|
||||
|
||||
#: index.docbook:76
|
||||
msgid ""
|
||||
"Suppose we have an interface <literal>Payment</literal>, with implementors "
|
||||
"<literal>CreditCardPayment</literal>, <literal>CashPayment</literal>, "
|
||||
"<literal>ChequePayment</literal>. The table per hierarchy mapping would look "
|
||||
"like:"
|
||||
msgstr ""
|
||||
"Supón que tenemos una interface <literal>Payment</literal>, con los "
|
||||
"implementadores <literal>CreditCardPayment</literal>, <literal>CashPayment</"
|
||||
"literal>, <literal>ChequePayment</literal>. El mapeo de tabla por "
|
||||
"jerarquía se vería así:"
|
||||
|
||||
#: index.docbook:83
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:85
|
||||
msgid ""
|
||||
"Exactly one table is required. There is one big limitation of this mapping "
|
||||
"strategy: columns declared by the subclasses, such as <literal>CCTYPE</"
|
||||
"literal>, may not have <literal>NOT NULL</literal> constraints."
|
||||
msgstr ""
|
||||
"Se requiere exactamente una tabla. Hay una gran limitación de esta "
|
||||
"estrategia de mapeo: las columnas declaradas por las subclases, como "
|
||||
"<literal>CCTYPE</literal>, no pueden tener restricciones <literal>NOT NULL</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:94
|
||||
msgid "Table per subclass"
|
||||
msgstr "Tabla por subclase"
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "A table per subclass mapping would look like:"
|
||||
msgstr "Un mapeo de tabla por sublclase se vería así:"
|
||||
|
||||
#: index.docbook:100
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <joined-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <joined-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:102
|
||||
msgid ""
|
||||
"Four tables are required. The three subclass tables have primary key "
|
||||
"associations to the superclass table (so the relational model is actually a "
|
||||
"one-to-one association)."
|
||||
msgstr ""
|
||||
"Se requieren cuatro tablas. Las tres tablas de subclase tienen asociaciones "
|
||||
"de clave primaria a la tabla de superclase (de modo que en el modelo "
|
||||
"relacional es realmente una asociación uno-a-uno)."
|
||||
|
||||
#: index.docbook:111
|
||||
msgid "Table per subclass, using a discriminator"
|
||||
msgstr "Tabla por subclase, usando un discriminador"
|
||||
|
||||
#: index.docbook:113
|
||||
msgid ""
|
||||
"Note that Hibernate's implementation of table per subclass requires no "
|
||||
"discriminator column. Other object/relational mappers use a different "
|
||||
"implementation of table per subclass which requires a type discriminator "
|
||||
"column in the superclass table. The approach taken by Hibernate is much more "
|
||||
"difficult to implement but arguably more correct from a relational point of "
|
||||
"view. If you would like to use a discriminator column with the table per "
|
||||
"subclass strategy, you may combine the use of <literal><subclass></"
|
||||
"literal> and <literal><join></literal>, as follow:"
|
||||
msgstr ""
|
||||
"Observa que la implementación de Hibernate de tabla por subclase no "
|
||||
"requiere ninguna columna discriminadora. Otros mapeadores objeto/relacional "
|
||||
"usan una implementación diferente de tabla por subclase que requiere "
|
||||
"una columna discriminadora de tipo en la tabla de superclase. Este enfoque "
|
||||
"es mucho más difícil de implementar pero discutiblemente "
|
||||
"más correcto desde un punto de vista relacional. Si quisieras usar "
|
||||
"una columna discriminadora con la estrategia de tabla por subclase, puedes "
|
||||
"combinar el uso de <literal><subclass></literal> y <literal><"
|
||||
"join></literal>, como sigue:"
|
||||
|
||||
#: index.docbook:125
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <join table=\"CREDIT_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" <join table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" <join table=\"CHEQUE_PAYMENT\" fetch=\"select\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <join table=\"CREDIT_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" <join table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" <join table=\"CHEQUE_PAYMENT\" fetch=\"select\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:127
|
||||
msgid ""
|
||||
"The optional <literal>fetch=\"select\"</literal> declaration tells Hibernate "
|
||||
"not to fetch the <literal>ChequePayment</literal> subclass data using an "
|
||||
"outer join when querying the superclass."
|
||||
msgstr ""
|
||||
"la declaración opcional <literal>fetch=\"select\"</literal> dice a "
|
||||
"Hibernate que no recupere los datos de la subclase <literal>ChequePayment</"
|
||||
"literal> usando una unión externa (outer join) al consultar la "
|
||||
"superclase."
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "Mixing table per class hierarchy with table per subclass"
|
||||
msgstr "Mezclando tabla por jerarquía de clases con tabla por subclase"
|
||||
|
||||
#: index.docbook:138
|
||||
msgid ""
|
||||
"You may even mix the table per hierarchy and table per subclass strategies "
|
||||
"using this approach:"
|
||||
msgstr ""
|
||||
"Puedes incluso mezclar las estrategias de tabla po jerarquía y tabla "
|
||||
"por subclase usando este enfoque:"
|
||||
|
||||
#: index.docbook:143
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <join table=\"CREDIT_PAYMENT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <join table=\"CREDIT_PAYMENT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:145
|
||||
msgid ""
|
||||
"For any of these mapping strategies, a polymorphic association to the root "
|
||||
"<literal>Payment</literal> class is mapped using <literal><many-to-one>"
|
||||
"</literal>."
|
||||
msgstr ""
|
||||
"Para cualquiera de estas estrategias de mapeo, una asociación "
|
||||
"polimórfica a la clase raíz <literal>Payment</literal> es "
|
||||
"mapeada usando <literal><many-to-one></literal>."
|
||||
|
||||
#: index.docbook:151
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment"
|
||||
"\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment"
|
||||
"\"/>]]>"
|
||||
|
||||
#: index.docbook:156
|
||||
msgid "Table per concrete class"
|
||||
msgstr "Tabla por clase concreta"
|
||||
|
||||
#: index.docbook:158
|
||||
msgid ""
|
||||
"There are two ways we could go about mapping the table per concrete class "
|
||||
"strategy. The first is to use <literal><union-subclass></literal>."
|
||||
msgstr ""
|
||||
"Podríamos ir de dos maneras a la estrategia de mapeo de tabla por "
|
||||
"clase concreta. La primera es usar <literal><union-subclass></literal>."
|
||||
|
||||
#: index.docbook:163
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <union-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
" <union-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
" <union-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Payment\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <union-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
" <union-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
" <union-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid ""
|
||||
"Three tables are involved for the subclasses. Each table defines columns for "
|
||||
"all properties of the class, including inherited properties."
|
||||
msgstr ""
|
||||
"Están implicadas tres tablas. Cada tabla define columnas para todas "
|
||||
"las propiedades de la clase, inccluyendo las propiedades heredadas."
|
||||
|
||||
#: index.docbook:170
|
||||
msgid ""
|
||||
"The limitation of this approach is that if a property is mapped on the "
|
||||
"superclass, the column name must be the same on all subclass tables. (We "
|
||||
"might relax this in a future release of Hibernate.) The identity generator "
|
||||
"strategy is not allowed in union subclass inheritance, indeed the primary "
|
||||
"key seed has to be shared accross all unioned subclasses of a hierarchy."
|
||||
msgstr ""
|
||||
"La limitación de este enfoque es que si una propiedad es mapeada en "
|
||||
"la superclase, el nombre de columna debe ser el mismo en todas las tablas de "
|
||||
"subclase. (Podríamos relajar esto en un lanzamiento futuro de "
|
||||
"Hibernate.) La estrategia de generador de indentidad no está "
|
||||
"permitida en la herencia de unión de subclase, de hecho la semilla de "
|
||||
"clave primaria tiene que ser compartida a través de todas las "
|
||||
"subclases unidas de una jerarquía."
|
||||
|
||||
#: index.docbook:179
|
||||
msgid ""
|
||||
"If your superclass is abstract, map it with <literal>abstract=\"true\"</"
|
||||
"literal>. Of course, if it is not abstract, an additional table (defaults to "
|
||||
"<literal>PAYMENT</literal> in the example above) is needed to hold instances "
|
||||
"of the superclass."
|
||||
msgstr ""
|
||||
"UNTRANSLATED! If your superclass is abstract, map it with <literal>abstract="
|
||||
"\"true\"</literal>. Of course, if it is not abstract, an additional table "
|
||||
"(defaults to <literal>PAYMENT</literal> in the example above) is needed to "
|
||||
"hold instances of the superclass."
|
||||
|
||||
#: index.docbook:189
|
||||
msgid "Table per concrete class, using implicit polymorphism"
|
||||
msgstr "Tabla por clase concreta, usando polimorfismo implícito"
|
||||
|
||||
#: index.docbook:191
|
||||
msgid "An alternative approach is to make use of implicit polymorphism:"
|
||||
msgstr "Un enfoque alternativo es hacer uso de polimorfismo implícito:"
|
||||
|
||||
#: index.docbook:195
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CREDIT_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CASH_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CASH_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CHEQUE_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CHEQUE_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CREDIT_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CASH_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CASH_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CHEQUE_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CHEQUE_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:197
|
||||
msgid ""
|
||||
"Notice that nowhere do we mention the <literal>Payment</literal> interface "
|
||||
"explicitly. Also notice that properties of <literal>Payment</literal> are "
|
||||
"mapped in each of the subclasses. If you want to avoid duplication, consider "
|
||||
"using XML entities (e.g. <literal>[ <!ENTITY allproperties SYSTEM "
|
||||
"\"allproperties.xml\"> ]</literal> in the <literal>DOCTYPE</literal> "
|
||||
"declartion and <literal>&allproperties;</literal> in the mapping)."
|
||||
msgstr ""
|
||||
"Nota que en ningún sitio mencionamos la interface <literal>Payment</"
|
||||
"literal> explícitamente. Nota además que las propiedades de "
|
||||
"<literal>Payment</literal> son mapeadas en cada una de las subclases. Si "
|
||||
"quieres evitar duplicación, considera usar entidades XML. (por "
|
||||
"ejemplo, <literal>[ <!ENTITY allproperties SYSTEM \"allproperties.xml"
|
||||
"\"> ]</literal> en la declaración <literal>DOCTYPE</literal> y "
|
||||
"<literal>&allproperties;</literal> en el mapeo)."
|
||||
|
||||
#: index.docbook:207
|
||||
msgid ""
|
||||
"The disadvantage of this approach is that Hibernate does not generate SQL "
|
||||
"<literal>UNION</literal>s when performing polymorphic queries."
|
||||
msgstr ""
|
||||
"La desventaja de este enfoque es que Hibernate no genera <literal>UNION</"
|
||||
"literal>s de SQL al realizar consultas polimórficas."
|
||||
|
||||
#: index.docbook:212
|
||||
msgid ""
|
||||
"For this mapping strategy, a polymorphic association to <literal>Payment</"
|
||||
"literal> is usually mapped using <literal><any></literal>."
|
||||
msgstr ""
|
||||
"Para esta estrategia de mapeo, una asociación polimórfica a "
|
||||
"<literal>Payment</literal> es mapeada generalmente usando <literal><"
|
||||
"any></literal>."
|
||||
|
||||
#: index.docbook:217
|
||||
msgid ""
|
||||
"<![CDATA[<any name=\"payment\" meta-type=\"string\" id-type=\"long\">\n"
|
||||
" <meta-value value=\"CREDIT\" class=\"CreditCardPayment\"/>\n"
|
||||
" <meta-value value=\"CASH\" class=\"CashPayment\"/>\n"
|
||||
" <meta-value value=\"CHEQUE\" class=\"ChequePayment\"/>\n"
|
||||
" <column name=\"PAYMENT_CLASS\"/>\n"
|
||||
" <column name=\"PAYMENT_ID\"/>\n"
|
||||
"</any>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<any name=\"payment\" meta-type=\"string\" id-type=\"long\">\n"
|
||||
" <meta-value value=\"CREDIT\" class=\"CreditCardPayment\"/>\n"
|
||||
" <meta-value value=\"CASH\" class=\"CashPayment\"/>\n"
|
||||
" <meta-value value=\"CHEQUE\" class=\"ChequePayment\"/>\n"
|
||||
" <column name=\"PAYMENT_CLASS\"/>\n"
|
||||
" <column name=\"PAYMENT_ID\"/>\n"
|
||||
"</any>]]>"
|
||||
|
||||
#: index.docbook:222
|
||||
msgid "Mixing implicit polymorphism with other inheritance mappings"
|
||||
msgstr "Mezclando polimorfismo implícito con otros mapeos de herencia"
|
||||
|
||||
#: index.docbook:224
|
||||
msgid ""
|
||||
"There is one further thing to notice about this mapping. Since the "
|
||||
"subclasses are each mapped in their own <literal><class></literal> "
|
||||
"element (and since <literal>Payment</literal> is just an interface), each of "
|
||||
"the subclasses could easily be part of another inheritance hierarchy! (And "
|
||||
"you can still use polymorphic queries against the <literal>Payment</literal> "
|
||||
"interface.)"
|
||||
msgstr ""
|
||||
"Hay una cosa más por notar acerca de este mapeo. Ya que las subclases "
|
||||
"se mapean cada una en su propio elemento <literal><class></literal> (y "
|
||||
"ya que <literal>Payment</literal> es sólo una interface), cada una de "
|
||||
"las subclases podría ser parte de otra jerarquía de herencia! "
|
||||
"(Y todavía puedes seguir usando consultas polimórficas contra "
|
||||
"la interface <literal>Payment</literal>.)"
|
||||
|
||||
#: index.docbook:232
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"CREDIT_CARD\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"CREDIT_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"MasterCardPayment\" discriminator-value=\"MDC\"/>\n"
|
||||
" <subclass name=\"VisaPayment\" discriminator-value=\"VISA\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"NonelectronicTransaction\" table=\"NONELECTRONIC_TXN\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"TXN_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" ...\n"
|
||||
" <joined-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"amount\" column=\"CASH_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"amount\" column=\"CHEQUE_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"CREDIT_CARD\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"CREDIT_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"MasterCardPayment\" discriminator-value=\"MDC\"/>\n"
|
||||
" <subclass name=\"VisaPayment\" discriminator-value=\"VISA\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"NonelectronicTransaction\" table=\"NONELECTRONIC_TXN\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"TXN_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" ...\n"
|
||||
" <joined-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"amount\" column=\"CASH_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"amount\" column=\"CHEQUE_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:234
|
||||
msgid ""
|
||||
"Once again, we don't mention <literal>Payment</literal> explicitly. If we "
|
||||
"execute a query against the <literal>Payment</literal> interface - for "
|
||||
"example, <literal>from Payment</literal> - Hibernate automatically returns "
|
||||
"instances of <literal>CreditCardPayment</literal> (and its subclasses, since "
|
||||
"they also implement <literal>Payment</literal>), <literal>CashPayment</"
|
||||
"literal> and <literal>ChequePayment</literal> but not instances of "
|
||||
"<literal>NonelectronicTransaction</literal>."
|
||||
msgstr ""
|
||||
"Una vez más, no mencionamos a <literal>Payment</literal> explí"
|
||||
"citamente. Si ejecutamos una consulta contra la interface <literal>Payment</"
|
||||
"literal> - por ejemplo, <literal>from Payment</literal> - Hibernate devuelve "
|
||||
"automáticamente instancias de <literal>CreditCardPayment</literal> (y "
|
||||
"sus subclases, ya que ellas también implementan <literal>Payment</"
|
||||
"literal>), <literal>CashPayment</literal> y <literal>ChequePayment</literal> "
|
||||
"pero no instancias de <literal>NonelectronicTransaction</literal>."
|
||||
|
||||
#: index.docbook:249
|
||||
msgid "Limitations"
|
||||
msgstr "Limitaciones"
|
||||
|
||||
#: index.docbook:251
|
||||
msgid ""
|
||||
"There are certain limitations to the \"implicit polymorphism\" approach to "
|
||||
"the table per concrete-class mapping strategy. There are somewhat less "
|
||||
"restrictive limitations to <literal><union-subclass></literal> "
|
||||
"mappings."
|
||||
msgstr ""
|
||||
"Existen ciertas limitaciones al enfoque de \"polimorfismo implícito\" "
|
||||
"en la estrategia de mapeo de tabla por clase concreta. Existen limitaciones "
|
||||
"algo menos restrictivas a los mapeos <literal><union-subclass></"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:258
|
||||
msgid ""
|
||||
"The following table shows the limitations of table per concrete-class "
|
||||
"mappings, and of implicit polymorphism, in Hibernate."
|
||||
msgstr ""
|
||||
"La siguiente tabla muestra las limitaciones de mapeos de tabla por clase "
|
||||
"concreta, y de polmorfismo implícito, en Hibernate."
|
||||
|
||||
#: index.docbook:264
|
||||
msgid "Features of inheritance mappings"
|
||||
msgstr "Funcionalidades de mapeo de herencia"
|
||||
|
||||
#: index.docbook:276
|
||||
msgid "Inheritance strategy"
|
||||
msgstr "Estrategia de herencia"
|
||||
|
||||
#: index.docbook:277
|
||||
msgid "Polymorphic many-to-one"
|
||||
msgstr "muchos-a-uno polimórfica"
|
||||
|
||||
#: index.docbook:278
|
||||
msgid "Polymorphic one-to-one"
|
||||
msgstr "uno-a-uno polimórfica"
|
||||
|
||||
#: index.docbook:279
|
||||
msgid "Polymorphic one-to-many"
|
||||
msgstr "uno-a-muchos polimórfica"
|
||||
|
||||
#: index.docbook:280
|
||||
msgid "Polymorphic many-to-many"
|
||||
msgstr "mushos-a-muchos polimórfica"
|
||||
|
||||
#: index.docbook:281
|
||||
msgid "Polymorphic <literal>load()/get()</literal>"
|
||||
msgstr "<literal>load()/get()</literal> polimórficos"
|
||||
|
||||
#: index.docbook:282
|
||||
msgid "Polymorphic queries"
|
||||
msgstr "Consultas polimórficas"
|
||||
|
||||
#: index.docbook:283
|
||||
msgid "Polymorphic joins"
|
||||
msgstr "Uniones polimórficas"
|
||||
|
||||
#: index.docbook:284
|
||||
msgid "Outer join fetching"
|
||||
msgstr "Recuperación por unión externa (outer join)"
|
||||
|
||||
#: index.docbook:289
|
||||
msgid "table per class-hierarchy"
|
||||
msgstr "<entry>tabla por jerarquía de clases</entry>"
|
||||
|
||||
#: index.docbook:290, index.docbook:301, index.docbook:312
|
||||
msgid "<many-to-one>"
|
||||
msgstr "<many-to-one>"
|
||||
|
||||
#: index.docbook:291, index.docbook:302, index.docbook:313
|
||||
msgid "<one-to-one>"
|
||||
msgstr "<one-to-one>"
|
||||
|
||||
#: index.docbook:292, index.docbook:303
|
||||
msgid "<one-to-many>"
|
||||
msgstr "<one-to-many>"
|
||||
|
||||
#: index.docbook:293, index.docbook:304, index.docbook:315
|
||||
msgid "<many-to-many>"
|
||||
msgstr "<many-to-many>"
|
||||
|
||||
#: index.docbook:294, index.docbook:305, index.docbook:316
|
||||
msgid "s.get(Payment.class, id)"
|
||||
msgstr "s.get(Payment.class, id)"
|
||||
|
||||
#: index.docbook:295, index.docbook:306, index.docbook:317, index.docbook:328
|
||||
msgid "from Payment p"
|
||||
msgstr "from Payment p"
|
||||
|
||||
#: index.docbook:296, index.docbook:307, index.docbook:318
|
||||
msgid "from Order o join o.payment p"
|
||||
msgstr "from Order o join o.payment p"
|
||||
|
||||
#: index.docbook:297, index.docbook:308, index.docbook:319
|
||||
msgid "supported"
|
||||
msgstr "soportada"
|
||||
|
||||
#: index.docbook:300
|
||||
msgid "<entry>table per subclass</entry>"
|
||||
msgstr "<entry>tabla por subclase</entry>"
|
||||
|
||||
#: index.docbook:311
|
||||
msgid "table per concrete-class (union-subclass)"
|
||||
msgstr "tabla por clase concreta (union-subclass)"
|
||||
|
||||
#: index.docbook:314
|
||||
msgid ""
|
||||
"<literal><one-to-many></literal> (for <literal>inverse=\"true\"</"
|
||||
"literal> only)"
|
||||
msgstr ""
|
||||
"<literal><one-to-many></literal> (para <literal>inverse=\"true\"</"
|
||||
"literal> solamente)"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "table per concrete class (implicit polymorphism)"
|
||||
msgstr "tabla por clase concreta (polimorfismo implícito)"
|
||||
|
||||
#: index.docbook:323
|
||||
msgid "<any>"
|
||||
msgstr "<any>"
|
||||
|
||||
#: index.docbook:324, index.docbook:325, index.docbook:329, index.docbook:330
|
||||
msgid "not supported"
|
||||
msgstr "no soportada"
|
||||
|
||||
#: index.docbook:326
|
||||
msgid "<many-to-any>"
|
||||
msgstr "<many-to-any>"
|
||||
|
||||
#: index.docbook:327
|
||||
msgid ""
|
||||
"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
|
||||
msgstr ""
|
||||
"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,993 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Persistent Classes"
|
||||
msgstr "Clases Persistentes"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"Persistent classes are classes in an application that implement the entities "
|
||||
"of the business problem (e.g. Customer and Order in an E-commerce "
|
||||
"application). Not all instances of a persistent class are considered to be "
|
||||
"in the persistent state - an instance may instead be transient or detached."
|
||||
msgstr ""
|
||||
"Clases presistentes son clases en una aplicación que implementan las "
|
||||
"entidades del problema de negocio (por ejemplo, Customer y Order en una "
|
||||
"aplicación de comercio electrónico). No todas las instancias "
|
||||
"de una clase persistente se considera que estén en el estado "
|
||||
"persistente, una instancia puede en cambio ser transitoria o estar separada."
|
||||
|
||||
#: index.docbook:14
|
||||
msgid ""
|
||||
"Hibernate works best if these classes follow some simple rules, also known "
|
||||
"as the Plain Old Java Object (POJO) programming model. However, none of "
|
||||
"these rules are hard requirements. Indeed, Hibernate3 assumes very little "
|
||||
"about the nature of your persistent objects. You may express a domain model "
|
||||
"in other ways: using trees of <literal>Map</literal> instances, for example."
|
||||
msgstr ""
|
||||
"Hibernate funciona mejor si las clases siguen algunas simples reglas, "
|
||||
"también conocidas como el modelo de programación de Viejas "
|
||||
"Clases Java Planas (Plain Old Java Object o POJO). Sin embargo, ninguna de "
|
||||
"estas reglas son requerimientos rígidos. En cambio, Hibernate3 asume "
|
||||
"muy poco acerca de la naturaleza de tus objetos persistentes. Puedes "
|
||||
"expresar un modelo de dominio en otras formas: usando árboles de "
|
||||
"instancias de <literal>Map</literal>, por ejemplo."
|
||||
|
||||
#: index.docbook:23
|
||||
msgid "A simple POJO example"
|
||||
msgstr "Un ejemplo simple de POJO"
|
||||
|
||||
#: index.docbook:25
|
||||
msgid "Most Java applications require a persistent class representing felines."
|
||||
msgstr ""
|
||||
"La mayoría de aplicaciones Java requieren una clase representando "
|
||||
"felinos."
|
||||
|
||||
#: index.docbook:29
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"import java.util.Set;\n"
|
||||
"import java.util.Date;\n"
|
||||
"\n"
|
||||
"public class Cat {\n"
|
||||
" private Long id; // identifier\n"
|
||||
"\n"
|
||||
" private Date birthdate;\n"
|
||||
" private Color color;\n"
|
||||
" private char sex;\n"
|
||||
" private float weight;\n"
|
||||
" private int litterId;\n"
|
||||
"\n"
|
||||
" private Cat mother;\n"
|
||||
" private Set kittens = new HashSet();\n"
|
||||
"\n"
|
||||
" private void setId(Long id) {\n"
|
||||
" this.id=id;\n"
|
||||
" }\n"
|
||||
" public Long getId() {\n"
|
||||
" return id;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setBirthdate(Date date) {\n"
|
||||
" birthdate = date;\n"
|
||||
" }\n"
|
||||
" public Date getBirthdate() {\n"
|
||||
" return birthdate;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setWeight(float weight) {\n"
|
||||
" this.weight = weight;\n"
|
||||
" }\n"
|
||||
" public float getWeight() {\n"
|
||||
" return weight;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public Color getColor() {\n"
|
||||
" return color;\n"
|
||||
" }\n"
|
||||
" void setColor(Color color) {\n"
|
||||
" this.color = color;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setSex(char sex) {\n"
|
||||
" this.sex=sex;\n"
|
||||
" }\n"
|
||||
" public char getSex() {\n"
|
||||
" return sex;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setLitterId(int id) {\n"
|
||||
" this.litterId = id;\n"
|
||||
" }\n"
|
||||
" public int getLitterId() {\n"
|
||||
" return litterId;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setMother(Cat mother) {\n"
|
||||
" this.mother = mother;\n"
|
||||
" }\n"
|
||||
" public Cat getMother() {\n"
|
||||
" return mother;\n"
|
||||
" }\n"
|
||||
" void setKittens(Set kittens) {\n"
|
||||
" this.kittens = kittens;\n"
|
||||
" }\n"
|
||||
" public Set getKittens() {\n"
|
||||
" return kittens;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // addKitten not needed by Hibernate\n"
|
||||
" public void addKitten(Cat kitten) {\n"
|
||||
" kitten.setMother(this);\n"
|
||||
" kitten.setLitterId( kittens.size() ); \n"
|
||||
" kittens.add(kitten);\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"import java.util.Set;\n"
|
||||
"import java.util.Date;\n"
|
||||
"\n"
|
||||
"public class Cat {\n"
|
||||
" private Long id; // identifier\n"
|
||||
"\n"
|
||||
" private Date birthdate;\n"
|
||||
" private Color color;\n"
|
||||
" private char sex;\n"
|
||||
" private float weight;\n"
|
||||
" private int litterId;\n"
|
||||
"\n"
|
||||
" private Cat mother;\n"
|
||||
" private Set kittens = new HashSet();\n"
|
||||
"\n"
|
||||
" private void setId(Long id) {\n"
|
||||
" this.id=id;\n"
|
||||
" }\n"
|
||||
" public Long getId() {\n"
|
||||
" return id;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setBirthdate(Date date) {\n"
|
||||
" birthdate = date;\n"
|
||||
" }\n"
|
||||
" public Date getBirthdate() {\n"
|
||||
" return birthdate;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setWeight(float weight) {\n"
|
||||
" this.weight = weight;\n"
|
||||
" }\n"
|
||||
" public float getWeight() {\n"
|
||||
" return weight;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public Color getColor() {\n"
|
||||
" return color;\n"
|
||||
" }\n"
|
||||
" void setColor(Color color) {\n"
|
||||
" this.color = color;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setSex(char sex) {\n"
|
||||
" this.sex=sex;\n"
|
||||
" }\n"
|
||||
" public char getSex() {\n"
|
||||
" return sex;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setLitterId(int id) {\n"
|
||||
" this.litterId = id;\n"
|
||||
" }\n"
|
||||
" public int getLitterId() {\n"
|
||||
" return litterId;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setMother(Cat mother) {\n"
|
||||
" this.mother = mother;\n"
|
||||
" }\n"
|
||||
" public Cat getMother() {\n"
|
||||
" return mother;\n"
|
||||
" }\n"
|
||||
" void setKittens(Set kittens) {\n"
|
||||
" this.kittens = kittens;\n"
|
||||
" }\n"
|
||||
" public Set getKittens() {\n"
|
||||
" return kittens;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // addKitten not needed by Hibernate\n"
|
||||
" public void addKitten(Cat kitten) {\n"
|
||||
" kitten.setMother(this);\n"
|
||||
" kitten.setLitterId( kittens.size() ); \n"
|
||||
" kittens.add(kitten);\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:31
|
||||
msgid "There are four main rules to follow here:"
|
||||
msgstr "Aquí hay cuatro reglas principales a seguir:"
|
||||
|
||||
#: index.docbook:37
|
||||
msgid "Implement a no-argument constructor"
|
||||
msgstr "Implementa un constructor sin argumentos"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid ""
|
||||
"<literal>Cat</literal> has a no-argument constructor. All persistent classes "
|
||||
"must have a default constructor (which may be non-public) so that Hibernate "
|
||||
"can instantiate them using <literal>Constructor.newInstance()</literal>. We "
|
||||
"strongly recommend having a default constructor with at least "
|
||||
"<emphasis>package</emphasis> visibility for runtime proxy generation in "
|
||||
"Hibernate."
|
||||
msgstr ""
|
||||
"<literal>Cat</literal> tiene un contructor sin argumentos. Todas las clases "
|
||||
"persistentes deben tener un constructor por defecto (que puede no ser "
|
||||
"público) de modo que Hibernate pueda instanciarlas usando "
|
||||
"<literal>Constructor.newInstance()</literal>. Recomendamos fuertemente tener "
|
||||
"un constructor por defecto con al menos visibilidad de <emphasis>package</"
|
||||
"emphasis> para la generación de proxies en tiempo de ejecución "
|
||||
"en Hibernate."
|
||||
|
||||
#: index.docbook:49
|
||||
msgid "Provide an identifier property (optional)"
|
||||
msgstr "Provee una propiedad identificadora (opcional)"
|
||||
|
||||
#: index.docbook:51
|
||||
msgid ""
|
||||
"<literal>Cat</literal> has a property called <literal>id</literal>. This "
|
||||
"property maps to the primary key column of a database table. The property "
|
||||
"might have been called anything, and its type might have been any primitive "
|
||||
"type, any primitive \"wrapper\" type, <literal>java.lang.String</literal> or "
|
||||
"<literal>java.util.Date</literal>. (If your legacy database table has "
|
||||
"composite keys, you can even use a user-defined class with properties of "
|
||||
"these types - see the section on composite identifiers later.)"
|
||||
msgstr ""
|
||||
"<literal>Cat</literal> tiene una propiedad llamada <literal>id</literal>. "
|
||||
"Esta propiedad mapea a la columna clave primaria de la tabla de base de "
|
||||
"datos. La propiedad podría llamarse cualquierCosa, y su tipo "
|
||||
"podría haber sido cualquier tipo primitivo, cualquier tipo de "
|
||||
"\"envoltura\" primitivo, <literal>java.lang.String</literal> o <literal>java."
|
||||
"util.Date</literal>. (Si tu tabla de base de datos heredada tiene claves "
|
||||
"compuestas, puedes incluso usar una clase definida por el usuario con "
|
||||
"propiedades de estos tipos, ver la sección sobre identificadores "
|
||||
"compuestos luego.)"
|
||||
|
||||
#: index.docbook:60
|
||||
msgid ""
|
||||
"The identifier property is strictly optional. You can leave them off and let "
|
||||
"Hibernate keep track of object identifiers internally. We do not recommend "
|
||||
"this, however."
|
||||
msgstr ""
|
||||
"La propiedad identificadora es estrictamente opcional. Puedes olvidarla y "
|
||||
"dejar que Hibernate siga internamente la pista de los identificadores del "
|
||||
"objeto. Sin embargo, no recomendamos esto."
|
||||
|
||||
#: index.docbook:65
|
||||
msgid ""
|
||||
"In fact, some functionality is available only to classes which declare an "
|
||||
"identifier property:"
|
||||
msgstr ""
|
||||
"De hecho, alguna funcionalidad está disponible sólo para "
|
||||
"clases que declaran una propiedad identificadora:"
|
||||
|
||||
#: index.docbook:72
|
||||
msgid ""
|
||||
"Transitive reattachment for detached objects (cascade update or cascade "
|
||||
"merge) - see"
|
||||
msgstr ""
|
||||
"Reasociación transitiva de objetos separados (actualizaciones o "
|
||||
"fusiones en cascada) - ver"
|
||||
|
||||
#: index.docbook:79
|
||||
msgid "Session.saveOrUpdate()"
|
||||
msgstr "Session.saveOrUpdate()"
|
||||
|
||||
#: index.docbook:84
|
||||
msgid "Session.merge()"
|
||||
msgstr "Session.merge()"
|
||||
|
||||
#: index.docbook:89
|
||||
msgid ""
|
||||
"We recommend you declare consistently-named identifier properties on "
|
||||
"persistent classes. We further recommend that you use a nullable (ie. non-"
|
||||
"primitive) type."
|
||||
msgstr ""
|
||||
"Recomendamos que declares propiedades identificadoras nombradas-"
|
||||
"consistentemente en clases persistentes. Mas aún, recomendamos que "
|
||||
"uses un tipo nulable (es decir, no primitivo)."
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "Prefer non-final classes (optional)"
|
||||
msgstr "Prefiere las clases no finales (opcional)"
|
||||
|
||||
#: index.docbook:97
|
||||
msgid ""
|
||||
"A central feature of Hibernate, <emphasis>proxies</emphasis>, depends upon "
|
||||
"the persistent class being either non-final, or the implementation of an "
|
||||
"interface that declares all public methods."
|
||||
msgstr ""
|
||||
"Un aspecto central de Hibernate, <emphasis>proxies</emphasis>, depende de "
|
||||
"que las clases persistentes sean ya no finales, o sean ya la "
|
||||
"implementación de una interface que declare todos los métodos "
|
||||
"públicos."
|
||||
|
||||
#: index.docbook:102
|
||||
msgid ""
|
||||
"You can persist <literal>final</literal> classes that do not implement an "
|
||||
"interface with Hibernate, but you won't be able to use proxies for lazy "
|
||||
"association fetching - which will limit your options for performance tuning."
|
||||
msgstr ""
|
||||
"Puedes persistir con Hibernate clases <literal>final</literal> que no "
|
||||
"implementen una interface, pero no serás capaz de usar proxies para "
|
||||
"recuperación perezosa de asociaciones, lo que limitará tus "
|
||||
"opciones para afinar el rendimiento."
|
||||
|
||||
#: index.docbook:107
|
||||
msgid ""
|
||||
"You should also avoid declaring <literal>public final</literal> methods on "
|
||||
"the non-final classes. If you want to use a class with a <literal>public "
|
||||
"final</literal> method, you must explicitly disable proxying by setting "
|
||||
"<literal>lazy=\"false\"</literal>."
|
||||
msgstr ""
|
||||
"Debes también evitar declarar métodos <literal>public final</"
|
||||
"literal> en clases non-final. Si quieres usar una clase con un método "
|
||||
"<literal>public final</literal>, debes deshabilitar explícitamente el "
|
||||
"uso de proxies estableciendo <literal>lazy=\"false\"</literal>."
|
||||
|
||||
#: index.docbook:115
|
||||
msgid "Declare accessors and mutators for persistent fields (optional)"
|
||||
msgstr ""
|
||||
"Declara métodos de acceso y modificación para los campos "
|
||||
"persistentes (opcional)"
|
||||
|
||||
#: index.docbook:117
|
||||
msgid ""
|
||||
"<literal>Cat</literal> declares accessor methods for all its persistent "
|
||||
"fields. Many other ORM tools directly persist instance variables. We believe "
|
||||
"it is better to provide an indirection between the relational schema and "
|
||||
"internal data structures of the class. By default, Hibernate persists "
|
||||
"JavaBeans style properties, and recognizes method names of the form "
|
||||
"<literal>getFoo</literal>, <literal>isFoo</literal> and <literal>setFoo</"
|
||||
"literal>. You may switch to direct field access for particular properties, "
|
||||
"if needed."
|
||||
msgstr ""
|
||||
"<literal>Cat</literal> declara métodos de acceso para todos sus "
|
||||
"campos persistente. Muchas otras herramientas ORM persisten directamente "
|
||||
"variables de instancia. Creemos que es mejor proveer una indirección "
|
||||
"entre el esquema relacional y las estructuras internas de la clase. Por "
|
||||
"defecto, Hibernate persiste propiedades del estilo JavaBeans, y reconoce "
|
||||
"nombres de método de la forma <literal>getFoo</literal>, "
|
||||
"<literal>isFoo</literal> y <literal>setFoo</literal>. Puedes cambiar a "
|
||||
"acceso directo a campos para propiedades en particular, de ser necesario."
|
||||
|
||||
#: index.docbook:127
|
||||
msgid ""
|
||||
"Properties need <emphasis>not</emphasis> be declared public - Hibernate can "
|
||||
"persist a property with a default, <literal>protected</literal> or "
|
||||
"<literal>private</literal> get / set pair."
|
||||
msgstr ""
|
||||
"Las propiedades <emphasis>no</emphasis> necesitan ser declaradas pú"
|
||||
"blicas. Hibernate puede persistir una propiedad con un par get / set "
|
||||
"<literal>protected</literal> o <literal>private</literal>."
|
||||
|
||||
#: index.docbook:138
|
||||
msgid "Implementing inheritance"
|
||||
msgstr "Implementando herencia"
|
||||
|
||||
#: index.docbook:140
|
||||
msgid ""
|
||||
"A subclass must also observe the first and second rules. It inherits its "
|
||||
"identifier property from the superclass, <literal>Cat</literal>."
|
||||
msgstr ""
|
||||
"Una subclase puede a su vez observar la primera y segunda regla. Hereda su "
|
||||
"propiedad identificadora de la superclase, <literal>Cat</literal>."
|
||||
|
||||
#: index.docbook:145
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"public class DomesticCat extends Cat {\n"
|
||||
" private String name;\n"
|
||||
"\n"
|
||||
" public String getName() {\n"
|
||||
" return name;\n"
|
||||
" }\n"
|
||||
" protected void setName(String name) {\n"
|
||||
" this.name=name;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"public class DomesticCat extends Cat {\n"
|
||||
" private String name;\n"
|
||||
"\n"
|
||||
" public String getName() {\n"
|
||||
" return name;\n"
|
||||
" }\n"
|
||||
" protected void setName(String name) {\n"
|
||||
" this.name=name;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:149
|
||||
msgid ""
|
||||
"Implementing <literal>equals()</literal> and <literal>hashCode()</literal>"
|
||||
msgstr ""
|
||||
"Implementando <literal>equals()</literal> y <literal>hashCode()</literal>"
|
||||
|
||||
#: index.docbook:151
|
||||
msgid ""
|
||||
"You have to override the <literal>equals()</literal> and <literal>hashCode()"
|
||||
"</literal> methods if you"
|
||||
msgstr ""
|
||||
"Tienes que sobrescribir los métodos <literal>equals()</literal> y "
|
||||
"<literal>hashCode()</literal> si :"
|
||||
|
||||
#: index.docbook:157
|
||||
msgid ""
|
||||
"intend to put instances of persistent classes in a <literal>Set</literal> "
|
||||
"(the recommended way to represent many-valued associations) <emphasis>and</"
|
||||
"emphasis>"
|
||||
msgstr ""
|
||||
"piensas poner instancias de clases persistentes en un <literal>Set</literal> "
|
||||
"(la forma recomendada de representar asociaciones multivaluadas) "
|
||||
"<emphasis>y</emphasis>"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "intend to use reattachment of detached instances"
|
||||
msgstr "piensas usar reasociación de instancias separadas."
|
||||
|
||||
#: index.docbook:170
|
||||
msgid ""
|
||||
"Hibernate guarantees equivalence of persistent identity (database row) and "
|
||||
"Java identity only inside a particular session scope. So as soon as we mix "
|
||||
"instances retrieved in different sessions, we must implement <literal>equals"
|
||||
"()</literal> and <literal>hashCode()</literal> if we wish to have meaningful "
|
||||
"semantics for <literal>Set</literal>s."
|
||||
msgstr ""
|
||||
"Hibernate garantiza la equivalencia de identidad persistente (fila de base "
|
||||
"de datos) y identidad Java sólo dentro del ámbito de una "
|
||||
"sesión en particular. De modo que en el momento que mezclamos "
|
||||
"instancias recuperadas en sesiones diferentes, debemos implementar "
|
||||
"<literal>equals()</literal> y <literal>hashCode()</literal> si deseamos "
|
||||
"tener una semántica significativa de <literal>Set</literal>s."
|
||||
|
||||
#: index.docbook:178
|
||||
msgid ""
|
||||
"The most obvious way is to implement <literal>equals()</literal>/"
|
||||
"<literal>hashCode()</literal> by comparing the identifier value of both "
|
||||
"objects. If the value is the same, both must be the same database row, they "
|
||||
"are therefore equal (if both are added to a <literal>Set</literal>, we will "
|
||||
"only have one element in the <literal>Set</literal>). Unfortunately, we "
|
||||
"can't use that approach with generated identifiers! Hibernate will only "
|
||||
"assign identifier values to objects that are persistent, a newly created "
|
||||
"instance will not have any identifier value! Furthermore, if an instance is "
|
||||
"unsaved and currently in a <literal>Set</literal>, saving it will assign an "
|
||||
"identifier value to the object. If <literal>equals()</literal> and "
|
||||
"<literal>hashCode()</literal> are based on the identifier value, the hash "
|
||||
"code would change, breaking the contract of the <literal>Set</literal>. See "
|
||||
"the Hibernate website for a full discussion of this problem. Note that this "
|
||||
"is not a Hibernate issue, but normal Java semantics of object identity and "
|
||||
"equality."
|
||||
msgstr ""
|
||||
"La forma más obvia es implementar <literal>equals()</literal>/"
|
||||
"<literal>hashCode()</literal> comparando el valor identificador de ambos "
|
||||
"objetos. Si el valor es el mismo, ambos deben ser la misma fila de base de "
|
||||
"datos, por lo tanto son iguales (si ambos son agregados a un <literal>Set</"
|
||||
"literal>, sólo tendremos un elemento en el <literal>Set</literal>). "
|
||||
"Desafortunadamente, no podemos usar este enfoque con identificadores "
|
||||
"generados! Hibernate sólo asignará valores identificadores a "
|
||||
"objetos que son persistentes, una instancia recién creada no "
|
||||
"tendrá ningún valor identificador! Además, si una "
|
||||
"instancia no está salvada y está actualmente en un "
|
||||
"<literal>Set</literal>, salvarla asignará un valor identificador al "
|
||||
"objeto. Si <literal>equals()</literal> and <literal>hashCode()</literal> "
|
||||
"están basados en el valor identificador, el código hash "
|
||||
"podría cambiar, rompiendo el contrato de <literal>Set</literal>. Ver "
|
||||
"el sitio web de Hibernate para una discusión completa de este "
|
||||
"problema. Observa que esto no es una incidencia de Hibernate, sino la "
|
||||
"semántica normal de Java de identidad de objeto e igualdad."
|
||||
|
||||
#: index.docbook:192
|
||||
msgid ""
|
||||
"We recommend implementing <literal>equals()</literal> and <literal>hashCode()"
|
||||
"</literal> using <emphasis>Business key equality</emphasis>. Business key "
|
||||
"equality means that the <literal>equals()</literal> method compares only the "
|
||||
"properties that form the business key, a key that would identify our "
|
||||
"instance in the real world (a <emphasis>natural</emphasis> candidate key):"
|
||||
msgstr ""
|
||||
"Recomendamos implementar <literal>equals()</literal> y <literal>hashCode()</"
|
||||
"literal> usando <emphasis>igualdad de clave de negocio (Business key "
|
||||
"equality)</emphasis>. Igualdad de clave de negocio significa que el mé"
|
||||
"todo <literal>equals()</literal> compara sólo las propiedades que "
|
||||
"forman la clave de negocio, una clave que podría identificar nuestra "
|
||||
"instancia en el mundo real (una clave candidata <emphasis>natural</"
|
||||
"emphasis>):"
|
||||
|
||||
#: index.docbook:200
|
||||
msgid ""
|
||||
"<![CDATA[public class Cat {\n"
|
||||
"\n"
|
||||
" ...\n"
|
||||
" public boolean equals(Object other) {\n"
|
||||
" if (this == other) return true;\n"
|
||||
" if ( !(other instanceof Cat) ) return false;\n"
|
||||
"\n"
|
||||
" final Cat cat = (Cat) other;\n"
|
||||
"\n"
|
||||
" if ( !cat.getLitterId().equals( getLitterId() ) ) return false;\n"
|
||||
" if ( !cat.getMother().equals( getMother() ) ) return false;\n"
|
||||
"\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public int hashCode() {\n"
|
||||
" int result;\n"
|
||||
" result = getMother().hashCode();\n"
|
||||
" result = 29 * result + getLitterId();\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[public class Cat {\n"
|
||||
"\n"
|
||||
" ...\n"
|
||||
" public boolean equals(Object other) {\n"
|
||||
" if (this == other) return true;\n"
|
||||
" if ( !(other instanceof Cat) ) return false;\n"
|
||||
"\n"
|
||||
" final Cat cat = (Cat) other;\n"
|
||||
"\n"
|
||||
" if ( !cat.getLitterId().equals( getLitterId() ) ) return false;\n"
|
||||
" if ( !cat.getMother().equals( getMother() ) ) return false;\n"
|
||||
"\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public int hashCode() {\n"
|
||||
" int result;\n"
|
||||
" result = getMother().hashCode();\n"
|
||||
" result = 29 * result + getLitterId();\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:202
|
||||
msgid ""
|
||||
"Note that a business key does not have to be as solid as a database primary "
|
||||
"key candidate (see <xref linkend=\"transactions-basics-identity\"/>). "
|
||||
"Immutable or unique properties are usually good candidates for a business "
|
||||
"key."
|
||||
msgstr ""
|
||||
"Nota que una clave de negocio no tiene que ser tan sólida como una "
|
||||
"clave primaria candidata de base de datos (ver <xref linkend=\"transactions-"
|
||||
"basics-identity\"/>). Las propiedades inmutables o únicas son "
|
||||
"usualmente buenas candidatas para una clave de negocio."
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "Dynamic models"
|
||||
msgstr "Modelos dinámicos"
|
||||
|
||||
#: index.docbook:215
|
||||
msgid ""
|
||||
"Note that the following features are currently considered experimental and "
|
||||
"may change in the near future."
|
||||
msgstr ""
|
||||
"Ten en cuenta que las siguientes funcionalidades están consideradas "
|
||||
"actualmente experimentales y pueden cambiar en el futuro cercano."
|
||||
|
||||
#: index.docbook:219
|
||||
msgid ""
|
||||
"Persistent entities don't necessarily have to be represented as POJO classes "
|
||||
"or as JavaBean objects at runtime. Hibernate also supports dynamic models "
|
||||
"(using <literal>Map</literal>s of <literal>Map</literal>s at runtime) and "
|
||||
"the representation of entities as DOM4J trees. With this approach, you don't "
|
||||
"write persistent classes, only mapping files."
|
||||
msgstr ""
|
||||
"Las entidades persistentes no necesariamente tienen que estar representadas "
|
||||
"como clases POJO o como objetos JavaBean en tiempo de ejecución. "
|
||||
"Hibernate soporta además modelos dinámicos (usando "
|
||||
"<literal>Map</literal>s de <literal>Map</literal>s en tiempo de "
|
||||
"ejecución) y la representación de entidades como á"
|
||||
"rboles de DOM4J. Con este enfoque no escribes clases persistentes, só"
|
||||
"lo ficheros de mapeo."
|
||||
|
||||
#: index.docbook:227
|
||||
msgid ""
|
||||
"By default, Hibernate works in normal POJO mode. You may set a default "
|
||||
"entity representation mode for a particular <literal>SessionFactory</"
|
||||
"literal> using the <literal>default_entity_mode</literal> configuration "
|
||||
"option (see <xref linkend=\"configuration-optional-properties\"/>."
|
||||
msgstr ""
|
||||
"Por defecto, Hibernate funciona en modo POJO normal. Puedes establecer una "
|
||||
"representación de entidad por defecto para una "
|
||||
"<literal>SessionFactory</literal> en particular usando la opción de "
|
||||
"configuración <literal>default_entity_mode</literal> (ver <xref "
|
||||
"linkend=\"configuration-optional-properties\"/>)."
|
||||
|
||||
#: index.docbook:234
|
||||
msgid ""
|
||||
"The following examples demonstrates the representation using <literal>Map</"
|
||||
"literal>s. First, in the mapping file, an <literal>entity-name</literal> has "
|
||||
"to be declared instead of (or in addition to) a class name:"
|
||||
msgstr ""
|
||||
"Los siguientes ejemplos demuestran la representación usando "
|
||||
"<literal>Map</literal>s. Primero, en el fichero de mapeo, tiene que "
|
||||
"declararse un <literal>entity-name</literal> en vez de (o como agregado a) "
|
||||
"un nombre de clase:"
|
||||
|
||||
#: index.docbook:240
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
"\n"
|
||||
" <class entity-name=\"Customer\">\n"
|
||||
"\n"
|
||||
" <id name=\"id\"\n"
|
||||
" type=\"long\"\n"
|
||||
" column=\"ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property name=\"name\"\n"
|
||||
" column=\"NAME\"\n"
|
||||
" type=\"string\"/>\n"
|
||||
"\n"
|
||||
" <property name=\"address\"\n"
|
||||
" column=\"ADDRESS\"\n"
|
||||
" type=\"string\"/>\n"
|
||||
"\n"
|
||||
" <many-to-one name=\"organization\"\n"
|
||||
" column=\"ORGANIZATION_ID\"\n"
|
||||
" class=\"Organization\"/>\n"
|
||||
"\n"
|
||||
" <bag name=\"orders\"\n"
|
||||
" inverse=\"true\"\n"
|
||||
" lazy=\"false\"\n"
|
||||
" cascade=\"all\">\n"
|
||||
" <key column=\"CUSTOMER_ID\"/>\n"
|
||||
" <one-to-many class=\"Order\"/>\n"
|
||||
" </bag>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
" \n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
"\n"
|
||||
" <class entity-name=\"Customer\">\n"
|
||||
"\n"
|
||||
" <id name=\"id\"\n"
|
||||
" type=\"long\"\n"
|
||||
" column=\"ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property name=\"name\"\n"
|
||||
" column=\"NAME\"\n"
|
||||
" type=\"string\"/>\n"
|
||||
"\n"
|
||||
" <property name=\"address\"\n"
|
||||
" column=\"ADDRESS\"\n"
|
||||
" type=\"string\"/>\n"
|
||||
"\n"
|
||||
" <many-to-one name=\"organization\"\n"
|
||||
" column=\"ORGANIZATION_ID\"\n"
|
||||
" class=\"Organization\"/>\n"
|
||||
"\n"
|
||||
" <bag name=\"orders\"\n"
|
||||
" inverse=\"true\"\n"
|
||||
" lazy=\"false\"\n"
|
||||
" cascade=\"all\">\n"
|
||||
" <key column=\"CUSTOMER_ID\"/>\n"
|
||||
" <one-to-many class=\"Order\"/>\n"
|
||||
" </bag>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
" \n"
|
||||
"</hibernate-mapping>]]>"
|
||||
|
||||
#: index.docbook:242
|
||||
msgid ""
|
||||
"Note that even though associations are declared using target class names, "
|
||||
"the target type of an associations may also be a dynamic entity instead of a "
|
||||
"POJO."
|
||||
msgstr ""
|
||||
"Ten en cuenta que aunque las asociaciones se declaran usando nombres de "
|
||||
"clase objetivo, el tipo objetivo de una asociación puede ser "
|
||||
"además una entidad dinámica en vez de un POJO."
|
||||
|
||||
#: index.docbook:249
|
||||
msgid ""
|
||||
"After setting the default entity mode to <literal>dynamic-map</literal> for "
|
||||
"the <literal>SessionFactory</literal>, we can at runtime work with "
|
||||
"<literal>Map</literal>s of <literal>Map</literal>s:"
|
||||
msgstr ""
|
||||
"Después de establecer el modo de entidad por defecto a "
|
||||
"<literal>dynamic-map</literal> para la <literal>SessionFactory</literal>, "
|
||||
"podemos trabajar en tiempo de ejecución con <literal>Map</literal>s "
|
||||
"de <literal>Map</literal>s:"
|
||||
|
||||
#: index.docbook:255
|
||||
msgid ""
|
||||
"<![CDATA[Session s = openSession();\n"
|
||||
"Transaction tx = s.beginTransaction();\n"
|
||||
"Session s = openSession();\n"
|
||||
"\n"
|
||||
"// Create a customer\n"
|
||||
"Map david = new HashMap();\n"
|
||||
"david.put(\"name\", \"David\");\n"
|
||||
"\n"
|
||||
"// Create an organization\n"
|
||||
"Map foobar = new HashMap();\n"
|
||||
"foobar.put(\"name\", \"Foobar Inc.\");\n"
|
||||
"\n"
|
||||
"// Link both\n"
|
||||
"david.put(\"organization\", foobar);\n"
|
||||
"\n"
|
||||
"// Save both\n"
|
||||
"s.save(\"Customer\", david);\n"
|
||||
"s.save(\"Organization\", foobar);\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"s.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session s = openSession();\n"
|
||||
"Transaction tx = s.beginTransaction();\n"
|
||||
"Session s = openSession();\n"
|
||||
"\n"
|
||||
"// Create a customer\n"
|
||||
"Map david = new HashMap();\n"
|
||||
"david.put(\"name\", \"David\");\n"
|
||||
"\n"
|
||||
"// Create an organization\n"
|
||||
"Map foobar = new HashMap();\n"
|
||||
"foobar.put(\"name\", \"Foobar Inc.\");\n"
|
||||
"\n"
|
||||
"// Link both\n"
|
||||
"david.put(\"organization\", foobar);\n"
|
||||
"\n"
|
||||
"// Save both\n"
|
||||
"s.save(\"Customer\", david);\n"
|
||||
"s.save(\"Organization\", foobar);\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"s.close();]]>"
|
||||
|
||||
#: index.docbook:257
|
||||
msgid ""
|
||||
"The advantages of a dynamic mapping are quick turnaround time for "
|
||||
"prototyping without the need for entity class implementation. However, you "
|
||||
"lose compile-time type checking and will very likely deal with many "
|
||||
"exceptions at runtime. Thanks to the Hibernate mapping, the database schema "
|
||||
"can easily be normalized and sound, allowing to add a proper domain model "
|
||||
"implementation on top later on."
|
||||
msgstr ""
|
||||
"Las ventajas de un mapeo dinámico es rápido tiempo de ciclo de "
|
||||
"prototipado sin la necesidad de implementación de clases de entidad. "
|
||||
"Sin embargo, pierdes chequeo de tipos en tiempo de compilación y muy "
|
||||
"probablemente tratarás con muchas excepciones en tiempo de "
|
||||
"ejecución. Gracias al mapeo de Hibernate, el esquema de base de datos "
|
||||
"puede estar facilmente sano y normalizado, permitiendo agregar una "
|
||||
"implementación apropiada del modelo de dominio más tarde."
|
||||
|
||||
#: index.docbook:265
|
||||
msgid ""
|
||||
"Entity representation modes can also be set on a per <literal>Session</"
|
||||
"literal> basis:"
|
||||
msgstr ""
|
||||
"Los modos de representación de entidad pueden ser establecidos por "
|
||||
"<literal>Session</literal>:"
|
||||
|
||||
#: index.docbook:270
|
||||
msgid ""
|
||||
"<![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);\n"
|
||||
"\n"
|
||||
"// Create a customer\n"
|
||||
"Map david = new HashMap();\n"
|
||||
"david.put(\"name\", \"David\");\n"
|
||||
"dynamicSession.save(\"Customer\", david);\n"
|
||||
"...\n"
|
||||
"dynamicSession.flush();\n"
|
||||
"dynamicSession.close()\n"
|
||||
"...\n"
|
||||
"// Continue on pojoSession\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);\n"
|
||||
"\n"
|
||||
"// Create a customer\n"
|
||||
"Map david = new HashMap();\n"
|
||||
"david.put(\"name\", \"David\");\n"
|
||||
"dynamicSession.save(\"Customer\", david);\n"
|
||||
"...\n"
|
||||
"dynamicSession.flush();\n"
|
||||
"dynamicSession.close()\n"
|
||||
"...\n"
|
||||
"// Continue on pojoSession\n"
|
||||
"]]>"
|
||||
|
||||
#: index.docbook:273
|
||||
msgid ""
|
||||
"Please note that the call to <literal>getSession()</literal> using an "
|
||||
"<literal>EntityMode</literal> is on the <literal>Session</literal> API, not "
|
||||
"the <literal>SessionFactory</literal>. That way, the new <literal>Session</"
|
||||
"literal> shares the underlying JDBC connection, transaction, and other "
|
||||
"context information. This means you don't have tocall <literal>flush()</"
|
||||
"literal> and <literal>close()</literal> on the secondary <literal>Session</"
|
||||
"literal>, and also leave the transaction and connection handling to the "
|
||||
"primary unit of work."
|
||||
msgstr ""
|
||||
"Por favor, ten en cuenta que la llamada a <literal>getSession()</literal> "
|
||||
"usando un <literal>EntityMode</literal> está en la API de "
|
||||
"<literal>Session</literal>, no en la de <literal>SessionFactory</literal>. "
|
||||
"De esta forma, la nueva <literal>Session</literal> comparte la conexió"
|
||||
"n JDBC, transacción y otra información de contexto. Esto "
|
||||
"significa que no tienes que llamar a <literal>flush()</literal> ni a "
|
||||
"<literal>close()</literal> en la <literal>Session</literal> secundaria, y "
|
||||
"tembién dejar el manejo de la transacción y de la "
|
||||
"conexión a la unidad de trabajo primaria."
|
||||
|
||||
#: index.docbook:283
|
||||
msgid ""
|
||||
"More information about the XML representation capabilities can be found in "
|
||||
"<xref linkend=\"xml\"/>."
|
||||
msgstr ""
|
||||
"Puede encontrarse más información sobre las capacidades de "
|
||||
"representación XML en <xref linkend=\"xml\"/>."
|
||||
|
||||
#: index.docbook:291
|
||||
msgid "Tuplizers"
|
||||
msgstr "UNTRANSLATED!!! Tuplizers"
|
||||
|
||||
#: index.docbook:293
|
||||
msgid ""
|
||||
"<literal>org.hibernate.tuple.Tuplizer</literal>, and its sub-interfaces, are "
|
||||
"responsible for managing a particular representation of a piece of data, "
|
||||
"given that representation's <literal>org.hibernate.EntityMode</literal>. If "
|
||||
"a given piece of data is thought of as a data structure, then a tuplizer is "
|
||||
"the thing which knows how to create such a data structure and how to extract "
|
||||
"values from and inject values into such a data structure. For example, for "
|
||||
"the POJO entity mode, the correpsonding tuplizer knows how create the POJO "
|
||||
"through its constructor and how to access the POJO properties using the "
|
||||
"defined property accessors. There are two high-level types of Tuplizers, "
|
||||
"represented by the <literal>org.hibernate.tuple.entity.EntityTuplizer</"
|
||||
"literal> and <literal>org.hibernate.tuple.component.ComponentTuplizer</"
|
||||
"literal> interfaces. <literal>EntityTuplizer</literal>s are responsible for "
|
||||
"managing the above mentioned contracts in regards to entities, while "
|
||||
"<literal>ComponentTuplizer</literal>s do the same for components."
|
||||
msgstr ""
|
||||
"<literal>org.hibernate.tuple.Tuplizer</literal>, and its sub-interfaces, are "
|
||||
"responsible for managing a particular representation of a piece of data, "
|
||||
"given that representation's <literal>org.hibernate.EntityMode</literal>. If "
|
||||
"a given piece of data is thought of as a data structure, then a tuplizer is "
|
||||
"the thing which knows how to create such a data structure and how to extract "
|
||||
"values from and inject values into such a data structure. For example, for "
|
||||
"the POJO entity mode, the correpsonding tuplizer knows how create the POJO "
|
||||
"through its constructor and how to access the POJO properties using the "
|
||||
"defined property accessors. There are two high-level types of Tuplizers, "
|
||||
"represented by the <literal>org.hibernate.tuple.entity.EntityTuplizer</"
|
||||
"literal> and <literal>org.hibernate.tuple.component.ComponentTuplizer</"
|
||||
"literal> interfaces. <literal>EntityTuplizer</literal>s are responsible for "
|
||||
"managing the above mentioned contracts in regards to entities, while "
|
||||
"<literal>ComponentTuplizer</literal>s do the same for components."
|
||||
|
||||
#: index.docbook:308
|
||||
msgid ""
|
||||
"Users may also plug in their own tuplizers. Perhaps you require that a "
|
||||
"<literal>java.util.Map</literal> implementation other than <literal>java."
|
||||
"util.HashMap</literal> be used while in the dynamic-map entity-mode; or "
|
||||
"perhaps you need to define a different proxy generation strategy than the "
|
||||
"one used by default. Both would be achieved by defining a custom tuplizer "
|
||||
"implementation. Tuplizers definitions are attached to the entity or "
|
||||
"component mapping they are meant to manage. Going back to the example of our "
|
||||
"customer entity:"
|
||||
msgstr ""
|
||||
"Users may also plug in their own tuplizers. Perhaps you require that a "
|
||||
"<literal>java.util.Map</literal> implementation other than <literal>java."
|
||||
"util.HashMap</literal> be used while in the dynamic-map entity-mode; or "
|
||||
"perhaps you need to define a different proxy generation strategy than the "
|
||||
"one used by default. Both would be achieved by defining a custom tuplizer "
|
||||
"implementation. Tuplizers definitions are attached to the entity or "
|
||||
"component mapping they are meant to manage. Going back to the example of our "
|
||||
"customer entity:"
|
||||
|
||||
#: index.docbook:317
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
" <class entity-name=\"Customer\">\n"
|
||||
" <!--\n"
|
||||
" Override the dynamic-map entity-mode\n"
|
||||
" tuplizer for the customer entity\n"
|
||||
" -->\n"
|
||||
" <tuplizer entity-mode=\"dynamic-map\"\n"
|
||||
" class=\"CustomMapTuplizerImpl\"/>\n"
|
||||
"\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <!-- other properties -->\n"
|
||||
" ...\n"
|
||||
" </class>\n"
|
||||
"</hibernate-mapping>\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"public class CustomMapTuplizerImpl\n"
|
||||
" extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {\n"
|
||||
" // override the buildInstantiator() method to plug in our custom map...\n"
|
||||
" protected final Instantiator buildInstantiator(\n"
|
||||
" org.hibernate.mapping.PersistentClass mappingInfo) {\n"
|
||||
" return new CustomMapInstantiator( mappingInfo );\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" private static final class CustomMapInstantiator\n"
|
||||
" extends org.hibernate.tuple.DynamicMapInstantitor {\n"
|
||||
" // override the generateMap() method to return our custom map...\n"
|
||||
" protected final Map generateMap() {\n"
|
||||
" return new CustomMap();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
" <class entity-name=\"Customer\">\n"
|
||||
" <!--\n"
|
||||
" Override the dynamic-map entity-"
|
||||
"mode\n"
|
||||
" tuplizer for the customer entity\n"
|
||||
" -->\n"
|
||||
" <tuplizer entity-mode=\"dynamic-map\"\n"
|
||||
" class=\"CustomMapTuplizerImpl"
|
||||
"\"/>\n"
|
||||
" \n"
|
||||
" <id name=\"id\" type=\"long\" column=\"ID"
|
||||
"\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
" \n"
|
||||
" <!-- other properties -->\n"
|
||||
" ...\n"
|
||||
" </class>\n"
|
||||
" </hibernate-mapping>\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" public class CustomMapTuplizerImpl\n"
|
||||
" extends org.hibernate.tuple.entity."
|
||||
"DynamicMapEntityTuplizer {\n"
|
||||
" // override the buildInstantiator() method to plug in "
|
||||
"our custom map...\n"
|
||||
" protected final Instantiator buildInstantiator(\n"
|
||||
" org.hibernate.mapping.PersistentClass mappingInfo) {\n"
|
||||
" return new CustomMapInstantiator( mappingInfo );\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" private static final class CustomMapInstantiator\n"
|
||||
" extends org.hibernate.tuple.DynamicMapInstantitor {\n"
|
||||
" // override the generateMap() method to return our "
|
||||
"custom map...\n"
|
||||
" protected final Map generateMap() {\n"
|
||||
" return new CustomMap();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }]]>"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid ""
|
||||
"TODO: Document user-extension framework in the property and proxy packages"
|
||||
msgstr ""
|
||||
"PORHACER: Documentar el framework de extensiones del usuario en los paquetes "
|
||||
"de propiedad y proxies."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,177 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "Preface"
|
||||
msgstr "Prefacio"
|
||||
|
||||
#: index.docbook:23
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Trabajar con software orientado a objetos y una base de datos relacional "
|
||||
"puede ser incómodo y consumir tiempo en los entornos de empresa de "
|
||||
"hoy. Hibernate es una herramienta de mapeo objeto/relacional para entornos "
|
||||
"Java. El término mapeo objeto/relacional (MOR) hace referencia a la "
|
||||
"técnica de mapear una representación de datos desde un modelo "
|
||||
"de objetos a un modelo de datos relacional con un esquema basado en SQL."
|
||||
|
||||
#: index.docbook:31
|
||||
msgid ""
|
||||
"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 and can significantly reduce development time "
|
||||
"otherwise spent with manual data handling in SQL and JDBC."
|
||||
msgstr ""
|
||||
"Hibernate no sólo se encarga de mapear de clases Java a tablas de "
|
||||
"base de datos (y de tipos de datos de Java a tipos de datos SQL), sino que "
|
||||
"también provee facilidades de consulta y recuperación de datos "
|
||||
"y puede reducir significativamente el tiempo de desarrollo que de otra forma "
|
||||
"se gasta en el manejo de los datos en SQL y JDBC."
|
||||
|
||||
#: index.docbook:38
|
||||
msgid ""
|
||||
"Hibernates 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 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 encapsulate vendor-"
|
||||
"specific SQL code and will help with the common task of result set "
|
||||
"translation from a tabular representation to a graph of objects."
|
||||
msgstr ""
|
||||
"La meta de Hibernate es relevar al desarrollador del 95 por ciento de las "
|
||||
"tareas comunes relacionadas a la programación de la persistencia de "
|
||||
"los datos. Hibernate puede no ser la mejor solución para aplicaciones "
|
||||
"que usan solamente procedimientos almacenados para implementar la ló"
|
||||
"gica de negocio en la base de datos, es mas útil con modelos de "
|
||||
"dominio orientados a objetos y lógica de negocio en middle-tier "
|
||||
"basada en Java. Sin embargo, Hibernate ciertamente puede ayudarte a quitar o "
|
||||
"encapsular código SQL específico de vendedor y ayudará "
|
||||
"con la tarea común de traducción de resultados desde una "
|
||||
"representación tabular a un grafo de objetos."
|
||||
|
||||
#: index.docbook:48
|
||||
msgid ""
|
||||
"If you are new to Hibernate and Object/Relational Mapping or even Java, "
|
||||
"please follow these steps:"
|
||||
msgstr ""
|
||||
"Si eres nuevo en Hibernate y lo del Mapeo Objeto/Relacional o incluso en "
|
||||
"Java, sigue por favor estos pasos:"
|
||||
|
||||
#: index.docbook:55
|
||||
msgid ""
|
||||
"Read <xref linkend=\"tutorial\"/> for a tutorial with step-by-step "
|
||||
"instructions. The source code for the tutorial is included in the "
|
||||
"distribution in the <literal>doc/reference/tutorial/</literal> directory."
|
||||
msgstr ""
|
||||
"Lee <xref linkend=\"quickstart\"/> para un tutorial de 30 minutos, usando "
|
||||
"Tomcat."
|
||||
|
||||
#: index.docbook:63
|
||||
msgid ""
|
||||
"Read <xref linkend=\"architecture\"/> to understand the environments where "
|
||||
"Hibernate can be used."
|
||||
msgstr ""
|
||||
"Lee <xref linkend=\"architecture\"/> para entender los entornos en los que "
|
||||
"puede ser usado Hibernate."
|
||||
|
||||
#: index.docbook:69
|
||||
msgid ""
|
||||
"Have a look at the <literal>eg/</literal> directory in the Hibernate "
|
||||
"distribution, it contains a simple standalone application. Copy your JDBC "
|
||||
"driver to the <literal>lib/</literal> directory and edit <literal>etc/"
|
||||
"hibernate.properties</literal>, specifying correct values for your database. "
|
||||
"From a command prompt in the distribution directory, type <literal>ant eg</"
|
||||
"literal> (using Ant), or under Windows, type <literal>build eg</literal>."
|
||||
msgstr ""
|
||||
"Dale una mirada al directorio <literal>eg/</literal> en la distribució"
|
||||
"n de Hibernate, contiene una aplicación independiente simple. Copia "
|
||||
"tu driver JDBC al directorio <literal>lib/</literal> y edita <literal>etc/"
|
||||
"hibernate.properties</literal>, especificando los valores correctos para tu "
|
||||
"base de datos. Desde línea de comandos en el directorio de la "
|
||||
"distribución, tipea <literal>ant eg</literal> (usando Ant), o bajo "
|
||||
"Windows, tipea <literal>build eg</literal>."
|
||||
|
||||
#: index.docbook:80
|
||||
msgid ""
|
||||
"Use this reference documentation as your primary source of information. "
|
||||
"Consider reading <emphasis>Java Persistence with Hibernate</emphasis> "
|
||||
"(http://www.manning.com/bauer2) if you need more help with application "
|
||||
"design or if you prefer a step-by-step tutorial. Also visit http://"
|
||||
"caveatemptor.hibernate.org and download the example application for Java "
|
||||
"Persistence with Hibernate."
|
||||
msgstr ""
|
||||
"Usa esta documentación de referencia como tu fuente de "
|
||||
"información primaria. Ten en consideración leer <emphasis>Java "
|
||||
"Persistence with Hibernate</emphasis> (http://www.manning.com/bauer2) si "
|
||||
"necesitas mas ayuda con el diseño de aplicaciones o si prefieres un "
|
||||
"tutorial paso a paso. Visita también http://caveatemptor.hibernate."
|
||||
"org y descarga la aplicación de ejemplo para Java Persistence with "
|
||||
"Hibernate."
|
||||
|
||||
#: index.docbook:90
|
||||
msgid "FAQs are answered on the Hibernate website."
|
||||
msgstr "Los FAQs son respondidos en el sitio web de Hibernate."
|
||||
|
||||
#: index.docbook:95
|
||||
msgid ""
|
||||
"Third party demos, examples, and tutorials are linked on the Hibernate "
|
||||
"website."
|
||||
msgstr ""
|
||||
"En el sitio web de Hibernate hay enlaces a demos de terceros, ejemplos y "
|
||||
"tutoriales."
|
||||
|
||||
#: index.docbook:101
|
||||
msgid ""
|
||||
"The Community Area on the Hibernate website is a good resource for design "
|
||||
"patterns and various integration solutions (Tomcat, JBoss AS, Struts, EJB, "
|
||||
"etc.)."
|
||||
msgstr ""
|
||||
"El Area de Comunidad en el sitio web de Hibernate es una buena fuente de "
|
||||
"patrones de diseño y varias soluciones de integración (Tomcat, "
|
||||
"JBoss, Struts, EJB, etc.)."
|
||||
|
||||
#: index.docbook:109
|
||||
msgid ""
|
||||
"If you have questions, use the user forum linked on the Hibernate website. "
|
||||
"We also provide a JIRA issue trackings 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."
|
||||
msgstr ""
|
||||
"Si tienes preguntas, usa el foro de usuarios enlazado en el sitio web de "
|
||||
"Hibernate. También proveemos un sistema de seguimiento JIRA para "
|
||||
"reportes de defectos y peticiones de nuevas características. Si estas "
|
||||
"interesado en el desarrollo de Hibernate, únete a la lista de correo "
|
||||
"de desarrolladores. Si estas interesado en traducir esta documentació"
|
||||
"n a tu lenguaje, contáctanos en la lista de correo de desarrolladores."
|
||||
|
||||
#: index.docbook:117
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"A través de JBoss Inc. (see http://www.hibernate.org/"
|
||||
"SupportTraining/) hay disponibilidad de soporte comercial de desarrollo, "
|
||||
"soporte de producción y entrenamiento en Hibernate. Hibernate es un "
|
||||
"proyecto de la suite de productos de código abierto JBoss "
|
||||
"Professional."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,840 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Criteria Queries"
|
||||
msgstr "Consultas por Criterios"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "Hibernate features an intuitive, extensible criteria query API."
|
||||
msgstr ""
|
||||
"Acompaña a Hibernate una API de consultas por criterios intuitiva y "
|
||||
"extensible."
|
||||
|
||||
#: index.docbook:12
|
||||
msgid "Creating a <literal>Criteria</literal> instance"
|
||||
msgstr "Creando una instancia de <literal>Criteria</literal>"
|
||||
|
||||
#: index.docbook:14
|
||||
msgid ""
|
||||
"The interface <literal>org.hibernate.Criteria</literal> represents a query "
|
||||
"against a particular persistent class. The <literal>Session</literal> is a "
|
||||
"factory for <literal>Criteria</literal> instances."
|
||||
msgstr ""
|
||||
"La interface <literal>org.hibernate.Criteria</literal> representa una "
|
||||
"consulta contra una clase persistente en particular. La <literal>Session</"
|
||||
"literal> es una fábrica de instancias de <literal>Criteria</literal>."
|
||||
|
||||
#: index.docbook:20
|
||||
msgid ""
|
||||
"<![CDATA[Criteria crit = sess.createCriteria(Cat.class);\n"
|
||||
"crit.setMaxResults(50);\n"
|
||||
"List cats = crit.list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Criteria crit = sess.createCriteria(Cat.class);\n"
|
||||
"crit.setMaxResults(50);\n"
|
||||
"List cats = crit.list();]]>"
|
||||
|
||||
#: index.docbook:25
|
||||
msgid "Narrowing the result set"
|
||||
msgstr "Estrechando el conjunto resultado"
|
||||
|
||||
#: index.docbook:27
|
||||
msgid ""
|
||||
"An individual query criterion is an instance of the interface <literal>org."
|
||||
"hibernate.criterion.Criterion</literal>. The class <literal>org.hibernate."
|
||||
"criterion.Restrictions</literal> defines factory methods for obtaining "
|
||||
"certain built-in <literal>Criterion</literal> types."
|
||||
msgstr ""
|
||||
"Un criterio individual de consulta es una instancia de la interface "
|
||||
"<literal>org.hibernate.criterion.Criterion</literal>. La clase <literal>org."
|
||||
"hibernate.criterion.Restrictions</literal> define métodos de fá"
|
||||
"brica para obtener ciertos tipos prefabricados de <literal>Criterion</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:35
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .add( Restrictions.between(\"weight\", minWeight, maxWeight) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .add( Restrictions.between(\"weight\", minWeight, maxWeight) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:37
|
||||
msgid "Restrictions may be grouped logically."
|
||||
msgstr "Las restricciones pueden ser agrupadas lógicamente."
|
||||
|
||||
#: index.docbook:41
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .add( Restrictions.or(\n"
|
||||
" Restrictions.eq( \"age\", new Integer(0) ),\n"
|
||||
" Restrictions.isNull(\"age\")\n"
|
||||
" ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .add( Restrictions.or(\n"
|
||||
" Restrictions.eq( \"age\", new Integer(0) ),\n"
|
||||
" Restrictions.isNull(\"age\")\n"
|
||||
" ) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:43
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.in( \"name\", new String[] { \"Fritz\", \"Izi\", \"Pk"
|
||||
"\" } ) )\n"
|
||||
" .add( Restrictions.disjunction()\n"
|
||||
" .add( Restrictions.isNull(\"age\") )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(0) ) )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(1) ) )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(2) ) )\n"
|
||||
" ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.in( \"name\", new String[] { \"Fritz\", \"Izi\", \"Pk"
|
||||
"\" } ) )\n"
|
||||
" .add( Restrictions.disjunction()\n"
|
||||
" .add( Restrictions.isNull(\"age\") )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(0) ) )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(1) ) )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(2) ) )\n"
|
||||
" ) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:45
|
||||
msgid ""
|
||||
"There are quite a range of built-in criterion types (<literal>Restrictions</"
|
||||
"literal> subclasses), but one that is especially useful lets you specify SQL "
|
||||
"directly."
|
||||
msgstr ""
|
||||
"Hay un gran rango de tipos de criterio prefabricados (subclases de "
|
||||
"<literal>Restrictions</literal>), pero uno que es especialmente útil te deja "
|
||||
"especificar SQL directamente."
|
||||
|
||||
#: index.docbook:50
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.sqlRestriction(\"lower({alias}.name) like lower(?)\", "
|
||||
"\"Fritz%\", Hibernate.STRING) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.sql(\"lower({alias}.name) like lower(?)\", \"Fritz%"
|
||||
"\", Hibernate.STRING) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:52
|
||||
msgid ""
|
||||
"The <literal>{alias}</literal> placeholder with be replaced by the row alias "
|
||||
"of the queried entity."
|
||||
msgstr ""
|
||||
"El sitio <literal>{alias}</literal> será remplazado por el alias de "
|
||||
"fila de la entidad consultada."
|
||||
|
||||
#: index.docbook:57
|
||||
msgid ""
|
||||
"An alternative approach to obtaining a criterion is to get it from a "
|
||||
"<literal>Property</literal> instance. You can create a <literal>Property</"
|
||||
"literal> by calling <literal>Property.forName()</literal>."
|
||||
msgstr ""
|
||||
"Un enfoque alternativo para obtener un criterio es tomarlo de una instancia "
|
||||
"de <literal>Property</literal>. Puedes crear una <literal>Property</literal> "
|
||||
"llamando a <literal>Property.forName()</literal>."
|
||||
|
||||
#: index.docbook:63
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"Property age = Property.forName(\"age\");\n"
|
||||
"List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.disjunction()\n"
|
||||
" .add( age.isNull() )\n"
|
||||
" .add( age.eq( new Integer(0) ) )\n"
|
||||
" .add( age.eq( new Integer(1) ) )\n"
|
||||
" .add( age.eq( new Integer(2) ) )\n"
|
||||
" ) )\n"
|
||||
" .add( Property.forName(\"name\").in( new String[] { \"Fritz\", \"Izi\", "
|
||||
"\"Pk\" } ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[\n"
|
||||
"Property age = Property.forName(\"age\");\n"
|
||||
"List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.disjunction()\n"
|
||||
" .add( age.isNull() )\n"
|
||||
" .add( age.eq( new Integer(0) ) )\n"
|
||||
" .add( age.eq( new Integer(1) ) )\n"
|
||||
" .add( age.eq( new Integer(2) ) )\n"
|
||||
" ) )\n"
|
||||
" .add( Property.forName(\"name\").in( new String[] { \"Fritz\", \"Izi\", "
|
||||
"\"Pk\" } ) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:68
|
||||
msgid "Ordering the results"
|
||||
msgstr "Ordenando los resultados"
|
||||
|
||||
#: index.docbook:70
|
||||
msgid ""
|
||||
"You may order the results using <literal>org.hibernate.criterion.Order</"
|
||||
"literal>."
|
||||
msgstr ""
|
||||
"Puedes ordenar los resultados usando <literal>org.hibernate.criterion.Order</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:74
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\")\n"
|
||||
" .addOrder( Order.asc(\"name\") )\n"
|
||||
" .addOrder( Order.desc(\"age\") )\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\")\n"
|
||||
" .addOrder( Order.asc(\"name\") )\n"
|
||||
" .addOrder( Order.desc(\"age\") )\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:76
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Property.forName(\"name\").like(\"F%\") )\n"
|
||||
" .addOrder( Property.forName(\"name\").asc() )\n"
|
||||
" .addOrder( Property.forName(\"age\").desc() )\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Property.forName(\"name\").like(\"F%\") )\n"
|
||||
" .addOrder( Property.forName(\"name\").asc() )\n"
|
||||
" .addOrder( Property.forName(\"age\").desc() )\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:81
|
||||
msgid "Associations"
|
||||
msgstr "Asociaciones"
|
||||
|
||||
#: index.docbook:83
|
||||
msgid ""
|
||||
"You may easily specify constraints upon related entities by navigating "
|
||||
"associations using <literal>createCriteria()</literal>."
|
||||
msgstr ""
|
||||
"Puedes especificar fácilmente restricciones sobre las entidades "
|
||||
"relacionadas al navegar asociaciones usando <literal>createCriteria()</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:88
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\") )\n"
|
||||
" .createCriteria(\"kittens\")\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\")\n"
|
||||
" .createCriteria(\"kittens\")\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\")\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:90
|
||||
msgid ""
|
||||
"note that the second <literal>createCriteria()</literal> returns a new "
|
||||
"instance of <literal>Criteria</literal>, which refers to the elements of the "
|
||||
"<literal>kittens</literal> collection."
|
||||
msgstr ""
|
||||
"nota que el segundo <literal>createCriteria()</literal> devuelve una nueva "
|
||||
"instancia de <literal>Criteria</literal>, que hace referencia a los "
|
||||
"elementos de la colección <literal>kittens</literal>."
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "The following, alternate form is useful in certain circumstances."
|
||||
msgstr "La siguiente forma alternativa es útil en ciertas circunstancias."
|
||||
|
||||
#: index.docbook:100
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .createAlias(\"kittens\", \"kt\")\n"
|
||||
" .createAlias(\"mate\", \"mt\")\n"
|
||||
" .add( Restrictions.eqProperty(\"kt.name\", \"mt.name\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .createAlias(\"kittens\", \"kt\")\n"
|
||||
" .createAlias(\"mate\", \"mt\")\n"
|
||||
" .add( Restrictions.eqProperty(\"kt.name\", \"mt.name\") )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:102
|
||||
msgid ""
|
||||
"(<literal>createAlias()</literal> does not create a new instance of "
|
||||
"<literal>Criteria</literal>.)"
|
||||
msgstr ""
|
||||
"(<literal>createAlias()</literal> no crea una nueva instancia de "
|
||||
"<literal>Criteria</literal>.)"
|
||||
|
||||
#: index.docbook:107
|
||||
msgid ""
|
||||
"Note that the kittens collections held by the <literal>Cat</literal> "
|
||||
"instances returned by the previous two queries are <emphasis>not</emphasis> "
|
||||
"pre-filtered by the criteria! If you wish to retrieve just the kittens that "
|
||||
"match the criteria, you must use a <literal>ResultTransformer</literal>."
|
||||
msgstr ""
|
||||
"¡Observa que las colecciones de gatitos tenidas por las instancias de "
|
||||
"<literal>Cat</literal> devueltas por las dos consultas previas <emphasis>no</"
|
||||
"emphasis> están prefiltradas por los criterios! Si deseas recuperar "
|
||||
"sólo los gatitos que emparejen los criterios, debes usar "
|
||||
"<literal>returnMaps()</literal>."
|
||||
|
||||
#: index.docbook:114
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .createCriteria(\"kittens\", \"kt\")\n"
|
||||
" .add( Restrictions.eq(\"name\", \"F%\") )\n"
|
||||
" .setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)\n"
|
||||
" .list();\n"
|
||||
"Iterator iter = cats.iterator();\n"
|
||||
"while ( iter.hasNext() ) {\n"
|
||||
" Map map = (Map) iter.next();\n"
|
||||
" Cat cat = (Cat) map.get(Criteria.ROOT_ALIAS);\n"
|
||||
" Cat kitten = (Cat) map.get(\"kt\");\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .createCriteria(\"kittens\", \"kt\")\n"
|
||||
" .add( Restrictions.eq(\"name\", \"F%\") )\n"
|
||||
" .returnMaps()\n"
|
||||
" .list();\n"
|
||||
"Iterator iter = cats.iterator();\n"
|
||||
"while ( iter.hasNext() ) {\n"
|
||||
" Map map = (Map) iter.next();\n"
|
||||
" Cat cat = (Cat) map.get(Criteria.ROOT_ALIAS);\n"
|
||||
" Cat kitten = (Cat) map.get(\"kt\");\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:119
|
||||
msgid "Dynamic association fetching"
|
||||
msgstr "Recuperación dinámica de asociaciones"
|
||||
|
||||
#: index.docbook:121
|
||||
msgid ""
|
||||
"You may specify association fetching semantics at runtime using "
|
||||
"<literal>setFetchMode()</literal>."
|
||||
msgstr ""
|
||||
"Puedes especificar la semántica de recuperación de "
|
||||
"asociaciones en tiempo de ejecución usando <literal>setFetchMode()</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:126
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .setFetchMode(\"mate\", FetchMode.EAGER)\n"
|
||||
" .setFetchMode(\"kittens\", FetchMode.EAGER)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .setFetchMode(\"mate\", FetchMode.EAGER)\n"
|
||||
" .setFetchMode(\"kittens\", FetchMode.EAGER)\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:128
|
||||
msgid ""
|
||||
"This query will fetch both <literal>mate</literal> and <literal>kittens</"
|
||||
"literal> by outer join. See <xref linkend=\"performance-fetching\"/> for "
|
||||
"more information."
|
||||
msgstr ""
|
||||
"Esta consulta recuperará tanto <literal>mate</literal> como "
|
||||
"<literal>kittens</literal> por unión exterior (outer join). Ver <xref "
|
||||
"linkend=\"performance-fetching\"/> para más información."
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "Example queries"
|
||||
msgstr "Consultas por ejemplos"
|
||||
|
||||
#: index.docbook:138
|
||||
msgid ""
|
||||
"The class <literal>org.hibernate.criterion.Example</literal> allows you to "
|
||||
"construct a query criterion from a given instance."
|
||||
msgstr ""
|
||||
"La clase <literal>org.hibernate.criterion.Example</literal> te permite "
|
||||
"construir un criterio de consulta a partir de una instancia dada."
|
||||
|
||||
#: index.docbook:143
|
||||
msgid ""
|
||||
"<![CDATA[Cat cat = new Cat();\n"
|
||||
"cat.setSex('F');\n"
|
||||
"cat.setColor(Color.BLACK);\n"
|
||||
"List results = session.createCriteria(Cat.class)\n"
|
||||
" .add( Example.create(cat) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Cat cat = new Cat();\n"
|
||||
"cat.setSex('F');\n"
|
||||
"cat.setColor(Color.BLACK);\n"
|
||||
"List results = session.createCriteria(Cat.class)\n"
|
||||
" .add( Example.create(cat) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:145
|
||||
msgid ""
|
||||
"Version properties, identifiers and associations are ignored. By default, "
|
||||
"null valued properties are excluded."
|
||||
msgstr ""
|
||||
"Las propiedades de versión, los identificadores y las asociaciones "
|
||||
"son ignorados. Por defecto, las propiedades valuadas a nulo son excluí"
|
||||
"das."
|
||||
|
||||
#: index.docbook:150
|
||||
msgid "You can adjust how the <literal>Example</literal> is applied."
|
||||
msgstr "Puedes ajustar cómo se aplica el <literal>Example</literal>."
|
||||
|
||||
#: index.docbook:154
|
||||
msgid ""
|
||||
"<![CDATA[Example example = Example.create(cat)\n"
|
||||
" .excludeZeroes() //exclude zero valued properties\n"
|
||||
" .excludeProperty(\"color\") //exclude the property named \"color\"\n"
|
||||
" .ignoreCase() //perform case insensitive string "
|
||||
"comparisons\n"
|
||||
" .enableLike(); //use like for string comparisons\n"
|
||||
"List results = session.createCriteria(Cat.class)\n"
|
||||
" .add(example)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Example example = Example.create(cat)\n"
|
||||
" .excludeZeroes() //exclude zero valued properties\n"
|
||||
" .excludeProperty(\"color\") //exclude the property named \"color\"\n"
|
||||
" .ignoreCase() //perform case insensitive string "
|
||||
"comparisons\n"
|
||||
" .enableLike(); //use like for string comparisons\n"
|
||||
"List results = session.createCriteria(Cat.class)\n"
|
||||
" .add(example)\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:156
|
||||
msgid "You can even use examples to place criteria upon associated objects."
|
||||
msgstr ""
|
||||
"Puedes incluso usar ejemplos para colocar criterios sobre objetos asociados."
|
||||
|
||||
#: index.docbook:160
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .add( Example.create(cat) )\n"
|
||||
" .createCriteria(\"mate\")\n"
|
||||
" .add( Example.create( cat.getMate() ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .add( Example.create(cat) )\n"
|
||||
" .createCriteria(\"mate\")\n"
|
||||
" .add( Example.create( cat.getMate() ) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "Projections, aggregation and grouping"
|
||||
msgstr "Proyecciones, agregación y agrupamiento"
|
||||
|
||||
#: index.docbook:166
|
||||
msgid ""
|
||||
"The class <literal>org.hibernate.criterion.Projections</literal> is a "
|
||||
"factory for <literal>Projection</literal> instances. We apply a projection "
|
||||
"to a query by calling <literal>setProjection()</literal>."
|
||||
msgstr ""
|
||||
"La clase <literal>org.hibernate.criterion.Projections</literal> es una "
|
||||
"fábrica de instancias de <literal>Projection</literal>. Aplicamos una "
|
||||
"proyección a una consulta llamando a <literal>setProjection()</"
|
||||
"literal>."
|
||||
|
||||
#: index.docbook:172
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.rowCount() )\n"
|
||||
" .add( Restrictions.eq(\"color\", Color.BLACK) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.rowCount() )\n"
|
||||
" .add( Restrictions.eq(\"color\", Color.BLACK) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:174
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount() )\n"
|
||||
" .add( Projections.avg(\"weight\") )\n"
|
||||
" .add( Projections.max(\"weight\") )\n"
|
||||
" .add( Projections.groupProperty(\"color\") )\n"
|
||||
" )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount() )\n"
|
||||
" .add( Projections.avg(\"weight\") )\n"
|
||||
" .add( Projections.max(\"weight\") )\n"
|
||||
" .add( Projections.groupProperty(\"color\") )\n"
|
||||
" )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:176
|
||||
msgid ""
|
||||
"There is no explicit \"group by\" necessary in a criteria query. Certain "
|
||||
"projection types are defined to be <emphasis>grouping projections</"
|
||||
"emphasis>, which also appear in the SQL <literal>group by</literal> clause."
|
||||
msgstr ""
|
||||
"No es necesario ningún \"group by\" explícito en una consulta por "
|
||||
"criterios. Ciertos tipos de proyecciones son definidos para ser "
|
||||
"<emphasis>proyecciones agrupadas</emphasis>, que además aparecen en "
|
||||
"la cláusula SQL <literal>group by</literal>."
|
||||
|
||||
#: index.docbook:182
|
||||
msgid ""
|
||||
"An alias may optionally be assigned to a projection, so that the projected "
|
||||
"value may be referred to in restrictions or orderings. Here are two "
|
||||
"different ways to do this:"
|
||||
msgstr ""
|
||||
"Puede opcionalmente asignarse un alias a una proyección, de modo que "
|
||||
"el valor proyectado pueda ser referido en restricciones u ordenamientos. "
|
||||
"Aquí hay dos formas diferentes de hacer esto:"
|
||||
|
||||
#: index.docbook:188
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.alias( Projections.groupProperty(\"color\"), "
|
||||
"\"colr\" ) )\n"
|
||||
" .addOrder( Order.asc(\"colr\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.alias( Projections.groupProperty(\"color\"), "
|
||||
"\"colr\" ) )\n"
|
||||
" .addOrder( Order.asc(\"colr\") )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:190
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.groupProperty(\"color\").as(\"colr\") )\n"
|
||||
" .addOrder( Order.asc(\"colr\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.groupProperty(\"color\").as(\"colr\") )\n"
|
||||
" .addOrder( Order.asc(\"colr\") )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:192
|
||||
msgid ""
|
||||
"The <literal>alias()</literal> and <literal>as()</literal> methods simply "
|
||||
"wrap a projection instance in another, aliased, instance of "
|
||||
"<literal>Projection</literal>. As a shortcut, you can assign an alias when "
|
||||
"you add the projection to a projection list:"
|
||||
msgstr ""
|
||||
"Los métodos <literal>alias()</literal> y <literal>as()</literal> "
|
||||
"simplemente envuelven una instancia de proyección en otra instancia "
|
||||
"de <literal>Projection</literal> con alias. Como un atajo, puedes asignar un "
|
||||
"alias cuando agregas la proyección a una lista de proyecciones:"
|
||||
|
||||
#: index.docbook:199
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount(), \"catCountByColor\" )\n"
|
||||
" .add( Projections.avg(\"weight\"), \"avgWeight\" )\n"
|
||||
" .add( Projections.max(\"weight\"), \"maxWeight\" )\n"
|
||||
" .add( Projections.groupProperty(\"color\"), \"color\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.desc(\"catCountByColor\") )\n"
|
||||
" .addOrder( Order.desc(\"avgWeight\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount(), \"catCountByColor\" )\n"
|
||||
" .add( Projections.avg(\"weight\"), \"avgWeight\" )\n"
|
||||
" .add( Projections.max(\"weight\"), \"maxWeight\" )\n"
|
||||
" .add( Projections.groupProperty(\"color\"), \"color\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.desc(\"catCountByColor\") )\n"
|
||||
" .addOrder( Order.desc(\"avgWeight\") )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:201
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Domestic.class, \"cat\")\n"
|
||||
" .createAlias(\"kittens\", \"kit\")\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.property(\"cat.name\"), \"catName\" )\n"
|
||||
" .add( Projections.property(\"kit.name\"), \"kitName\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.asc(\"catName\") )\n"
|
||||
" .addOrder( Order.asc(\"kitName\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Domestic.class, \"cat\")\n"
|
||||
" .createAlias(\"kittens\", \"kit\")\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.property(\"cat.name\"), \"catName\" )\n"
|
||||
" .add( Projections.property(\"kit.name\"), \"kitName\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.asc(\"catName\") )\n"
|
||||
" .addOrder( Order.asc(\"kitName\") )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:203
|
||||
msgid ""
|
||||
"You can also use <literal>Property.forName()</literal> to express "
|
||||
"projections:"
|
||||
msgstr ""
|
||||
"Puedes también usar <literal>Property.forName()</literal> para "
|
||||
"expresar proyecciones:"
|
||||
|
||||
#: index.docbook:207
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"name\") )\n"
|
||||
" .add( Property.forName(\"color\").eq(Color.BLACK) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"name\") )\n"
|
||||
" .add( Property.forName(\"color\").eq(Color.BLACK) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:209
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount().as(\"catCountByColor\") )\n"
|
||||
" .add( Property.forName(\"weight\").avg().as(\"avgWeight\") )\n"
|
||||
" .add( Property.forName(\"weight\").max().as(\"maxWeight\") )\n"
|
||||
" .add( Property.forName(\"color\").group().as(\"color\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.desc(\"catCountByColor\") )\n"
|
||||
" .addOrder( Order.desc(\"avgWeight\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount().as(\"catCountByColor\") )\n"
|
||||
" .add( Property.forName(\"weight\").avg().as(\"avgWeight\") )\n"
|
||||
" .add( Property.forName(\"weight\").max().as(\"maxWeight\") )\n"
|
||||
" .add( Property.forName(\"color\").group().as(\"color\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.desc(\"catCountByColor\") )\n"
|
||||
" .addOrder( Order.desc(\"avgWeight\") )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:214
|
||||
msgid "Detached queries and subqueries"
|
||||
msgstr "Consultas y subconsultas separadas"
|
||||
|
||||
#: index.docbook:215
|
||||
msgid ""
|
||||
"The <literal>DetachedCriteria</literal> class lets you create a query "
|
||||
"outside the scope of a session, and then later execute it using some "
|
||||
"arbitrary <literal>Session</literal>."
|
||||
msgstr ""
|
||||
"La clase <literal>DetachedCriteria</literal> te deja crear una consulta "
|
||||
"fuera del ámbito de una sesión, y entonces ejecutarla luego "
|
||||
"usando alguna <literal>Session</literal> arbitraria."
|
||||
|
||||
#: index.docbook:220
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .add( Property.forName(\"sex\").eq('F') );\n"
|
||||
" \n"
|
||||
"Session session = ....;\n"
|
||||
"Transaction txn = session.beginTransaction();\n"
|
||||
"List results = query.getExecutableCriteria(session).setMaxResults(100).list"
|
||||
"();\n"
|
||||
"txn.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .add( Property.forName(\"sex\").eq('F') );\n"
|
||||
" \n"
|
||||
"Session session = ....;\n"
|
||||
"Transaction txn = session.beginTransaction();\n"
|
||||
"List results = query.getExecutableCriteria(session).setMaxResults(100).list"
|
||||
"();\n"
|
||||
"txn.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:222
|
||||
msgid ""
|
||||
"A <literal>DetachedCriteria</literal> may also be used to express a "
|
||||
"subquery. Criterion instances involving subqueries may be obtained via "
|
||||
"<literal>Subqueries</literal> or <literal>Property</literal>."
|
||||
msgstr ""
|
||||
"También una <literal>DetachedCriteria</literal> puede usarse para "
|
||||
"expresar una subconsulta. Las instancias de Criterion implicando "
|
||||
"subconsultas pueden obtenerse vía <literal>Subqueries</literal> o "
|
||||
"<literal>Property</literal>."
|
||||
|
||||
#: index.docbook:228
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"weight\").avg() );\n"
|
||||
"session.createCriteria(Cat.class)\n"
|
||||
" .add( Property.forName(\"weight\").gt(avgWeight) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"weight\").avg() );\n"
|
||||
"session.createCriteria(Cat.class)\n"
|
||||
" .add( Property.forName(\"weight\").gt(avgWeight) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:230
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"weight\") );\n"
|
||||
"session.createCriteria(Cat.class)\n"
|
||||
" .add( Subqueries.geAll(\"weight\", weights) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"weight\") );\n"
|
||||
"session.createCriteria(Cat.class)\n"
|
||||
" .add( Subqueries.geAll(\"weight\", weights) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:232
|
||||
msgid "Even correlated subqueries are possible:"
|
||||
msgstr "Incluso son posibles las subconsultas correlacionadas:"
|
||||
|
||||
#: index.docbook:236
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat."
|
||||
"class, \"cat2\")\n"
|
||||
" .setProjection( Property.forName(\"weight\").avg() )\n"
|
||||
" .add( Property.forName(\"cat2.sex\").eqProperty(\"cat.sex\") );\n"
|
||||
"session.createCriteria(Cat.class, \"cat\")\n"
|
||||
" .add( Property.forName(\"weight\").gt(avgWeightForSex) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat."
|
||||
"class, \"cat2\")\n"
|
||||
" .setProjection( Property.forName(\"weight\").avg() )\n"
|
||||
" .add( Property.forName(\"cat2.sex\").eqProperty(\"cat.sex\") );\n"
|
||||
"session.createCriteria(Cat.class, \"cat\")\n"
|
||||
" .add( Property.forName(\"weight\").gt(avgWeightForSex) )\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:245
|
||||
msgid "Queries by natural identifier"
|
||||
msgstr "Consultas por identificador natural"
|
||||
|
||||
#: index.docbook:247
|
||||
msgid ""
|
||||
"For most queries, including criteria queries, the query cache is not very "
|
||||
"efficient, because query cache invalidation occurs too frequently. However, "
|
||||
"there is one special kind of query where we can optimize the cache "
|
||||
"invalidation algorithm: lookups by a constant natural key. In some "
|
||||
"applications, this kind of query occurs frequently. The criteria API "
|
||||
"provides special provision for this use case."
|
||||
msgstr ""
|
||||
"Para la mayoría de consultas, incluyendo las consultas por criterios, "
|
||||
"el caché de consulta no es muy eficiente, debido a que la "
|
||||
"invalidación del caché de consulta ocurre demasiado "
|
||||
"frecuentemente. Sin embargo, hay un tipo especial de consulta donde podemos "
|
||||
"optimizar el algoritmo de invalidación de caché: búsquedas por "
|
||||
"una clave natural constante. En algunas aplicaciones, este tipo de consulta, "
|
||||
"ocurre frecuentemente. La API de criterios brinda especial provisión "
|
||||
"para este caso de uso."
|
||||
|
||||
#: index.docbook:255
|
||||
msgid ""
|
||||
"First, you should map the natural key of your entity using <literal><"
|
||||
"natural-id></literal>, and enable use of the second-level cache."
|
||||
msgstr ""
|
||||
"Primero, debes mapear la clave natural de tu entidad usando <literal><"
|
||||
"natural-id></literal>, y habilitar el uso del caché de segundo "
|
||||
"nivel."
|
||||
|
||||
#: index.docbook:260
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"User\">\n"
|
||||
" <cache usage=\"read-write\"/>\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <natural-id>\n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" <property name=\"org\"/>\n"
|
||||
" </natural-id>\n"
|
||||
" <property name=\"password\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"User\">\n"
|
||||
" <cache usage=\"read-write\"/>\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <natural-id>\n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" <property name=\"org\"/>\n"
|
||||
" </natural-id>\n"
|
||||
" <property name=\"password\"/>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:262
|
||||
msgid ""
|
||||
"Note that this functionality is not intended for use with entities with "
|
||||
"<emphasis>mutable</emphasis> natural keys."
|
||||
msgstr ""
|
||||
"Nota que esta funcionalidad no está pensada para uso con entidades "
|
||||
"con claves naturales <emphasis>mutable</emphasis>."
|
||||
|
||||
#: index.docbook:267
|
||||
msgid "Next, enable the Hibernate query cache."
|
||||
msgstr "Seguido, habilita el caché de consulta de Hibernate."
|
||||
|
||||
#: index.docbook:271
|
||||
msgid ""
|
||||
"Now, <literal>Restrictions.naturalId()</literal> allows us to make use of "
|
||||
"the more efficient cache algorithm."
|
||||
msgstr ""
|
||||
"Ahora, <literal>Restrictions.naturalId()</literal> nos permite hacer uso de "
|
||||
"el algoritmo de caché más eficiente."
|
||||
|
||||
#: index.docbook:276
|
||||
msgid ""
|
||||
"<![CDATA[session.createCriteria(User.class)\n"
|
||||
" .add( Restrictions.naturalId()\n"
|
||||
" .set(\"name\", \"gavin\")\n"
|
||||
" .set(\"org\", \"hb\") \n"
|
||||
" ).setCacheable(true)\n"
|
||||
" .uniqueResult();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[session.createCriteria(User.class)\n"
|
||||
" .add( Restrictions.naturalId()\n"
|
||||
" .set(\"name\", \"gavin\")\n"
|
||||
" .set(\"org\", \"hb\") \n"
|
||||
" ).setCacheable(true)\n"
|
||||
" .uniqueResult();]]>"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,474 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
#: index.docbook:5
|
||||
msgid "appended paragraph 1"
|
||||
msgstr "Comienzo rápido con Tomcat"
|
||||
|
||||
#: index.docbook:8
|
||||
msgid "appended paragraph 2"
|
||||
msgstr "Empezando con Hibernate"
|
||||
|
||||
#: index.docbook:10
|
||||
msgid "appended paragraph 3"
|
||||
msgstr "Este tutorial explica una instalación de Hibernate con el contenedor de servlets Apache Tomcat (hemos usado la versión 4.1, las diferencias con la 5.0 deben ser mínimas) para una aplicación basada en web. Hibernate trabaja bien en un entorno manejado con todos los servidores de aplicaciones J2EE importantes, o incluso en aplicaciones Java independientes. El sistema de base de datos es sólo una cuestión de cambiar la configuración del dialecto SQL de Hibernate y las propiedades de conexión."
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "appended paragraph 4"
|
||||
msgstr "Primero, tenemos que copiar todas las bibliotecas requeridas a la instalación de Tomcat. Usamos un contexto web separado (<literal>webapps/quickstart</literal>) para este tutorial, de modo que tenemos que considerar tanto la ruta de búsqueda de bibliotecas global (<literal>TOMCAT/common/lib</literal>) como también el cargador de clases a nivel de contexto en <literal>webapps/quickstart/WEB-INF/lib</literal> (para ficheros JAR) y <literal>webapps/quickstart/WEB-INF/classes</literal>. Nos referiremos a ambos niveles de cargador de clases como el classpath global y el classpath de contexto, respectivamente."
|
||||
|
||||
#: index.docbook:32
|
||||
msgid "appended paragraph 5"
|
||||
msgstr "Ahora, copia las bibliotecas a los dos classpaths:"
|
||||
|
||||
#: index.docbook:38
|
||||
msgid "appended paragraph 6"
|
||||
msgstr "Copia el driver JDBC para la base de datos al classpath global. Esto se requiere para el software de pool de conexiones DBCP que se distribuye con Tomcat. Hibernate usa conexiones JDBC para ejecutar SQL sobre la base de datos, de modo que, o bien tienes que proveer conexiones JDBC en pool, o bien configurar Hibernate para que use uno de los pools soportados directamente (C3P0, Proxool). Para este tutorial, copia la biblioteca <literal>pg74jdbc3.jar</literal> (para PostgreSQL 7.4 y JDK 1.4) al classpath del cargador global. Si quisieras usar una base de datos diferente, simplemente copia su apropiado driver JDBC."
|
||||
|
||||
#: index.docbook:51
|
||||
msgid "appended paragraph 7"
|
||||
msgstr "Nunca copies nada más dentro de la ruta del cargador de clases global en Tomcat, o tendrás problemas con varias herramientas, incluyendo Log4J, commons-logging y otras. Siempre usa el classpath de contexto para cada aplicación web, esto es, copia las bibliotecas a <literal>WEB-INF/lib</literal> y tus propias clases y ficheros de configuración/propiedades a <literal>WEB-INF/classes</literal>. Ambos directorios están a nivel del classpath de contexto por defecto."
|
||||
|
||||
#: index.docbook:62
|
||||
msgid "appended paragraph 8"
|
||||
msgstr "Hibernate está empaquetado como una biblioteca JAR. El fichero <literal>hibernate3.jar</literal> debe ser copiado en el classpath de contexto junto a las otras clases de la aplicación. Hibernate requiere algunas bibliotecas de terceros en tiempo de ejecución; éstas vienen incluídas con la distribución de Hibernate en el directorio <literal>lib/</literal>. Ver <xref linkend=\"3rdpartylibs\"/>. Copia las bibliotecas de terceros requeridas al classpath de contexto."
|
||||
|
||||
#: index.docbook:75
|
||||
msgid "appended paragraph 9"
|
||||
msgstr "Bibliotecas de terceros de Hibernate"
|
||||
|
||||
#: index.docbook:83
|
||||
msgid "appended paragraph 10"
|
||||
msgstr "Biblioteca"
|
||||
|
||||
#: index.docbook:86
|
||||
msgid "appended paragraph 11"
|
||||
msgstr "Descripción"
|
||||
|
||||
#: index.docbook:93
|
||||
msgid "appended paragraph 12"
|
||||
msgstr "antlr (requerida)"
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "appended paragraph 13"
|
||||
msgstr "Hibernate usa ANTLR para producir analizadores de consultas, esta biblioteca también se necesita en tiempo de ejecución."
|
||||
|
||||
#: index.docbook:102
|
||||
msgid "appended paragraph 14"
|
||||
msgstr "dom4j (requerida)"
|
||||
|
||||
#: index.docbook:105
|
||||
msgid "appended paragraph 15"
|
||||
msgstr "Hibernate usa dom4j para analizar ficheros de configuración XML y ficheros de metadatos de mapeo XML."
|
||||
|
||||
#: index.docbook:111
|
||||
msgid "appended paragraph 16"
|
||||
msgstr "CGLIB, asm (requerida)"
|
||||
|
||||
#: index.docbook:114
|
||||
msgid "appended paragraph 17"
|
||||
msgstr "Hibernate usa la biblioteca de generación de código para aumentar las clases en tiempo de ejecución (en combinación con reflección Java)."
|
||||
|
||||
#: index.docbook:121
|
||||
msgid "appended paragraph 18"
|
||||
msgstr "Commons Collections, Commons Logging (requeridas)"
|
||||
|
||||
#: index.docbook:124
|
||||
msgid "appended paragraph 19"
|
||||
msgstr "Hibernate usa varias bibliotecas de utilidad del proyecto Jakarta Commons de Apache."
|
||||
|
||||
#: index.docbook:130
|
||||
msgid "appended paragraph 20"
|
||||
msgstr "EHCache (requerida)"
|
||||
|
||||
#: index.docbook:133
|
||||
msgid "appended paragraph 21"
|
||||
msgstr "Hibernate puede usar varios provedores de caché para el caché de segundo nivel. EHCache es el provedor de caché por defecto si no se cambia en la configuración."
|
||||
|
||||
#: index.docbook:140
|
||||
msgid "appended paragraph 22"
|
||||
msgstr "Log4j (opcional)"
|
||||
|
||||
#: index.docbook:143
|
||||
msgid "appended paragraph 23"
|
||||
msgstr "Hibernate usa la API de Commons Logging, que a su vez puede usar Log4J como el mecanismo de logging subyacente. Si la biblioteca Log4J está disponible en el directorio de bibliotecas del contexto, Commons Logging usará Log4J y la configuración <literal>log4j.properties</literal> en el classpath de contexto. Un fichero de propiedades de ejemplo para Log4J se incluye con la distribución de Hibernate. Así que copia log4j.jar y el fichero de configuración (de <literal>src/</literal>) a tu classpath de contexto si quieres ver que ocurre tras escénas."
|
||||
|
||||
#: index.docbook:157
|
||||
msgid "appended paragraph 24"
|
||||
msgstr "¿Requerida o no?"
|
||||
|
||||
#: index.docbook:160
|
||||
msgid "appended paragraph 25"
|
||||
msgstr "Echa una mirada al fichero <literal>lib/README.txt</literal> en la distribución de Hibernate. Esta es una lista actualizada de bibliotecas de terceros distribuídas con Hibernate. Encontrarás listadas ahí todas las bibliotecas requeridas y opcionales (Observa que \"buildtame required\" significa aquí para la construcción de Hibernate, no de tu aplicación)."
|
||||
|
||||
#: index.docbook:174
|
||||
msgid "appended paragraph 26"
|
||||
msgstr "Ahora instalamos el pooling y modo compartido de conexiones de base de datos tanto en Tomcat como Hibernate. Esto significa que Tomcat proveerá conexiones JDBC en pool (usando su funcionalidad prefabricada de pooling DBCP). Hibernate pide esas conexiones a través de JNDI. Alternativamente, puedes dejar que Hibernate maneje el pool de conexiones. Tomcat liga su pool de conexiones a JNDI; agregamos una declaración de recurso al fichero de configuración principal de Tomcat, <literal>TOMCAT/conf/server.xml</literal>:"
|
||||
|
||||
#: index.docbook:184
|
||||
msgid "appended paragraph 27"
|
||||
msgstr ""
|
||||
"<![CDATA[<Context path=\"/quickstart\" docBase=\"quickstart\">\n"
|
||||
" <Resource name=\"jdbc/quickstart\" scope=\"Shareable\" type=\"javax.sql.DataSource\"/>\n"
|
||||
" <ResourceParams name=\"jdbc/quickstart\">\n"
|
||||
" <parameter>\n"
|
||||
" <name>factory</name>\n"
|
||||
" <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>\n"
|
||||
" </parameter>\n"
|
||||
"\n"
|
||||
" <!-- DBCP database connection settings -->\n"
|
||||
" <parameter>\n"
|
||||
" <name>url</name>\n"
|
||||
" <value>jdbc:postgresql://localhost/quickstart</value>\n"
|
||||
" </parameter>\n"
|
||||
" <parameter>\n"
|
||||
" <name>driverClassName</name><value>org.postgresql.Driver</value>\n"
|
||||
" </parameter>\n"
|
||||
" <parameter>\n"
|
||||
" <name>username</name>\n"
|
||||
" <value>quickstart</value>\n"
|
||||
" </parameter>\n"
|
||||
" <parameter>\n"
|
||||
" <name>password</name>\n"
|
||||
" <value>secret</value>\n"
|
||||
" </parameter>\n"
|
||||
"\n"
|
||||
" <!-- DBCP connection pooling options -->\n"
|
||||
" <parameter>\n"
|
||||
" <name>maxWait</name>\n"
|
||||
" <value>3000</value>\n"
|
||||
" </parameter>\n"
|
||||
" <parameter>\n"
|
||||
" <name>maxIdle</name>\n"
|
||||
" <value>100</value>\n"
|
||||
" </parameter>\n"
|
||||
" <parameter>\n"
|
||||
" <name>maxActive</name>\n"
|
||||
" <value>10</value>\n"
|
||||
" </parameter>\n"
|
||||
" </ResourceParams>\n"
|
||||
"</Context>]]>"
|
||||
|
||||
#: index.docbook:186
|
||||
msgid "appended paragraph 28"
|
||||
msgstr "El contexto que configuramos en este ejemplo se llama <literal>quickstart</literal>, su base es el directorio <literal>TOMCAT/webapp/quickstart</literal>. Para acceder a cualquier servlet, llama a la ruta <literal>http://localhost:8080/quickstart</literal> en tu navegador (por supuesto, agregando el nombre del servlet como se mapee en tu <literal>web.xml</literal>). Puedes también ir más allá y crear ahora un servlet simple que tenga un método <literal>process()</literal> vacío."
|
||||
|
||||
#: index.docbook:196
|
||||
msgid "appended paragraph 29"
|
||||
msgstr "Tomcat provee ahora conexiones a través de JNDI en <literal>java:comp/env/jdbc/quickstart</literal>. Si tienes problemas obteniendo el pool de conexiones en ejecución, refiérete a la documentación de Tomcat. Si obtienes mensajes de excepción del driver JDBC, intenta instalar primero el pool de conexiones JDBC sin Hibernate. Hay disponibles en la Web tutoriales de Tomcat y JDBC."
|
||||
|
||||
#: index.docbook:205
|
||||
msgid "appended paragraph 30"
|
||||
msgstr "Tu próximo paso es configurar Hibernate. Hibernate tiene que saber cómo debe obtener conexiones JDBC. Usamos la configuración de Hibernate basada en XML. El otro enfoque, usando un ficheros de propiedad, es casi equivalente pero pierde unas pocas funcionalidades que sí permite la sintaxis XML. El fichero de configuración XML se ubica en el classpath de contexto (<literal>WEB-INF/classes</literal>), como <literal>hibernate.cfg.xml</literal>:"
|
||||
|
||||
#: index.docbook:214
|
||||
msgid "appended paragraph 31"
|
||||
msgstr ""
|
||||
"<![CDATA[<?xml version='1.0' encoding='utf-8'?>\n"
|
||||
"<!DOCTYPE hibernate-configuration PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Configuration DTD//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-configuration>\n"
|
||||
"\n"
|
||||
" <session-factory>\n"
|
||||
"\n"
|
||||
" <property name=\"connection.datasource\">java:comp/env/jdbc/quickstart</property>\n"
|
||||
" <property name=\"show_sql\">false</property>\n"
|
||||
" <property name=\"dialect\">org.hibernate.dialect.PostgreSQLDialect</property>\n"
|
||||
"\n"
|
||||
" <!-- Mapping files -->\n"
|
||||
" <mapping resource=\"Cat.hbm.xml\"/>\n"
|
||||
"\n"
|
||||
" </session-factory>\n"
|
||||
"\n"
|
||||
"</hibernate-configuration>]]>"
|
||||
|
||||
#: index.docbook:216
|
||||
msgid "appended paragraph 32"
|
||||
msgstr "Desactivamos el registro (logging) de comandos SQL y decimos a Hibernate qué dialecto SQL de base de datos se usa y dónde obtener conexiones JDBC (declarando la dirección JNDI del pool ligado a Tomcat). El dialecto es una configuración requerida, las bases de datos difieren en su interpretación del \"estándar\" de SQL. Hibernate cuidará de las diferencias y viene con dialectos incluídos para todas las principales bases de datos comerciales y de código abierto."
|
||||
|
||||
#: index.docbook:227
|
||||
msgid "appended paragraph 33"
|
||||
msgstr "Una <literal>SessionFactory</literal> es el concepto de Hibernate de un almacén de datos solo. Pueden usarse múltiples bases de datos creando múltiples ficheros de configuración XML y creando múltiples objetos <literal>Configuration</literal> y <literal>SessionFactory</literal> en tu aplicación."
|
||||
|
||||
#: index.docbook:235
|
||||
msgid "appended paragraph 34"
|
||||
msgstr "El último elemento del <literal>hibernate.cfg.xml</literal> declara <literal>Cat.hbm.xml</literal> como el nombre de un fichero de mapeo XML para la clase persistente <literal>Cat</literal>. Este fichero contiene los metadatos para el mapeo de la clase POJO <literal>Cat</literal> a una tabla (o tablas) de base de datos. Volveremos a este fichero pronto. Escribamos primero la clase POJO y luego declaremos los metadatos de mapeo para ella."
|
||||
|
||||
#: index.docbook:248
|
||||
msgid "appended paragraph 35"
|
||||
msgstr "Primera clase persistente"
|
||||
|
||||
#: index.docbook:250
|
||||
msgid "appended paragraph 36"
|
||||
msgstr "Hibernate trabaja mejor con el modelo de programación de los Viejos Objetos Planos de Java (POJOs, a veces llamados Ordinarios Objetos Planos de Java) para clases persistentes. Un POJO es como un JavaBean, con las propiedades de la clase accesible vía métodos getter y setter, encapsulando la representación interna de la interfaz publicamente visible (Hibernate puede también acceder a los campos directamente, si se necesita):"
|
||||
|
||||
#: index.docbook:260
|
||||
msgid "appended paragraph 37"
|
||||
msgstr ""
|
||||
"<![CDATA[package org.hibernate.examples.quickstart;\n"
|
||||
"\n"
|
||||
"public class Cat {\n"
|
||||
"\n"
|
||||
" private String id;\n"
|
||||
" private String name;\n"
|
||||
" private char sex;\n"
|
||||
" private float weight;\n"
|
||||
"\n"
|
||||
" public Cat() {\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public String getId() {\n"
|
||||
" return id;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" private void setId(String id) {\n"
|
||||
" this.id = id;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public String getName() {\n"
|
||||
" return name;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public void setName(String name) {\n"
|
||||
" this.name = name;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public char getSex() {\n"
|
||||
" return sex;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public void setSex(char sex) {\n"
|
||||
" this.sex = sex;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public float getWeight() {\n"
|
||||
" return weight;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public void setWeight(float weight) {\n"
|
||||
" this.weight = weight;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:262
|
||||
msgid "appended paragraph 38"
|
||||
msgstr "Hibernate no está restringido en su uso de tipos de propiedad, todos los tipos y tipos primitivos del JDK de Java (como <literal>String</literal>, <literal>char</literal> y <literal>Date</literal>) pueden ser mapeados, incluyendo clases del framework de colecciones de Java. Puedes mapearlos como valores, colecciones de valores, o asociaciones a otras entidades. El <literal>id</literal> es una propiedad especial que representa el identificador de base de datos (clave primaria) de la clase. Es altamente recomendado para entidades como un <literal>Cat</literal>. Hibernate puede usar identificadores sólo internamente, pero perderíamos algo de la flexibilidad en nuestra arquitectura de aplicación."
|
||||
|
||||
#: index.docbook:275
|
||||
msgid "appended paragraph 39"
|
||||
msgstr "No tiene que implementarse ninguna interface especial para las clases persistentes ni tienes que subclasear de una clase persistente raíz en especial. Hibernate tampoco requiere ningún procesamiento en tiempo de construcción, como manipulación del byte-code. Se basa solamente en reflección de Java y aumentación de clases en tiempo de ejecución (a través de CGLIB). De modo que, sin ninguna dependencia de la clase POJO en Hibernate, podemos mapearla a una tabla de base de datos."
|
||||
|
||||
#: index.docbook:288
|
||||
msgid "appended paragraph 40"
|
||||
msgstr "Mapeando el gato"
|
||||
|
||||
#: index.docbook:290
|
||||
msgid "appended paragraph 41"
|
||||
msgstr "El fichero de mapeo <literal>Cat.hbm.xml</literal> contiene los metadatos requeridos para el mapeo objeto/relacional. Los metadatos incluyen la declaración de clases persistentes y el mapeo de propiedades (a columnas y relaciones de claves foráneas a otras entidades) a tablas de base de datos."
|
||||
|
||||
#: index.docbook:298
|
||||
msgid "appended paragraph 42"
|
||||
msgstr ""
|
||||
"<![CDATA[<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE hibernate-mapping PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-mapping>\n"
|
||||
"\n"
|
||||
" <class name=\"org.hibernate.examples.quickstart.Cat\" table=\"CAT\">\n"
|
||||
"\n"
|
||||
" <!-- A 32 hex character is our surrogate key. It's automatically\n"
|
||||
" generated by Hibernate with the UUID pattern. -->\n"
|
||||
" <id name=\"id\" type=\"string\" unsaved-value=\"null\" >\n"
|
||||
" <column name=\"CAT_ID\" sql-type=\"char(32)\" not-null=\"true\"/>\n"
|
||||
" <generator class=\"uuid.hex\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <!-- A cat has to have a name, but it shouldn' be too long. -->\n"
|
||||
" <property name=\"name\">\n"
|
||||
" <column name=\"NAME\" length=\"16\" not-null=\"true\"/>\n"
|
||||
" </property>\n"
|
||||
"\n"
|
||||
" <property name=\"sex\"/>\n"
|
||||
"\n"
|
||||
" <property name=\"weight\"/>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
|
||||
#: index.docbook:300
|
||||
msgid "appended paragraph 43"
|
||||
msgstr "Cada clase persistente debe tener un atributo identificador (realmente, sólo las clases que representen entidades, no las clases dependientes de tipo-valor, que son mapeadas como componentes de una entidad). Esta propiedad es usada para distinguir los objetos persistentes: Dos gatos son iguales si <literal>catA.getId().equals(catB.getId())</literal> es verdadero. Este concepto se llama <emphasis>identidad de base de datos (database identity)</emphasis>. Hibernate viene empaquetado con varios generadores de identificador para diferentes escenarios (incluyendo generadores nativos para secuencias de base de datos, tablas de identificadores alto/bajo, e identificadores asignados por aplicación). Usamos el generador UUID (recomendado sólo para pruebas, pues deben preferirse las claves enteras delegadas generadas por la base de datos) y también especificamos la columna <literal>CAT_ID</literal> de la tabla <literal>CAT</literal> para el valor identificador generado por Hibernate (como una clave primaria de la tabla)."
|
||||
|
||||
#: index.docbook:317
|
||||
msgid "appended paragraph 44"
|
||||
msgstr "Todas las demás propiedades de <literal>Cat</literal> son mapeadas a la misma tabla. En el caso de la propiedad <literal>name</literal>, la hemos mapeado con una declaración explícita de columna de base de datos. Esto es especialmente útil cuando el esquema de base de datos es generado automáticamente (como sentencias DDL de SQL) desde la declaración de mapeo con la herramienta <emphasis>SchemaExport</emphasis> de Hibernate. Todas las demás propiedades son mapeadas usando la configuración por defecto de Hibernate, que es lo que necesitas la mayoría del tiempo. La tabla <literal>CAT</literal> en la base de datos se ve así como:"
|
||||
|
||||
#: index.docbook:329
|
||||
msgid "appended paragraph 45"
|
||||
msgstr ""
|
||||
"<![CDATA[ Columna | Tipo | Modificadores\n"
|
||||
"--------+-----------------------+-----------\n"
|
||||
" cat_id | character(32) | not null\n"
|
||||
" name | character varying(16) | not null\n"
|
||||
" sex | character(1) |\n"
|
||||
" weight | real |\n"
|
||||
"Indexes: cat_pkey primary key btree (cat_id)]]>"
|
||||
|
||||
#: index.docbook:331
|
||||
msgid "appended paragraph 46"
|
||||
msgstr "Ahora debes crear esta tabla manualmente en tu base de datos, y luego leer el <xref linkend=\"toolsetguide\"/> si quieres automatizar este paso con la herramienta <literal>hbm2ddl</literal>. Esta herramienta puede crear un DDL SQL completo, incluyendo definición de tablas, restricciones personalizadas de tipo de columnas, restricciones de unicidad e índices."
|
||||
|
||||
#: index.docbook:342
|
||||
msgid "appended paragraph 47"
|
||||
msgstr "Jugando con gatos"
|
||||
|
||||
#: index.docbook:344
|
||||
msgid "appended paragraph 48"
|
||||
msgstr "Ahora estamos listos para comenzar la <literal>Session</literal> de Hibernate. Es el <emphasis>manejador de persistencia</emphasis> que usamos para almacenar y traer <literal>Cat</literal>s hacia y desde la base de datos. Pero primero, tenemos que obtener una <literal>Session</literal> (unidad de trabajo de Hibernate) de la <literal>SessionFactory</literal>:"
|
||||
|
||||
#: index.docbook:352
|
||||
msgid "appended paragraph 49"
|
||||
msgstr ""
|
||||
"<![CDATA[SessionFactory sessionFactory =\n"
|
||||
" new Configuration().configure().buildSessionFactory();]]>"
|
||||
|
||||
#: index.docbook:354
|
||||
msgid "appended paragraph 50"
|
||||
msgstr "La llamada a <literal>configure()</literal> carga el fichero de configuración <literal>hibernate.cfg.xml</literal> e inicializa la instancia de <literal>Configuration</literal>. Puedes establecer otras propiedades (e incluso cambiar los metadatos de mapeo) accediendo a la <literal>Configuration</literal> <emphasis>antes</emphasis> que construyas la <literal>SessionFactory</literal> (que es inmutable). ¿Dónde creamos la <literal>SessionFactory</literal> y cómo accedemos a ella en nuestra aplicación?"
|
||||
|
||||
#: index.docbook:365
|
||||
msgid "appended paragraph 51"
|
||||
msgstr "Una <literal>SessionFactory</literal> usualmente se construye una vez, por ejemplo, al arrancar con un servlet <emphasis>load-on-startup</emphasis>. Esto significa también que no debes mantenerla en una variable de instancia en tus servlets, sino en alguna otro sitio. Además, necesitamos algún tipo de <emphasis>Singleton</emphasis>, de modo que podamos acceder a la <literal>SessionFactory</literal> fácilmente en el código de aplicación. El siguiente enfoque mostrado resuelve ambos problemas: configuración de arranque y fácil acceso a una <literal>SessionFactory</literal>."
|
||||
|
||||
#: index.docbook:377
|
||||
msgid "appended paragraph 52"
|
||||
msgstr "Implementamos una clase de ayuda <literal>HibernateUtil</literal>:"
|
||||
|
||||
#: index.docbook:381
|
||||
msgid "appended paragraph 53"
|
||||
msgstr ""
|
||||
"<![CDATA[import org.hibernate.*;\n"
|
||||
"import org.hibernate.cfg.*;\n"
|
||||
"\n"
|
||||
"public class HibernateUtil {\n"
|
||||
"\n"
|
||||
" private static Logger log = LoggerFactory.getLogger(HibernateUtil.class);\n"
|
||||
"\n"
|
||||
" private static final SessionFactory sessionFactory;\n"
|
||||
"\n"
|
||||
" static {\n"
|
||||
" try {\n"
|
||||
" // Create the SessionFactory\n"
|
||||
" sessionFactory = new Configuration().configure().buildSessionFactory();\n"
|
||||
" } catch (Throwable ex) {\n"
|
||||
" // Make sure you log the exception, as it might be swallowed\n"
|
||||
" log.error(\"Initial SessionFactory creation failed.\", ex);\n"
|
||||
" throw new ExceptionInInitializerError(ex);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public static final ThreadLocal session = new ThreadLocal();\n"
|
||||
"\n"
|
||||
" public static Session currentSession() {\n"
|
||||
" Session s = (Session) session.get();\n"
|
||||
" // Open a new Session, if this Thread has none yet\n"
|
||||
" if (s == null) {\n"
|
||||
" s = sessionFactory.openSession();\n"
|
||||
" session.set(s);\n"
|
||||
" }\n"
|
||||
" return s;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public static void closeSession() {\n"
|
||||
" Session s = (Session) session.get();\n"
|
||||
" if (s != null)\n"
|
||||
" s.close();\n"
|
||||
" session.set(null);\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:383
|
||||
msgid "appended paragraph 54"
|
||||
msgstr "Esta clase no sólo cuida de la <literal>SessionFactory</literal> con su inicializador static, sino que además tiene una variable <literal>ThreadLocal</literal> que tiene la <literal>Session</literal> para la hebra actual. Asegúrate de entender el concepto Java de una variable local a una hebra antes de intentar usar esta ayuda. Una clase <literal>HibernateUtil</literal> más compleja y potente puede encontrarse en <literal>CaveatEmptor</literal>, http://caveatemptor.hibernate.org/"
|
||||
|
||||
#: index.docbook:393
|
||||
msgid "appended paragraph 55"
|
||||
msgstr "Una <literal>SessionFactory</literal> es segura entre hebras, muchas hebras pueden acceder a ella concurrentemente y pedirle <literal>Session</literal>s. Una <literal>Session</literal> no es un objeto seguro entre hebras que representa una sola unidad-de-trabajo con la base de datos. Las <literal>Session</literal>s se abren desde una <literal>SessionFactory</literal> y son cerradas cuando todo el trabajo está completo. Un ejemplo en el método <literal>process()</literal> de tu servlet podría parecerse a esto (sin manejo de excepciones):"
|
||||
|
||||
#: index.docbook:404
|
||||
msgid "appended paragraph 56"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = HibernateUtil.currentSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"Cat princess = new Cat();\n"
|
||||
"princess.setName(\"Princess\");\n"
|
||||
"princess.setSex('F');\n"
|
||||
"princess.setWeight(7.4f);\n"
|
||||
"\n"
|
||||
"session.save(princess);\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"HibernateUtil.closeSession();]]>"
|
||||
|
||||
#: index.docbook:406
|
||||
msgid "appended paragraph 57"
|
||||
msgstr "En una <literal>Session</literal>, cada operación de base de datos ocurre dentro de una transacción que aísla las operaciones de base de datos (incluso operaciones de sólo lectura). Usamos la API de <literal>Transaction</literal> de Hibernate para abstraer de la estrategia de transacciones subyacente (en nuestro caso, transacciones JDBC). Esto permite que nuestro código sea desplegado con transacciones manejadas por contenedor (usando JTA) sin cambio alguno."
|
||||
|
||||
#: index.docbook:416
|
||||
msgid "appended paragraph 58"
|
||||
msgstr "Observa que puedes llamar <literal>HibernateUtil.currentSession();</literal> tantas veces como quieras, siempre obtendrás la <literal>Session</literal> actual de esta hebra. Tienes que asegurarte que la <literal>Session</literal> sea cerrada después que se complete tu unidad-de-trabajo, ya sea en código de tu servlet o en un filtro de servlet antes que la respuesta HTTP sea enviada. El bonito efecto colateral de la segunda opción es la fácil inicialización perezosa: la <literal>Session</literal> todavía está abierta cuando se dibuja la vista, de modo que Hibernate puede cargar objetos no inicializados mientras navegas tu actual grafo de objetos."
|
||||
|
||||
#: index.docbook:428
|
||||
msgid "appended paragraph 59"
|
||||
msgstr "Hibernate tiene varios métodos que pueden ser usados para traer objetos desde la base de datos. La forma más flexible es usando el Lenguaje de Consulta de Hibernate (Hibernate Query Language o HQL), que es una extensión orientada a objetos de SQL fácil de aprender:"
|
||||
|
||||
#: index.docbook:436
|
||||
msgid "appended paragraph 60"
|
||||
msgstr ""
|
||||
"<![CDATA[Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"Query query = session.createQuery(\"select c from Cat as c where c.sex = :sex\");\n"
|
||||
"query.setCharacter(\"sex\", 'F');\n"
|
||||
"for (Iterator it = query.iterate(); it.hasNext();) {\n"
|
||||
" Cat cat = (Cat) it.next();\n"
|
||||
" out.println(\"Female Cat: \" + cat.getName() );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();]]>"
|
||||
|
||||
#: index.docbook:438
|
||||
msgid "appended paragraph 61"
|
||||
msgstr "Hibernate también ofrece una API <emphasis>consulta por criterios</emphasis> orientada a objetos que puede ser usada para formular consultas de tipo seguro. Por supuesto, Hibernate usa <literal>PreparedStatement</literal>s y ligado de parámetros para toda la comunicación SQL con la base de datos. También puedes usar la funcionalidad de consulta SQL directa de Hibernate u obtener una conexión plana de JDBC de una <literal>Session</literal> en casos raros."
|
||||
|
||||
#: index.docbook:451
|
||||
msgid "appended paragraph 62"
|
||||
msgstr "Finalmente"
|
||||
|
||||
#: index.docbook:453
|
||||
msgid "appended paragraph 63"
|
||||
msgstr "Rasguñamos solamente la superficie de Hibernate en este pequeño tutorial. Por favor, observa que no incluimos ningún código específico de servlet en nuestros ejemplos. Tienes que crear un servlet por tí mismo e insertar el código de Hibernate como lo veas ubicado."
|
||||
|
||||
#: index.docbook:461
|
||||
msgid "appended paragraph 64"
|
||||
msgstr "Ten en mente que Hibernate, como capa de acceso a datos, está firmemente integrado dentro de tu aplicación. Usualmente, todas las otras capas dependen del mecanismo de persistencia. Asegúrate de entender las implicaciones de este diseño."
|
||||
|
||||
#: index.docbook:468
|
||||
msgid "appended paragraph 65"
|
||||
msgstr "Para un ejemplo de aplicación más compleja, ver http://caveatemptor.hibernate.org/ y echa una mirada a los otros tutoriales con links en http://www.hibernate.org/Documentation"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,969 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "Toolset Guide"
|
||||
msgstr "Guía del Conjunto de Herramientas"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"Roundtrip engineering with Hibernate is possible using a set of Eclipse "
|
||||
"plugins, commandline tools, as well as Ant tasks."
|
||||
msgstr ""
|
||||
"La ingeniería de ida y vuelta con Hibernate es posible usando un "
|
||||
"conjunto de plugins de Eclipse, herramientas de línea de comandos, "
|
||||
"así como tareas de Ant."
|
||||
|
||||
#: index.docbook:12
|
||||
msgid ""
|
||||
"The <emphasis>Hibernate Tools</emphasis> currently include plugins for the "
|
||||
"Eclipse IDE as well as Ant tasks for reverse engineering of existing "
|
||||
"databases:"
|
||||
msgstr ""
|
||||
"Las <emphasis>Herramientas de Hibernate</emphasis> actualmente incluyen "
|
||||
"plugins para la IDE de Eclipse así como tareas de Ant para la "
|
||||
"ingeniería inversa de bases de datos existentes:"
|
||||
|
||||
#: index.docbook:18
|
||||
msgid ""
|
||||
"<emphasis>Mapping Editor:</emphasis> An editor for Hibernate XML mapping "
|
||||
"files, supporting auto-completion and syntax highlighting. It also supports "
|
||||
"semantic auto-completion for class names and property/field names, making it "
|
||||
"much more versatile than a normal XML editor."
|
||||
msgstr ""
|
||||
"<emphasis>Editor de Mapeo:</emphasis> Un editor de ficheros de mapeo XML, "
|
||||
"que soporta autocompleción y resaltado de sintáxis. Soporta "
|
||||
"también autocompleción semántica de nombres de clases y "
|
||||
"nombres de campos/propiedades, haciéndolo mucho más "
|
||||
"versátil que un editor de XML normal."
|
||||
|
||||
#: index.docbook:23
|
||||
msgid ""
|
||||
"<emphasis>Console:</emphasis> The console is a new view in Eclipse. In "
|
||||
"addition to a tree overview of your console configurations, you also get an "
|
||||
"interactive view of your persistent classes and their relationships. The "
|
||||
"console allows you to execute HQL queries against your database and browse "
|
||||
"the result directly in Eclipse."
|
||||
msgstr ""
|
||||
"<emphasis>Consola:</emphasis> La consola es una nueva vista en Eclipse. "
|
||||
"Además de la vista de árbol de tus configuraciones de consola, "
|
||||
"tienes también una vista interactiva de tus clases persistentes y sus "
|
||||
"relaciones. La console te permite ejecutar consultas HQL contra tu base de "
|
||||
"datos y navegar el resultado directamente en Eclipse."
|
||||
|
||||
#: index.docbook:30
|
||||
msgid ""
|
||||
"<emphasis>Development Wizards:</emphasis> Several wizards are provided with "
|
||||
"the Hibernate Eclipse tools; you can use a wizard to quickly generate "
|
||||
"Hibernate configuration (cfg.xml) files, or you may even completely reverse "
|
||||
"engineer an existing database schema into POJO source files and Hibernate "
|
||||
"mapping files. The reverse engineering wizard supports customizable "
|
||||
"templates."
|
||||
msgstr ""
|
||||
"<emphasis>Asistentes de Desarrollo:</emphasis> Se proveen muchos asistentes "
|
||||
"con las herramientas de Eclipse. Puedes usar un asistente para generar "
|
||||
"rápidamente ficheros de configuración de Hibernate (cfg.xml), "
|
||||
"o incluso puedes haceruna ingeniería inversa completa de un esquema "
|
||||
"de base de datos existente en ficheros de código de POJO y ficheros "
|
||||
"de mapeo de Hibernate. El asistente de ingeniería inversa soporta "
|
||||
"plantillas personalizables."
|
||||
|
||||
#: index.docbook:38
|
||||
msgid "Ant Tasks:"
|
||||
msgstr "Tareas de Ant:"
|
||||
|
||||
#: index.docbook:43
|
||||
msgid ""
|
||||
"Please refer to the <emphasis>Hibernate Tools</emphasis> package and it's "
|
||||
"documentation for more information."
|
||||
msgstr ""
|
||||
"Por favor refiérete al paquete <emphasis>Herramientas de Hibernate</"
|
||||
"emphasis> y su documentación para más información."
|
||||
|
||||
#: index.docbook:48
|
||||
msgid ""
|
||||
"However, the Hibernate main package comes bundled with an integrated tool "
|
||||
"(it can even be used from \"inside\" Hibernate on-the-fly): "
|
||||
"<emphasis>SchemaExport</emphasis> aka <literal>hbm2ddl</literal>."
|
||||
msgstr ""
|
||||
"Sin embargo, el paquete principal de Hibernate viene incluyendo una "
|
||||
"herramienta integrada (puede ser usada incluso \"dentro\" de Hibernate on-"
|
||||
"the-fly): <emphasis>SchemaExport</emphasis> también conocido como "
|
||||
"<literal>hbm2ddl</literal>."
|
||||
|
||||
#: index.docbook:55
|
||||
msgid "Automatic schema generation"
|
||||
msgstr "Generación automática de esquemas"
|
||||
|
||||
#: index.docbook:57
|
||||
msgid ""
|
||||
"DDL may be generated from your mapping files by a Hibernate utility. The "
|
||||
"generated schema includes referential integrity constraints (primary and "
|
||||
"foreign keys) for entity and collection tables. Tables and sequences are "
|
||||
"also created for mapped identifier generators."
|
||||
msgstr ""
|
||||
"Una utilidad de Hibernate puede generar DDL desde tus ficheros de mapeo. El "
|
||||
"esquema generado incluye restricciones de integridad referencial (claves "
|
||||
"primarias y foráneas) para las tablas de entidades y colecciones. Las "
|
||||
"tablas y secuencias también son creadas para los generadores de "
|
||||
"identificadores mapeados."
|
||||
|
||||
#: index.docbook:64
|
||||
msgid ""
|
||||
"You <emphasis>must</emphasis> specify a SQL <literal>Dialect</literal> via "
|
||||
"the <literal>hibernate.dialect</literal> property when using this tool, as "
|
||||
"DDL is highly vendor specific."
|
||||
msgstr ""
|
||||
"<emphasis>Debes</emphasis> especificar un <literal>Dialecto</literal> SQL "
|
||||
"vía la propiedad <literal>hibernate.dialect</literal> al usar esta "
|
||||
"herramienta, ya que el DDL es altamente específico del vendedor."
|
||||
|
||||
#: index.docbook:70
|
||||
msgid "First, customize your mapping files to improve the generated schema."
|
||||
msgstr "First, customize your mapping files to improve the generated schema."
|
||||
|
||||
#: index.docbook:75
|
||||
msgid "Customizing the schema"
|
||||
msgstr "Personalizando el esquema"
|
||||
|
||||
#: index.docbook:77
|
||||
msgid ""
|
||||
"Many Hibernate mapping elements define optional attributes named "
|
||||
"<literal>length</literal>, <literal>precision</literal> and <literal>scale</"
|
||||
"literal>. You may set the length, precision and scale of a column with this "
|
||||
"attribute."
|
||||
msgstr ""
|
||||
"Muchos elementos de mapeo de Hibernate definen un atributo opcional llamado "
|
||||
"<literal>length</literal>. Con este atributo puedes establecer el "
|
||||
"tamaño de una columna. (O, para tipos de datos numéricos/"
|
||||
"decimales, la precisión.)"
|
||||
|
||||
#: index.docbook:84
|
||||
msgid "<![CDATA[<property name=\"zip\" length=\"5\"/>]]>"
|
||||
msgstr "<![CDATA[<property name=\"zip\" length=\"5\"/>]]>"
|
||||
|
||||
#: index.docbook:85
|
||||
msgid "<![CDATA[<property name=\"balance\" precision=\"12\" scale=\"2\"/>]]>"
|
||||
msgstr "<![CDATA[<property name=\"balance\" precision=\"12\" scale=\"2\"/>]]>"
|
||||
|
||||
#: index.docbook:87
|
||||
msgid ""
|
||||
"Some tags also accept a <literal>not-null</literal> attribute (for "
|
||||
"generating a <literal>NOT NULL</literal> constraint on table columns) and a "
|
||||
"<literal>unique</literal> attribute (for generating <literal>UNIQUE</"
|
||||
"literal> constraint on table columns)."
|
||||
msgstr ""
|
||||
"Algunas etiquetas también aceptan un atributo <literal>not-null</"
|
||||
"literal> (para generar una restricción <literal>NOT NULL</literal> en "
|
||||
"columnas de tablas) y y un atributo <literal>unique</literal> (para generar "
|
||||
"restricciones <literal>UNIQUE</literal> en columnas de tablas)."
|
||||
|
||||
#: index.docbook:93
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"bar\" column=\"barId\" not-null=\"true\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<many-to-one name=\"bar\" column=\"barId\" not-null=\"true\"/>]]>"
|
||||
|
||||
#: index.docbook:95
|
||||
msgid ""
|
||||
"<![CDATA[<element column=\"serialNumber\" type=\"long\" not-null=\"true\" "
|
||||
"unique=\"true\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<element column=\"serialNumber\" type=\"long\" not-null=\"true\" "
|
||||
"unique=\"true\"/>]]>"
|
||||
|
||||
#: index.docbook:97
|
||||
msgid ""
|
||||
"A <literal>unique-key</literal> attribute may be used to group columns in a "
|
||||
"single unique key constraint. Currently, the specified value of the "
|
||||
"<literal>unique-key</literal> attribute is <emphasis>not</emphasis> used to "
|
||||
"name the constraint in the generated DDL, only to group the columns in the "
|
||||
"mapping file."
|
||||
msgstr ""
|
||||
"A <literal>unique-key</literal> attribute may be used to group columns in a "
|
||||
"single unique key constraint. Currently, the specified value of the "
|
||||
"<literal>unique-key</literal> attribute is <emphasis>not</emphasis> used to "
|
||||
"name the constraint in the generated DDL, only to group the columns in the "
|
||||
"mapping file."
|
||||
|
||||
#: index.docbook:105
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"org\" column=\"orgId\" unique-key="
|
||||
"\"OrgEmployeeId\"/>\n"
|
||||
"<property name=\"employeeId\" unique-key=\"OrgEmployee\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<many-to-one name=\"org\" column=\"orgId\" unique-key="
|
||||
"\"OrgEmployeeId\"/>\n"
|
||||
"<property name=\"employeeId\" unique-key=\"OrgEmployee\"/>]]>"
|
||||
|
||||
#: index.docbook:107
|
||||
msgid ""
|
||||
"An <literal>index</literal> attribute specifies the name of an index that "
|
||||
"will be created using the mapped column or columns. Multiple columns may be "
|
||||
"grouped into the same index, simply by specifying the same index name."
|
||||
msgstr ""
|
||||
"An <literal>index</literal> attribute specifies the name of an index that "
|
||||
"will be created using the mapped column or columns. Multiple columns may be "
|
||||
"grouped into the same index, simply by specifying the same index name."
|
||||
|
||||
#: index.docbook:113
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"lastName\" index=\"CustName\"/>\n"
|
||||
"<property name=\"firstName\" index=\"CustName\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"lastName\" index=\"CustName\"/>\n"
|
||||
" <property name=\"firstName\" index=\"CustName\"/>]]>"
|
||||
|
||||
#: index.docbook:115
|
||||
msgid ""
|
||||
"A <literal>foreign-key</literal> attribute may be used to override the name "
|
||||
"of any generated foreign key constraint."
|
||||
msgstr ""
|
||||
"A <literal>foreign-key</literal> attribute may be used to override the name "
|
||||
"of any generated foreign key constraint."
|
||||
|
||||
#: index.docbook:120
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"bar\" column=\"barId\" foreign-key=\"FKFooBar\"/"
|
||||
">]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<many-to-one name=\"bar\" column=\"barId\" foreign-key=\"FKFooBar\"/"
|
||||
">]]>"
|
||||
|
||||
#: index.docbook:122
|
||||
msgid ""
|
||||
"Many mapping elements also accept a child <literal><column></literal> "
|
||||
"element. This is particularly useful for mapping multi-column types:"
|
||||
msgstr ""
|
||||
"Many mapping elements also accept a child <literal><column></literal> "
|
||||
"element. This is particularly useful for mapping multi-column types:"
|
||||
|
||||
#: index.docbook:127
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"name\" type=\"my.customtypes.Name\"/>\n"
|
||||
" <column name=\"last\" not-null=\"true\" index=\"bar_idx\" length=\"30\"/"
|
||||
">\n"
|
||||
" <column name=\"first\" not-null=\"true\" index=\"bar_idx\" length=\"20\"/"
|
||||
">\n"
|
||||
" <column name=\"initial\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"name\" type=\"my.customtypes.Name\"/>\n"
|
||||
" <column name=\"last\" not-null=\"true\" index=\"bar_idx\" length=\"30"
|
||||
"\"/>\n"
|
||||
" <column name=\"first\" not-null=\"true\" index=\"bar_idx\" length="
|
||||
"\"20\"/>\n"
|
||||
" <column name=\"initial\"/>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: index.docbook:129
|
||||
msgid ""
|
||||
"The <literal>default</literal> attribute lets you specify a default value "
|
||||
"for a column (you should assign the same value to the mapped property before "
|
||||
"saving a new instance of the mapped class)."
|
||||
msgstr ""
|
||||
"The <literal>default</literal> attribute lets you specify a default value "
|
||||
"for a column (you should assign the same value to the mapped property before "
|
||||
"saving a new instance of the mapped class)."
|
||||
|
||||
#: index.docbook:135
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"credits\" type=\"integer\" insert=\"false\">\n"
|
||||
" <column name=\"credits\" default=\"10\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"credits\" type=\"integer\" insert=\"false\">\n"
|
||||
" <column name=\"credits\" default=\"10\"/>\n"
|
||||
" </property>]]>"
|
||||
|
||||
#: index.docbook:137
|
||||
msgid ""
|
||||
"<![CDATA[<version name=\"version\" type=\"integer\" insert=\"false\">\n"
|
||||
" <column name=\"version\" default=\"0\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<version name=\"version\" type=\"integer\" insert=\"false\">\n"
|
||||
" <column name=\"version\" default=\"0\"/>\n"
|
||||
" </property>]]>"
|
||||
|
||||
#: index.docbook:139
|
||||
msgid ""
|
||||
"The <literal>sql-type</literal> attribute allows the user to override the "
|
||||
"default mapping of a Hibernate type to SQL datatype."
|
||||
msgstr ""
|
||||
"El atributo <literal>sql-type</literal> permite al usuario sobrescribir el "
|
||||
"mapeo por defecto de tipo Hibernate a tipo de datos SQL."
|
||||
|
||||
#: index.docbook:144
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"balance\" type=\"float\">\n"
|
||||
" <column name=\"balance\" sql-type=\"decimal(13,3)\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"balance\" type=\"float\">\n"
|
||||
" <column name=\"balance\" sql-type=\"decimal(13,3)"
|
||||
"\"/>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: index.docbook:146
|
||||
msgid ""
|
||||
"The <literal>check</literal> attribute allows you to specify a check "
|
||||
"constraint."
|
||||
msgstr ""
|
||||
"El atributo <literal>check</literal> te permite especificar una "
|
||||
"comprobación de restricción."
|
||||
|
||||
#: index.docbook:150
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"foo\" type=\"integer\">\n"
|
||||
" <column name=\"foo\" check=\"foo > 10\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"foo\" type=\"integer\">\n"
|
||||
" <column name=\"foo\" check=\"foo > 10\"/>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: index.docbook:152
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Foo\" table=\"foos\" check=\"bar < 100.0\">\n"
|
||||
" ...\n"
|
||||
" <property name=\"bar\" type=\"float\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Foo\" table=\"foos\" check=\"bar < 100.0\">\n"
|
||||
" ...\n"
|
||||
" <property name=\"bar\" type=\"float\"/>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:156
|
||||
msgid "Summary"
|
||||
msgstr "Resumen"
|
||||
|
||||
#: index.docbook:163
|
||||
msgid "Attribute"
|
||||
msgstr "Atributo"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "Values"
|
||||
msgstr "Valores"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "Interpretation"
|
||||
msgstr "Interpretación"
|
||||
|
||||
#: index.docbook:170
|
||||
msgid "length"
|
||||
msgstr "length"
|
||||
|
||||
#: index.docbook:171, index.docbook:176, index.docbook:181
|
||||
msgid "number"
|
||||
msgstr "number"
|
||||
|
||||
#: index.docbook:172
|
||||
msgid "column length"
|
||||
msgstr "largo de columna/precisión decimal"
|
||||
|
||||
#: index.docbook:175
|
||||
msgid "precision"
|
||||
msgstr "precision"
|
||||
|
||||
#: index.docbook:177
|
||||
msgid "column decimal precision"
|
||||
msgstr "column decimal precision"
|
||||
|
||||
#: index.docbook:180
|
||||
msgid "scale"
|
||||
msgstr "scale"
|
||||
|
||||
#: index.docbook:182
|
||||
msgid "column decimal scale"
|
||||
msgstr "column decimal scale"
|
||||
|
||||
#: index.docbook:185
|
||||
msgid "not-null"
|
||||
msgstr "not-null"
|
||||
|
||||
#: index.docbook:186, index.docbook:191
|
||||
msgid "true|false"
|
||||
msgstr "true|false"
|
||||
|
||||
#: index.docbook:187
|
||||
msgid "specfies that the column should be non-nullable"
|
||||
msgstr "especifica que la columna debe ser no nulable"
|
||||
|
||||
#: index.docbook:190
|
||||
msgid "unique"
|
||||
msgstr "unique"
|
||||
|
||||
#: index.docbook:192
|
||||
msgid "specifies that the column should have a unique constraint"
|
||||
msgstr ""
|
||||
"especifica que la columna debe tener una restricción de unicidad"
|
||||
|
||||
#: index.docbook:195
|
||||
msgid "index"
|
||||
msgstr "index"
|
||||
|
||||
#: index.docbook:196
|
||||
msgid "index_name"
|
||||
msgstr "index_name"
|
||||
|
||||
#: index.docbook:197
|
||||
msgid "specifies the name of a (multi-column) index"
|
||||
msgstr "especifica el nombre de un índice (multicolumna)"
|
||||
|
||||
#: index.docbook:200
|
||||
msgid "unique-key"
|
||||
msgstr "unique-key"
|
||||
|
||||
#: index.docbook:201
|
||||
msgid "unique_key_name"
|
||||
msgstr "unique_key_name"
|
||||
|
||||
#: index.docbook:202
|
||||
msgid "specifies the name of a multi-column unique constraint"
|
||||
msgstr ""
|
||||
"especifica el nombre de una restricción de unicidad multicolumna"
|
||||
|
||||
#: index.docbook:205
|
||||
msgid "foreign-key"
|
||||
msgstr "foreign-key"
|
||||
|
||||
#: index.docbook:206
|
||||
msgid "foreign_key_name"
|
||||
msgstr "foreign_key_name"
|
||||
|
||||
#: index.docbook:207
|
||||
msgid ""
|
||||
"specifies the name of the foreign key constraint generated for an "
|
||||
"association, for a <literal><one-to-one></literal>, <literal><many-"
|
||||
"to-one></literal>, <literal><key></literal>, or <literal><many-"
|
||||
"to-many></literal> mapping element. Note that <literal>inverse=\"true\"</"
|
||||
"literal> sides will not be considered by <literal>SchemaExport</literal>."
|
||||
msgstr ""
|
||||
"especifica el nombre de la restricción de clave foránea "
|
||||
"generada por una asociación, úsalo e <literal><one-to-"
|
||||
"one></literal>, <literal><many-to-one></literal>, <literal><"
|
||||
"key></literal>, or <literal><many-to-many></literal> . Nota que los "
|
||||
"lados <literal>inverse=\"true\"</literal> no serán considerados por "
|
||||
"<literal>SchemaExport</literal>."
|
||||
|
||||
#: index.docbook:217
|
||||
msgid "sql-type"
|
||||
msgstr "sql-type"
|
||||
|
||||
#: index.docbook:218
|
||||
msgid "SQL column type"
|
||||
msgstr "column_type"
|
||||
|
||||
#: index.docbook:219
|
||||
msgid ""
|
||||
"overrides the default column type (attribute of <literal><column></"
|
||||
"literal> element only)"
|
||||
msgstr ""
|
||||
"sobrescribe el tipo de columna por defecto (sólo atributo del "
|
||||
"elemento <literal><column></literal>)"
|
||||
|
||||
#: index.docbook:225
|
||||
msgid "default"
|
||||
msgstr "default"
|
||||
|
||||
#: index.docbook:226, index.docbook:233
|
||||
msgid "SQL expression"
|
||||
msgstr "SQL expression"
|
||||
|
||||
#: index.docbook:227
|
||||
msgid "specify a default value for the column"
|
||||
msgstr "specify a default value for the column"
|
||||
|
||||
#: index.docbook:232
|
||||
msgid "check"
|
||||
msgstr "check"
|
||||
|
||||
#: index.docbook:234
|
||||
msgid "create an SQL check constraint on either column or table"
|
||||
msgstr ""
|
||||
"crea una restricción de comprobación SQL en columna o tabla"
|
||||
|
||||
#: index.docbook:242
|
||||
msgid ""
|
||||
"The <literal><comment></literal> element allows you to specify "
|
||||
"comments for the generated schema."
|
||||
msgstr ""
|
||||
"El elemento <literal><comment></literal> te permite especificar un "
|
||||
"comentario para el esquema generado."
|
||||
|
||||
#: index.docbook:247
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Customer\" table=\"CurCust\">\n"
|
||||
" <comment>Current customers only</comment>\n"
|
||||
" ...\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Customer\" table=\"CurCust\">\n"
|
||||
" <comment>Current customers only</comment>\n"
|
||||
" ...\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:249
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"balance\">\n"
|
||||
" <column name=\"bal\">\n"
|
||||
" <comment>Balance in USD</comment>\n"
|
||||
" </column>\n"
|
||||
"</property>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"balance\">\n"
|
||||
" <column name=\"bal\">\n"
|
||||
" <comment>Balance in USD</comment>\n"
|
||||
" </column>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: index.docbook:251
|
||||
msgid ""
|
||||
"This results in a <literal>comment on table</literal> or <literal>comment on "
|
||||
"column</literal> statement in the generated DDL (where supported)."
|
||||
msgstr ""
|
||||
"Esto resulta en una sentencia <literal>comment on table</literal> o "
|
||||
"<literal>comment on column</literal> en el DDL generado (donde esté "
|
||||
"soportado)."
|
||||
|
||||
#: index.docbook:260
|
||||
msgid "Running the tool"
|
||||
msgstr "Ejecutando la herramienta"
|
||||
|
||||
#: index.docbook:262
|
||||
msgid ""
|
||||
"The <literal>SchemaExport</literal> tool writes a DDL script to standard out "
|
||||
"and/or executes the DDL statements."
|
||||
msgstr ""
|
||||
"La herramienta <literal>SchemaExport</literal> escribe un guión DDL a "
|
||||
"la salida estándar y/o ejecuta las sentencias DDL."
|
||||
|
||||
#: index.docbook:267
|
||||
msgid ""
|
||||
"<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis> "
|
||||
"<literal>org.hibernate.tool.hbm2ddl.SchemaExport</literal> <emphasis>options "
|
||||
"mapping_files</emphasis>"
|
||||
msgstr ""
|
||||
"<literal>java -cp </literal><emphasis>classpaths_de_hibernate</emphasis> "
|
||||
"<literal>org.hibernate.tool.hbm2ddl.SchemaExport</literal> "
|
||||
"<emphasis>opciones ficheros_de_mapeo</emphasis>"
|
||||
|
||||
#: index.docbook:273
|
||||
msgid "<literal>SchemaExport</literal> Command Line Options"
|
||||
msgstr ""
|
||||
"Opciones de Línea de Comandos de <literal>SchemaExport</literal>"
|
||||
|
||||
#: index.docbook:279, index.docbook:429, index.docbook:498
|
||||
msgid "Option"
|
||||
msgstr "Opción"
|
||||
|
||||
#: index.docbook:280, index.docbook:367, index.docbook:430, index.docbook:499
|
||||
msgid "Description"
|
||||
msgstr "Descripción"
|
||||
|
||||
#: index.docbook:285, index.docbook:435
|
||||
msgid "--quiet"
|
||||
msgstr "--quiet"
|
||||
|
||||
#: index.docbook:286, index.docbook:436
|
||||
msgid "don't output the script to stdout"
|
||||
msgstr "no enviar a salida estándar el guión"
|
||||
|
||||
#: index.docbook:289
|
||||
msgid "--drop"
|
||||
msgstr "--drop"
|
||||
|
||||
#: index.docbook:290
|
||||
msgid "only drop the tables"
|
||||
msgstr "sólo desechar las tablas"
|
||||
|
||||
#: index.docbook:293
|
||||
msgid "--create"
|
||||
msgstr "--create"
|
||||
|
||||
#: index.docbook:294
|
||||
msgid "only create the tables"
|
||||
msgstr "only create the tables"
|
||||
|
||||
#: index.docbook:297, index.docbook:439
|
||||
msgid "--text"
|
||||
msgstr "--text"
|
||||
|
||||
#: index.docbook:298
|
||||
msgid "don't export to the database"
|
||||
msgstr "no exportar a la base de datos"
|
||||
|
||||
#: index.docbook:301
|
||||
msgid "--output=my_schema.ddl"
|
||||
msgstr "--output=my_schema.ddl"
|
||||
|
||||
#: index.docbook:302
|
||||
msgid "output the ddl script to a file"
|
||||
msgstr "enviar la salida del guión ddl a un fichero"
|
||||
|
||||
#: index.docbook:305, index.docbook:443, index.docbook:504
|
||||
msgid "--naming=eg.MyNamingStrategy"
|
||||
msgstr "--naming=eg.MyNamingStrategy"
|
||||
|
||||
#: index.docbook:306, index.docbook:444, index.docbook:505
|
||||
msgid "select a <literal>NamingStrategy</literal>"
|
||||
msgstr "select a <literal>NamingStrategy</literal>"
|
||||
|
||||
#: index.docbook:309, index.docbook:451, index.docbook:512
|
||||
msgid "--config=hibernate.cfg.xml"
|
||||
msgstr "--config=hibernate.cfg.xml"
|
||||
|
||||
#: index.docbook:310
|
||||
msgid "read Hibernate configuration from an XML file"
|
||||
msgstr "lee la configuración de Hibernate de un fichero XML"
|
||||
|
||||
#: index.docbook:313, index.docbook:447, index.docbook:508
|
||||
msgid "--properties=hibernate.properties"
|
||||
msgstr "--properties=hibernate.properties"
|
||||
|
||||
#: index.docbook:314, index.docbook:448, index.docbook:509
|
||||
msgid "read database properties from a file"
|
||||
msgstr "lee las propiedades de base de datos de un fichero"
|
||||
|
||||
#: index.docbook:317
|
||||
msgid "--format"
|
||||
msgstr "--format"
|
||||
|
||||
#: index.docbook:318
|
||||
msgid "format the generated SQL nicely in the script"
|
||||
msgstr "formatea agradablemente el SQL generado en el guión"
|
||||
|
||||
#: index.docbook:321
|
||||
msgid "--delimiter=;"
|
||||
msgstr "--delimiter=x"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "set an end of line delimiter for the script"
|
||||
msgstr "establece un delimitador de fin de línea para el guión"
|
||||
|
||||
#: index.docbook:328
|
||||
msgid "You may even embed <literal>SchemaExport</literal> in your application:"
|
||||
msgstr ""
|
||||
"Puedes incluso encajar <literal>SchemaExport</literal> en tu aplicació"
|
||||
"n:"
|
||||
|
||||
#: index.docbook:332
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaExport(cfg).create(false, true);]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaExport(cfg).create(false, true);]]>"
|
||||
|
||||
#: index.docbook:337
|
||||
msgid "Properties"
|
||||
msgstr "Propiedades"
|
||||
|
||||
#: index.docbook:339
|
||||
msgid "Database properties may be specified"
|
||||
msgstr "Las propiedades de base de datos pueden especificarse"
|
||||
|
||||
#: index.docbook:345
|
||||
msgid ""
|
||||
"as system properties with <literal>-D</literal><emphasis><property></"
|
||||
"emphasis>"
|
||||
msgstr ""
|
||||
"como propiedades de sistema con <literal>-D</literal><emphasis><"
|
||||
"property></emphasis>"
|
||||
|
||||
#: index.docbook:348
|
||||
msgid "in <literal>hibernate.properties</literal>"
|
||||
msgstr "en <literal>hibernate.properties</literal>"
|
||||
|
||||
#: index.docbook:351
|
||||
msgid "in a named properties file with <literal>--properties</literal>"
|
||||
msgstr ""
|
||||
"en un fichero de propiedades mencionado con <literal>--properties</literal>"
|
||||
|
||||
#: index.docbook:355
|
||||
msgid "The needed properties are:"
|
||||
msgstr "Las propiedades necesarias son:"
|
||||
|
||||
#: index.docbook:360
|
||||
msgid "SchemaExport Connection Properties"
|
||||
msgstr "Propiedades de Conexión de SchemaExport"
|
||||
|
||||
#: index.docbook:366
|
||||
msgid "Property Name"
|
||||
msgstr "Nombre de Propiedad"
|
||||
|
||||
#: index.docbook:372
|
||||
msgid "hibernate.connection.driver_class"
|
||||
msgstr "hibernate.connection.driver_class"
|
||||
|
||||
#: index.docbook:373
|
||||
msgid "jdbc driver class"
|
||||
msgstr "clase del driver jdbc"
|
||||
|
||||
#: index.docbook:376
|
||||
msgid "hibernate.connection.url"
|
||||
msgstr "hibernate.connection.url"
|
||||
|
||||
#: index.docbook:377
|
||||
msgid "jdbc url"
|
||||
msgstr "url de jdbc"
|
||||
|
||||
#: index.docbook:380
|
||||
msgid "hibernate.connection.username"
|
||||
msgstr "hibernate.connection.username"
|
||||
|
||||
#: index.docbook:381
|
||||
msgid "database user"
|
||||
msgstr "usuario de base de datos"
|
||||
|
||||
#: index.docbook:384
|
||||
msgid "hibernate.connection.password"
|
||||
msgstr "hibernate.connection.password"
|
||||
|
||||
#: index.docbook:385
|
||||
msgid "user password"
|
||||
msgstr "contraseña de usuario"
|
||||
|
||||
#: index.docbook:388
|
||||
msgid "hibernate.dialect"
|
||||
msgstr "hibernate.dialect"
|
||||
|
||||
#: index.docbook:389
|
||||
msgid "dialect"
|
||||
msgstr "dialecto"
|
||||
|
||||
#: index.docbook:398
|
||||
msgid "Using Ant"
|
||||
msgstr "Usando Ant"
|
||||
|
||||
#: index.docbook:400
|
||||
msgid ""
|
||||
"You can call <literal>SchemaExport</literal> from your Ant build script:"
|
||||
msgstr ""
|
||||
"Puedes llamar a <literal>SchemaExport</literal> desde tu guión de "
|
||||
"construcción de Ant:"
|
||||
|
||||
#: index.docbook:404
|
||||
msgid ""
|
||||
"<![CDATA[<target name=\"schemaexport\">\n"
|
||||
" <taskdef name=\"schemaexport\"\n"
|
||||
" classname=\"org.hibernate.tool.hbm2ddl.SchemaExportTask\"\n"
|
||||
" classpathref=\"class.path\"/>\n"
|
||||
" \n"
|
||||
" <schemaexport\n"
|
||||
" properties=\"hibernate.properties\"\n"
|
||||
" quiet=\"no\"\n"
|
||||
" text=\"no\"\n"
|
||||
" drop=\"no\"\n"
|
||||
" delimiter=\";\"\n"
|
||||
" output=\"schema-export.sql\">\n"
|
||||
" <fileset dir=\"src\">\n"
|
||||
" <include name=\"**/*.hbm.xml\"/>\n"
|
||||
" </fileset>\n"
|
||||
" </schemaexport>\n"
|
||||
"</target>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<target name=\"schemaexport\">\n"
|
||||
" <taskdef name=\"schemaexport\"\n"
|
||||
" classname=\"org.hibernate.tool.hbm2ddl.SchemaExportTask\"\n"
|
||||
" classpathref=\"class.path\"/>\n"
|
||||
" \n"
|
||||
" <schemaexport\n"
|
||||
" properties=\"hibernate.properties\"\n"
|
||||
" quiet=\"no\"\n"
|
||||
" text=\"no\"\n"
|
||||
" drop=\"no\"\n"
|
||||
" delimiter=\";\"\n"
|
||||
" output=\"schema-export.sql\">\n"
|
||||
" <fileset dir=\"src\">\n"
|
||||
" <include name=\"**/*.hbm.xml\"/>\n"
|
||||
" </fileset>\n"
|
||||
" </schemaexport>\n"
|
||||
"</target>]]>"
|
||||
|
||||
#: index.docbook:409
|
||||
msgid "Incremental schema updates"
|
||||
msgstr "Actualizaciones incrementales de esquema"
|
||||
|
||||
#: index.docbook:411
|
||||
msgid ""
|
||||
"The <literal>SchemaUpdate</literal> tool will update an existing schema with "
|
||||
"\"incremental\" changes. Note that <literal>SchemaUpdate</literal> depends "
|
||||
"heavily upon the JDBC metadata API, so it will not work with all JDBC "
|
||||
"drivers."
|
||||
msgstr ""
|
||||
"La herramienta <literal>SchemaUpdate</literal> actualizará un esquema "
|
||||
"existente con cambios \"incrementales\". Nota que <literal>SchemaUpdate</"
|
||||
"literal> depende fuertemente de la API de metadatos de JDBC, de modo que no "
|
||||
"funcionará con todos los drivers JDBC."
|
||||
|
||||
#: index.docbook:417
|
||||
msgid ""
|
||||
"<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis> "
|
||||
"<literal>org.hibernate.tool.hbm2ddl.SchemaUpdate</literal> <emphasis>options "
|
||||
"mapping_files</emphasis>"
|
||||
msgstr ""
|
||||
"<literal>java -cp </literal><emphasis>classpaths_de_hibernate</emphasis> "
|
||||
"<literal>org.hibernate.tool.hbm2ddl.SchemaUpdate</literal> "
|
||||
"<emphasis>opciones ficheros_de_mapeo</emphasis>"
|
||||
|
||||
#: index.docbook:423
|
||||
msgid "<literal>SchemaUpdate</literal> Command Line Options"
|
||||
msgstr ""
|
||||
"Opciones de Línea de Comandos de <literal>SchemaUpdate</literal>"
|
||||
|
||||
#: index.docbook:440
|
||||
msgid "don't export the script to the database"
|
||||
msgstr "don't export the script to the database"
|
||||
|
||||
#: index.docbook:452, index.docbook:513
|
||||
msgid "specify a <literal>.cfg.xml</literal> file"
|
||||
msgstr "specify a <literal>.cfg.xml</literal> file"
|
||||
|
||||
#: index.docbook:458
|
||||
msgid "You may embed <literal>SchemaUpdate</literal> in your application:"
|
||||
msgstr ""
|
||||
"Puedes encajar <literal>SchemaUpdate</literal> en tu aplicación:"
|
||||
|
||||
#: index.docbook:462
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaUpdate(cfg).execute(false);]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaUpdate(cfg).execute(false);]]>"
|
||||
|
||||
#: index.docbook:467
|
||||
msgid "Using Ant for incremental schema updates"
|
||||
msgstr "Usando Ant para actualizaciones incrementales de esquema"
|
||||
|
||||
#: index.docbook:469
|
||||
msgid "You can call <literal>SchemaUpdate</literal> from the Ant script:"
|
||||
msgstr ""
|
||||
"Puedes llamar a <literal>SchemaUpdate</literal> desde el guión de Ant:"
|
||||
|
||||
#: index.docbook:473
|
||||
msgid ""
|
||||
"<![CDATA[<target name=\"schemaupdate\">\n"
|
||||
" <taskdef name=\"schemaupdate\"\n"
|
||||
" classname=\"org.hibernate.tool.hbm2ddl.SchemaUpdateTask\"\n"
|
||||
" classpathref=\"class.path\"/>\n"
|
||||
" \n"
|
||||
" <schemaupdate\n"
|
||||
" properties=\"hibernate.properties\"\n"
|
||||
" quiet=\"no\">\n"
|
||||
" <fileset dir=\"src\">\n"
|
||||
" <include name=\"**/*.hbm.xml\"/>\n"
|
||||
" </fileset>\n"
|
||||
" </schemaupdate>\n"
|
||||
"</target>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<target name=\"schemaupdate\">\n"
|
||||
" <taskdef name=\"schemaupdate\"\n"
|
||||
" classname=\"org.hibernate.tool.hbm2ddl.SchemaUpdateTask\"\n"
|
||||
" classpathref=\"class.path\"/>\n"
|
||||
" \n"
|
||||
" <schemaupdate\n"
|
||||
" properties=\"hibernate.properties\"\n"
|
||||
" quiet=\"no\">\n"
|
||||
" <fileset dir=\"src\">\n"
|
||||
" <include name=\"**/*.hbm.xml\"/>\n"
|
||||
" </fileset>\n"
|
||||
" </schemaupdate>\n"
|
||||
"</target>]]>"
|
||||
|
||||
#: index.docbook:478
|
||||
msgid "Schema validation"
|
||||
msgstr "Schema validation"
|
||||
|
||||
#: index.docbook:480
|
||||
msgid ""
|
||||
"The <literal>SchemaValidator</literal> tool will validate that the existing "
|
||||
"database schema \"matches\" your mapping documents. Note that "
|
||||
"<literal>SchemaValidator</literal> depends heavily upon the JDBC metadata "
|
||||
"API, so it will not work with all JDBC drivers. This tool is extremely "
|
||||
"useful for testing."
|
||||
msgstr ""
|
||||
"The <literal>SchemaValidator</literal> tool will validate that the existing "
|
||||
"database schema \"matches\" your mapping documents. Note that "
|
||||
"<literal>SchemaValidator</literal> depends heavily upon the JDBC metadata "
|
||||
"API, so it will not work with all JDBC drivers. This tool is extremely "
|
||||
"useful for testing."
|
||||
|
||||
#: index.docbook:486
|
||||
msgid ""
|
||||
"<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis> "
|
||||
"<literal>org.hibernate.tool.hbm2ddl.SchemaValidator</literal> "
|
||||
"<emphasis>options mapping_files</emphasis>"
|
||||
msgstr ""
|
||||
"<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis> "
|
||||
"<literal>org.hibernate.tool.hbm2ddl.SchemaValidator</literal> "
|
||||
"<emphasis>options mapping_files</emphasis>"
|
||||
|
||||
#: index.docbook:492
|
||||
msgid "<literal>SchemaValidator</literal> Command Line Options"
|
||||
msgstr "<literal>SchemaValidator</literal> Command Line Options"
|
||||
|
||||
#: index.docbook:519
|
||||
msgid "You may embed <literal>SchemaValidator</literal> in your application:"
|
||||
msgstr "You may embed <literal>SchemaValidator</literal> in your application:"
|
||||
|
||||
#: index.docbook:523
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaValidator(cfg).validate();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
" new SchemaValidator"
|
||||
"(cfg).validate();]]>"
|
||||
|
||||
#: index.docbook:528
|
||||
msgid "Using Ant for schema validation"
|
||||
msgstr "Using Ant for schema validation"
|
||||
|
||||
#: index.docbook:530
|
||||
msgid "You can call <literal>SchemaValidator</literal> from the Ant script:"
|
||||
msgstr "You can call <literal>SchemaValidator</literal> from the Ant script:"
|
||||
|
||||
#: index.docbook:534
|
||||
msgid ""
|
||||
"<![CDATA[<target name=\"schemavalidate\">\n"
|
||||
" <taskdef name=\"schemavalidator\"\n"
|
||||
" classname=\"org.hibernate.tool.hbm2ddl.SchemaValidatorTask\"\n"
|
||||
" classpathref=\"class.path\"/>\n"
|
||||
" \n"
|
||||
" <schemavalidator\n"
|
||||
" properties=\"hibernate.properties\">\n"
|
||||
" <fileset dir=\"src\">\n"
|
||||
" <include name=\"**/*.hbm.xml\"/>\n"
|
||||
" </fileset>\n"
|
||||
" </schemavalidator>\n"
|
||||
"</target>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<target name=\"schemavalidate\">\n"
|
||||
" <taskdef name=\"schemavalidator\"\n"
|
||||
" classname=\"org.hibernate.tool."
|
||||
"hbm2ddl.SchemaValidatorTask\"\n"
|
||||
" classpathref=\"class.path\"/>\n"
|
||||
" \n"
|
||||
" <schemavalidator\n"
|
||||
" properties=\"hibernate."
|
||||
"properties\">\n"
|
||||
" <fileset dir=\"src\">\n"
|
||||
" <include name=\"**/*.hbm.xml"
|
||||
"\"/>\n"
|
||||
" </fileset>\n"
|
||||
" </schemavalidator>\n"
|
||||
" </target>]]>"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,520 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#: index.docbook:5
|
||||
msgid "XML Mapping"
|
||||
msgstr "Mapeo XML"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid ""
|
||||
"Note that this is an experimental feature in Hibernate 3.0 and is under "
|
||||
"extremely active development."
|
||||
msgstr ""
|
||||
"Nota que esta es una funcionalidad experimental en Hibernate 3.0 y está bajo "
|
||||
"un desarrollo extremadamente activo."
|
||||
|
||||
#: index.docbook:13
|
||||
msgid "Working with XML data"
|
||||
msgstr "Trabajando con datos XML"
|
||||
|
||||
#: index.docbook:15
|
||||
msgid ""
|
||||
"Hibernate lets you work with persistent XML data in much the same way you "
|
||||
"work with persistent POJOs. A parsed XML tree can be thought of as just "
|
||||
"another way to represent the relational data at the object level, instead of "
|
||||
"POJOs."
|
||||
msgstr ""
|
||||
"Hibernate te permite trabajar con datos XML persistentes en casi la misma "
|
||||
"forma que trabajas con POJOs persistentes. Un árbol XML analizado (parsed) "
|
||||
"puede ser pensado como sólo otra forma de representar los datos relacionales "
|
||||
"a nivel de objetos, en vez de POJOs."
|
||||
|
||||
#: index.docbook:22
|
||||
msgid ""
|
||||
"Hibernate supports dom4j as API for manipulating XML trees. You can write "
|
||||
"queries that retrieve dom4j trees from the database and have any "
|
||||
"modification you make to the tree automatically synchronized to the "
|
||||
"database. You can even take an XML document, parse it using dom4j, and write "
|
||||
"it to the database with any of Hibernate's basic operations: <literal>persist"
|
||||
"(), saveOrUpdate(), merge(), delete(), replicate()</literal> (merging is not "
|
||||
"yet supported)."
|
||||
msgstr ""
|
||||
"Hibernate soporta dom4j como API para manipular árboles XML. Puedes escribir "
|
||||
"consultas que traigan árboles dom4j de la base de datos y tener cualquier "
|
||||
"modificación que hagas al árbol sincronizada automáticamente a la base de "
|
||||
"datos. Puedes incluso tomar un documento XML, analizarlo usando dom4j, y "
|
||||
"escribirlo a la base de datos con cualquiera de las operaciones básicas de "
|
||||
"Hibernate: <literal>persist(), saveOrUpdate(), merge(), delete(), replicate()"
|
||||
"</literal> (la fusión no está aún soportada)."
|
||||
|
||||
#: index.docbook:32
|
||||
msgid ""
|
||||
"This feature has many applications including data import/export, "
|
||||
"externalization of entity data via JMS or SOAP and XSLT-based reporting."
|
||||
msgstr ""
|
||||
"Esta funcionalidad tiene muchas aplicaciones incluyendo la importación/"
|
||||
"exportación de datos, externalización de datos de entidad vía JMS o SOAP y "
|
||||
"reportes basados en XSLT."
|
||||
|
||||
#: index.docbook:37
|
||||
msgid ""
|
||||
"A single mapping may be used to simultaneously map properties of a class and "
|
||||
"nodes of an XML document to the database, or, if there is no class to map, "
|
||||
"it may be used to map just the XML."
|
||||
msgstr ""
|
||||
"Un solo mapeo puede ser usado para mapear simultáneamente las propiedades de "
|
||||
"una clase y los nodos de un documento XML a la base de datos, o, si no hay "
|
||||
"ninguna clase a mapear, puede ser usado para mapear sólo el XML."
|
||||
|
||||
#: index.docbook:44
|
||||
msgid "Specifying XML and class mapping together"
|
||||
msgstr "Especificando los mapeos de XML y de clase juntos"
|
||||
|
||||
#: index.docbook:46
|
||||
msgid "Here is an example of mapping a POJO and XML simultaneously:"
|
||||
msgstr "He aquí un ejemplo de mapear un POJO y XML simultáneamente:"
|
||||
|
||||
#: index.docbook:50
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Account\" \n"
|
||||
" table=\"ACCOUNTS\" \n"
|
||||
" node=\"account\">\n"
|
||||
" \n"
|
||||
" <id name=\"accountId\" \n"
|
||||
" column=\"ACCOUNT_ID\" \n"
|
||||
" node=\"@id\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"customer\" \n"
|
||||
" column=\"CUSTOMER_ID\" \n"
|
||||
" node=\"customer/@id\" \n"
|
||||
" embed-xml=\"false\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"balance\" \n"
|
||||
" column=\"BALANCE\" \n"
|
||||
" node=\"balance\"/>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Account\" \n"
|
||||
" table=\"ACCOUNTS\" \n"
|
||||
" node=\"account\">\n"
|
||||
" \n"
|
||||
" <id name=\"accountId\" \n"
|
||||
" column=\"ACCOUNT_ID\" \n"
|
||||
" node=\"@id\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"customer\" \n"
|
||||
" column=\"CUSTOMER_ID\" \n"
|
||||
" node=\"customer/@id\" \n"
|
||||
" embed-xml=\"false\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"balance\" \n"
|
||||
" column=\"BALANCE\" \n"
|
||||
" node=\"balance\"/>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:54
|
||||
msgid "Specifying only an XML mapping"
|
||||
msgstr "Especificando sólo un mapeo XML"
|
||||
|
||||
#: index.docbook:56
|
||||
msgid "Here is an example where there is no POJO class:"
|
||||
msgstr "He aquí un ejemplo donde no hay ninguna clase POJO:"
|
||||
|
||||
#: index.docbook:60
|
||||
msgid ""
|
||||
"<![CDATA[<class entity-name=\"Account\" \n"
|
||||
" table=\"ACCOUNTS\" \n"
|
||||
" node=\"account\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\" \n"
|
||||
" column=\"ACCOUNT_ID\" \n"
|
||||
" node=\"@id\" \n"
|
||||
" type=\"string\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"customerId\" \n"
|
||||
" column=\"CUSTOMER_ID\" \n"
|
||||
" node=\"customer/@id\" \n"
|
||||
" embed-xml=\"false\" \n"
|
||||
" entity-name=\"Customer\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"balance\" \n"
|
||||
" column=\"BALANCE\" \n"
|
||||
" node=\"balance\" \n"
|
||||
" type=\"big_decimal\"/>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class entity-name=\"Account\" \n"
|
||||
" table=\"ACCOUNTS\" \n"
|
||||
" node=\"account\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\" \n"
|
||||
" column=\"ACCOUNT_ID\" \n"
|
||||
" node=\"@id\" \n"
|
||||
" type=\"string\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"customerId\" \n"
|
||||
" column=\"CUSTOMER_ID\" \n"
|
||||
" node=\"customer/@id\" \n"
|
||||
" embed-xml=\"false\" \n"
|
||||
" entity-name=\"Customer\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"balance\" \n"
|
||||
" column=\"BALANCE\" \n"
|
||||
" node=\"balance\" \n"
|
||||
" type=\"big_decimal\"/>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:62
|
||||
msgid ""
|
||||
"This mapping allows you to access the data as a dom4j tree, or as a graph of "
|
||||
"property name/value pairs (java <literal>Map</literal>s). The property names "
|
||||
"are purely logical constructs that may be referred to in HQL queries."
|
||||
msgstr ""
|
||||
"Este mapeo te permite acceder a los datos como un árbol dom4j, o como un "
|
||||
"grafo de pares nombre/valor de propiedad (<literal>Map</literal>s de Java). "
|
||||
"Los nombres de propiedades son construcciones puramente lógicas a las que se "
|
||||
"puede hacer referencia en consultas HQL."
|
||||
|
||||
#: index.docbook:73
|
||||
msgid "XML mapping metadata"
|
||||
msgstr "Mapeo de metadatos XML"
|
||||
|
||||
#: index.docbook:75
|
||||
msgid ""
|
||||
"Many Hibernate mapping elements accept the <literal>node</literal> "
|
||||
"attribute. This let's you specify the name of an XML attribute or element "
|
||||
"that holds the property or entity data. The format of the <literal>node</"
|
||||
"literal> attribute must be one of the following:"
|
||||
msgstr ""
|
||||
"Muchos elementos de mapeo de Hibernate aceptan el atributo <literal>node</"
|
||||
"literal>. Esto te permite espcificar el nombre de un atributo o elemento XML "
|
||||
"que contenga los datos de la propiedad o entidad. El formato del atributo "
|
||||
"<literal>node</literal> debe ser uno de los siguientes:"
|
||||
|
||||
#: index.docbook:84
|
||||
msgid "<literal>\"element-name\"</literal> - map to the named XML element"
|
||||
msgstr "<literal>\"element-name\"</literal> - mapea al elemento XML mencionado"
|
||||
|
||||
#: index.docbook:87
|
||||
msgid "<literal>\"@attribute-name\"</literal> - map to the named XML attribute"
|
||||
msgstr ""
|
||||
"<literal>\"@attribute-name\"</literal> - mapea al atributo XML mencionado"
|
||||
|
||||
#: index.docbook:90
|
||||
msgid "<literal>\".\"</literal> - map to the parent element"
|
||||
msgstr "<literal>\".\"</literal> - mapea al elemento padre"
|
||||
|
||||
#: index.docbook:93
|
||||
msgid ""
|
||||
"<literal>\"element-name/@attribute-name\"</literal> - map to the named "
|
||||
"attribute of the named element"
|
||||
msgstr ""
|
||||
"<literal>\"element-name/@attribute-name\"</literal> - mapea al atributo "
|
||||
"mencionado del elemento mencionado"
|
||||
|
||||
#: index.docbook:100
|
||||
msgid ""
|
||||
"For collections and single valued associations, there is an additional "
|
||||
"<literal>embed-xml</literal> attribute. If <literal>embed-xml=\"true\"</"
|
||||
"literal>, the default, the XML tree for the associated entity (or collection "
|
||||
"of value type) will be embedded directly in the XML tree for the entity that "
|
||||
"owns the association. Otherwise, if <literal>embed-xml=\"false\"</literal>, "
|
||||
"then only the referenced identifier value will appear in the XML for single "
|
||||
"point associations and collections will simply not appear at all."
|
||||
msgstr ""
|
||||
"Para las colecciones y asociaciones monovaluadas, existe un atributo "
|
||||
"adicional <literal>embed-xml</literal>. Si <literal>embed-xml=\"true\"</"
|
||||
"literal>, que es el valor por defecto, el árbol XML para la entidad asociada "
|
||||
"(o colección de tipo de valor) será embebida directamente en el árbol XML "
|
||||
"para la entidad que posee la asociación. En otro caso, si <literal>embed-xml="
|
||||
"\"false\"</literal>, sólo el valor identificador referenciado aparecerá en "
|
||||
"el XML para asociaciones de punto único y para las colecciones simplemente "
|
||||
"no aparecerá en absoluto."
|
||||
|
||||
#: index.docbook:110
|
||||
msgid ""
|
||||
"You should be careful not to leave <literal>embed-xml=\"true\"</literal> for "
|
||||
"too many associations, since XML does not deal well with circularity!"
|
||||
msgstr ""
|
||||
"¡Debes ser cuidadoso de no dejar <literal>embed-xml=\"true\"</literal> para "
|
||||
"demasiadas asociaciones, ya que XML no trata bien la circularidad!"
|
||||
|
||||
#: index.docbook:115
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Customer\" \n"
|
||||
" table=\"CUSTOMER\" \n"
|
||||
" node=\"customer\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\" \n"
|
||||
" column=\"CUST_ID\" \n"
|
||||
" node=\"@id\"/>\n"
|
||||
" \n"
|
||||
" <map name=\"accounts\" \n"
|
||||
" node=\".\" \n"
|
||||
" embed-xml=\"true\">\n"
|
||||
" <key column=\"CUSTOMER_ID\" \n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" <map-key column=\"SHORT_DESC\" \n"
|
||||
" node=\"@short-desc\" \n"
|
||||
" type=\"string\"/>\n"
|
||||
" <one-to-many entity-name=\"Account\"\n"
|
||||
" embed-xml=\"false\" \n"
|
||||
" node=\"account\"/>\n"
|
||||
" </map>\n"
|
||||
" \n"
|
||||
" <component name=\"name\" \n"
|
||||
" node=\"name\">\n"
|
||||
" <property name=\"firstName\" \n"
|
||||
" node=\"first-name\"/>\n"
|
||||
" <property name=\"initial\" \n"
|
||||
" node=\"initial\"/>\n"
|
||||
" <property name=\"lastName\" \n"
|
||||
" node=\"last-name\"/>\n"
|
||||
" </component>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Customer\" \n"
|
||||
" table=\"CUSTOMER\" \n"
|
||||
" node=\"customer\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\" \n"
|
||||
" column=\"CUST_ID\" \n"
|
||||
" node=\"@id\"/>\n"
|
||||
" \n"
|
||||
" <map name=\"accounts\" \n"
|
||||
" node=\".\" \n"
|
||||
" embed-xml=\"true\">\n"
|
||||
" <key column=\"CUSTOMER_ID\" \n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" <map-key column=\"SHORT_DESC\" \n"
|
||||
" node=\"@short-desc\" \n"
|
||||
" type=\"string\"/>\n"
|
||||
" <one-to-many entity-name=\"Account\"\n"
|
||||
" embed-xml=\"false\" \n"
|
||||
" node=\"account\"/>\n"
|
||||
" </map>\n"
|
||||
" \n"
|
||||
" <component name=\"name\" \n"
|
||||
" node=\"name\">\n"
|
||||
" <property name=\"firstName\" \n"
|
||||
" node=\"first-name\"/>\n"
|
||||
" <property name=\"initial\" \n"
|
||||
" node=\"initial\"/>\n"
|
||||
" <property name=\"lastName\" \n"
|
||||
" node=\"last-name\"/>\n"
|
||||
" </component>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:117
|
||||
msgid ""
|
||||
"in this case, we have decided to embed the collection of account ids, but "
|
||||
"not the actual account data. The following HQL query:"
|
||||
msgstr ""
|
||||
"en este caso, hemos decidido embeber la colección de ids de cuenta, pero no "
|
||||
"los datos reales de cuenta. La siguiente consulta HQL:"
|
||||
|
||||
#: index.docbook:122
|
||||
msgid ""
|
||||
"<![CDATA[from Customer c left join fetch c.accounts where c.lastName like :"
|
||||
"lastName]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[from Customer c left join fetch c.accounts where c.lastName like :"
|
||||
"lastName]]>"
|
||||
|
||||
#: index.docbook:124
|
||||
msgid "Would return datasets such as this:"
|
||||
msgstr "devolvería conjuntos de datos como estos:"
|
||||
|
||||
#: index.docbook:128
|
||||
msgid ""
|
||||
"<![CDATA[<customer id=\"123456789\">\n"
|
||||
" <account short-desc=\"Savings\">987632567</account>\n"
|
||||
" <account short-desc=\"Credit Card\">985612323</account>\n"
|
||||
" <name>\n"
|
||||
" <first-name>Gavin</first-name>\n"
|
||||
" <initial>A</initial>\n"
|
||||
" <last-name>King</last-name>\n"
|
||||
" </name>\n"
|
||||
" ...\n"
|
||||
"</customer>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<customer id=\"123456789\">\n"
|
||||
" <account short-desc=\"Savings\">987632567</account>\n"
|
||||
" <account short-desc=\"Credit Card\">985612323</account>\n"
|
||||
" <name>\n"
|
||||
" <first-name>Gavin</first-name>\n"
|
||||
" <initial>A</initial>\n"
|
||||
" <last-name>King</last-name>\n"
|
||||
" </name>\n"
|
||||
" ...\n"
|
||||
"</customer>]]>"
|
||||
|
||||
#: index.docbook:130
|
||||
msgid ""
|
||||
"If you set <literal>embed-xml=\"true\"</literal> on the <literal><one-to-"
|
||||
"many></literal> mapping, the data might look more like this:"
|
||||
msgstr ""
|
||||
"Si estableces <literal>embed-xml=\"true\"</literal> en el mapeo <literal><"
|
||||
"one-to-many></literal>, los datos podrían verse así:"
|
||||
|
||||
#: index.docbook:135
|
||||
msgid ""
|
||||
"<![CDATA[<customer id=\"123456789\">\n"
|
||||
" <account id=\"987632567\" short-desc=\"Savings\">\n"
|
||||
" <customer id=\"123456789\"/>\n"
|
||||
" <balance>100.29</balance>\n"
|
||||
" </account>\n"
|
||||
" <account id=\"985612323\" short-desc=\"Credit Card\">\n"
|
||||
" <customer id=\"123456789\"/>\n"
|
||||
" <balance>-2370.34</balance>\n"
|
||||
" </account>\n"
|
||||
" <name>\n"
|
||||
" <first-name>Gavin</first-name>\n"
|
||||
" <initial>A</initial>\n"
|
||||
" <last-name>King</last-name>\n"
|
||||
" </name>\n"
|
||||
" ...\n"
|
||||
"</customer>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<customer id=\"123456789\">\n"
|
||||
" <account id=\"987632567\" short-desc=\"Savings\">\n"
|
||||
" <customer id=\"123456789\"/>\n"
|
||||
" <balance>100.29</balance>\n"
|
||||
" </account>\n"
|
||||
" <account id=\"985612323\" short-desc=\"Credit Card\">\n"
|
||||
" <customer id=\"123456789\"/>\n"
|
||||
" <balance>-2370.34</balance>\n"
|
||||
" </account>\n"
|
||||
" <name>\n"
|
||||
" <first-name>Gavin</first-name>\n"
|
||||
" <initial>A</initial>\n"
|
||||
" <last-name>King</last-name>\n"
|
||||
" </name>\n"
|
||||
" ...\n"
|
||||
"</customer>]]>"
|
||||
|
||||
#: index.docbook:141
|
||||
msgid "Manipulating XML data"
|
||||
msgstr "Manipulando datos XML"
|
||||
|
||||
#: index.docbook:143
|
||||
msgid ""
|
||||
"Let's rearead and update XML documents in the application. We do this by "
|
||||
"obtaining a dom4j session:"
|
||||
msgstr ""
|
||||
"Vamos a releer y actualizar documentos XML en la aplicación. Hacemos esto "
|
||||
"obteniendo una sesión dom4j:"
|
||||
|
||||
#: index.docbook:148
|
||||
msgid ""
|
||||
"<![CDATA[Document doc = ....;\n"
|
||||
" \n"
|
||||
"Session session = factory.openSession();\n"
|
||||
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"List results = dom4jSession\n"
|
||||
" .createQuery(\"from Customer c left join fetch c.accounts where c."
|
||||
"lastName like :lastName\")\n"
|
||||
" .list();\n"
|
||||
"for ( int i=0; i<results.size(); i++ ) {\n"
|
||||
" //add the customer data to the XML document\n"
|
||||
" Element customer = (Element) results.get(i);\n"
|
||||
" doc.add(customer);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Document doc = ....;\n"
|
||||
" \n"
|
||||
"Session session = factory.openSession();\n"
|
||||
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"List results = dom4jSession\n"
|
||||
" .createQuery(\"from Customer c left join fetch c.accounts where c."
|
||||
"lastName like :lastName\")\n"
|
||||
" .list();\n"
|
||||
"for ( int i=0; i<results.size(); i++ ) {\n"
|
||||
" //add the customer data to the XML document\n"
|
||||
" Element customer = (Element) results.get(i);\n"
|
||||
" doc.add(customer);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:150
|
||||
msgid ""
|
||||
"<![CDATA[Session session = factory.openSession();\n"
|
||||
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"Element cust = (Element) dom4jSession.get(\"Customer\", customerId);\n"
|
||||
"for ( int i=0; i<results.size(); i++ ) {\n"
|
||||
" Element customer = (Element) results.get(i);\n"
|
||||
" //change the customer name in the XML and database\n"
|
||||
" Element name = customer.element(\"name\");\n"
|
||||
" name.element(\"first-name\").setText(firstName);\n"
|
||||
" name.element(\"initial\").setText(initial);\n"
|
||||
" name.element(\"last-name\").setText(lastName);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = factory.openSession();\n"
|
||||
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"Element cust = (Element) dom4jSession.get(\"Customer\", customerId);\n"
|
||||
"for ( int i=0; i<results.size(); i++ ) {\n"
|
||||
" Element customer = (Element) results.get(i);\n"
|
||||
" //change the customer name in the XML and database\n"
|
||||
" Element name = customer.element(\"name\");\n"
|
||||
" name.element(\"first-name\").setText(firstName);\n"
|
||||
" name.element(\"initial\").setText(initial);\n"
|
||||
" name.element(\"last-name\").setText(lastName);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:152
|
||||
msgid ""
|
||||
"It is extremely useful to combine this feature with Hibernate's "
|
||||
"<literal>replicate()</literal> operation to implement XML-based data import/"
|
||||
"export."
|
||||
msgstr ""
|
||||
"Es extremadamente útil combinar esta funcionalidad con la operación "
|
||||
"<literal>replicate()</literal> de Hibernate para implementar la importación/"
|
||||
"exportación de datos basada en XML."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
|
@ -0,0 +1,40 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
#: index.docbook:20
|
||||
msgid "Legal Notice"
|
||||
msgstr "Legal Notice"
|
||||
|
||||
#: index.docbook:22
|
||||
msgid "<street>1801 Varsity Drive</street> <city>Raleigh</city>, <state>NC</state><postcode>27606-2072</postcode><country>USA</country> <phone>Phone: +1 919 754 3700</phone> <phone>Phone: 888 733 4281</phone> <fax>Fax: +1 919 754 3701</fax> <pob>PO Box 13588</pob><city>Research Triangle Park</city>, <state>NC</state><postcode>27709</postcode><country>USA</country>"
|
||||
msgstr "<street>1801 Varsity Drive</street> <city>Raleigh</city>, <state>NC</state><postcode>27606-2072</postcode><country>USA</country> <phone>Phone: +1 919 754 3700</phone> <phone>Phone: 888 733 4281</phone> <fax>Fax: +1 919 754 3701</fax> <pob>PO Box 13588</pob><city>Research Triangle Park</city>, <state>NC</state><postcode>27709</postcode><country>USA</country>"
|
||||
|
||||
#: index.docbook:31
|
||||
msgid "Copyright <trademark class=\"copyright\"></trademark> 2007 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 <ulink url=\"http://www.gnu.org/licenses/lgpl-2.1.html\">Lesser General Public License</ulink>, as published by the Free Software Foundation."
|
||||
msgstr "Copyright <trademark class=\"copyright\"></trademark> 2007 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 <ulink url=\"http://www.gnu.org/licenses/lgpl-2.1.html\">Lesser General Public License</ulink>, as published by the Free Software Foundation."
|
||||
|
||||
#: index.docbook:40
|
||||
msgid "Red Hat and the Red Hat \"Shadow Man\" logo are registered trademarks of Red Hat, Inc. in the United States and other countries."
|
||||
msgstr "Red Hat and the Red Hat \"Shadow Man\" logo are registered trademarks of Red Hat, Inc. in the United States and other countries."
|
||||
|
||||
#: index.docbook:43
|
||||
msgid "All other trademarks referenced herein are the property of their respective owners."
|
||||
msgstr "All other trademarks referenced herein are the property of their respective owners."
|
||||
|
||||
#: index.docbook:46
|
||||
msgid "The GPG fingerprint of the security@redhat.com key is:"
|
||||
msgstr "The GPG fingerprint of the security@redhat.com key is:"
|
||||
|
||||
#: index.docbook:49
|
||||
msgid "CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E"
|
||||
msgstr "CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
#: index.docbook:26
|
||||
msgid "HIBERNATE - Relational Persistence for Idiomatic Java"
|
||||
msgstr "HIBERNATE - Persistance relationnelle en Java standard"
|
||||
|
||||
#: index.docbook:27
|
||||
msgid "Hibernate Reference Documentation"
|
||||
msgstr "Documentation de référence d'Hibernate"
|
||||
|
||||
#: index.docbook:41
|
||||
msgid "©rightHolder;"
|
||||
msgstr "©rightHolder;"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,652 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: architecture.xml:30
|
||||
#, no-c-format
|
||||
msgid "Architecture"
|
||||
msgstr "Architecture"
|
||||
|
||||
#. Tag: title
|
||||
#: architecture.xml:33
|
||||
#, no-c-format
|
||||
msgid "Overview"
|
||||
msgstr "Généralités"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:35
|
||||
#, no-c-format
|
||||
msgid "A (very) high-level view of the Hibernate architecture:"
|
||||
msgstr "Voici une vue (très) haut niveau de l'architecture d'Hibernate :"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:48
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This diagram shows Hibernate using the database and configuration data to "
|
||||
"provide persistence services (and persistent objects) to the application."
|
||||
msgstr ""
|
||||
"Ce diagramme montre Hibernate utilisant une base de données et des données "
|
||||
"de configuration pour fournir un service de persistance (et des objets "
|
||||
"persistants) à l'application."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:53
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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:"
|
||||
msgstr ""
|
||||
"Nous aimerions décrire une vue plus détaillée de l'architecture. "
|
||||
"Malheureusement, Hibernate est flexible et supporte différentes approches. "
|
||||
"Nous allons en montrer les deux extrêmes. L'architecture légère laisse "
|
||||
"l'application fournir ses propres connexions JDBC et gérer ses propres "
|
||||
"transactions. Cette approche utilise le minimum des APIs Hibernate :"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:70
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The \"full cream\" architecture abstracts the application away from the "
|
||||
"underlying JDBC/JTA APIs and lets Hibernate take care of the details."
|
||||
msgstr ""
|
||||
"L'architecture la plus complète abstrait l'application des APIs JDBC/JTA "
|
||||
"sous-jacentes et laisse Hibernate s'occuper des détails."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:84
|
||||
#, fuzzy, no-c-format
|
||||
msgid "Heres some definitions of the objects in the diagrams:"
|
||||
msgstr ""
|
||||
"Voici quelques définitions des objets des diagrammes : <placeholder-1/>"
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:89
|
||||
#, no-c-format
|
||||
msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
|
||||
msgstr "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:91
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Un cache threadsafe (immuable) des mappings vers une (et une seule) base de "
|
||||
"données. Une factory (fabrique) de <literal>Session</literal> et un client "
|
||||
"de <literal>ConnectionProvider</literal>. Peut contenir un cache optionnel "
|
||||
"de données (de second niveau) qui est réutilisable entre les différentes "
|
||||
"transactions que cela soit au sein du même processus (JVLM) ou par plusieurs "
|
||||
"nœuds d'un cluster."
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:101
|
||||
#, no-c-format
|
||||
msgid "Session (<literal>org.hibernate.Session</literal>)"
|
||||
msgstr "Session (<literal>org.hibernate.Session</literal>)"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:103
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Un objet mono-threadé, à durée de vie courte, qui représente une "
|
||||
"conversation entre l'application et l'entrepôt de persistance. Encapsule une "
|
||||
"connexion JDBC. Factory (fabrique) des objets <literal>Transaction</"
|
||||
"literal>. Contient un cache (de premier niveau) des objets persistants, ce "
|
||||
"cache est obligatoire. Il est utilisé lors de la navigation dans le graphe "
|
||||
"d'objets ou lors de la récupération d'objets par leur identifiant."
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:113
|
||||
#, no-c-format
|
||||
msgid "Persistent objects and collections"
|
||||
msgstr "Objets et Collections persistants"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:115
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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)."
|
||||
msgstr ""
|
||||
"Objets mono-threadés à vie courte contenant l'état de persistance et la "
|
||||
"fonction métier. Ceux-ci sont en général les objets de type JavaBean (ou "
|
||||
"POJOs) ; la seule particularité est qu'ils sont associés avec une (et une "
|
||||
"seule) <literal>Session</literal>. Dès que la <literal>Session</literal> est "
|
||||
"fermée, ils seront détachés et libres d'être utilisés par n'importe laquelle "
|
||||
"des couches de l'application (ie. de et vers la présentation en tant que "
|
||||
"Data Transfer Objects - DTO : objet de transfert de données)."
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:126
|
||||
#, no-c-format
|
||||
msgid "Transient and detached objects and collections"
|
||||
msgstr "Objets et collections transients"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:128
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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>."
|
||||
msgstr ""
|
||||
"Instances de classes persistantes qui ne sont actuellement pas associées à "
|
||||
"une <literal>Session</literal>. Elles ont pu être instanciées par "
|
||||
"l'application et ne pas avoir (encore) été persistées ou elle ont pu être "
|
||||
"instanciées par une <literal>Session</literal> fermée."
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:137
|
||||
#, no-c-format
|
||||
msgid "Transaction (<literal>org.hibernate.Transaction</literal>)"
|
||||
msgstr "Transaction (<literal>org.hibernate.Transaction</literal>)"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:139
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"(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!"
|
||||
msgstr ""
|
||||
"(Optionnel) Un objet mono-threadé à vie courte utilisé par l'application "
|
||||
"pour définir une unité de travail atomique. Abstrait l'application des "
|
||||
"transactions sous-jacentes qu'elles soient JDBC, JTA ou CORBA. Une "
|
||||
"<literal>Session</literal> peut fournir plusieurs <literal>Transaction</"
|
||||
"literal>s dans certains cas. Toutefois, la délimitation des transactions, "
|
||||
"via l'API d'Hibernate ou par la <literal>Transaction</literal> sous-jacente, "
|
||||
"n'est jamais optionnelle!"
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:150
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
|
||||
"literal>)"
|
||||
msgstr ""
|
||||
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
|
||||
"literal>)"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:152
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"(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."
|
||||
msgstr ""
|
||||
"(Optionnel) Une fabrique de (pool de) connexions JDBC. Abstrait "
|
||||
"l'application de la <literal>Datasource</literal> ou du "
|
||||
"<literal>DriverManager</literal> sous-jacent. Non exposé à l'application, "
|
||||
"mais peut être étendu/implémenté par le développeur."
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:160
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
|
||||
msgstr ""
|
||||
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:162
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"(Optional) A factory for <literal>Transaction</literal> instances. Not "
|
||||
"exposed to the application, but can be extended/implemented by the developer."
|
||||
msgstr ""
|
||||
"(Optionnel) Une fabrique d'instances de <literal>Transaction</literal>. Non "
|
||||
"exposé à l'application, mais peut être étendu/implémenté par le développeur."
|
||||
|
||||
#. Tag: emphasis
|
||||
#: architecture.xml:169
|
||||
#, no-c-format
|
||||
msgid "Extension Interfaces"
|
||||
msgstr "Interfaces d'extension"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:171
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate offers many optional extension interfaces you can implement to "
|
||||
"customize the behavior of your persistence layer. See the API documentation "
|
||||
"for details."
|
||||
msgstr ""
|
||||
"Hibernate fournit de nombreuses interfaces d'extensions optionnelles que "
|
||||
"vous pouvez implémenter pour personnaliser le comportement de votre couche "
|
||||
"de persistance. Reportez vous à la documentation de l'API pour plus de "
|
||||
"détails."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:180
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Dans une architecture légère, l'application n'aura pas à utiliser les APIs "
|
||||
"<literal>Transaction</literal>/<literal>TransactionFactory</literal> et/ou "
|
||||
"n'utilisera pas les APIs <literal>ConnectionProvider</literal> pour utiliser "
|
||||
"JTA ou JDBC."
|
||||
|
||||
#. Tag: title
|
||||
#: architecture.xml:188
|
||||
#, no-c-format
|
||||
msgid "Instance states"
|
||||
msgstr "Etats des instances"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:189
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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:"
|
||||
msgstr ""
|
||||
"Une instance d'une classe persistante peut être dans l'un des trois états "
|
||||
"suivants, définis par rapport à un <emphasis>contexte de persistance</"
|
||||
"emphasis>. L'objet <literal>Session</literal> d'hibernate correspond à ce "
|
||||
"concept de contexte de persistance :"
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:197
|
||||
#, no-c-format
|
||||
msgid "transient"
|
||||
msgstr "passager (transient)"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:199
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The instance is not, and has never been associated with any persistence "
|
||||
"context. It has no persistent identity (primary key value)."
|
||||
msgstr ""
|
||||
"L'instance n'est pas et n'a jamais été associée à un contexte de "
|
||||
"persistance. Elle ne possède pas d'identité persistante (valeur de clé "
|
||||
"primaire)"
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:207
|
||||
#, no-c-format
|
||||
msgid "persistent"
|
||||
msgstr "persistant"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:209
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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)."
|
||||
msgstr ""
|
||||
"L'instance est associée au contexte de persistance. Elle possède une "
|
||||
"identité persistante (valeur de clé primaire) et, peut-être, un "
|
||||
"enregistrement correspondant dans la base. Pour un contexte de persistance "
|
||||
"particulier, Hibernate <emphasis>garantit</emphasis> que l'identité "
|
||||
"persistante est équivalente à l'identité Java (emplacement mémoire de "
|
||||
"l'objet)"
|
||||
|
||||
#. Tag: term
|
||||
#: architecture.xml:221
|
||||
#, no-c-format
|
||||
msgid "detached"
|
||||
msgstr "détaché"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:223
|
||||
#, fuzzy, no-c-format
|
||||
msgid ""
|
||||
"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 corresponding row in the database. "
|
||||
"For detached instances, Hibernate makes no guarantees about the relationship "
|
||||
"between persistent identity and Java identity."
|
||||
msgstr ""
|
||||
"L'instance a été associée au contexte de persistance mais ce contexte a été "
|
||||
"fermé, ou l'instance a été sérialisée vers un autre processus. Elle possède "
|
||||
"une identité persistante et peut-être un enregistrement correspondant dans "
|
||||
"la base. Pour des instances détachées, Hibernate ne donne aucune garantie "
|
||||
"sur la relation entre l'identité persistante et l'identité Java."
|
||||
|
||||
#. Tag: title
|
||||
#: architecture.xml:238
|
||||
#, no-c-format
|
||||
msgid "JMX Integration"
|
||||
msgstr "Intégration JMX"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:240
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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>."
|
||||
msgstr ""
|
||||
"JMX est le standard J2EE de gestion des composants Java. Hibernate peut être "
|
||||
"géré via un service JMX standard. Nous fournissons une implémentation d'un "
|
||||
"MBean dans la distribution : <literal>org.hibernate.jmx.HibernateService</"
|
||||
"literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:246
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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:"
|
||||
msgstr ""
|
||||
"Pour avoir un exemple sur la manière de déployer Hibernate en tant que "
|
||||
"service JMX dans le serveur d'application JBoss Application Server, référez "
|
||||
"vous au guide utilisateur JBoss (JBoss User Guide). Si vous déployez "
|
||||
"Hibernate via JMX sur JBoss AS, vous aurez également les bénéfices suivants :"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:254
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<emphasis>Session Management:</emphasis> The Hibernate <literal>Session</"
|
||||
"literal>'s life cycle 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>."
|
||||
msgstr ""
|
||||
"<emphasis>Gestion de la session :</emphasis> Le cycle de vie de la "
|
||||
"<literal>Session</literal> Hibernate peut être automatiquement limitée à la "
|
||||
"portée d'une transaction JTA. Cela signifie que vous n'avez plus besoin "
|
||||
"d'ouvrir et de fermer la <literal>Session</literal> manuellement, cela "
|
||||
"devient le travail de l'intercepteur EJB de JBoss. Vous n'avez pas non plus "
|
||||
"à vous occuper des démarcations des transactions dans votre code (sauf si "
|
||||
"vous voulez écrire une couche de persistance qui soit portable, dans ce cas "
|
||||
"vous pouvez utiliser l'API optionnelle <literal>Transaction</literal> "
|
||||
"d'Hibernate). Vous appelez l'<literal>HibernateContext</literal> pour "
|
||||
"accéder à la <literal>Session</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:266
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<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."
|
||||
msgstr ""
|
||||
"<emphasis>Déploiement HAR :</emphasis> Habituellement vous déployez le "
|
||||
"service JMX Hibernate en utilisant le descripteur de déploiement de JBoss "
|
||||
"(dans un fichier EAR et/ou un SAR), il supporte toutes les options de "
|
||||
"configuration usuelles d'une <literal>SessionFactory</literal> Hibernate. "
|
||||
"Cependant, vous devez toujours nommer tous vos fichiers de mapping dans le "
|
||||
"descripteur de déploiement. Si vous décidez d'utiliser le déploiement "
|
||||
"optionnel sous forme de HAR, JBoss détectera automatiquement tous vos "
|
||||
"fichiers de mapping dans votre fichier HAR."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:277
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Consult the JBoss AS user guide for more information about these options."
|
||||
msgstr ""
|
||||
"Consultez le guide d'utilisation de JBoss AS pour plus d'informations sur "
|
||||
"ces options."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:281
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Another feature available as a JMX service are runtime Hibernate statistics. "
|
||||
"See <xref linkend=\"configuration-optional-statistics\"/>."
|
||||
msgstr ""
|
||||
"Les statistiques pendant l'exécution d'Hibernate (au runtime) sont une autre "
|
||||
"fonctionnalité disponible en tant que service JMX. Voyez pour cela <xref "
|
||||
"linkend=\"configuration-optional-statistics\"/>."
|
||||
|
||||
#. Tag: title
|
||||
#: architecture.xml:288
|
||||
#, no-c-format
|
||||
msgid "JCA Support"
|
||||
msgstr "Support JCA"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:289
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Hibernate peut aussi être configuré en tant que connecteur JCA. Référez-vous "
|
||||
"au site web pour de plus amples détails. Il est important de noter que le "
|
||||
"support JCA d'Hibernate est encore considéré comme expérimental."
|
||||
|
||||
#. Tag: title
|
||||
#: architecture.xml:296
|
||||
#, no-c-format
|
||||
msgid "Contextual Sessions"
|
||||
msgstr "Sessions Contextuelles"
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:297
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Certaines applications utilisant Hibernate ont besoin d'une sorte de session "
|
||||
"\"contextuelle\", où une session est liée à la portée d'un contexte "
|
||||
"particulier. Cependant, les applications ne définissent pas toutes la notion "
|
||||
"de contexte de la même manière, et différents contextes définissent "
|
||||
"différentes portées à la notion de \"courant\". Les applications à base "
|
||||
"d'Hibernate, versions précédentes à la 3.0 utilisaient généralement un "
|
||||
"principe maison de sessions contextuelles basées sur le "
|
||||
"<literal>ThreadLocal</literal>, ainsi que sur des classes utilitaires comme "
|
||||
"<literal>HibernateUtil</literal>, ou utilisaient des framework tiers (comme "
|
||||
"Spring ou Pico) qui fournissaient des sessions contextuelles basées sur "
|
||||
"l'utilisation de proxy/interception."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:306
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"A partir de la version 3.0.1, Hibernate a ajouté la méthode "
|
||||
"<literal>SessionFactory.getCurrentSession()</literal>. Initialement, cela "
|
||||
"demandait l'usage de transactions <literal>JTA</literal>, où la transaction "
|
||||
"<literal>JTA</literal> définissait la portée et le contexte de la session "
|
||||
"courante. L'équipe Hibernate pense que, étant donnée la maturité des "
|
||||
"implémentations de <literal>JTA TransactionManager</literal> , la plupart "
|
||||
"(sinon toutes) des applications devraient utiliser la gestion des "
|
||||
"transactions par <literal>JTA</literal> qu'elles soient ou non déployées "
|
||||
"dans un conteneur <literal>J2EE</literal>. Par conséquent, vous devriez "
|
||||
"toujours contextualiser vos sessions, si vous en avez besoin, via la méthode "
|
||||
"basée sur JTA."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:316
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Cependant, depuis la version 3.1, la logique derrière "
|
||||
"<literal>SessionFactory.getCurrentSession()</literal> est désormais "
|
||||
"branchable. A cette fin, une nouvelle interface d'extension (<literal>org."
|
||||
"hibernate.context.CurrentSessionContext</literal>) et un nouveau paramètre "
|
||||
"de configuration (<literal>hibernate.current_session_context_class</"
|
||||
"literal>) ont été ajoutés pour permettre de configurer d'autres moyens de "
|
||||
"définir la portée et le contexte des sessions courantes."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:323
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Allez voir les Javadocs de l'interface <literal>org.hibernate.context."
|
||||
"CurrentSessionContext</literal> pour une description détaillée de son "
|
||||
"contrat. Elle définit une seule méthode, <literal>currentSession()</"
|
||||
"literal>, depuis laquelle l'implémentation est responsable de traquer la "
|
||||
"session courante du contexte. Hibernate fournit deux implémentation de cette "
|
||||
"interface."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:333
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<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."
|
||||
msgstr ""
|
||||
"<literal>org.hibernate.context.JTASessionContext</literal> - les sessions "
|
||||
"courantes sont associées à une transaction <literal>JTA</literal>. La "
|
||||
"logique est la même que l'ancienne approche basée sur JTA. Voir les javadocs "
|
||||
"pour les détails."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:341
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current "
|
||||
"sessions are tracked by thread of execution. Again, see the Javadocs for "
|
||||
"details."
|
||||
msgstr ""
|
||||
"<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - les "
|
||||
"sessions courantes sont associées au thread d'exécution. Voir les javadocs "
|
||||
"pour les détails."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:347
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<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>."
|
||||
msgstr ""
|
||||
"<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>."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:356
|
||||
#, fuzzy, no-c-format
|
||||
msgid ""
|
||||
"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 programmatic "
|
||||
"transaction demarcation in plain JSE without JTA, you are advised 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."
|
||||
msgstr ""
|
||||
"Les deux implémentations fournissent un modèle de programmation de type "
|
||||
"\"une session - une transaction à la base de données\", aussi connu sous le "
|
||||
"nom de <emphasis>session-per-request</emphasis>. Le début et la fin d'une "
|
||||
"session Hibernate sont définis par la durée d'une transaction de base de "
|
||||
"données. Si vous utilisez une démarcation programmatique de la transaction "
|
||||
"(par exemple sous J2SE ou JTA/UserTransaction/BMT), nous vous conseillons "
|
||||
"d'utiliser l'API Hibernate <literal>Transaction</literal> pour masquer le "
|
||||
"système de transaction utilisé. Si vous exécutez sous un conteneur EJB qui "
|
||||
"supporte CMT, vous n'avez besoin d'aucune opérations de démarcations de "
|
||||
"session ou transaction dans votre code puisque tout est géré de manière "
|
||||
"déclarative. Référez vous à <xref linkend=\"transactions\"/> pour plus "
|
||||
"d'informations et des exemples de code."
|
||||
|
||||
#. Tag: para
|
||||
#: architecture.xml:368
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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 three corresponding short names, \"jta\", \"thread\", and "
|
||||
"\"managed\"."
|
||||
msgstr ""
|
||||
"Le paramètre de configuration <literal>hibernate."
|
||||
"current_session_context_class</literal> définit quelle implémentation de "
|
||||
"<literal>org.hibernate.context.CurrentSessionContext</literal> doit être "
|
||||
"utilisée. Notez que pour assurer la compatibilité avec les versions "
|
||||
"précédentes, si ce paramètre n'est pas défini mais qu'un <literal>org."
|
||||
"hibernate.transaction.TransactionManagerLookup</literal> est configuré, "
|
||||
"Hibernate utilisera le <literal>org.hibernate.context.JTASessionContext</"
|
||||
"literal>. La valeur de ce paramètre devrait juste nommer la classe "
|
||||
"d'implémentation à utiliser, pour les deux implémentations fournies, il y a "
|
||||
"cependant deux alias correspondant: \"jta\" et \"thread\"."
|
|
@ -0,0 +1,912 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:30
|
||||
#, no-c-format
|
||||
msgid "Association Mappings"
|
||||
msgstr "Mapper les associations"
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:33
|
||||
#, no-c-format
|
||||
msgid "Introduction"
|
||||
msgstr "Introduction"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:35
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Association mappings are the often most difficult thing to get right. In "
|
||||
"this section we'll go through the canonical cases one by one, starting with "
|
||||
"unidirectional mappings, and then considering the bidirectional cases. We'll "
|
||||
"use <literal>Person</literal> and <literal>Address</literal> in all the "
|
||||
"examples."
|
||||
msgstr ""
|
||||
"Correctement mapper les associations est souvent la tâche la plus difficile. "
|
||||
"Dans cette section nous traiterons les cas classiques les uns après les "
|
||||
"autres. Nous commencerons d'abbord par les mappings unidirectionnels, puis "
|
||||
"nous aborderons la question des mappings bidirectionnels. Nous illustrerons "
|
||||
"tous nos exemples avec les classes <literal>Person</literal> et "
|
||||
"<literal>Address</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:43
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"We'll classify associations by whether or not they map to an intervening "
|
||||
"join table, and by multiplicity."
|
||||
msgstr ""
|
||||
"Nous utiliserons deux critères pour classer les associations : le premier "
|
||||
"sera de savoir si l'association est bâti sur une table supplémentaire "
|
||||
"d'association et le deuxieme sera basé sur la multiplicité de cette "
|
||||
"association."
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:48
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Nullable foreign keys are not considered good practice in traditional data "
|
||||
"modelling, so all our examples use not null foreign keys. This is not a "
|
||||
"requirement of Hibernate, and the mappings will all work if you drop the "
|
||||
"nullability constraints."
|
||||
msgstr ""
|
||||
"Autoriser une clé étrangère nulle est considéré comme un mauvais choix dans "
|
||||
"la construction d'un modèle de données. Nous supposerons donc que dans tous "
|
||||
"les exemples qui vont suivre on aura interdit la valeur nulle pour les clés "
|
||||
"étrangères. Attention, ceci ne veut pas dire que Hibernate ne supporte pas "
|
||||
"les clés étrangères pouvant prendre des valeurs nulles, les exemples qui "
|
||||
"suivent continueront de fonctionner si vous décidiez ne plus imposer la "
|
||||
"contrainte de non-nullité sur les clés étrangères."
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:58
|
||||
#, no-c-format
|
||||
msgid "Unidirectional associations"
|
||||
msgstr "Association unidirectionnelle"
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:61 association_mapping.xml:132
|
||||
#, no-c-format
|
||||
msgid "many to one"
|
||||
msgstr "plusieurs à un"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:63
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>unidirectional many-to-one association</emphasis> is the most "
|
||||
"common kind of unidirectional association."
|
||||
msgstr ""
|
||||
"Une <emphasis>association plusieurs-à-un (many-to-one) unidirectionnelle </"
|
||||
"emphasis> est le type que l'on rencontre le plus souvent dans les "
|
||||
"associations unidirectionnelles."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:68
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <many-to-one name=\"address\" \n"
|
||||
" column=\"addressId\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:69 association_mapping.xml:185
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key, addressId bigint "
|
||||
"not null )\n"
|
||||
"create table Address ( addressId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:74 association_mapping.xml:145
|
||||
#: association_mapping.xml:209 association_mapping.xml:249
|
||||
#, fuzzy, no-c-format
|
||||
msgid "one to one"
|
||||
msgstr ""
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"un à un\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"un à un\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"Un à un\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"Un à un"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:76
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>unidirectional one-to-one association on a foreign key</"
|
||||
"emphasis> is almost identical. The only difference is the column unique "
|
||||
"constraint."
|
||||
msgstr ""
|
||||
"une <emphasis>association un-à-un (one-to-one) sur une clé étrangère</"
|
||||
"emphasis> est presque identique. La seule différence est sur la contrainte "
|
||||
"d'unicité que l'on impose à cette colonne."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:81
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <many-to-one name=\"address\" \n"
|
||||
" column=\"addressId\" \n"
|
||||
" unique=\"true\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:82 association_mapping.xml:217
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key, addressId bigint "
|
||||
"not null unique )\n"
|
||||
"create table Address ( addressId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:84
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>unidirectional one-to-one association on a primary key</"
|
||||
"emphasis> usually uses a special id generator. (Notice that we've reversed "
|
||||
"the direction of the association in this example.)"
|
||||
msgstr ""
|
||||
"Une <emphasis>association un-à-un (one-to-one) unidirectionnelle sur une clé "
|
||||
"primaire</emphasis> utilise un générateur d'identifiant particulier. "
|
||||
"(Remarquez que nous avons inversé le sens de cette association dans cet "
|
||||
"exemple.)"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:90
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"foreign\">\n"
|
||||
" <param name=\"property\">person</param>\n"
|
||||
" </generator>\n"
|
||||
" </id>\n"
|
||||
" <one-to-one name=\"person\" constrained=\"true\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:91 association_mapping.xml:225
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( personId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:96 association_mapping.xml:118
|
||||
#, no-c-format
|
||||
msgid "one to many"
|
||||
msgstr "un à plusieurs"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:98
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>unidirectional one-to-many association on a foreign key</"
|
||||
"emphasis> is a very unusual case, and is not really recommended."
|
||||
msgstr ""
|
||||
"Une <emphasis>association un-à-plusieurs (one-to-many) unidirectionnelle sur "
|
||||
"une clé étrangère</emphasis> est vraiment inhabituelle, et n'est pas "
|
||||
"vraiment recommandée."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:103
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <set name=\"addresses\">\n"
|
||||
" <key column=\"personId\" \n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" <one-to-many class=\"Address\"/>\n"
|
||||
" </set>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:104
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( addressId bigint not null primary key, personId "
|
||||
"bigint not null )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:106
|
||||
#, no-c-format
|
||||
msgid "We think it's better to use a join table for this kind of association."
|
||||
msgstr ""
|
||||
"Nous pensons qu'il est préférable d'utiliser une table de jointure pour ce "
|
||||
"type d'association."
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:115
|
||||
#, no-c-format
|
||||
msgid "Unidirectional associations with join tables"
|
||||
msgstr "Associations unidirectionnelles avec tables de jointure"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:120
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>unidirectional one-to-many association on a join table</"
|
||||
"emphasis> is much preferred. Notice that by specifying <literal>unique=\"true"
|
||||
"\"</literal>, we have changed the multiplicity from many-to-many to one-to-"
|
||||
"many."
|
||||
msgstr ""
|
||||
"Une <emphasis>association unidirectionnelle un-à-plusieurs (one-to-many) "
|
||||
"avec une table de jointure</emphasis> est un bien meilleur choix. Remarquez "
|
||||
"qu'en spécifiant <literal>unique=\"true\"</literal>, on a changé la "
|
||||
"multiplicité plusieurs-à-plusieurs (many-to-many) pour un-à-plusieurs (one-"
|
||||
"to-many)."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:126
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <set name=\"addresses\" table=\"PersonAddress\">\n"
|
||||
" <key column=\"personId\"/>\n"
|
||||
" <many-to-many column=\"addressId\"\n"
|
||||
" unique=\"true\"\n"
|
||||
" class=\"Address\"/>\n"
|
||||
" </set>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:127
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table PersonAddress ( personId not null, addressId bigint not null "
|
||||
"primary key )\n"
|
||||
"create table Address ( addressId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:134
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>unidirectional many-to-one association on a join table</"
|
||||
"emphasis> is quite common when the association is optional."
|
||||
msgstr ""
|
||||
"Une <emphasis>assiociation plusieurs-à-un (many-to-one) unidirectionnelle "
|
||||
"sur une table de jointure</emphasis> est très fréquente quand l'association "
|
||||
"est optionnelle."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:139
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <join table=\"PersonAddress\" \n"
|
||||
" optional=\"true\">\n"
|
||||
" <key column=\"personId\" unique=\"true\"/>\n"
|
||||
" <many-to-one name=\"address\"\n"
|
||||
" column=\"addressId\" \n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" </join>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:140
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table PersonAddress ( personId bigint not null primary key, addressId "
|
||||
"bigint not null )\n"
|
||||
"create table Address ( addressId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:147
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>unidirectional one-to-one association on a join table</emphasis> "
|
||||
"is extremely unusual, but possible."
|
||||
msgstr ""
|
||||
"Une <emphasis>association unidirectionnelle un-à-un (one-to-one) sur une "
|
||||
"table de jointure</emphasis> est extrèmement rare mais envisageable."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:152
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <join table=\"PersonAddress\" \n"
|
||||
" optional=\"true\">\n"
|
||||
" <key column=\"personId\" \n"
|
||||
" unique=\"true\"/>\n"
|
||||
" <many-to-one name=\"address\"\n"
|
||||
" column=\"addressId\" \n"
|
||||
" not-null=\"true\"\n"
|
||||
" unique=\"true\"/>\n"
|
||||
" </join>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:153 association_mapping.xml:257
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table PersonAddress ( personId bigint not null primary key, addressId "
|
||||
"bigint not null unique )\n"
|
||||
"create table Address ( addressId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:158 association_mapping.xml:262
|
||||
#, no-c-format
|
||||
msgid "many to many"
|
||||
msgstr "plusieurs à plusieurs"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:160
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Finally, we have a <emphasis>unidirectional many-to-many association</"
|
||||
"emphasis>."
|
||||
msgstr ""
|
||||
"Finallement, nous avons <emphasis>l'association unidirectionnelle plusieurs-"
|
||||
"à-plusieurs (many-to-many)</emphasis>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:164
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <set name=\"addresses\" table=\"PersonAddress\">\n"
|
||||
" <key column=\"personId\"/>\n"
|
||||
" <many-to-many column=\"addressId\"\n"
|
||||
" class=\"Address\"/>\n"
|
||||
" </set>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:165 association_mapping.xml:270
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table PersonAddress ( personId bigint not null, addressId bigint not "
|
||||
"null, primary key (personId, addressId) )\n"
|
||||
"create table Address ( addressId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:172
|
||||
#, no-c-format
|
||||
msgid "Bidirectional associations"
|
||||
msgstr "Associations bidirectionnelles"
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:175 association_mapping.xml:235
|
||||
#, no-c-format
|
||||
msgid "one to many / many to one"
|
||||
msgstr "un à plusieurs / plusieurs à un"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:177
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>bidirectional many-to-one association</emphasis> is the most "
|
||||
"common kind of association. (This is the standard parent/child relationship.)"
|
||||
msgstr ""
|
||||
"Une <emphasis>association bidirectionnelle plusieurs à un (many-to-one)</"
|
||||
"emphasis> est le type d'association que l'on rencontre le plus souvent. "
|
||||
"(c'est la façon standard de créer des relations parents/enfants.)"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:183
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <many-to-one name=\"address\" \n"
|
||||
" column=\"addressId\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <set name=\"people\" inverse=\"true\">\n"
|
||||
" <key column=\"addressId\"/>\n"
|
||||
" <one-to-many class=\"Person\"/>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:187
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If you use a <literal>List</literal> (or other indexed collection) you need "
|
||||
"to set the <literal>key</literal> column of the foreign key to <literal>not "
|
||||
"null</literal>, and let Hibernate manage the association from the "
|
||||
"collections side to maintain the index of each element (making the other "
|
||||
"side virtually inverse by setting <literal>update=\"false\"</literal> and "
|
||||
"<literal>insert=\"false\"</literal>):"
|
||||
msgstr ""
|
||||
"Si vous utilisez une <literal>List</literal> (ou toute autre collection "
|
||||
"indexée) vous devez paramétrer la colonne <literal>key</literal> de la clé "
|
||||
"étrangère à <literal>not null</literal>, et laisser Hibernate gérer "
|
||||
"l'association depuis l'extrémité collection pour maintenir l'index de chaque "
|
||||
"élément (rendant l'autre extrémité virtuellement inverse en paramétrant "
|
||||
"<literal>update=\"false\"</literal> et <literal>insert=\"false\"</literal>):"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:195
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\"/>\n"
|
||||
" ...\n"
|
||||
" <many-to-one name=\"address\"\n"
|
||||
" column=\"addressId\"\n"
|
||||
" not-null=\"true\"\n"
|
||||
" insert=\"false\"\n"
|
||||
" update=\"false\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\"/>\n"
|
||||
" ...\n"
|
||||
" <list name=\"people\">\n"
|
||||
" <key column=\"addressId\" not-null=\"true\"/>\n"
|
||||
" <list-index column=\"peopleIdx\"/>\n"
|
||||
" <one-to-many class=\"Person\"/>\n"
|
||||
" </list>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:197
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"It is important that you define <literal>not-null=\"true\"</literal> on the "
|
||||
"<literal><key></literal> element of the collection mapping if the "
|
||||
"underlying foreign key column is <literal>NOT NULL</literal>. Don't only "
|
||||
"declare <literal>not-null=\"true\"</literal> on a possible nested "
|
||||
"<literal><column></literal> element, but on the <literal><key></"
|
||||
"literal> element."
|
||||
msgstr ""
|
||||
"It is important that you define <literal>not-null=\"true\"</literal> on the "
|
||||
"<literal><key></literal> element of the collection mapping if the "
|
||||
"underlying foreign key column is <literal>NOT NULL</literal>. Don't only "
|
||||
"declare <literal>not-null=\"true\"</literal> on a possible nested "
|
||||
"<literal><column></literal> element, but on the <literal><key></"
|
||||
"literal> element."
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:211
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> "
|
||||
"is quite common."
|
||||
msgstr ""
|
||||
"Une <emphasis>association bidirectionnelle un à un (one-to-one) sur une clé "
|
||||
"étrangère</emphasis> est aussi très fréquente."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:216
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <many-to-one name=\"address\" \n"
|
||||
" column=\"addressId\" \n"
|
||||
" unique=\"true\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <one-to-one name=\"person\" \n"
|
||||
" property-ref=\"address\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:219
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>bidirectional one-to-one association on a primary key</emphasis> "
|
||||
"uses the special id generator."
|
||||
msgstr ""
|
||||
"Une <emphasis>association bidirectionnelle un-à-un (one-to-one) sur une clé "
|
||||
"primaire</emphasis> utilise un générateur particulier d'id."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:224
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <one-to-one name=\"address\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"foreign\">\n"
|
||||
" <param name=\"property\">person</param>\n"
|
||||
" </generator>\n"
|
||||
" </id>\n"
|
||||
" <one-to-one name=\"person\" \n"
|
||||
" constrained=\"true\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:232
|
||||
#, no-c-format
|
||||
msgid "Bidirectional associations with join tables"
|
||||
msgstr "Associations bidirectionnelles avec table de jointure"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:237
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>bidirectional one-to-many association on a join table</"
|
||||
"emphasis>. Note that the <literal>inverse=\"true\"</literal> can go on "
|
||||
"either end of the association, on the collection, or on the join."
|
||||
msgstr ""
|
||||
"Une <emphasis>association bidirectionnelle un-à-plusieurs (one-to-many) sur "
|
||||
"une table de jointure </emphasis>. Remarquez que <literal>inverse=\"true\"</"
|
||||
"literal> peut s'appliquer sur les deux extrémités de l' association, sur la "
|
||||
"collection, ou sur la jointure."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:243
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <set name=\"addresses\" \n"
|
||||
" table=\"PersonAddress\">\n"
|
||||
" <key column=\"personId\"/>\n"
|
||||
" <many-to-many column=\"addressId\"\n"
|
||||
" unique=\"true\"\n"
|
||||
" class=\"Address\"/>\n"
|
||||
" </set>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <join table=\"PersonAddress\" \n"
|
||||
" inverse=\"true\" \n"
|
||||
" optional=\"true\">\n"
|
||||
" <key column=\"addressId\"/>\n"
|
||||
" <many-to-one name=\"person\"\n"
|
||||
" column=\"personId\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" </join>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:244
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table PersonAddress ( personId bigint not null, addressId bigint not "
|
||||
"null primary key )\n"
|
||||
"create table Address ( addressId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:251
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <emphasis>bidirectional one-to-one association on a join table</emphasis> "
|
||||
"is extremely unusual, but possible."
|
||||
msgstr ""
|
||||
"Une <emphasis>association bidirectionnelle un-à-un (one-to-one) sur une "
|
||||
"table de jointure</emphasis> est extrèmement rare mais envisageable."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:256
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <join table=\"PersonAddress\" \n"
|
||||
" optional=\"true\">\n"
|
||||
" <key column=\"personId\" \n"
|
||||
" unique=\"true\"/>\n"
|
||||
" <many-to-one name=\"address\"\n"
|
||||
" column=\"addressId\" \n"
|
||||
" not-null=\"true\"\n"
|
||||
" unique=\"true\"/>\n"
|
||||
" </join>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <join table=\"PersonAddress\" \n"
|
||||
" optional=\"true\"\n"
|
||||
" inverse=\"true\">\n"
|
||||
" <key column=\"addressId\" \n"
|
||||
" unique=\"true\"/>\n"
|
||||
" <many-to-one name=\"person\"\n"
|
||||
" column=\"personId\" \n"
|
||||
" not-null=\"true\"\n"
|
||||
" unique=\"true\"/>\n"
|
||||
" </join>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:264
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Finally, we have a <emphasis>bidirectional many-to-many association</"
|
||||
"emphasis>."
|
||||
msgstr ""
|
||||
"Finallement nous avons <emphasis>l'association bidirectionnelle plusieurs à "
|
||||
"plusieurs</emphasis>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:268
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\" column=\"personId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <set name=\"addresses\" table=\"PersonAddress\">\n"
|
||||
" <key column=\"personId\"/>\n"
|
||||
" <many-to-many column=\"addressId\"\n"
|
||||
" class=\"Address\"/>\n"
|
||||
" </set>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
" <id name=\"id\" column=\"addressId\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <set name=\"people\" inverse=\"true\" table=\"PersonAddress\">\n"
|
||||
" <key column=\"addressId\"/>\n"
|
||||
" <many-to-many column=\"personId\"\n"
|
||||
" class=\"Person\"/>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: association_mapping.xml:277
|
||||
#, no-c-format
|
||||
msgid "More complex association mappings"
|
||||
msgstr "Des mappings plus complexes"
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:279
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"More complex association joins are <emphasis>extremely</emphasis> rare. "
|
||||
"Hibernate makes it possible to handle more complex situations using SQL "
|
||||
"fragments embedded in the mapping document. For example, if a table with "
|
||||
"historical account information data defines <literal>accountNumber</"
|
||||
"literal>, <literal>effectiveEndDate</literal> and "
|
||||
"<literal>effectiveStartDate</literal>columns, mapped as follows:"
|
||||
msgstr ""
|
||||
"Des associations encore plus complexes sont <emphasis>extrêmement</emphasis> "
|
||||
"rares. Hibernate permet de gérer des situations plus complexes en utilisant "
|
||||
"des parties SQL dans les fichiers de mapping. Par exemple, si une table avec "
|
||||
"l'historiques des informations d'un compte définit les colonnes "
|
||||
"<literal>accountNumber</literal>, <literal>effectiveEndDate</literal> et "
|
||||
"<literal>effectiveStartDate</literal>, mappées de telle sorte:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:288
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<properties name=\"currentAccountKey\">\n"
|
||||
" <property name=\"accountNumber\" type=\"string\" not-null=\"true\"/>\n"
|
||||
" <property name=\"currentAccount\" type=\"boolean\">\n"
|
||||
" <formula>case when effectiveEndDate is null then 1 else 0 end</"
|
||||
"formula>\n"
|
||||
" </property>\n"
|
||||
"</properties>\n"
|
||||
"<property name=\"effectiveEndDate\" type=\"date\"/>\n"
|
||||
"<property name=\"effectiveStateDate\" type=\"date\" not-null=\"true\"/>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:290
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Then we can map an association to the <emphasis>current</emphasis> instance "
|
||||
"(the one with null <literal>effectiveEndDate</literal>) using:"
|
||||
msgstr ""
|
||||
"alors nous pouvons mapper une association à l'instance <emphasis>courante</"
|
||||
"emphasis> (celle avec une <literal>effectiveEndDate</literal>) nulle en "
|
||||
"utilisant:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:295
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"currentAccountInfo\" \n"
|
||||
" property-ref=\"currentAccountKey\"\n"
|
||||
" class=\"AccountInfo\">\n"
|
||||
" <column name=\"accountNumber\"/>\n"
|
||||
" <formula>'1'</formula>\n"
|
||||
"</many-to-one>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:297
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"In a more complex example, imagine that the association between "
|
||||
"<literal>Employee</literal> and <literal>Organization</literal> is "
|
||||
"maintained in an <literal>Employment</literal> table full of historical "
|
||||
"employment data. Then an association to the employee's <emphasis>most "
|
||||
"recent</emphasis> employer (the one with the most recent <literal>startDate</"
|
||||
"literal>) might be mapped this way:"
|
||||
msgstr ""
|
||||
"Dans un exemple plus complexe, imaginez qu'une association entre "
|
||||
"<literal>Employee</literal> et <literal>Organization</literal> est gérée "
|
||||
"dans une table <literal>Employment</literal> pleines de données historiques. "
|
||||
"Dans ce cas, une association vers l'employeur <emphasis>le plus récent</"
|
||||
"emphasis> (celui avec la <literal>startDate</literal> la plus récente) "
|
||||
"pourrait être mappée comme cela:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: association_mapping.xml:305
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<join>\n"
|
||||
" <key column=\"employeeId\"/>\n"
|
||||
" <subselect>\n"
|
||||
" select employeeId, orgId \n"
|
||||
" from Employments \n"
|
||||
" group by orgId \n"
|
||||
" having startDate = max(startDate)\n"
|
||||
" </subselect>\n"
|
||||
" <many-to-one name=\"mostRecentEmployer\" \n"
|
||||
" class=\"Organization\" \n"
|
||||
" column=\"orgId\"/>\n"
|
||||
"</join>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: association_mapping.xml:307
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You can get quite creative with this functionality, but it is usually more "
|
||||
"practical to handle these kinds of cases using HQL or a criteria query."
|
||||
msgstr ""
|
||||
"Vous pouvez être créatif grace à ces possibilités, mais il est généralement "
|
||||
"plus pratique d'utiliser des requêtes HQL ou criteria dans ce genre de "
|
||||
"situation."
|
|
@ -0,0 +1,642 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: batch.xml:29
|
||||
#, no-c-format
|
||||
msgid "Batch processing"
|
||||
msgstr "Traitement par paquet"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A naive approach to inserting 100 000 rows in the database using Hibernate "
|
||||
"might look like this:"
|
||||
msgstr ""
|
||||
"Une approche naïve pour insérer 100 000 lignes dans la base de données en "
|
||||
"utilisant Hibernate pourrait ressembler à ça :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:36
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"for ( int i=0; i<100000; i++ ) {\n"
|
||||
" Customer customer = new Customer(.....);\n"
|
||||
" session.save(customer);\n"
|
||||
"}\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:38
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This would fall over with an <literal>OutOfMemoryException</literal> "
|
||||
"somewhere around the 50 000th row. That's because Hibernate caches all the "
|
||||
"newly inserted <literal>Customer</literal> instances in the session-level "
|
||||
"cache."
|
||||
msgstr ""
|
||||
"Ceci devrait s'écrouler avec une <literal>OutOfMemoryException</literal> "
|
||||
"quelque part aux alentours de la 50 000ème ligne. C'est parce qu'Hibernate "
|
||||
"cache toutes les instances de <literal>Customer</literal> nouvellement "
|
||||
"insérées dans le cache de second niveau."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:44
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"In this chapter we'll show you how to avoid this problem. First, however, if "
|
||||
"you are doing batch processing, it is absolutely critical that you enable "
|
||||
"the use of JDBC batching, if you intend to achieve reasonable performance. "
|
||||
"Set the JDBC batch size to a reasonable number (say, 10-50):"
|
||||
msgstr ""
|
||||
"Dans ce chapitre nous montrerons comment éviter ce problème. D'abord, "
|
||||
"cependant, si vous faites des traitements par batch, il est absolument "
|
||||
"critique que vous activiez l'utilisation ds paquet JDBC (NdT : JDBC "
|
||||
"batching), si vous avez l'intention d'obtenir des performances raisonnables. "
|
||||
"Configurez la taille du paquet JDBC avec un nombre raisonnable (disons, 10-"
|
||||
"50) :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:51
|
||||
#, no-c-format
|
||||
msgid "<![CDATA[hibernate.jdbc.batch_size 20]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:53
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that Hibernate disables insert batching at the JDBC level transparently "
|
||||
"if you use an <literal>identiy</literal> identifier generator."
|
||||
msgstr ""
|
||||
"Vous pourriez aussi vouloir faire cette sorte de travail dans un traitement "
|
||||
"où l'interaction avec le cache de second niveau est complètement désactivé :"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:58
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You also might like to do this kind of work in a process where interaction "
|
||||
"with the second-level cache is completely disabled:"
|
||||
msgstr "Insertions en paquet"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:63
|
||||
#, no-c-format
|
||||
msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:65
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"However, this is not absolutely necessary, since we can explicitly set the "
|
||||
"<literal>CacheMode</literal> to disable interaction with the second-level "
|
||||
"cache."
|
||||
msgstr ""
|
||||
"Lorsque vous rendez des nouveaux objets persistants, vous devez "
|
||||
"régulièrement appeler <literal>flush()</literal> et puis <literal>clear()</"
|
||||
"literal> sur la session, pour contrôler la taille du cache de premier niveau."
|
||||
|
||||
#. Tag: title
|
||||
#: batch.xml:71
|
||||
#, no-c-format
|
||||
msgid "Batch inserts"
|
||||
msgstr "Paquet de mises à jour"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:73
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"When making new objects persistent, you must <literal>flush()</literal> and "
|
||||
"then <literal>clear()</literal> the session regularly, to control the size "
|
||||
"of the first-level cache."
|
||||
msgstr ""
|
||||
"Pour récupérer et mettre à jour des données les mêmes idées s'appliquent. En "
|
||||
"plus, vous avez besoin d'utiliser <literal>scroll()</literal> pour tirer "
|
||||
"partie des curseurs côté serveur pour les requêtes qui retournent beaucoup "
|
||||
"de lignes de données."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:79
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"for ( int i=0; i<100000; i++ ) {\n"
|
||||
" Customer customer = new Customer(.....);\n"
|
||||
" session.save(customer);\n"
|
||||
" if ( i % 20 == 0 ) { //20, same as the JDBC batch size\n"
|
||||
" //flush a batch of inserts and release memory:\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: batch.xml:84
|
||||
#, no-c-format
|
||||
msgid "Batch updates"
|
||||
msgstr "L'interface StatelessSession"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:86
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"For retrieving and updating data the same ideas apply. In addition, you need "
|
||||
"to use <literal>scroll()</literal> to take advantage of server-side cursors "
|
||||
"for queries that return many rows of data."
|
||||
msgstr ""
|
||||
"Alternativement, Hibernate fournit une API orientée commande qui peut être "
|
||||
"utilisée avec des flux de données pour et en provenance de la base de "
|
||||
"données sous la forme d'objets détachés. Une <literal>StatelessSession</"
|
||||
"literal> n'a pas de contexte de persistance associé et ne fournit pas "
|
||||
"beaucoup de sémantique de durée de vie de haut niveau. En particulier, une "
|
||||
"session sans état n'implémente pas de cache de premier niveau et n'interagit "
|
||||
"pas non plus avec un cache de seconde niveau ou un cache de requêtes. Elle "
|
||||
"n'implémente pas les transactions ou la vérification sale automatique (NdT : "
|
||||
"automatic dirty checking). Les opérations réalisées avec une session sans "
|
||||
"état ne sont jamais répercutées en cascade sur les instances associées. Les "
|
||||
"collections sont ignorées par une session sans état. Les opérations "
|
||||
"exécutées via une session sans état outrepasse le modèle d'événements "
|
||||
"d'Hibernate et les intercepteurs. Les sessions sans état sont vulnérables "
|
||||
"aux effets de modification des données, ceci est dû au manque de cache de "
|
||||
"premier niveau. Une session sans état est une abstraction bas niveau, plus "
|
||||
"proche de la couche JDBC sous-jacente."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:92
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
|
||||
" .setCacheMode(CacheMode.IGNORE)\n"
|
||||
" .scroll(ScrollMode.FORWARD_ONLY);\n"
|
||||
"int count=0;\n"
|
||||
"while ( customers.next() ) {\n"
|
||||
" Customer customer = (Customer) customers.get(0);\n"
|
||||
" customer.updateStuff(...);\n"
|
||||
" if ( ++count % 20 == 0 ) {\n"
|
||||
" //flush a batch of updates and release memory:\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: batch.xml:97
|
||||
#, no-c-format
|
||||
msgid "The StatelessSession interface"
|
||||
msgstr ""
|
||||
"Notez que dans le code de l'exemple, les intances de <literal>Customer</"
|
||||
"literal> retournées par la requête sont immédiatement détachées. Elles ne "
|
||||
"sont jamais associées à un contexte de persistance."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:98
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Alternatively, Hibernate provides a command-oriented API that may be used "
|
||||
"for streaming data to and from the database in the form of detached objects. "
|
||||
"A <literal>StatelessSession</literal> has no persistence context associated "
|
||||
"with it and does not provide many of the higher-level life cycle semantics. "
|
||||
"In particular, a stateless session does not implement a first-level cache "
|
||||
"nor interact with any second-level or query cache. It does not implement "
|
||||
"transactional write-behind or automatic dirty checking. Operations performed "
|
||||
"using a stateless session do not ever cascade to associated instances. "
|
||||
"Collections are ignored by a stateless session. Operations performed via a "
|
||||
"stateless session bypass Hibernate's event model and interceptors. Stateless "
|
||||
"sessions are vulnerable to data aliasing effects, due to the lack of a first-"
|
||||
"level cache. A stateless session is a lower-level abstraction, much closer "
|
||||
"to the underlying JDBC."
|
||||
msgstr ""
|
||||
"Les opérations <literal>insert()</literal>, <literal>update()</literal> et "
|
||||
"<literal>delete()</literal> définies par l'interface "
|
||||
"<literal>StatelessSession</literal> sont considérées comme des opérations "
|
||||
"d'accès direct aux lignes de la base de données, ce qui résulte en une "
|
||||
"exécution immédiate du SQL <literal>INSERT</literal>, <literal>UPDATE</"
|
||||
"literal> ou <literal>DELETE</literal> respectif. De là, elles ont des "
|
||||
"sémantiques tres différentes des opérations <literal>save()</literal>, "
|
||||
"<literal>saveOrUpdate()</literal> et <literal>delete()</literal> définies "
|
||||
"par l'interface <literal>Session</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:113
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[StatelessSession session = sessionFactory.openStatelessSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
" \n"
|
||||
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
|
||||
" .scroll(ScrollMode.FORWARD_ONLY);\n"
|
||||
"while ( customers.next() ) {\n"
|
||||
" Customer customer = (Customer) customers.get(0);\n"
|
||||
" customer.updateStuff(...);\n"
|
||||
" session.update(customer);\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:115
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that in this code example, the <literal>Customer</literal> instances "
|
||||
"returned by the query are immediately detached. They are never associated "
|
||||
"with any persistence context."
|
||||
msgstr "Opérations de style DML"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:121
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal>insert(), update()</literal> and <literal>delete()</literal> "
|
||||
"operations defined by the <literal>StatelessSession</literal> interface are "
|
||||
"considered to be direct database row-level operations, which result in "
|
||||
"immediate execution of a SQL <literal>INSERT, UPDATE</literal> or "
|
||||
"<literal>DELETE</literal> respectively. Thus, they have very different "
|
||||
"semantics to the <literal>save(), saveOrUpdate()</literal> and "
|
||||
"<literal>delete()</literal> operations defined by the <literal>Session</"
|
||||
"literal> interface."
|
||||
msgstr ""
|
||||
"Comme déjà discuté avant, le mapping objet/relationnel automatique et "
|
||||
"transparent est intéressé par la gestion de l'état de l'objet. Ceci implique "
|
||||
"que l'état de l'objet est disponible en mémoire, d'où manipuler (en "
|
||||
"utilisant des expressions du langage de manipulation de données - "
|
||||
"<literal>Data Manipulation Language</literal> (DML) - SQL) les données "
|
||||
"directement dans la base n'affectera pas l'état en mémoire. Pourtant, "
|
||||
"Hibernate fournit des méthodes pour l'exécution d'expression DML de style "
|
||||
"SQL lesquelles sont réalisées à travers le langage de requête d'Hibernate "
|
||||
"(<xref linkend=\"queryhql\">HQL</xref>)."
|
||||
|
||||
#. Tag: title
|
||||
#: batch.xml:134
|
||||
#, no-c-format
|
||||
msgid "DML-style operations"
|
||||
msgstr ""
|
||||
"La pseudo-syntaxe pour les expressions <literal>UPDATE</literal> et "
|
||||
"<literal>DELETE</literal> est : <literal>( UPDATE | DELETE ) FROM? "
|
||||
"EntityName (WHERE where_conditions)?</literal>. Certains points sont à "
|
||||
"noter :"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:136
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"As already discussed, automatic and transparent object/relational mapping is "
|
||||
"concerned with the management of object state. This implies that the object "
|
||||
"state is available in memory, hence manipulating (using the SQL "
|
||||
"<literal>Data Manipulation Language</literal> (DML) statements: "
|
||||
"<literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</"
|
||||
"literal>) data directly in the database will not affect in-memory state. "
|
||||
"However, Hibernate provides methods for bulk SQL-style DML statement "
|
||||
"execution which are performed through the Hibernate Query Language (<link "
|
||||
"linkend=\"queryhql\">HQL</link>)."
|
||||
msgstr "Dans la clause from, le mot-clef FROM est optionnel"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:146
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The pseudo-syntax for <literal>UPDATE</literal> and <literal>DELETE</"
|
||||
"literal> statements is: <literal>( UPDATE | DELETE ) FROM? EntityName (WHERE "
|
||||
"where_conditions)?</literal>. Some points to note:"
|
||||
msgstr ""
|
||||
"Il ne peut y avoir qu'une seule entité nommée dans la clause from ; elle "
|
||||
"peut optionnellement avoir un alias. Si le nom de l'entité a un alias, alors "
|
||||
"n'importe quelle référence de propriété doit être qualifiée en ayant un "
|
||||
"alias ; si le nom de l'entité n'a pas d'alias, alors il est illégal pour "
|
||||
"n'importe quelle référence de propriété d'être qualifiée."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:154
|
||||
#, no-c-format
|
||||
msgid "In the from-clause, the FROM keyword is optional"
|
||||
msgstr ""
|
||||
"Aucune jointure (implicite ou explicite) ne peut être spécifiée dans une "
|
||||
"requête HQL. Les sous-requêtes peuvent être utilisées dans la clause where ; "
|
||||
"les sous-requêtes, elles-mêmes, peuvent contenir des jointures."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:159
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There can only be a single entity named in the from-clause; it can "
|
||||
"optionally be aliased. If the entity name is aliased, then any property "
|
||||
"references must be qualified using that alias; if the entity name is not "
|
||||
"aliased, then it is illegal for any property references to be qualified."
|
||||
msgstr "La clause where est aussi optionnelle."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:167
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"No <link linkend=\"queryhql-joins-forms\">joins</link> (either implicit or "
|
||||
"explicit) can be specified in a bulk HQL query. Sub-queries may be used in "
|
||||
"the where-clause; the subqueries, themselves, may contain joins."
|
||||
msgstr ""
|
||||
"Par exemple, pour exécuter un <literal>UPDATE</literal> HQL, utilisez la "
|
||||
"méthode <literal>Query.executeUpdate()</literal> (la méthode est données "
|
||||
"pour ceux qui sont familiers avec <literal>PreparedStatement.executeUpdate()"
|
||||
"</literal> de JDBC) :"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:174
|
||||
#, no-c-format
|
||||
msgid "The where-clause is also optional."
|
||||
msgstr ""
|
||||
"Pour exécuter un <literal>DELETE</literal> HQL, utilisez la même méthode "
|
||||
"<literal>Query.executeUpdate()</literal> :"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:180
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"As an example, to execute an HQL <literal>UPDATE</literal>, use the "
|
||||
"<literal>Query.executeUpdate()</literal> method (the method is named for "
|
||||
"those familiar with JDBC's <literal>PreparedStatement.executeUpdate()</"
|
||||
"literal>):"
|
||||
msgstr ""
|
||||
"La valeur du <literal>int</literal> retourné par la méthode <literal>Query."
|
||||
"executeUpdate()</literal> indique le nombre d'entités affectées par "
|
||||
"l'opération. Considérez que cela peut ou pas corréler le nombre de lignes "
|
||||
"affectés dans la base de données. Une opération HQL pourrait entraîner "
|
||||
"l'exécution de multiples expressions SQL réelles, pour des classes filles "
|
||||
"mappées par jointure (NdT: join-subclass), par exemple. Le nombre retourné "
|
||||
"indique le nombre d'entités réelles affectées par l'expression. Retour à "
|
||||
"l'exemple de la classe fille mappée par jointure, un effacement d'une des "
|
||||
"classes filles peut réellement entraîner des suppressions pas seulement dans "
|
||||
"la table qui mappe la classe fille, mais aussi dans la table \"racine\" et "
|
||||
"potentillement dans les tables des classes filles plus bas dans la "
|
||||
"hiérarchie d'héritage."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:186
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"String hqlUpdate = \"update Customer c set c.name = :newName where c.name = :"
|
||||
"oldName\";\n"
|
||||
"// or String hqlUpdate = \"update Customer set name = :newName where name = :"
|
||||
"oldName\";\n"
|
||||
"int updatedEntities = s.createQuery( hqlUpdate )\n"
|
||||
" .setString( \"newName\", newName )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:188
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"HQL <literal>UPDATE</literal> statements, by default do not effect the <link "
|
||||
"linkend=\"mapping-declaration-version\">version</link> or the <link linkend="
|
||||
"\"mapping-declaration-timestamp\">timestamp</link> property values for the "
|
||||
"affected entities; this is in keeping with the EJB3 specification. However, "
|
||||
"you can force Hibernate to properly reset the <literal>version</literal> or "
|
||||
"<literal>timestamp</literal> property values through the use of a "
|
||||
"<literal>versioned update</literal>. This is achieved by adding the "
|
||||
"<literal>VERSIONED</literal> keyword after the <literal>UPDATE</literal> "
|
||||
"keyword."
|
||||
msgstr ""
|
||||
"La pseudo-syntaxe pour l'expression <literal>INSERT</literal> est : "
|
||||
"<literal>INSERT INTO EntityName properties_list select_statement</literal>. "
|
||||
"Quelques points sont à noter :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:198
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"String hqlVersionedUpdate = \"update versioned Customer set name = :newName "
|
||||
"where name = :oldName\";\n"
|
||||
"int updatedEntities = s.createQuery( hqlUpdate )\n"
|
||||
" .setString( \"newName\", newName )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:200
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that custom version types (<literal>org.hibernate.usertype."
|
||||
"UserVersionType</literal>) are not allowed in conjunction with a "
|
||||
"<literal>update versioned</literal> statement."
|
||||
msgstr ""
|
||||
"Seule la forme INSERT INTO ... SELECT ... est supportée ; pas la forme "
|
||||
"INSERT INTO ... VALUES ... ."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:205
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"To execute an HQL <literal>DELETE</literal>, use the same <literal>Query."
|
||||
"executeUpdate()</literal> method:"
|
||||
msgstr ""
|
||||
"La properties_list est analogue à la <literal>spécification de la colonne</"
|
||||
"literal> The properties_list is analogous to the <literal>column "
|
||||
"speficiation</literal> dans l'expression SQL <literal>INSERT</literal>. Pour "
|
||||
"les entités impliquées dans un héritage mappé, seules les propriétés "
|
||||
"directement définies à ce niveau de classe donné peuvent être utilisées dans "
|
||||
"properties_list. Les propriétés de la classe mère ne sont pas permises ; et "
|
||||
"les propriétés des classes filles n'ont pas de sens. En d'autres mots, les "
|
||||
"expressions <literal>INSERT</literal> par nature non polymorphiques."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:210
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"String hqlDelete = \"delete Customer c where c.name = :oldName\";\n"
|
||||
"// or String hqlDelete = \"delete Customer where name = :oldName\";\n"
|
||||
"int deletedEntities = s.createQuery( hqlDelete )\n"
|
||||
" .setString( \"oldName\", oldName )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:212
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal>int</literal> value returned by the <literal>Query.executeUpdate"
|
||||
"()</literal> method indicate the number of entities effected by the "
|
||||
"operation. Consider this may or may not correlate to the number of rows "
|
||||
"effected in the database. An HQL bulk operation might result in multiple "
|
||||
"actual SQL statements being executed, for joined-subclass, for example. The "
|
||||
"returned number indicates the number of actual entities affected by the "
|
||||
"statement. Going back to the example of joined-subclass, a delete against "
|
||||
"one of the subclasses may actually result in deletes against not just the "
|
||||
"table to which that subclass is mapped, but also the \"root\" table and "
|
||||
"potentially joined-subclass tables further down the inheritence hierarchy."
|
||||
msgstr ""
|
||||
"select_statement peut être n'importe quelle requête de sélection HQl valide, "
|
||||
"avec l'avertissement que les types de retour doivent correspondre aux types "
|
||||
"attendus par l'insertion. Actuellement, c'est vérifié durant la compilation "
|
||||
"de la requête plutôt que la vérification soit reléguée à la base de données. "
|
||||
"Notez cependant que cela pourrait poser des problèmes entre les "
|
||||
"<literal>Type</literal>s d'Hibernate qui sont <emphasis>équivalents</"
|
||||
"emphasis> opposé à <emphasis>égaux</emphasis>. Cela pourrait poser des "
|
||||
"problèmes avec des disparités entre une propriété définie comme un "
|
||||
"<literal>org.hibernate.type.DateType</literal> et une propriété définie "
|
||||
"comme un <literal>org.hibernate.type.TimestampType</literal>, même si la "
|
||||
"base de données ne ferait pas de distinction ou ne serait pas capable de "
|
||||
"gérer la conversion."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:223
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The pseudo-syntax for <literal>INSERT</literal> statements is: "
|
||||
"<literal>INSERT INTO EntityName properties_list select_statement</literal>. "
|
||||
"Some points to note:"
|
||||
msgstr ""
|
||||
"Pour la propriéte id, l'expression d'insertion vous donne deux options. Vous "
|
||||
"pouvez soit spécifier explicitement la propriété id dans properties_list "
|
||||
"(auquel cas sa valeur est extraite de l'expression de sélection "
|
||||
"correspondante), soit l'omettre de properties_list (auquel cas une valeur "
|
||||
"générée est utilisée). Cette dernière option est seulement disponible en "
|
||||
"utilisant le générateur d'identifiant qui opère dans la base de données ; "
|
||||
"tenter d'utiliser cette option avec n'importe quel type de générateur \"en "
|
||||
"mémoire\" causera une exception durant l'analyse. Notez que pour les buts de "
|
||||
"cette discussion, les générateurs \"en base\" sont considérés être "
|
||||
"<literal>org.hibernate.id.SequenceGenerator</literal> (et ses classes "
|
||||
"filles) et n'importe quelles implémentations de <literal>org.hibernate.id."
|
||||
"PostInsertIdentifierGenerator</literal>. L'exception la plus notable ici est "
|
||||
"<literal>org.hibernate.id.TableHiLoGenerator</literal>, qu ne peut pas être "
|
||||
"utilisée parce qu'il ne propose pas un moyen de d'exposer ses valeurs par un "
|
||||
"select."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:231
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Only the INSERT INTO ... SELECT ... form is supported; not the INSERT "
|
||||
"INTO ... VALUES ... form."
|
||||
msgstr ""
|
||||
"Pour des propriétés mappées comme <literal>version</literal> ou "
|
||||
"<literal>timestamp</literal>, l'expression d'insertion vous donne deux "
|
||||
"options. Vous pouvez soit spécifier la propriété dans properties_list "
|
||||
"(auquel cas sa valeur est extraite des expressions select correspondantes), "
|
||||
"soit l'omettre de properties_list (auquel cas la <literal>valeur de graine</"
|
||||
"literal> (NdT : seed value) définie par le <literal>org.hibernate.type."
|
||||
"VersionType</literal> est utilisée)."
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:234
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The properties_list is analogous to the <literal>column speficiation</"
|
||||
"literal> in the SQL <literal>INSERT</literal> statement. For entities "
|
||||
"involved in mapped inheritence, only properties directly defined on that "
|
||||
"given class-level can be used in the properties_list. Superclass properties "
|
||||
"are not allowed; and subclass properties do not make sense. In other words, "
|
||||
"<literal>INSERT</literal> statements are inherently non-polymorphic."
|
||||
msgstr ""
|
||||
"Un exemple d'exécution d'une expression <literal>INSERT</literal> HQL :"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:244
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"select_statement can be any valid HQL select query, with the caveat that the "
|
||||
"return types must match the types expected by the insert. Currently, this is "
|
||||
"checked during query compilation rather than allowing the check to relegate "
|
||||
"to the database. Note however that this might cause problems between "
|
||||
"Hibernate <literal>Type</literal>s which are <emphasis>equivalent</emphasis> "
|
||||
"as opposed to <emphasis>equal</emphasis>. This might cause issues with "
|
||||
"mismatches between a property defined as a <literal>org.hibernate.type."
|
||||
"DateType</literal> and a property defined as a <literal>org.hibernate.type."
|
||||
"TimestampType</literal>, even though the database might not make a "
|
||||
"distinction or might be able to handle the conversion."
|
||||
msgstr "translator-credits"
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:256
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"For the id property, the insert statement gives you two options. You can "
|
||||
"either explicitly specify the id property in the properties_list (in which "
|
||||
"case its value is taken from the corresponding select expression) or omit it "
|
||||
"from the properties_list (in which case a generated value is used). This "
|
||||
"later option is only available when using id generators that operate in the "
|
||||
"database; attempting to use this option with any \"in memory\" type "
|
||||
"generators will cause an exception during parsing. Note that for the "
|
||||
"purposes of this discussion, in-database generators are considered to be "
|
||||
"<literal>org.hibernate.id.SequenceGenerator</literal> (and its subclasses) "
|
||||
"and any implementors of <literal>org.hibernate.id."
|
||||
"PostInsertIdentifierGenerator</literal>. The most notable exception here is "
|
||||
"<literal>org.hibernate.id.TableHiLoGenerator</literal>, which cannot be used "
|
||||
"because it does not expose a selectable way to get its values."
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:271
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"For properties mapped as either <literal>version</literal> or "
|
||||
"<literal>timestamp</literal>, the insert statement gives you two options. "
|
||||
"You can either specify the property in the properties_list (in which case "
|
||||
"its value is taken from the corresponding select expressions) or omit it "
|
||||
"from the properties_list (in which case the <literal>seed value</literal> "
|
||||
"defined by the <literal>org.hibernate.type.VersionType</literal> is used)."
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: batch.xml:281
|
||||
#, no-c-format
|
||||
msgid "An example HQL <literal>INSERT</literal> statement execution:"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: batch.xml:285
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"String hqlInsert = \"insert into DelinquentAccount (id, name) select c.id, c."
|
||||
"name from Customer c where ...\";\n"
|
||||
"int createdEntities = s.createQuery( hqlInsert )\n"
|
||||
" .executeUpdate();\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
|
@ -0,0 +1,466 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: best_practices.xml:29
|
||||
#, no-c-format
|
||||
msgid "Best Practices"
|
||||
msgstr "Meilleures pratiques"
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:33
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Write fine-grained classes and map them using <literal><component></"
|
||||
"literal>."
|
||||
msgstr ""
|
||||
"Découpez finement vos classes et mappez les en utilisant <literal><"
|
||||
"component></literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:35
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Use an <literal>Address</literal> class to encapsulate <literal>street</"
|
||||
"literal>, <literal>suburb</literal>, <literal>state</literal>, "
|
||||
"<literal>postcode</literal>. This encourages code reuse and simplifies "
|
||||
"refactoring."
|
||||
msgstr ""
|
||||
"Utilisez une classe <literal>Adresse</literal> pour encapsuler <literal>Rue</"
|
||||
"literal>, <literal>Region</literal>, <literal>CodePostal</literal>. Ceci "
|
||||
"permet la réutilisation du code et simplifie la maintenance."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:43
|
||||
#, no-c-format
|
||||
msgid "Declare identifier properties on persistent classes."
|
||||
msgstr "Déclarez des propriétés d'identifiants dans les classes persistantes."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:45
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate makes identifier properties optional. There are all sorts of "
|
||||
"reasons why you should use them. We recommend that identifiers be "
|
||||
"'synthetic' (generated, with no business meaning)."
|
||||
msgstr ""
|
||||
"Hibernate rend les propriétés d'identifiants optionnelles. Il existe "
|
||||
"beaucoup de raisons pour lesquelles vous devriez les utiliser. Nous "
|
||||
"recommandons que vous utilisiez des identifiants techniques (générés, et "
|
||||
"sans connotation métier)."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:53
|
||||
#, no-c-format
|
||||
msgid "Identify natural keys."
|
||||
msgstr "Identifiez les clefs naturelles."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:55
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Identify natural keys for all entities, and map them using <literal><"
|
||||
"natural-id></literal>. Implement <literal>equals()</literal> and "
|
||||
"<literal>hashCode()</literal> to compare the properties that make up the "
|
||||
"natural key."
|
||||
msgstr ""
|
||||
"Identifiez les clefs naturelles pour toutes les entités, et mappez les avec "
|
||||
"<literal><natural-id></literal>. Implémentez <literal>equals()</"
|
||||
"literal> et <literal>hashCode()</literal> pour comparer les propriétés qui "
|
||||
"composent la clef naturelle."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:63
|
||||
#, no-c-format
|
||||
msgid "Place each class mapping in its own file."
|
||||
msgstr "Placez chaque mapping de classe dans son propre fichier."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:65
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Don't use a single monolithic mapping document. Map <literal>com.eg.Foo</"
|
||||
"literal> in the file <literal>com/eg/Foo.hbm.xml</literal>. This makes "
|
||||
"particularly good sense in a team environment."
|
||||
msgstr ""
|
||||
"N'utilisez pas un unique document de mapping. Mappez <literal>com.eg.Foo</"
|
||||
"literal> dans le fichier <literal>com/eg/Foo.hbm.xml</literal>. Cela prend "
|
||||
"tout son sens lors d'un travail en équipe."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:73
|
||||
#, no-c-format
|
||||
msgid "Load mappings as resources."
|
||||
msgstr "Chargez les mappings comme des ressources."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:75
|
||||
#, no-c-format
|
||||
msgid "Deploy the mappings along with the classes they map."
|
||||
msgstr "Déployez les mappings en même temps que les classes qu'ils mappent."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:81
|
||||
#, no-c-format
|
||||
msgid "Consider externalising query strings."
|
||||
msgstr "Pensez à externaliser les chaînes de caractères."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:83
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This is a good practice if your queries call non-ANSI-standard SQL "
|
||||
"functions. Externalising the query strings to mapping files will make the "
|
||||
"application more portable."
|
||||
msgstr ""
|
||||
"Ceci est une bonne habitude si vos requêtes appellent des fonctions SQL qui "
|
||||
"ne sont pas au standard ANSI. Cette externalisation dans les fichiers de "
|
||||
"mapping rendra votre application plus portable."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:91
|
||||
#, no-c-format
|
||||
msgid "Use bind variables."
|
||||
msgstr "Utilisez les variables \"bindées\"."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:93
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"As in JDBC, always replace non-constant values by \"?\". Never use string "
|
||||
"manipulation to bind a non-constant value in a query! Even better, consider "
|
||||
"using named parameters in queries."
|
||||
msgstr ""
|
||||
"Comme en JDBC, remplacez toujours les valeurs non constantes par \"?\". "
|
||||
"N'utilisez jamais la manipulation des chaînes de caractères pour remplacer "
|
||||
"des valeurs non constantes dans une requête ! Encore mieux, utilisez les "
|
||||
"paramètres nommés dans les requêtes."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:101
|
||||
#, no-c-format
|
||||
msgid "Don't manage your own JDBC connections."
|
||||
msgstr "Ne gérez pas vous même les connexions JDBC."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:103
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate lets the application manage JDBC connections. This approach should "
|
||||
"be considered a last-resort. If you can't use the built-in connections "
|
||||
"providers, consider providing your own implementation of <literal>org."
|
||||
"hibernate.connection.ConnectionProvider</literal>."
|
||||
msgstr ""
|
||||
"Hibernate laisse l'application gérer les connexions JDBC. Vous ne devriez "
|
||||
"gérer vos connexions qu'en dernier recours. Si vous ne pouvez pas utiliser "
|
||||
"les systèmes de connexions livrés, réfléchissez à l'idée de fournir votre "
|
||||
"propre implémentation de <literal>org.hibernate.connection."
|
||||
"ConnectionProvider</literal>."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:111
|
||||
#, no-c-format
|
||||
msgid "Consider using a custom type."
|
||||
msgstr "Pensez à utiliser les types utilisateurs."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:113
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Suppose you have a Java type, say from some library, that needs to be "
|
||||
"persisted but doesn't provide the accessors needed to map it as a component. "
|
||||
"You should consider implementing <literal>org.hibernate.UserType</literal>. "
|
||||
"This approach frees the application code from implementing transformations "
|
||||
"to / from a Hibernate type."
|
||||
msgstr ""
|
||||
"Supposez que vous ayez une type Java, de telle bibliothèque, qui a besoin "
|
||||
"d'être persisté mais qui ne fournit pas les accesseurs nécessaires pour le "
|
||||
"mapper comme composant. Vous devriez implémenter <literal>org.hibernate."
|
||||
"UserType</literal>.Cette approche libère le code de l'application de "
|
||||
"l'implémentation des transformations vers / depuis les types Hibernate."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:122
|
||||
#, no-c-format
|
||||
msgid "Use hand-coded JDBC in bottlenecks."
|
||||
msgstr "Utilisez du JDBC pur dans les goulets d'étranglement."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:124
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"In performance-critical areas of the system, some kinds of operations might "
|
||||
"benefit from direct JDBC. But please, wait until you <emphasis>know</"
|
||||
"emphasis> something is a bottleneck. And don't assume that direct JDBC is "
|
||||
"necessarily faster. If you need to use direct JDBC, it might be worth "
|
||||
"opening a Hibernate <literal>Session</literal> and using that JDBC "
|
||||
"connection. That way you can still use the same transaction strategy and "
|
||||
"underlying connection provider."
|
||||
msgstr ""
|
||||
"Dans certaines parties critiques de votre système d'un point de vue "
|
||||
"performance, quelques opérations peuvent tirer partie d'un appel JDBC natif. "
|
||||
"Mais attendez de <emphasis>savoir</emphasis> que c'est un goulet "
|
||||
"d'étranglement. Ne supposez jamais qu'un appel JDBC sera forcément plus "
|
||||
"rapide. Si vous avez besoin d'utiliser JDBC directement, ouvrez une "
|
||||
"<literal>Session</literal> Hibernate et utilisez la connexion SQL sous-"
|
||||
"jacente. Ainsi vous pourrez utiliser la même stratégie de transation et la "
|
||||
"même gestion des connexions."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:134
|
||||
#, no-c-format
|
||||
msgid "Understand <literal>Session</literal> flushing."
|
||||
msgstr "Comprendre le flush de <literal>Session</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:136
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"From time to time the Session synchronizes its persistent state with the "
|
||||
"database. Performance will be affected if this process occurs too often. You "
|
||||
"may sometimes minimize unnecessary flushing by disabling automatic flushing "
|
||||
"or even by changing the order of queries and other operations within a "
|
||||
"particular transaction."
|
||||
msgstr ""
|
||||
"De temps en temps la Session synchronise ses états persistants avec la base "
|
||||
"de données. Les performances seront affectées si ce processus arrive trop "
|
||||
"souvent. Vous pouvez parfois minimiser les flush non nécessaires en "
|
||||
"désactivant le flush automatique ou même en changeant l'ordre des opérations "
|
||||
"menées dans une transaction particulière."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:145
|
||||
#, no-c-format
|
||||
msgid "In a three tiered architecture, consider using detached objects."
|
||||
msgstr ""
|
||||
"Dans une architecture à trois couches, pensez à utiliser "
|
||||
"<literal>saveOrUpdate()</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:147
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"When using a servlet / session bean architecture, you could pass persistent "
|
||||
"objects loaded in the session bean to and from the servlet / JSP layer. Use "
|
||||
"a new session to service each request. Use <literal>Session.merge()</"
|
||||
"literal> or <literal>Session.saveOrUpdate()</literal> to synchronize objects "
|
||||
"with the database."
|
||||
msgstr ""
|
||||
"Quand vous utilisez une architecture à base de servlet / session bean, vous "
|
||||
"pourriez passer des objets chargés dans le bean session vers et depuis la "
|
||||
"couche servlet / JSP. Utilisez une nouvelle session pour traiter chaque "
|
||||
"requête. Utilisez <literal>Session.merge()</literal> ou <literal>Session."
|
||||
"saveOrUpdate()</literal> pour synchroniser les objets avec la base de "
|
||||
"données."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:156
|
||||
#, no-c-format
|
||||
msgid "In a two tiered architecture, consider using long persistence contexts."
|
||||
msgstr ""
|
||||
"Dans une architecture à deux couches, pensez à utiliser la déconnexion de "
|
||||
"session."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:158
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Database Transactions have to be as short as possible for best scalability. "
|
||||
"However, it is often neccessary to implement long running "
|
||||
"<emphasis>application transactions</emphasis>, a single unit-of-work from "
|
||||
"the point of view of a user. An application transaction might span several "
|
||||
"client request/response cycles. It is common to use detached objects to "
|
||||
"implement application transactions. An alternative, extremely appropriate in "
|
||||
"two tiered architecture, is to maintain a single open persistence contact "
|
||||
"(session) for the whole life cycle of the application transaction and simply "
|
||||
"disconnect from the JDBC connection at the end of each request and reconnect "
|
||||
"at the beginning of the subsequent request. Never share a single session "
|
||||
"across more than one application transaction, or you will be working with "
|
||||
"stale data."
|
||||
msgstr ""
|
||||
"Les transactions de bases de données doivent être aussi courtes que possible "
|
||||
"pour une meilleure montée en charge.Cependant, il est souvent nécessaire "
|
||||
"d'implémenter de longues <emphasis>transactions applicatives</emphasis>, une "
|
||||
"simple unité de travail du point de vue de l'utilisateur. Une transaction "
|
||||
"applicative peut s'étaler sur plusieurs cycles de requêtes/réponses du "
|
||||
"client. Il est commun d'utiliser des objets détachés pour implémenter des "
|
||||
"transactions applicatives. Une alternative, extrêmement appropriée dans une "
|
||||
"architecture à 2 couches, est de maintenir un seul contact de persistance "
|
||||
"ouvert (session) pour toute la durée de vie de la transaction applicative et "
|
||||
"simplement se déconnecter de la connexion JDBC à la fin de chaque requête, "
|
||||
"et se reconnecter au début de la requête suivante. Ne partagez jamais une "
|
||||
"seule session avec plus d'une transaction applicative, ou vous travaillerez "
|
||||
"avec des données périmées."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:172
|
||||
#, no-c-format
|
||||
msgid "Don't treat exceptions as recoverable."
|
||||
msgstr "Considérez que les exceptions ne sont pas rattrapables."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:174
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This is more of a necessary practice than a \"best\" practice. When an "
|
||||
"exception occurs, roll back the <literal>Transaction</literal> and close the "
|
||||
"<literal>Session</literal>. If you don't, Hibernate can't guarantee that in-"
|
||||
"memory state accurately represents persistent state. As a special case of "
|
||||
"this, do not use <literal>Session.load()</literal> to determine if an "
|
||||
"instance with the given identifier exists on the database; use "
|
||||
"<literal>Session.get()</literal> or a query instead."
|
||||
msgstr ""
|
||||
"Il s'agit plus d'une pratique obligatoire que d'une \"meilleure pratique\". "
|
||||
"Quand une exception intervient, il faut faire un rollback de la "
|
||||
"<literal>Transaction</literal> et fermer la <literal>Session</literal>. "
|
||||
"Sinon, Hibernate ne peut garantir l'intégrité des états persistants en "
|
||||
"mémoire. En particulier, n'utilisez pas <literal>Session.load()</literal> "
|
||||
"pour déterminer si une instance avec un identifiant donné existe en base de "
|
||||
"données, utilisez <literal>Session.get()</literal> ou un requête."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:184
|
||||
#, no-c-format
|
||||
msgid "Prefer lazy fetching for associations."
|
||||
msgstr "Préférez le chargement tardif des associations."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:186
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Use eager fetching sparingly. Use proxies and lazy collections for most "
|
||||
"associations to classes that are not likely to be completely held in the "
|
||||
"second-level cache. For associations to cached classes, where there is an a "
|
||||
"extremely high probability of a cache hit, explicitly disable eager fetching "
|
||||
"using <literal>lazy=\"false\"</literal>. When an join fetching is "
|
||||
"appropriate to a particular use case, use a query with a <literal>left join "
|
||||
"fetch</literal>."
|
||||
msgstr ""
|
||||
"Utilisez le chargement complet avec modération. Utilisez les proxies et les "
|
||||
"collections chargées tardivement pour la plupart des associations vers des "
|
||||
"classes qui ne sont pas susceptibles d'être complètement retenues dans le "
|
||||
"cache de second niveau. Pour les assocations de classes en cache, où il y a "
|
||||
"une extrêmement forte probabilité que l'élément soit en cache, désactivez "
|
||||
"explicitement le chargement par jointures ouvertes en utilisant "
|
||||
"<literal>outer-join=\"false\"</literal>. Lorsqu'un chargement par jointure "
|
||||
"ouverte est approprié pour un cas d'utilisation particulier, utilisez une "
|
||||
"requête avec un <literal>left join fetch</literal>."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:196
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Use the <emphasis>open session in view</emphasis> pattern, or a disciplined "
|
||||
"<emphasis>assembly phase</emphasis> to avoid problems with unfetched data."
|
||||
msgstr ""
|
||||
"Utilisez le pattern <emphasis>d'une ouverture de session dans une vue</"
|
||||
"emphasis>, ou une <emphasis>phase d'assemblage</emphasis> disciplinée pour "
|
||||
"éviter des problèmes avec des données non rapatriées."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:201
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate frees the developer from writing tedious <emphasis>Data Transfer "
|
||||
"Objects</emphasis> (DTO). In a traditional EJB architecture, DTOs serve dual "
|
||||
"purposes: first, they work around the problem that entity beans are not "
|
||||
"serializable; second, they implicitly define an assembly phase where all "
|
||||
"data to be used by the view is fetched and marshalled into the DTOs before "
|
||||
"returning control to the presentation tier. Hibernate eliminates the first "
|
||||
"purpose. However, you will still need an assembly phase (think of your "
|
||||
"business methods as having a strict contract with the presentation tier "
|
||||
"about what data is available in the detached objects) unless you are "
|
||||
"prepared to hold the persistence context (the session) open across the view "
|
||||
"rendering process. This is not a limitation of Hibernate! It is a "
|
||||
"fundamental requirement of safe transactional data access."
|
||||
msgstr ""
|
||||
"Hibernate libère les développeurs de l'écriture fastidieuse des "
|
||||
"<emphasis>objets de transfert de données (NdT : Data Transfer Objects)</"
|
||||
"emphasis> (DTO). Dans une architecture EJB traditionnelle, les DTOs ont deux "
|
||||
"buts : premièrement, ils contournent le problème des \"entity bean\" qui ne "
|
||||
"sont pas sérialisables ; deuxièmement, ils définissent implicitement une "
|
||||
"phase d'assemblage où toutes les données utilisées par la vue sont "
|
||||
"rapatriées et organisées dans les DTOs avant de retourner sous le contrôle "
|
||||
"de la couche de présentation. Hibernate élimine le premier but. Pourtant, "
|
||||
"vous aurez encore besoin d'une phase d'assemblage (pensez vos méthodes "
|
||||
"métier comme ayant un contrat strict avec la couche de présentation à propos "
|
||||
"de quelles données sont disponibles dans les objets détachés) à moins que "
|
||||
"vous soyez préparés à garder le contexte de persistance (la session) ouvert "
|
||||
"à travers tout le processus de rendu de la vue."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:215
|
||||
#, no-c-format
|
||||
msgid "Consider abstracting your business logic from Hibernate."
|
||||
msgstr "Pensez à abstraite votre logique métier d'Hibernate."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:217
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hide (Hibernate) data-access code behind an interface. Combine the "
|
||||
"<emphasis>DAO</emphasis> and <emphasis>Thread Local Session</emphasis> "
|
||||
"patterns. You can even have some classes persisted by handcoded JDBC, "
|
||||
"associated to Hibernate via a <literal>UserType</literal>. (This advice is "
|
||||
"intended for \"sufficiently large\" applications; it is not appropriate for "
|
||||
"an application with five tables!)"
|
||||
msgstr ""
|
||||
"Cachez le mécanisme d'accès aux données (Hibernate) derrière une interface. "
|
||||
"Combinez les patterns <emphasis>DAO</emphasis> et <emphasis>Thread Local "
|
||||
"Session</emphasis>. Vous pouvez même avoir quelques classes persistées par "
|
||||
"du JDBC pur, associées à Hibernate via un <literal>UserType</literal> (ce "
|
||||
"conseil est valable pour des applications de taille respectables ; il n'est "
|
||||
"pas valable pour une application avec cinq tables)."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:227
|
||||
#, no-c-format
|
||||
msgid "Don't use exotic association mappings."
|
||||
msgstr "N'utilisez pas d'associations de mapping exotiques."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:229
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Good usecases for a real many-to-many associations are rare. Most of the "
|
||||
"time you need additional information stored in the \"link table\". In this "
|
||||
"case, it is much better to use two one-to-many associations to an "
|
||||
"intermediate link class. In fact, we think that most associations are one-to-"
|
||||
"many and many-to-one, you should be careful when using any other association "
|
||||
"style and ask yourself if it is really neccessary."
|
||||
msgstr ""
|
||||
"De bons cas d'utilisation pour de vraies associations plusieurs-vers-"
|
||||
"plusieurs sont rares. La plupart du temps vous avez besoin d'informations "
|
||||
"additionnelles stockées dans la table d'association. Dans ce cas, il est "
|
||||
"préférable d'utiliser deux associations un-vers-plusieurs vers une classe de "
|
||||
"liaisons intermédiaire. En fait, nous pensons que la plupart des "
|
||||
"associations sont de type un-vers-plusieurs ou plusieurs-vers-un, vous devez "
|
||||
"être très attentifs lorsque vous utilisez autre chose et vous demander si "
|
||||
"c'est vraiment nécessaire."
|
||||
|
||||
#. Tag: term
|
||||
#: best_practices.xml:239
|
||||
#, no-c-format
|
||||
msgid "Prefer bidirectional associations."
|
||||
msgstr "Préférez les associations bidirectionnelles."
|
||||
|
||||
#. Tag: para
|
||||
#: best_practices.xml:241
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Unidirectional associations are more difficult to query. In a large "
|
||||
"application, almost all associations must be navigable in both directions in "
|
||||
"queries."
|
||||
msgstr ""
|
||||
"Les associations unidirectionnelles sont plus difficiles à questionner. Dans "
|
||||
"une grande application, la plupart des associations devraient être "
|
||||
"navigables dans les deux directions dans les requêtes."
|
|
@ -0,0 +1,687 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: component_mapping.xml:29
|
||||
#, no-c-format
|
||||
msgid "Component Mapping"
|
||||
msgstr "Mapping de composants"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The notion of a <emphasis>component</emphasis> is re-used in several "
|
||||
"different contexts, for different purposes, throughout Hibernate."
|
||||
msgstr ""
|
||||
"La notion de <emphasis>composants</emphasis> est réutilisé dans différents "
|
||||
"contextes, avec différents objectifs, à travers Hibernate."
|
||||
|
||||
#. Tag: title
|
||||
#: component_mapping.xml:37
|
||||
#, no-c-format
|
||||
msgid "Dependent objects"
|
||||
msgstr "Objects dépendants"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:39
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A component is a contained object that is persisted as a value type, not an "
|
||||
"entity reference. The term \"component\" refers to the object-oriented "
|
||||
"notion of composition (not to architecture-level components). For example, "
|
||||
"you might model a person like this:"
|
||||
msgstr ""
|
||||
"Le composant est un objet inclu dans un autre qui est sauvegardé comme une "
|
||||
"valeur, et non pas comme une entité. Le composant fait référence à la notion "
|
||||
"(au sens objet) de composition (et non pas de composant au sens "
|
||||
"d'architecture de composants). Par exemple on pourrait modélisé l'objet "
|
||||
"personne de cette façon:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:45
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[public class Person {\n"
|
||||
" private java.util.Date birthday;\n"
|
||||
" private Name name;\n"
|
||||
" private String key;\n"
|
||||
" public String getKey() {\n"
|
||||
" return key;\n"
|
||||
" }\n"
|
||||
" private void setKey(String key) {\n"
|
||||
" this.key=key;\n"
|
||||
" }\n"
|
||||
" public java.util.Date getBirthday() {\n"
|
||||
" return birthday;\n"
|
||||
" }\n"
|
||||
" public void setBirthday(java.util.Date birthday) {\n"
|
||||
" this.birthday = birthday;\n"
|
||||
" }\n"
|
||||
" public Name getName() {\n"
|
||||
" return name;\n"
|
||||
" }\n"
|
||||
" public void setName(Name name) {\n"
|
||||
" this.name = name;\n"
|
||||
" }\n"
|
||||
" ......\n"
|
||||
" ......\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:47
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[public class Name {\n"
|
||||
" char initial;\n"
|
||||
" String first;\n"
|
||||
" String last;\n"
|
||||
" public String getFirst() {\n"
|
||||
" return first;\n"
|
||||
" }\n"
|
||||
" void setFirst(String first) {\n"
|
||||
" this.first = first;\n"
|
||||
" }\n"
|
||||
" public String getLast() {\n"
|
||||
" return last;\n"
|
||||
" }\n"
|
||||
" void setLast(String last) {\n"
|
||||
" this.last = last;\n"
|
||||
" }\n"
|
||||
" public char getInitial() {\n"
|
||||
" return initial;\n"
|
||||
" }\n"
|
||||
" void setInitial(char initial) {\n"
|
||||
" this.initial = initial;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:49
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Now <literal>Name</literal> may be persisted as a component of "
|
||||
"<literal>Person</literal>. Notice that <literal>Name</literal> defines "
|
||||
"getter and setter methods for its persistent properties, but doesn't need to "
|
||||
"declare any interfaces or identifier properties."
|
||||
msgstr ""
|
||||
"Maintenant <literal>Name</literal> peut-être sauvegardé comme un composant "
|
||||
"de <literal>Person</literal>. Remarquer que <literal>Name</literal> définit "
|
||||
"des methodes d'accès et de modification pour ses propriétés persistantes, "
|
||||
"mais il n'a pas besoin des interfaces ou des propriétés d'identification "
|
||||
"( par exemple getId() ) qui sont propres aux entités."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:56
|
||||
#, no-c-format
|
||||
msgid "Our Hibernate mapping would look like:"
|
||||
msgstr "Nous serions alors amené à mapper ce composant de cette façon:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:60
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
|
||||
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
|
||||
" <generator class=\"uuid\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"birthday\" type=\"date\"/>\n"
|
||||
" <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute "
|
||||
"optional -->\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </component>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:62
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The person table would have the columns <literal>pid</literal>, "
|
||||
"<literal>birthday</literal>, <literal>initial</literal>, <literal>first</"
|
||||
"literal> and <literal>last</literal>."
|
||||
msgstr ""
|
||||
"La table person aurai les colonnes <literal>pid</literal>, "
|
||||
"<literal>birthday</literal>, <literal>initial</literal>, <literal>first</"
|
||||
"literal> and <literal>last</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:70
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Like all value types, components do not support shared references. In other "
|
||||
"words, two persons could have the same name, but the two person objects "
|
||||
"would contain two independent name ojects, only \"the same\" by value. The "
|
||||
"null value semantics of a component are <emphasis>ad hoc</emphasis>. When "
|
||||
"reloading the containing object, Hibernate will assume that if all component "
|
||||
"columns are null, then the entire component is null. This should be okay for "
|
||||
"most purposes."
|
||||
msgstr ""
|
||||
"Comme tous les types valeurs, les composants ne supportent pas les "
|
||||
"références partagés. En d'autres mots, deux instances de person peuvent "
|
||||
"avoir un même nom, mais ces noms sont indépendants, ils peuvent être "
|
||||
"identiques si on les compare par valeur mais ils représentent deux objets "
|
||||
"distincts en mémoire. La notion de nullité pour un composant est "
|
||||
"<emphasis>ad hoc</emphasis>. Quand il recharge l'objet qui contient le "
|
||||
"composant, Hibernate supposera que si tous les champs du composants sont "
|
||||
"nuls alors le composant sera positionné à la valeur null. Ce choix "
|
||||
"programmatif devrait être satisfaisant dans la plupart des cas."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:79
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The properties of a component may be of any Hibernate type (collections, "
|
||||
"many-to-one associations, other components, etc). Nested components should "
|
||||
"<emphasis>not</emphasis> be considered an exotic usage. Hibernate is "
|
||||
"intended to support a very fine-grained object model."
|
||||
msgstr ""
|
||||
"Les propriétés d'un composant peuvent être de tous les types qu'Hibernate "
|
||||
"supporte habituellement (collections, many-to-one associations, autres "
|
||||
"composants, etc). Les composants inclus ne doivent <emphasis>pas</emphasis> "
|
||||
"être vus comme quelque chose d'exotique. Hibernate a été conçu pour "
|
||||
"supporter un modèle objet très granulaire."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:86
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal><component></literal> element allows a <literal><"
|
||||
"parent></literal> subelement that maps a property of the component class "
|
||||
"as a reference back to the containing entity."
|
||||
msgstr ""
|
||||
"Le <literal><component></literal> peut inclure dans la liste de ses "
|
||||
"propriétés une référence au <literal><parent></literal> conteneur."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:92
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
|
||||
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
|
||||
" <generator class=\"uuid\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"birthday\" type=\"date\"/>\n"
|
||||
" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"
|
||||
" <parent name=\"namedPerson\"/> <!-- reference back to the Person --"
|
||||
">\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </component>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: component_mapping.xml:97
|
||||
#, no-c-format
|
||||
msgid "Collections of dependent objects"
|
||||
msgstr "Collection d'objets dépendants"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:99
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Collections of components are supported (eg. an array of type <literal>Name</"
|
||||
"literal>). Declare your component collection by replacing the <literal><"
|
||||
"element></literal> tag with a <literal><composite-element></"
|
||||
"literal> tag."
|
||||
msgstr ""
|
||||
"Les collections d'objets dépendants sont supportés (exemple: un tableau de "
|
||||
"type <literal>Name</literal>). Déclarer la collection de composants en "
|
||||
"remplaçant le tag <literal><element></literal> par le tag <literal><"
|
||||
"composite-element></literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:106
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"
|
||||
" <key column=\"id\"/>\n"
|
||||
" <composite-element class=\"eg.Name\"> <!-- class attribute required -->\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"first\"/>\n"
|
||||
" <property name=\"last\"/>\n"
|
||||
" </composite-element>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:108
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note: if you define a <literal>Set</literal> of composite elements, it is "
|
||||
"very important to implement <literal>equals()</literal> and <literal>hashCode"
|
||||
"()</literal> correctly."
|
||||
msgstr ""
|
||||
"Remarque: Si vous définissez un <literal>Set</literal> d'élément composite, "
|
||||
"il est très important d'implémenter la méthode <literal>equals()</literal> "
|
||||
"et <literal>hashCode()</literal> correctement."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:114
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Composite elements may contain components but not collections. If your "
|
||||
"composite element itself contains components, use the <literal><nested-"
|
||||
"composite-element></literal> tag. This is a pretty exotic case - a "
|
||||
"collection of components which themselves have components. By this stage you "
|
||||
"should be asking yourself if a one-to-many association is more appropriate. "
|
||||
"Try remodelling the composite element as an entity - but note that even "
|
||||
"though the Java model is the same, the relational model and persistence "
|
||||
"semantics are still slightly different."
|
||||
msgstr ""
|
||||
"Les élements composite peuvent aussi contenir des composants mais pas des "
|
||||
"collections. Si votre élément composite contient aussi des composants, "
|
||||
"utilisez l'élément <literal><nested-composite-element></literal> . Une "
|
||||
"collections de composants qui ccontiennent eux-mêmes des composants est un "
|
||||
"cas très exotique. A ce stade demandez-vous si une association un-à-"
|
||||
"plusieurs ne serait pas plus approprié. Essayez de re remodeler votre "
|
||||
"élément composite comme une entité ( Dans ce cas même si le modèle Java est "
|
||||
"le même la logique de persitence et de relation sont tout de même "
|
||||
"différentes)"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:126
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Please note that a composite element mapping doesn't support null-able "
|
||||
"properties if you're using a <literal><set></literal>. Hibernate has "
|
||||
"to use each columns value to identify a record when deleting objects (there "
|
||||
"is no separate primary key column in the composite element table), which is "
|
||||
"not possible with null values. You have to either use only not-null "
|
||||
"properties in a composite-element or choose a <literal><list></"
|
||||
"literal>, <literal><map></literal>, <literal><bag></literal> or "
|
||||
"<literal><idbag></literal>."
|
||||
msgstr ""
|
||||
"Remarque, le mapping d'éléments composites ne supporte pas la nullité des "
|
||||
"propriétés lorsqu'on utilise un <literal><set></literal>. Hibernate "
|
||||
"lorsqu'il supprime un objet utilise chaque colonne pour identifier un objet "
|
||||
"(on ne peut pas utiliser des clés primaires distinctes dans une table "
|
||||
"d'éléments composites), ce qui n'est pas possible avec des valeurs nulles. "
|
||||
"Vous devez donc choisir d'interdire la nullité des propriétés d'un élément "
|
||||
"composite ou choisir un autre type de collection comme : <literal><"
|
||||
"list></literal>, <literal><map></literal>, <literal><bag></"
|
||||
"literal> ou <literal><idbag></literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:137
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A special case of a composite element is a composite element with a nested "
|
||||
"<literal><many-to-one></literal> element. A mapping like this allows "
|
||||
"you to map extra columns of a many-to-many association table to the "
|
||||
"composite element class. The following is a many-to-many association from "
|
||||
"<literal>Order</literal> to <literal>Item</literal> where "
|
||||
"<literal>purchaseDate</literal>, <literal>price</literal> and "
|
||||
"<literal>quantity</literal> are properties of the association:"
|
||||
msgstr ""
|
||||
"Un cas particulier d'élément composite est un élément composite qui inclut "
|
||||
"un élément <literal><many-to-one></literal>. Un mapping comme celui-ci "
|
||||
"vous permet d'associer les colonnes d'une table d'association plusieurs à "
|
||||
"plusieurs (many-to-many) à la classse de l'élément composite. L'exemple "
|
||||
"suivant est une association plusieurs à plusieurs de <literal>Order</"
|
||||
"literal> à <literal>Item</literal> à <literal>purchaseDate</literal>, "
|
||||
"<literal>price</literal> et <literal>quantity</literal> sont des propriétés "
|
||||
"de l'association."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:147
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Order\" .... >\n"
|
||||
" ....\n"
|
||||
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
|
||||
" <key column=\"order_id\">\n"
|
||||
" <composite-element class=\"eg.Purchase\">\n"
|
||||
" <property name=\"purchaseDate\"/>\n"
|
||||
" <property name=\"price\"/>\n"
|
||||
" <property name=\"quantity\"/>\n"
|
||||
" <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class "
|
||||
"attribute is optional -->\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:149
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Of course, there can't be a reference to the purchae on the other side, for "
|
||||
"bidirectional association navigation. Remember that components are value "
|
||||
"types and don't allow shared references. A single <literal>Purchase</"
|
||||
"literal> can be in the set of an <literal>Order</literal>, but it can't be "
|
||||
"referenced by the <literal>Item</literal> at the same time."
|
||||
msgstr ""
|
||||
"Bien sûr, il ne peut pas y avoir de référence à l'achat (purchase) depuis "
|
||||
"l'article (item), pour pouvoir naviguer de façon bidirectionnelle dans "
|
||||
"l'association. N'oubliez pas que les composants sont de type valeurs et "
|
||||
"n'autorise pas les références partagées."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:157
|
||||
#, no-c-format
|
||||
msgid "Even ternary (or quaternary, etc) associations are possible:"
|
||||
msgstr "Même les associations ternaires ou quaternaires sont possibles:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:159
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"eg.Order\" .... >\n"
|
||||
" ....\n"
|
||||
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
|
||||
" <key column=\"order_id\">\n"
|
||||
" <composite-element class=\"eg.OrderLine\">\n"
|
||||
" <many-to-one name=\"purchaseDetails class=\"eg.Purchase\"/>\n"
|
||||
" <many-to-one name=\"item\" class=\"eg.Item\"/>\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:161
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Composite elements may appear in queries using the same syntax as "
|
||||
"associations to other entities."
|
||||
msgstr ""
|
||||
"Les éléments composites peuvent apparaître dans les requêtes en utilisant la "
|
||||
"même syntaxe que associations"
|
||||
|
||||
#. Tag: title
|
||||
#: component_mapping.xml:169
|
||||
#, no-c-format
|
||||
msgid "Components as Map indices"
|
||||
msgstr "Utiliser les composants comme index de map"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:171
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal><composite-map-key></literal> element lets you map a "
|
||||
"component class as the key of a <literal>Map</literal>. Make sure you "
|
||||
"override <literal>hashCode()</literal> and <literal>equals()</literal> "
|
||||
"correctly on the component class."
|
||||
msgstr ""
|
||||
"l'élément <literal><composite-map-key></literal> vous permet "
|
||||
"d'utiliser une classe de composant comme indice de <literal>Map</literal>. "
|
||||
"Assurez-vous d'avoir surdéfini <literal>hashCode()</literal> et "
|
||||
"<literal>equals()</literal> dans la classe du composant."
|
||||
|
||||
#. Tag: title
|
||||
#: component_mapping.xml:180
|
||||
#, no-c-format
|
||||
msgid "Components as composite identifiers"
|
||||
msgstr "Utiliser un composant comme identifiant"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:182
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You may use a component as an identifier of an entity class. Your component "
|
||||
"class must satisfy certain requirements:"
|
||||
msgstr ""
|
||||
"Vous pouvez utiliser un composant comme identifiant d'une entité. Mais pour "
|
||||
"cela la classe du composant doit respecter certaines règles."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:189
|
||||
#, no-c-format
|
||||
msgid "It must implement <literal>java.io.Serializable</literal>."
|
||||
msgstr "Elle doit implémenter <literal>java.io.Serializable</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:194
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"It must re-implement <literal>equals()</literal> and <literal>hashCode()</"
|
||||
"literal>, consistently with the database's notion of composite key equality."
|
||||
msgstr ""
|
||||
"Elle doit redéfinir <literal>equals()</literal> et <literal>hashCode()</"
|
||||
"literal>, de façon cohérente avec le fait qu'elle définit une clé composite "
|
||||
"dans la base de données."
|
||||
|
||||
#. Tag: emphasis
|
||||
#: component_mapping.xml:203
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note: in Hibernate3, the second requirement is not an absolutely hard "
|
||||
"requirement of Hibernate. But do it anyway."
|
||||
msgstr ""
|
||||
"Remarque: avec hibernate3, la seconde règle n'est plus absolument necessaire "
|
||||
"mais faîtes le quand même."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:207
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You can't use an <literal>IdentifierGenerator</literal> to generate "
|
||||
"composite keys. Instead the application must assign its own identifiers."
|
||||
msgstr ""
|
||||
"Vous ne pouvez pas utiliser de <literal>IdentifierGenerator</literal> pour "
|
||||
"générer une clé composite, l'application devra définir elle même ses propres "
|
||||
"identifiants."
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:212
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Use the <literal><composite-id></literal> tag (with nested "
|
||||
"<literal><key-property></literal> elements) in place of the usual "
|
||||
"<literal><id></literal> declaration. For example, the "
|
||||
"<literal>OrderLine</literal> class has a primary key that depends upon the "
|
||||
"(composite) primary key of <literal>Order</literal>."
|
||||
msgstr ""
|
||||
"Utiliser l'élément <literal><composite-id></literal> (en incluant "
|
||||
"l'élément <literal><key-property></literal>) à la place de l'habituel "
|
||||
"déclaration <literal><id></literal>. Par exemple la classe "
|
||||
"<literal>OrderLine</literal> qui dépend de la clé primaire (composite) de "
|
||||
"<literal>Order</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:220
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"OrderLine\">\n"
|
||||
" \n"
|
||||
" <composite-id name=\"id\" class=\"OrderLineId\">\n"
|
||||
" <key-property name=\"lineId\"/>\n"
|
||||
" <key-property name=\"orderId\"/>\n"
|
||||
" <key-property name=\"customerId\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" \n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"order\" class=\"Order\"\n"
|
||||
" insert=\"false\" update=\"false\">\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </many-to-one>\n"
|
||||
" ....\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:222
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Now, any foreign keys referencing the <literal>OrderLine</literal> table are "
|
||||
"also composite. You must declare this in your mappings for other classes. An "
|
||||
"association to <literal>OrderLine</literal> would be mapped like this:"
|
||||
msgstr ""
|
||||
"Maintenant toutes clés étrangères référençant la table <literal>OrderLine</"
|
||||
"literal> devra aussi être composite. Vous devez en tenir compte lorsque vous "
|
||||
"écrivez vos mapping d'association pour les autres classes. Une association à "
|
||||
"<literal>OrderLine</literal> devrait être mappé de la façon suivante :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:228
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"orderLine\" class=\"OrderLine\">\n"
|
||||
"<!-- the \"class\" attribute is optional, as usual -->\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
"</many-to-one>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:230
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"(Note that the <literal><column></literal> tag is an alternative to "
|
||||
"the <literal>column</literal> attribute everywhere.)"
|
||||
msgstr ""
|
||||
"(Remarque: l'élément <literal><column></literal> est une alternative à "
|
||||
"l'attribut <literal>column</literal> que l'on utilise partout.)"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:235
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <literal>many-to-many</literal> association to <literal>OrderLine</"
|
||||
"literal> also uses the composite foreign key:"
|
||||
msgstr ""
|
||||
"Une association <literal>plusieurs-à-plusieurs</literal> (many-to-many) à "
|
||||
"<literal>OrderLine</literal> utilisera aussi une clé étrangère composite:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:240
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"undeliveredOrderLines\">\n"
|
||||
" <key column name=\"warehouseId\"/>\n"
|
||||
" <many-to-many class=\"OrderLine\">\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </many-to-many>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:242
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The collection of <literal>OrderLine</literal>s in <literal>Order</literal> "
|
||||
"would use:"
|
||||
msgstr ""
|
||||
"La collection des <literal>OrderLine</literal>s dans <literal>Order</"
|
||||
"literal> utilisera:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:247
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"orderLines\" inverse=\"true\">\n"
|
||||
" <key>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </key>\n"
|
||||
" <one-to-many class=\"OrderLine\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:249
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"(The <literal><one-to-many></literal> element, as usual, declares no "
|
||||
"columns.)"
|
||||
msgstr ""
|
||||
"(L'élément <literal><one-to-many></literal>, comme d'habitude, ne "
|
||||
"déclare pas de colonne.)"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:253
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If <literal>OrderLine</literal> itself owns a collection, it also has a "
|
||||
"composite foreign key."
|
||||
msgstr ""
|
||||
"Si <literal>OrderLine</literal> lui-même possède une collection, celle-ci "
|
||||
"aura aussi une clé composite étrangère."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:258
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"OrderLine\">\n"
|
||||
" ....\n"
|
||||
" ....\n"
|
||||
" <list name=\"deliveryAttempts\">\n"
|
||||
" <key> <!-- a collection inherits the composite key type -->\n"
|
||||
" <column name=\"lineId\"/>\n"
|
||||
" <column name=\"orderId\"/>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" </key>\n"
|
||||
" <list-index column=\"attemptId\" base=\"1\"/>\n"
|
||||
" <composite-element class=\"DeliveryAttempt\">\n"
|
||||
" ...\n"
|
||||
" </composite-element>\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: component_mapping.xml:263
|
||||
#, no-c-format
|
||||
msgid "Dynamic components"
|
||||
msgstr "Composant Dynamique"
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:265
|
||||
#, no-c-format
|
||||
msgid "You may even map a property of type <literal>Map</literal>:"
|
||||
msgstr "Vous pouvez même mapper une propriété de type <literal>Map</literal>:"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: component_mapping.xml:269
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<dynamic-component name=\"userAttributes\">\n"
|
||||
" <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n"
|
||||
" <property name=\"bar\" column=\"BAR\" type=\"integer\"/>\n"
|
||||
" <many-to-one name=\"baz\" class=\"Baz\" column=\"BAZ_ID\"/>\n"
|
||||
"</dynamic-component>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: component_mapping.xml:271
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The semantics of a <literal><dynamic-component></literal> mapping are "
|
||||
"identical to <literal><component></literal>. The advantage of this "
|
||||
"kind of mapping is the ability to determine the actual properties of the "
|
||||
"bean at deployment time, just by editing the mapping document. Runtime "
|
||||
"manipulation of the mapping document is also possible, using a DOM parser. "
|
||||
"Even better, you can access (and change) Hibernate's configuration-time "
|
||||
"metamodel via the <literal>Configuration</literal> object."
|
||||
msgstr ""
|
||||
"La sémantique de l'association à un <literal><dynamic-component></"
|
||||
"literal> est identique à celle que l'on utilise pour les composants. "
|
||||
"L'avantage de ce type de mapping est qu'il pemet de déterminer les "
|
||||
"véritables propriétés du bean au moment su déploiement en éditant simplement "
|
||||
"le document de mapping. La manipulation du document de mapping pendant "
|
||||
"l'execution de l'application est aussi possible en utilisant un parser DOM. "
|
||||
"Il ya même mieux, vous pouvez accéder (et changer) le metamodel de "
|
||||
"configuration d'hibernate en utilisant l'objet <literal>Configuration</"
|
||||
"literal>"
|
|
@ -0,0 +1,480 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: events.xml:29
|
||||
#, no-c-format
|
||||
msgid "Interceptors and events"
|
||||
msgstr "Les intercepteurs et les événements"
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"It is often useful for the application to react to certain events that occur "
|
||||
"inside Hibernate. This allows implementation of certain kinds of generic "
|
||||
"functionality, and extension of Hibernate functionality."
|
||||
msgstr ""
|
||||
"Il est souvent utile pour l'application de réagir à certains événements qui "
|
||||
"surviennent dans Hibernate. Cela autorise l'implémentation de certaines "
|
||||
"sortes de fonctionnalités génériques, et d'extensions de fonctionnalités "
|
||||
"d'Hibernate."
|
||||
|
||||
#. Tag: title
|
||||
#: events.xml:38
|
||||
#, no-c-format
|
||||
msgid "Interceptors"
|
||||
msgstr "Intercepteurs"
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:40
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal>Interceptor</literal> interface provides callbacks from the "
|
||||
"session to the application allowing the application to inspect and/or "
|
||||
"manipulate properties of a persistent object before it is saved, updated, "
|
||||
"deleted or loaded. One possible use for this is to track auditing "
|
||||
"information. For example, the following <literal>Interceptor</literal> "
|
||||
"automatically sets the <literal>createTimestamp</literal> when an "
|
||||
"<literal>Auditable</literal> is created and updates the "
|
||||
"<literal>lastUpdateTimestamp</literal> property when an <literal>Auditable</"
|
||||
"literal> is updated."
|
||||
msgstr ""
|
||||
"L'interface <literal>Interceptor</literal> fournit des \"callbacks\" de la "
|
||||
"session vers l'application et permettent à l'application de consulter et/ou "
|
||||
"de manipuler des propriétés d'un objet persistant avant qu'il soit "
|
||||
"sauvegardé, mis à jour, supprimé ou chargé. Une utilisation possible de "
|
||||
"cette fonctionnalité est de tracer l'accès à l'information. Par exemple, "
|
||||
"l'<literal>Interceptor</literal> suivant positionne "
|
||||
"<literal>createTimestamp</literal> quand un <literal>Auditable</literal> est "
|
||||
"créé et met à jour la propriété <literal>lastUpdateTimestamp</literal> quand "
|
||||
"un <literal>Auditable</literal> est mis à jour."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:51
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You may either implement <literal>Interceptor</literal> directly or (better) "
|
||||
"extend <literal>EmptyInterceptor</literal>."
|
||||
msgstr ""
|
||||
"Vous pouvez soit implémenter <literal>Interceptor</literal> directement ou "
|
||||
"(mieux) étendre <literal>EmptyInterceptor</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:56
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[package org.hibernate.test;\n"
|
||||
"\n"
|
||||
"import java.io.Serializable;\n"
|
||||
"import java.util.Date;\n"
|
||||
"import java.util.Iterator;\n"
|
||||
"\n"
|
||||
"import org.hibernate.EmptyInterceptor;\n"
|
||||
"import org.hibernate.Transaction;\n"
|
||||
"import org.hibernate.type.Type;\n"
|
||||
"\n"
|
||||
"public class AuditInterceptor extends EmptyInterceptor {\n"
|
||||
"\n"
|
||||
" private int updates;\n"
|
||||
" private int creates;\n"
|
||||
" private int loads;\n"
|
||||
"\n"
|
||||
" public void onDelete(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
" // do nothing\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onFlushDirty(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] currentState,\n"
|
||||
" Object[] previousState,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
"\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" updates++;\n"
|
||||
" for ( int i=0; i < propertyNames.length; i++ ) {\n"
|
||||
" if ( \"lastUpdateTimestamp\".equals( propertyNames[i] ) ) {\n"
|
||||
" currentState[i] = new Date();\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onLoad(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" loads++;\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public boolean onSave(Object entity,\n"
|
||||
" Serializable id,\n"
|
||||
" Object[] state,\n"
|
||||
" String[] propertyNames,\n"
|
||||
" Type[] types) {\n"
|
||||
"\n"
|
||||
" if ( entity instanceof Auditable ) {\n"
|
||||
" creates++;\n"
|
||||
" for ( int i=0; i<propertyNames.length; i++ ) {\n"
|
||||
" if ( \"createTimestamp\".equals( propertyNames[i] ) ) {\n"
|
||||
" state[i] = new Date();\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public void afterTransactionCompletion(Transaction tx) {\n"
|
||||
" if ( tx.wasCommitted() ) {\n"
|
||||
" System.out.println(\"Creations: \" + creates + \", Updates: \" + "
|
||||
"updates, \"Loads: \" + loads);\n"
|
||||
" }\n"
|
||||
" updates=0;\n"
|
||||
" creates=0;\n"
|
||||
" loads=0;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:58
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Interceptors come in two flavors: <literal>Session</literal>-scoped and "
|
||||
"<literal>SessionFactory</literal>-scoped."
|
||||
msgstr ""
|
||||
"Interceptors come in two flavors: <literal>Session</literal>-scoped and "
|
||||
"<literal>SessionFactory</literal>-scoped."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:63
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <literal>Session</literal>-scoped interceptor is specified when a session "
|
||||
"is opened using one of the overloaded SessionFactory.openSession() methods "
|
||||
"accepting an <literal>Interceptor</literal>."
|
||||
msgstr ""
|
||||
"A <literal>Session</literal>-scoped interceptor is specified when a session "
|
||||
"is opened using one of the overloaded SessionFactory.openSession() methods "
|
||||
"accepting an <literal>Interceptor</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:69
|
||||
#, no-c-format
|
||||
msgid "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:71
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <literal>SessionFactory</literal>-scoped interceptor is registered with "
|
||||
"the <literal>Configuration</literal> object prior to building the "
|
||||
"<literal>SessionFactory</literal>. In this case, the supplied interceptor "
|
||||
"will be applied to all sessions opened from that <literal>SessionFactory</"
|
||||
"literal>; this is true unless a session is opened explicitly specifying the "
|
||||
"interceptor to use. <literal>SessionFactory</literal>-scoped interceptors "
|
||||
"must be thread safe, taking care to not store session-specific state since "
|
||||
"multiple sessions will use this interceptor (potentially) concurrently."
|
||||
msgstr ""
|
||||
"A <literal>SessionFactory</literal>-scoped interceptor is registered with "
|
||||
"the <literal>Configuration</literal> object prior to building the "
|
||||
"<literal>SessionFactory</literal>. In this case, the supplied interceptor "
|
||||
"will be applied to all sessions opened from that <literal>SessionFactory</"
|
||||
"literal>; this is true unless a session is opened explicitly specifying the "
|
||||
"interceptor to use. <literal>SessionFactory</literal>-scoped interceptors "
|
||||
"must be thread safe, taking care to not store session-specific state since "
|
||||
"multiple sessions will use this interceptor (potentially) concurrently."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:80
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: events.xml:85
|
||||
#, no-c-format
|
||||
msgid "Event system"
|
||||
msgstr "Système d'événements"
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:87
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If you have to react to particular events in your persistence layer, you may "
|
||||
"also use the Hibernate3 <emphasis>event</emphasis> architecture. The event "
|
||||
"system can be used in addition or as a replacement for interceptors."
|
||||
msgstr ""
|
||||
"Si vous devez réagir à des événements particuliers dans votre couche de "
|
||||
"persistance, vous pouvez aussi utiliser l'architecture "
|
||||
"d'<emphasis>événements</emphasis> d'Hibernate3. Le système d'événements peut "
|
||||
"être utilisé en supplément ou en remplacement des interceptors."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:93
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Essentially all of the methods of the <literal>Session</literal> interface "
|
||||
"correlate to an event. You have a <literal>LoadEvent</literal>, a "
|
||||
"<literal>FlushEvent</literal>, etc (consult the XML configuration-file DTD "
|
||||
"or the <literal>org.hibernate.event</literal> package for the full list of "
|
||||
"defined event types). When a request is made of one of these methods, the "
|
||||
"Hibernate <literal>Session</literal> generates an appropriate event and "
|
||||
"passes it to the configured event listeners for that type. Out-of-the-box, "
|
||||
"these listeners implement the same processing in which those methods always "
|
||||
"resulted. However, you are free to implement a customization of one of the "
|
||||
"listener interfaces (i.e., the <literal>LoadEvent</literal> is processed by "
|
||||
"the registered implemenation of the <literal>LoadEventListener</literal> "
|
||||
"interface), in which case their implementation would be responsible for "
|
||||
"processing any <literal>load()</literal> requests made of the "
|
||||
"<literal>Session</literal>."
|
||||
msgstr ""
|
||||
"Essentiellement toutes les méthodes de l'interface <literal>Session</"
|
||||
"literal> sont corrélées à un événement. Vous avez un <literal>LoadEvent</"
|
||||
"literal>, un <literal>FlushEvent</literal>, etc (consultez la DTD du fichier "
|
||||
"de configuration XML ou le paquet <literal>org.hibernate.event</literal> "
|
||||
"pour avoir la liste complète des types d'événement définis). Quand une "
|
||||
"requête est faite à partir d'une de ces méthodes, la <literal>Session</"
|
||||
"literal> Hibernate génère un événement approprié et le passe au listener "
|
||||
"configuré pour ce type. Par défaut, ces listeners implémentent le même "
|
||||
"traitement dans lequel ces méthodes aboutissent toujours. Cependant, vous "
|
||||
"êtes libre d'implémenter une version personnalisée d'une de ces interfaces "
|
||||
"de listener (c'est-à-dire, le <literal>LoadEvent</literal> est traité par "
|
||||
"l'implémentation de l'interface <literal>LoadEventListener</literal> "
|
||||
"déclarée), dans quel cas leur implémentation devrait être responsable du "
|
||||
"traitement des requêtes <literal>load()</literal> faites par la "
|
||||
"<literal>Session</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:108
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The listeners should be considered effectively singletons; meaning, they are "
|
||||
"shared between requests, and thus should not save any state as instance "
|
||||
"variables."
|
||||
msgstr ""
|
||||
"Les listeners devraient effectivement être considérés comme des singletons ; "
|
||||
"dans le sens où ils sont partagés entre des requêtes, et donc ne devraient "
|
||||
"pas sauvegarder des états de variables d'instance."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:113
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A custom listener should implement the appropriate interface for the event "
|
||||
"it wants to process and/or extend one of the convenience base classes (or "
|
||||
"even the default event listeners used by Hibernate out-of-the-box as these "
|
||||
"are declared non-final for this purpose). Custom listeners can either be "
|
||||
"registered programmatically through the <literal>Configuration</literal> "
|
||||
"object, or specified in the Hibernate configuration XML (declarative "
|
||||
"configuration through the properties file is not supported). Here's an "
|
||||
"example of a custom load event listener:"
|
||||
msgstr ""
|
||||
"Un listener personnalisé devrait implémenter l'interface appropriée pour "
|
||||
"l'événement qu'il veut traiter et/ou étendre une des classes de base (ou "
|
||||
"même l'événement prêt à l'emploi utilisé par Hibernate comme ceux déclarés "
|
||||
"non-finaux à cette intention). Les listeners personnalisés peuvent être soit "
|
||||
"inscrits par programmation à travers l'objet <literal>Configuration</"
|
||||
"literal>, ou spécifiés la configuration XML d'Hibernate (la configuration "
|
||||
"déclarative à travers le fichier de propriétés n'est pas supportée). Voici "
|
||||
"un exemple de listener personnalisé pour l'événement de chargement :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:123
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[public class MyLoadListener implements LoadEventListener {\n"
|
||||
" // this is the single method defined by the LoadEventListener interface\n"
|
||||
" public void onLoad(LoadEvent event, LoadEventListener.LoadType "
|
||||
"loadType)\n"
|
||||
" throws HibernateException {\n"
|
||||
" if ( !MySecurity.isAuthorized( event.getEntityClassName(), event."
|
||||
"getEntityId() ) ) {\n"
|
||||
" throw MySecurityException(\"Unauthorized access\");\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:125
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You also need a configuration entry telling Hibernate to use the listener in "
|
||||
"addition to the default listener:"
|
||||
msgstr ""
|
||||
"Vous avez aussi besoin d'une entrée de configuration disant à Hibernate "
|
||||
"d'utiliser ce listener en plus du listener par défaut :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:130
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-configuration>\n"
|
||||
" <session-factory>\n"
|
||||
" ...\n"
|
||||
" <event type=\"load\">\n"
|
||||
" <listener class=\"com.eg.MyLoadListener\"/>\n"
|
||||
" <listener class=\"org.hibernate.event.def."
|
||||
"DefaultLoadEventListener\"/>\n"
|
||||
" </event>\n"
|
||||
" </session-factory>\n"
|
||||
"</hibernate-configuration>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:132
|
||||
#, no-c-format
|
||||
msgid "Instead, you may register it programmatically:"
|
||||
msgstr "Vous pouvez aussi l'inscrire par programmation :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:136
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = new Configuration();\n"
|
||||
"LoadEventListener[] stack = { new MyLoadListener(), new "
|
||||
"DefaultLoadEventListener() };\n"
|
||||
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:138
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Listeners registered declaratively cannot share instances. If the same class "
|
||||
"name is used in multiple <literal><listener/></literal> elements, each "
|
||||
"reference will result in a separate instance of that class. If you need the "
|
||||
"capability to share listener instances between listener types you must use "
|
||||
"the programmatic registration approach."
|
||||
msgstr ""
|
||||
"Les listeners inscrits déclarativement ne peuvent pas partager d'instances. "
|
||||
"Si le même nom de classe est utilisée dans plusieurs éléments <literal><"
|
||||
"listener/></literal>, chaque référence sera une instance distincte de "
|
||||
"cette classe. Si vous avez besoin de la faculté de partager des instances de "
|
||||
"listener entre plusieurs types de listener, vous devez utiliser l'approche "
|
||||
"d'inscription par programmation."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:146
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Why implement an interface and define the specific type during "
|
||||
"configuration? Well, a listener implementation could implement multiple "
|
||||
"event listener interfaces. Having the type additionally defined during "
|
||||
"registration makes it easier to turn custom listeners on or off during "
|
||||
"configuration."
|
||||
msgstr ""
|
||||
"Pourquoi implémenter une interface et définir le type spécifique durant la "
|
||||
"configuration ? Une implémentation de listener pourrait implémenter "
|
||||
"plusieurs interfaces de listener d'événements. Avoir en plus le type défini "
|
||||
"durant l'inscription rend plus facile l'activation ou la désactivation "
|
||||
"pendant la configuration."
|
||||
|
||||
#. Tag: title
|
||||
#: events.xml:156
|
||||
#, no-c-format
|
||||
msgid "Hibernate declarative security"
|
||||
msgstr "Sécurité déclarative d'Hibernate"
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:157
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Usually, declarative security in Hibernate applications is managed in a "
|
||||
"session facade layer. Now, Hibernate3 allows certain actions to be "
|
||||
"permissioned via JACC, and authorized via JAAS. This is optional "
|
||||
"functionality built on top of the event architecture."
|
||||
msgstr ""
|
||||
"Généralement, la sécurité déclarative dans les applications Hibernate est "
|
||||
"gérée dans la couche de session. Maintenant, Hibernate3 permet à certaines "
|
||||
"actions d'être approuvées via JACC, et autorisées via JAAS. Cette "
|
||||
"fonctionnalité optionnelle est construite au dessus de l'architecture "
|
||||
"d'événements."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:163
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"First, you must configure the appropriate event listeners, to enable the use "
|
||||
"of JAAS authorization."
|
||||
msgstr ""
|
||||
"D'abord, vous devez configurer les listeners d'événements appropriés pour "
|
||||
"permettre l'utilisation d'autorisations JAAS."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:168
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<listener type=\"pre-delete\" class=\"org.hibernate.secure."
|
||||
"JACCPreDeleteEventListener\"/>\n"
|
||||
"<listener type=\"pre-update\" class=\"org.hibernate.secure."
|
||||
"JACCPreUpdateEventListener\"/>\n"
|
||||
"<listener type=\"pre-insert\" class=\"org.hibernate.secure."
|
||||
"JACCPreInsertEventListener\"/>\n"
|
||||
"<listener type=\"pre-load\" class=\"org.hibernate.secure."
|
||||
"JACCPreLoadEventListener\"/>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:170
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that <literal><listener type=\"...\" class=\"...\"/></literal> is "
|
||||
"just a shorthand for <literal><event type=\"...\"><listener class="
|
||||
"\"...\"/></event></literal> when there is exactly one listener for "
|
||||
"a particular event type."
|
||||
msgstr ""
|
||||
"Notez que <literal><listener type=\"...\" class=\"...\"/></literal> "
|
||||
"est juste un raccourci pour <literal><event type=\"...\"><listener "
|
||||
"class=\"...\"/></event></literal> quand il y a exactement un "
|
||||
"listener pour un type d'événement particulier."
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:176
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to "
|
||||
"roles:"
|
||||
msgstr ""
|
||||
"Ensuite, toujours dans <literal>hibernate.cfg.xml</literal>, lier les "
|
||||
"permissions aux rôles :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: events.xml:180
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,"
|
||||
"read\"/>\n"
|
||||
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: events.xml:182
|
||||
#, no-c-format
|
||||
msgid "The role names are the roles understood by your JACC provider."
|
||||
msgstr "Les noms de rôle sont les rôles compris par votre fournisseur JAAC."
|
|
@ -0,0 +1,795 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:29
|
||||
#, no-c-format
|
||||
msgid "Example: Various Mappings"
|
||||
msgstr "Exemple : quelques mappings"
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:31
|
||||
#, no-c-format
|
||||
msgid "This chapters shows off some more complex association mappings."
|
||||
msgstr "Ce chapitre montre quelques mappings plus complexes."
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:36
|
||||
#, no-c-format
|
||||
msgid "Employer/Employee"
|
||||
msgstr "Employeur/Employé (Employer/Employee)"
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:38
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The following model of the relationship between <literal>Employer</literal> "
|
||||
"and <literal>Employee</literal> uses an actual entity class "
|
||||
"(<literal>Employment</literal>) to represent the association. This is done "
|
||||
"because there might be more than one period of employment for the same two "
|
||||
"parties. Components are used to model monetary values and employee names."
|
||||
msgstr ""
|
||||
"Le modèle suivant de relation entre <literal>Employer</literal> et "
|
||||
"<literal>Employee</literal> utilise une vraie classe entité "
|
||||
"(<literal>Employment</literal>) pour représenter l'association. On a fait "
|
||||
"cela parce qu'il peut y avoir plus d'une période d'emploi pour les deux "
|
||||
"mêmes parties. Des composants sont utilisés pour modéliser les valeurs "
|
||||
"monétaires et les noms des employés."
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:55
|
||||
#, no-c-format
|
||||
msgid "Heres a possible mapping document:"
|
||||
msgstr "Voici un document de mapping possible :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:59
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
" \n"
|
||||
" <class name=\"Employer\" table=\"employers\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"sequence\">\n"
|
||||
" <param name=\"sequence\">employer_id_seq</param>\n"
|
||||
" </generator>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
" <class name=\"Employment\" table=\"employment_periods\">\n"
|
||||
"\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"sequence\">\n"
|
||||
" <param name=\"sequence\">employment_id_seq</param>\n"
|
||||
" </generator>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"startDate\" column=\"start_date\"/>\n"
|
||||
" <property name=\"endDate\" column=\"end_date\"/>\n"
|
||||
"\n"
|
||||
" <component name=\"hourlyRate\" class=\"MonetaryAmount\">\n"
|
||||
" <property name=\"amount\">\n"
|
||||
" <column name=\"hourly_rate\" sql-type=\"NUMERIC(12, 2)\"/>\n"
|
||||
" </property>\n"
|
||||
" <property name=\"currency\" length=\"12\"/>\n"
|
||||
" </component>\n"
|
||||
"\n"
|
||||
" <many-to-one name=\"employer\" column=\"employer_id\" not-null=\"true"
|
||||
"\"/>\n"
|
||||
" <many-to-one name=\"employee\" column=\"employee_id\" not-null=\"true"
|
||||
"\"/>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
" <class name=\"Employee\" table=\"employees\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"sequence\">\n"
|
||||
" <param name=\"sequence\">employee_id_seq</param>\n"
|
||||
" </generator>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"taxfileNumber\"/>\n"
|
||||
" <component name=\"name\" class=\"Name\">\n"
|
||||
" <property name=\"firstName\"/>\n"
|
||||
" <property name=\"initial\"/>\n"
|
||||
" <property name=\"lastName\"/>\n"
|
||||
" </component>\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:61
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"And heres the table schema generated by <literal>SchemaExport</literal>."
|
||||
msgstr ""
|
||||
"Et voici le schéma des tables générées par <literal>SchemaExport</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:65
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[create table employers (\n"
|
||||
" id BIGINT not null, \n"
|
||||
" name VARCHAR(255), \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table employment_periods (\n"
|
||||
" id BIGINT not null,\n"
|
||||
" hourly_rate NUMERIC(12, 2),\n"
|
||||
" currency VARCHAR(12), \n"
|
||||
" employee_id BIGINT not null, \n"
|
||||
" employer_id BIGINT not null, \n"
|
||||
" end_date TIMESTAMP, \n"
|
||||
" start_date TIMESTAMP, \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table employees (\n"
|
||||
" id BIGINT not null, \n"
|
||||
" firstName VARCHAR(255), \n"
|
||||
" initial CHAR(1), \n"
|
||||
" lastName VARCHAR(255), \n"
|
||||
" taxfileNumber VARCHAR(255), \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"alter table employment_periods \n"
|
||||
" add constraint employment_periodsFK0 foreign key (employer_id) "
|
||||
"references employers\n"
|
||||
"alter table employment_periods \n"
|
||||
" add constraint employment_periodsFK1 foreign key (employee_id) "
|
||||
"references employees\n"
|
||||
"create sequence employee_id_seq\n"
|
||||
"create sequence employment_id_seq\n"
|
||||
"create sequence employer_id_seq]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:70
|
||||
#, no-c-format
|
||||
msgid "Author/Work"
|
||||
msgstr "Auteur/Travail (Author/Work)"
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:72
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Consider the following model of the relationships between <literal>Work</"
|
||||
"literal>, <literal>Author</literal> and <literal>Person</literal>. We "
|
||||
"represent the relationship between <literal>Work</literal> and "
|
||||
"<literal>Author</literal> as a many-to-many association. We choose to "
|
||||
"represent the relationship between <literal>Author</literal> and "
|
||||
"<literal>Person</literal> as one-to-one association. Another possibility "
|
||||
"would be to have <literal>Author</literal> extend <literal>Person</literal>."
|
||||
msgstr ""
|
||||
"Soit le modèle de la relation entre <literal>Work</literal>, "
|
||||
"<literal>Author</literal> et <literal>Person</literal>. Nous représentons la "
|
||||
"relation entre <literal>Work</literal> et <literal>Author</literal> comme "
|
||||
"une association plusieurs-vers-plusieurs. Nous avons choisi de représenter "
|
||||
"la relation entre <literal>Author</literal> et <literal>Person</literal> "
|
||||
"comme une association un-vers-un. Une autre possibilité aurait été que "
|
||||
"<literal>Author</literal> hérite de <literal>Person</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:90
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The following mapping document correctly represents these relationships:"
|
||||
msgstr "Le mapping suivant représente exactement ces relations :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:94
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
"\n"
|
||||
" <class name=\"Work\" table=\"works\" discriminator-value=\"W\">\n"
|
||||
"\n"
|
||||
" <id name=\"id\" column=\"id\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"type\" type=\"character\"/>\n"
|
||||
"\n"
|
||||
" <property name=\"title\"/>\n"
|
||||
" <set name=\"authors\" table=\"author_work\">\n"
|
||||
" <key column name=\"work_id\"/>\n"
|
||||
" <many-to-many class=\"Author\" column name=\"author_id\"/>\n"
|
||||
" </set>\n"
|
||||
"\n"
|
||||
" <subclass name=\"Book\" discriminator-value=\"B\">\n"
|
||||
" <property name=\"text\"/>\n"
|
||||
" </subclass>\n"
|
||||
"\n"
|
||||
" <subclass name=\"Song\" discriminator-value=\"S\">\n"
|
||||
" <property name=\"tempo\"/>\n"
|
||||
" <property name=\"genre\"/>\n"
|
||||
" </subclass>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
" <class name=\"Author\" table=\"authors\">\n"
|
||||
"\n"
|
||||
" <id name=\"id\" column=\"id\">\n"
|
||||
" <!-- The Author must have the same identifier as the Person -->\n"
|
||||
" <generator class=\"assigned\"/> \n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property name=\"alias\"/>\n"
|
||||
" <one-to-one name=\"person\" constrained=\"true\"/>\n"
|
||||
"\n"
|
||||
" <set name=\"works\" table=\"author_work\" inverse=\"true\">\n"
|
||||
" <key column=\"author_id\"/>\n"
|
||||
" <many-to-many class=\"Work\" column=\"work_id\"/>\n"
|
||||
" </set>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
" <class name=\"Person\" table=\"persons\">\n"
|
||||
" <id name=\"id\" column=\"id\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:96
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There are four tables in this mapping. <literal>works</literal>, "
|
||||
"<literal>authors</literal> and <literal>persons</literal> hold work, author "
|
||||
"and person data respectively. <literal>author_work</literal> is an "
|
||||
"association table linking authors to works. Heres the table schema, as "
|
||||
"generated by <literal>SchemaExport</literal>."
|
||||
msgstr ""
|
||||
"Il y a quatre tables dans ce mapping. <literal>works</literal>, "
|
||||
"<literal>authors</literal> et <literal>persons</literal> qui contiennent "
|
||||
"respectivement les données de work, author et person. <literal>author_work</"
|
||||
"literal> est une table d'association qui lie authors à works. Voici le "
|
||||
"schéma de tables, généré par <literal>SchemaExport</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:104
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[create table works (\n"
|
||||
" id BIGINT not null generated by default as identity, \n"
|
||||
" tempo FLOAT, \n"
|
||||
" genre VARCHAR(255), \n"
|
||||
" text INTEGER, \n"
|
||||
" title VARCHAR(255), \n"
|
||||
" type CHAR(1) not null, \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table author_work (\n"
|
||||
" author_id BIGINT not null, \n"
|
||||
" work_id BIGINT not null, \n"
|
||||
" primary key (work_id, author_id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table authors (\n"
|
||||
" id BIGINT not null generated by default as identity, \n"
|
||||
" alias VARCHAR(255), \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table persons (\n"
|
||||
" id BIGINT not null generated by default as identity, \n"
|
||||
" name VARCHAR(255), \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"alter table authors \n"
|
||||
" add constraint authorsFK0 foreign key (id) references persons\n"
|
||||
"alter table author_work \n"
|
||||
" add constraint author_workFK0 foreign key (author_id) references "
|
||||
"authors\n"
|
||||
"alter table author_work\n"
|
||||
" add constraint author_workFK1 foreign key (work_id) references works]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:109
|
||||
#, no-c-format
|
||||
msgid "Customer/Order/Product"
|
||||
msgstr "Client/Commande/Produit (Customer/Order/Product)"
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:111
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Now consider a model of the relationships between <literal>Customer</"
|
||||
"literal>, <literal>Order</literal> and <literal>LineItem</literal> and "
|
||||
"<literal>Product</literal>. There is a one-to-many association between "
|
||||
"<literal>Customer</literal> and <literal>Order</literal>, but how should we "
|
||||
"represent <literal>Order</literal> / <literal>LineItem</literal> / "
|
||||
"<literal>Product</literal>? I've chosen to map <literal>LineItem</literal> "
|
||||
"as an association class representing the many-to-many association between "
|
||||
"<literal>Order</literal> and <literal>Product</literal>. In Hibernate, this "
|
||||
"is called a composite element."
|
||||
msgstr ""
|
||||
"Imaginons maintenant le modèle de relation entre <literal>Customer</"
|
||||
"literal>, <literal>Order</literal>, <literal>LineItem</literal> et "
|
||||
"<literal>Product</literal>. Il y a une association un-vers-plusieurs entre "
|
||||
"<literal>Customer</literal> et <literal>Order</literal>, mais comment "
|
||||
"devrions nous représenter <literal>Order</literal> / <literal>LineItem</"
|
||||
"literal> / <literal>Product</literal>? J'ai choisi de mapper "
|
||||
"<literal>LineItem</literal> comme une classe d'association représentant "
|
||||
"l'association plusieurs-vers-plusieurs entre <literal>Order</literal> et "
|
||||
"<literal>Product</literal>. Dans Hibernate, on appelle cela un élément "
|
||||
"composite."
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:131
|
||||
#, no-c-format
|
||||
msgid "The mapping document:"
|
||||
msgstr "Le document de mapping :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:135
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
"\n"
|
||||
" <class name=\"Customer\" table=\"customers\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" <set name=\"orders\" inverse=\"true\">\n"
|
||||
" <key column=\"customer_id\"/>\n"
|
||||
" <one-to-many class=\"Order\"/>\n"
|
||||
" </set>\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
" <class name=\"Order\" table=\"orders\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"date\"/>\n"
|
||||
" <many-to-one name=\"customer\" column=\"customer_id\"/>\n"
|
||||
" <list name=\"lineItems\" table=\"line_items\">\n"
|
||||
" <key column=\"order_id\"/>\n"
|
||||
" <list-index column=\"line_number\"/>\n"
|
||||
" <composite-element class=\"LineItem\">\n"
|
||||
" <property name=\"quantity\"/>\n"
|
||||
" <many-to-one name=\"product\" column=\"product_id\"/>\n"
|
||||
" </composite-element>\n"
|
||||
" </list>\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
" <class name=\"Product\" table=\"products\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"serialNumber\"/>\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:137
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal>customers</literal>, <literal>orders</literal>, "
|
||||
"<literal>line_items</literal> and <literal>products</literal> hold customer, "
|
||||
"order, order line item and product data respectively. <literal>line_items</"
|
||||
"literal> also acts as an association table linking orders with products."
|
||||
msgstr ""
|
||||
"<literal>customers</literal>, <literal>orders</literal>, "
|
||||
"<literal>line_items</literal> et <literal>products</literal> contiennent les "
|
||||
"données de customer, order, order line item et product. <literal>line_items</"
|
||||
"literal> est aussi la table d'association liant orders à products."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:144
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[create table customers (\n"
|
||||
" id BIGINT not null generated by default as identity, \n"
|
||||
" name VARCHAR(255), \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table orders (\n"
|
||||
" id BIGINT not null generated by default as identity, \n"
|
||||
" customer_id BIGINT, \n"
|
||||
" date TIMESTAMP, \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table line_items (\n"
|
||||
" line_number INTEGER not null, \n"
|
||||
" order_id BIGINT not null, \n"
|
||||
" product_id BIGINT, \n"
|
||||
" quantity INTEGER, \n"
|
||||
" primary key (order_id, line_number)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"create table products (\n"
|
||||
" id BIGINT not null generated by default as identity, \n"
|
||||
" serialNumber VARCHAR(255), \n"
|
||||
" primary key (id)\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"alter table orders \n"
|
||||
" add constraint ordersFK0 foreign key (customer_id) references customers\n"
|
||||
"alter table line_items\n"
|
||||
" add constraint line_itemsFK0 foreign key (product_id) references "
|
||||
"products\n"
|
||||
"alter table line_items\n"
|
||||
" add constraint line_itemsFK1 foreign key (order_id) references orders]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:149
|
||||
#, no-c-format
|
||||
msgid "Miscellaneous example mappings"
|
||||
msgstr "Divers mappings d'exemple"
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:151
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"These examples are all taken from the Hibernate test suite. You will find "
|
||||
"many other useful example mappings there. Look in the <literal>test</"
|
||||
"literal> folder of the Hibernate distribution."
|
||||
msgstr ""
|
||||
"Ces exemples sont tous pris de la suite de tests d'Hibernate. Vous en "
|
||||
"trouverez beaucoup d'autres. Regardez dans le dossier <literal>test</"
|
||||
"literal> de la distribution d'Hibernate."
|
||||
|
||||
#. Tag: para
|
||||
#: example_mappings.xml:157
|
||||
#, no-c-format
|
||||
msgid "TODO: put words around this stuff"
|
||||
msgstr "TODO: put words around this stuff"
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:160
|
||||
#, no-c-format
|
||||
msgid "\"Typed\" one-to-one association"
|
||||
msgstr "\"Typed\" one-to-one association"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:161
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"name\"/>\n"
|
||||
" <one-to-one name=\"address\" \n"
|
||||
" cascade=\"all\">\n"
|
||||
" <formula>name</formula>\n"
|
||||
" <formula>'HOME'</formula>\n"
|
||||
" </one-to-one>\n"
|
||||
" <one-to-one name=\"mailingAddress\" \n"
|
||||
" cascade=\"all\">\n"
|
||||
" <formula>name</formula>\n"
|
||||
" <formula>'MAILING'</formula>\n"
|
||||
" </one-to-one>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\" batch-size=\"2\" \n"
|
||||
" check=\"addressType in ('MAILING', 'HOME', 'BUSINESS')\">\n"
|
||||
" <composite-id>\n"
|
||||
" <key-many-to-one name=\"person\" \n"
|
||||
" column=\"personName\"/>\n"
|
||||
" <key-property name=\"type\" \n"
|
||||
" column=\"addressType\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" <property name=\"street\" type=\"text\"/>\n"
|
||||
" <property name=\"state\"/>\n"
|
||||
" <property name=\"zip\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:165
|
||||
#, no-c-format
|
||||
msgid "Composite key example"
|
||||
msgstr "Exemple de clef composée"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:166
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Customer\">\n"
|
||||
"\n"
|
||||
" <id name=\"customerId\"\n"
|
||||
" length=\"10\">\n"
|
||||
" <generator class=\"assigned\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property name=\"name\" not-null=\"true\" length=\"100\"/>\n"
|
||||
" <property name=\"address\" not-null=\"true\" length=\"200\"/>\n"
|
||||
"\n"
|
||||
" <list name=\"orders\"\n"
|
||||
" inverse=\"true\"\n"
|
||||
" cascade=\"save-update\">\n"
|
||||
" <key column=\"customerId\"/>\n"
|
||||
" <index column=\"orderNumber\"/>\n"
|
||||
" <one-to-many class=\"Order\"/>\n"
|
||||
" </list>\n"
|
||||
"\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Order\" table=\"CustomerOrder\" lazy=\"true\">\n"
|
||||
" <synchronize table=\"LineItem\"/>\n"
|
||||
" <synchronize table=\"Product\"/>\n"
|
||||
" \n"
|
||||
" <composite-id name=\"id\" \n"
|
||||
" class=\"Order$Id\">\n"
|
||||
" <key-property name=\"customerId\" length=\"10\"/>\n"
|
||||
" <key-property name=\"orderNumber\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" \n"
|
||||
" <property name=\"orderDate\" \n"
|
||||
" type=\"calendar_date\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"total\">\n"
|
||||
" <formula>\n"
|
||||
" ( select sum(li.quantity*p.price) \n"
|
||||
" from LineItem li, Product p \n"
|
||||
" where li.productId = p.productId \n"
|
||||
" and li.customerId = customerId \n"
|
||||
" and li.orderNumber = orderNumber )\n"
|
||||
" </formula>\n"
|
||||
" </property>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"customer\"\n"
|
||||
" column=\"customerId\"\n"
|
||||
" insert=\"false\"\n"
|
||||
" update=\"false\" \n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" \n"
|
||||
" <bag name=\"lineItems\"\n"
|
||||
" fetch=\"join\" \n"
|
||||
" inverse=\"true\"\n"
|
||||
" cascade=\"save-update\">\n"
|
||||
" <key>\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" <column name=\"orderNumber\"/>\n"
|
||||
" </key>\n"
|
||||
" <one-to-many class=\"LineItem\"/>\n"
|
||||
" </bag>\n"
|
||||
" \n"
|
||||
"</class>\n"
|
||||
" \n"
|
||||
"<class name=\"LineItem\">\n"
|
||||
" \n"
|
||||
" <composite-id name=\"id\" \n"
|
||||
" class=\"LineItem$Id\">\n"
|
||||
" <key-property name=\"customerId\" length=\"10\"/>\n"
|
||||
" <key-property name=\"orderNumber\"/>\n"
|
||||
" <key-property name=\"productId\" length=\"10\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" \n"
|
||||
" <property name=\"quantity\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"order\"\n"
|
||||
" insert=\"false\"\n"
|
||||
" update=\"false\" \n"
|
||||
" not-null=\"true\">\n"
|
||||
" <column name=\"customerId\"/>\n"
|
||||
" <column name=\"orderNumber\"/>\n"
|
||||
" </many-to-one>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"product\"\n"
|
||||
" insert=\"false\"\n"
|
||||
" update=\"false\" \n"
|
||||
" not-null=\"true\"\n"
|
||||
" column=\"productId\"/>\n"
|
||||
" \n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Product\">\n"
|
||||
" <synchronize table=\"LineItem\"/>\n"
|
||||
"\n"
|
||||
" <id name=\"productId\"\n"
|
||||
" length=\"10\">\n"
|
||||
" <generator class=\"assigned\"/>\n"
|
||||
" </id>\n"
|
||||
" \n"
|
||||
" <property name=\"description\" \n"
|
||||
" not-null=\"true\" \n"
|
||||
" length=\"200\"/>\n"
|
||||
" <property name=\"price\" length=\"3\"/>\n"
|
||||
" <property name=\"numberAvailable\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"numberOrdered\">\n"
|
||||
" <formula>\n"
|
||||
" ( select sum(li.quantity) \n"
|
||||
" from LineItem li \n"
|
||||
" where li.productId = productId )\n"
|
||||
" </formula>\n"
|
||||
" </property>\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:170
|
||||
#, no-c-format
|
||||
msgid "Many-to-many with shared composite key attribute"
|
||||
msgstr "Many-to-many avec une clef composée partagée"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:171
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"User\" table=\"`User`\">\n"
|
||||
" <composite-id>\n"
|
||||
" <key-property name=\"name\"/>\n"
|
||||
" <key-property name=\"org\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" <set name=\"groups\" table=\"UserGroup\">\n"
|
||||
" <key>\n"
|
||||
" <column name=\"userName\"/>\n"
|
||||
" <column name=\"org\"/>\n"
|
||||
" </key>\n"
|
||||
" <many-to-many class=\"Group\">\n"
|
||||
" <column name=\"groupName\"/>\n"
|
||||
" <formula>org</formula>\n"
|
||||
" </many-to-many>\n"
|
||||
" </set>\n"
|
||||
"</class>\n"
|
||||
" \n"
|
||||
"<class name=\"Group\" table=\"`Group`\">\n"
|
||||
" <composite-id>\n"
|
||||
" <key-property name=\"name\"/>\n"
|
||||
" <key-property name=\"org\"/>\n"
|
||||
" </composite-id>\n"
|
||||
" <property name=\"description\"/>\n"
|
||||
" <set name=\"users\" table=\"UserGroup\" inverse=\"true\">\n"
|
||||
" <key>\n"
|
||||
" <column name=\"groupName\"/>\n"
|
||||
" <column name=\"org\"/>\n"
|
||||
" </key>\n"
|
||||
" <many-to-many class=\"User\">\n"
|
||||
" <column name=\"userName\"/>\n"
|
||||
" <formula>org</formula>\n"
|
||||
" </many-to-many>\n"
|
||||
" </set>\n"
|
||||
"</class>\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:175
|
||||
#, no-c-format
|
||||
msgid "Content based discrimination"
|
||||
msgstr "Contenu basé sur une discrimination"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:176
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\"\n"
|
||||
" discriminator-value=\"P\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\" \n"
|
||||
" column=\"person_id\" \n"
|
||||
" unsaved-value=\"0\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" <discriminator \n"
|
||||
" type=\"character\">\n"
|
||||
" <formula>\n"
|
||||
" case \n"
|
||||
" when title is not null then 'E' \n"
|
||||
" when salesperson is not null then 'C' \n"
|
||||
" else 'P' \n"
|
||||
" end\n"
|
||||
" </formula>\n"
|
||||
" </discriminator>\n"
|
||||
"\n"
|
||||
" <property name=\"name\" \n"
|
||||
" not-null=\"true\"\n"
|
||||
" length=\"80\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"sex\" \n"
|
||||
" not-null=\"true\"\n"
|
||||
" update=\"false\"/>\n"
|
||||
" \n"
|
||||
" <component name=\"address\">\n"
|
||||
" <property name=\"address\"/>\n"
|
||||
" <property name=\"zip\"/>\n"
|
||||
" <property name=\"country\"/>\n"
|
||||
" </component>\n"
|
||||
" \n"
|
||||
" <subclass name=\"Employee\" \n"
|
||||
" discriminator-value=\"E\">\n"
|
||||
" <property name=\"title\"\n"
|
||||
" length=\"20\"/>\n"
|
||||
" <property name=\"salary\"/>\n"
|
||||
" <many-to-one name=\"manager\"/>\n"
|
||||
" </subclass>\n"
|
||||
" \n"
|
||||
" <subclass name=\"Customer\" \n"
|
||||
" discriminator-value=\"C\">\n"
|
||||
" <property name=\"comments\"/>\n"
|
||||
" <many-to-one name=\"salesperson\"/>\n"
|
||||
" </subclass>\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_mappings.xml:180
|
||||
#, no-c-format
|
||||
msgid "Associations on alternate keys"
|
||||
msgstr "Associations sur des clefs alternées"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_mappings.xml:181
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"hilo\"/>\n"
|
||||
" </id>\n"
|
||||
" \n"
|
||||
" <property name=\"name\" length=\"100\"/>\n"
|
||||
" \n"
|
||||
" <one-to-one name=\"address\" \n"
|
||||
" property-ref=\"person\"\n"
|
||||
" cascade=\"all\"\n"
|
||||
" fetch=\"join\"/>\n"
|
||||
" \n"
|
||||
" <set name=\"accounts\" \n"
|
||||
" inverse=\"true\">\n"
|
||||
" <key column=\"userId\"\n"
|
||||
" property-ref=\"userId\"/>\n"
|
||||
" <one-to-many class=\"Account\"/>\n"
|
||||
" </set>\n"
|
||||
" \n"
|
||||
" <property name=\"userId\" length=\"8\"/>\n"
|
||||
"\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Address\">\n"
|
||||
"\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"hilo\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property name=\"address\" length=\"300\"/>\n"
|
||||
" <property name=\"zip\" length=\"5\"/>\n"
|
||||
" <property name=\"country\" length=\"25\"/>\n"
|
||||
" <many-to-one name=\"person\" unique=\"true\" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Account\">\n"
|
||||
" <id name=\"accountId\" length=\"32\">\n"
|
||||
" <generator class=\"uuid\"/>\n"
|
||||
" </id>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"user\"\n"
|
||||
" column=\"userId\"\n"
|
||||
" property-ref=\"userId\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"type\" not-null=\"true\"/>\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
|
@ -0,0 +1,617 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: example_parentchild.xml:29
|
||||
#, no-c-format
|
||||
msgid "Example: Parent/Child"
|
||||
msgstr "Exemple : Père/Fils"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"One of the very first things that new users try to do with Hibernate is to "
|
||||
"model a parent / child type relationship. There are two different approaches "
|
||||
"to this. For various reasons the most convenient approach, especially for "
|
||||
"new users, is to model both <literal>Parent</literal> and <literal>Child</"
|
||||
"literal> as entity classes with a <literal><one-to-many></literal> "
|
||||
"association from <literal>Parent</literal> to <literal>Child</literal>. (The "
|
||||
"alternative approach is to declare the <literal>Child</literal> as a "
|
||||
"<literal><composite-element></literal>.) Now, it turns out that "
|
||||
"default semantics of a one to many association (in Hibernate) are much less "
|
||||
"close to the usual semantics of a parent / child relationship than those of "
|
||||
"a composite element mapping. We will explain how to use a "
|
||||
"<emphasis>bidirectional one to many association with cascades</emphasis> to "
|
||||
"model a parent / child relationship efficiently and elegantly. It's not at "
|
||||
"all difficult!"
|
||||
msgstr ""
|
||||
"L'une des premières choses que les nouveaux utilisateurs essaient de faire "
|
||||
"avec Hibernate est de modéliser une relation père/fils. Il y a deux "
|
||||
"approches différentes pour cela. Pour un certain nombre de raisons, la "
|
||||
"méthode la plus courante, en particulier pour les nouveaux utilisateurs, est "
|
||||
"de modéliser les deux relations <literal>Père</literal> et <literal>Fils</"
|
||||
"literal> comme des classes entités liées par une association <literal><"
|
||||
"one-to-many></literal> du <literal>Père</literal> vers le <literal>Fils</"
|
||||
"literal> (l'autre approche est de déclarer le <literal>Fils</literal> comme "
|
||||
"un <literal><composite-element></literal>). Il est évident que le sens "
|
||||
"de l'association un vers plusieurs (dans Hibernate) est bien moins proche du "
|
||||
"sens habituel d'une relation père/fils que ne l'est celui d'un élément "
|
||||
"cmposite. Nous allons vous expliquer comment utiliser une association "
|
||||
"<emphasis>un vers plusieurs bidirectionnelle avec cascade</emphasis> afin de "
|
||||
"modéliser efficacement et élégamment une relation père/fils, ce n'est "
|
||||
"vraiment pas difficile !"
|
||||
|
||||
#. Tag: title
|
||||
#: example_parentchild.xml:45
|
||||
#, no-c-format
|
||||
msgid "A note about collections"
|
||||
msgstr "Une note à propos des collections"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:47
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate collections are considered to be a logical part of their owning "
|
||||
"entity; never of the contained entities. This is a crucial distinction! It "
|
||||
"has the following consequences:"
|
||||
msgstr ""
|
||||
"Les collections Hibernate sont considérées comme étant une partie logique de "
|
||||
"l'entité dans laquelle elles sont contenues ; jamais des entités qu'elle "
|
||||
"contient. C'est une distinction crutiale ! Les conséquences sont les "
|
||||
"suivantes :"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:54
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"When we remove / add an object from / to a collection, the version number of "
|
||||
"the collection owner is incremented."
|
||||
msgstr ""
|
||||
"Quand nous ajoutons / retirons un objet d'une collection, le numéro de "
|
||||
"version du propriétaire de la collection est incrémenté."
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:60
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If an object that was removed from a collection is an instance of a value "
|
||||
"type (eg, a composite element), that object will cease to be persistent and "
|
||||
"its state will be completely removed from the database. Likewise, adding a "
|
||||
"value type instance to the collection will cause its state to be immediately "
|
||||
"persistent."
|
||||
msgstr ""
|
||||
"Si un objet qui a été enlevé d'une collection est une instance de type "
|
||||
"valeur (ex : élément composite), cet objet cessera d'être persistant et son "
|
||||
"état sera complètement effacé de la base de données. Par ailleurs, ajouter "
|
||||
"une instance de type valeur dans une collection aura pour conséquence que "
|
||||
"son état sera immédiatement persistant."
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:68
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"On the other hand, if an entity is removed from a collection (a one-to-many "
|
||||
"or many-to-many association), it will not be deleted, by default. This "
|
||||
"behaviour is completely consistent - a change to the internal state of "
|
||||
"another entity should not cause the associated entity to vanish! Likewise, "
|
||||
"adding an entity to a collection does not cause that entity to become "
|
||||
"persistent, by default."
|
||||
msgstr ""
|
||||
"Si une entité est enlevée d'une collection (association un-vers-plusieurs ou "
|
||||
"plusieurs-vers-plusieurs), par défaut, elle ne sera pas effacée. Ce "
|
||||
"comportement est complètement logique - une modification de l'un des états "
|
||||
"internes d'une entité ne doit pas causer la disparition de l'entité "
|
||||
"associée ! De même, l'ajout d'une entité dans une collection n'engendre pas, "
|
||||
"par défaut, la persistance de cette entité."
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:78
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Instead, the default behaviour is that adding an entity to a collection "
|
||||
"merely creates a link between the two entities, while removing it removes "
|
||||
"the link. This is very appropriate for all sorts of cases. Where it is not "
|
||||
"appropriate at all is the case of a parent / child relationship, where the "
|
||||
"life of the child is bound to the life cycle of the parent."
|
||||
msgstr ""
|
||||
"Le comportement par défaut est donc que l'ajout d'une entité dans une "
|
||||
"collection créé simplement le lien entre les deux entités, et qu'effacer une "
|
||||
"entité supprime ce lien. C'est le comportement le plus approprié dans la "
|
||||
"plupart des cas. Ce comportement n'est cependant pas approprié lorsque la "
|
||||
"vie du fils est liée au cycle de vie du père."
|
||||
|
||||
#. Tag: title
|
||||
#: example_parentchild.xml:88
|
||||
#, no-c-format
|
||||
msgid "Bidirectional one-to-many"
|
||||
msgstr "un-vers-plusieurs bidirectionnel"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:90
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Suppose we start with a simple <literal><one-to-many></literal> "
|
||||
"association from <literal>Parent</literal> to <literal>Child</literal>."
|
||||
msgstr ""
|
||||
"Supposons que nous ayons une simple association <literal><one-to-many>"
|
||||
"</literal> de <literal>Parent</literal> vers <literal>Child</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:95
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:97
|
||||
#, no-c-format
|
||||
msgid "If we were to execute the following code"
|
||||
msgstr "Si nous executions le code suivant"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:101
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = .....;\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.getChildren().add(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:103
|
||||
#, no-c-format
|
||||
msgid "Hibernate would issue two SQL statements:"
|
||||
msgstr "Hibernate exécuterait deux ordres SQL:"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:109
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"an <literal>INSERT</literal> to create the record for <literal>c</literal>"
|
||||
msgstr ""
|
||||
"un <literal>INSERT</literal> pour créer l'enregistrement pour <literal>c</"
|
||||
"literal>"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:112
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"an <literal>UPDATE</literal> to create the link from <literal>p</literal> to "
|
||||
"<literal>c</literal>"
|
||||
msgstr ""
|
||||
"un <literal>UPDATE</literal> pour créer le lien de <literal>p</literal> vers "
|
||||
"<literal>c</literal>"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:119
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This is not only inefficient, but also violates any <literal>NOT NULL</"
|
||||
"literal> constraint on the <literal>parent_id</literal> column. We can fix "
|
||||
"the nullability constraint violation by specifying <literal>not-null=\"true"
|
||||
"\"</literal> in the collection mapping:"
|
||||
msgstr ""
|
||||
"Ceci est non seuleument inefficace, mais viole aussi toute contrainte "
|
||||
"<literal>NOT NULL</literal> sur la colonne <literal>parent_id</literal>. "
|
||||
"Nous pouvons réparer la contrainte de nullité en spécifiant <literal>not-"
|
||||
"null=\"true\"</literal> dans le mapping de la collection :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:125
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\">\n"
|
||||
" <key column=\"parent_id\" not-null=\"true\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:127
|
||||
#, no-c-format
|
||||
msgid "However, this is not the recommended solution."
|
||||
msgstr "Cependant ce n'est pas la solution recommandée."
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:130
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The underlying cause of this behaviour is that the link (the foreign key "
|
||||
"<literal>parent_id</literal>) from <literal>p</literal> to <literal>c</"
|
||||
"literal> is not considered part of the state of the <literal>Child</literal> "
|
||||
"object and is therefore not created in the <literal>INSERT</literal>. So the "
|
||||
"solution is to make the link part of the <literal>Child</literal> mapping."
|
||||
msgstr ""
|
||||
"La cause sous jacente à ce comportement est que le lien (la clé étrangère "
|
||||
"<literal>parent_id</literal>) de <literal>p</literal> vers <literal>c</"
|
||||
"literal> n'est pas considérée comme faisant partie de l'état de l'objet "
|
||||
"<literal>Child</literal> et n'est donc pas créé par l'<literal>INSERT</"
|
||||
"literal>. La solution est donc que ce lien fasse partie du mapping de "
|
||||
"<literal>Child</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:137
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"parent\" column=\"parent_id\" not-null=\"true\"/"
|
||||
">]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:139
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"(We also need to add the <literal>parent</literal> property to the "
|
||||
"<literal>Child</literal> class.)"
|
||||
msgstr ""
|
||||
"(Nous avons aussi besoin d'ajouter la propriété <literal>parent</literal> "
|
||||
"dans la classe <literal>Child</literal>)."
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:143
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Now that the <literal>Child</literal> entity is managing the state of the "
|
||||
"link, we tell the collection not to update the link. We use the "
|
||||
"<literal>inverse</literal> attribute."
|
||||
msgstr ""
|
||||
"Maintenant que l'état du lien est géré par l'entité <literal>Child</"
|
||||
"literal>, nous spécifions à la collection de ne pas mettre à jour le lien. "
|
||||
"Nous utilisons l'attribut <literal>inverse</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:148
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:150
|
||||
#, no-c-format
|
||||
msgid "The following code would be used to add a new <literal>Child</literal>"
|
||||
msgstr ""
|
||||
"Le code suivant serait utilisé pour ajouter un nouveau <literal>Child</"
|
||||
"literal>"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:154
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"c.setParent(p);\n"
|
||||
"p.getChildren().add(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:156
|
||||
#, no-c-format
|
||||
msgid "And now, only one SQL <literal>INSERT</literal> would be issued!"
|
||||
msgstr "Maintenant, seul un <literal>INSERT</literal> SQL est nécessaire !"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:160
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"To tighten things up a bit, we could create an <literal>addChild()</literal> "
|
||||
"method of <literal>Parent</literal>."
|
||||
msgstr ""
|
||||
"Pour alléger encore un peu les choses, nous devrions créer une méthode "
|
||||
"<literal>addChild()</literal> dans <literal>Parent</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:165
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[public void addChild(Child c) {\n"
|
||||
" c.setParent(this);\n"
|
||||
" children.add(c);\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:167
|
||||
#, no-c-format
|
||||
msgid "Now, the code to add a <literal>Child</literal> looks like"
|
||||
msgstr "Le code d'ajout d'un <literal>Child</literal> serait alors"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:171
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.addChild(c);\n"
|
||||
"session.save(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_parentchild.xml:176
|
||||
#, no-c-format
|
||||
msgid "Cascading life cycle"
|
||||
msgstr "Cycle de vie en cascade"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:178
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The explicit call to <literal>save()</literal> is still annoying. We will "
|
||||
"address this by using cascades."
|
||||
msgstr ""
|
||||
"L'appel explicite de <literal>save()</literal> est un peu fastidieux. Nous "
|
||||
"pouvons simplifier cela en utilisant les cascades."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:183
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:185
|
||||
#, no-c-format
|
||||
msgid "This simplifies the code above to"
|
||||
msgstr "Simplifie le code précédent en"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:189
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = new Child();\n"
|
||||
"p.addChild(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:191
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Similarly, we don't need to iterate over the children when saving or "
|
||||
"deleting a <literal>Parent</literal>. The following removes <literal>p</"
|
||||
"literal> and all its children from the database."
|
||||
msgstr ""
|
||||
"De la même manière, nous n'avons pas à itérer sur les fils lorsque nous "
|
||||
"sauvons ou effacons un <literal>Parent</literal>. Le code suivant efface "
|
||||
"<literal>p</literal> et tous ses fils de la base de données."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:196
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"session.delete(p);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:198
|
||||
#, no-c-format
|
||||
msgid "However, this code"
|
||||
msgstr "Par contre, ce code"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:202
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = (Child) p.getChildren().iterator().next();\n"
|
||||
"p.getChildren().remove(c);\n"
|
||||
"c.setParent(null);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:204
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"will not remove <literal>c</literal> from the database; it will ony remove "
|
||||
"the link to <literal>p</literal> (and cause a <literal>NOT NULL</literal> "
|
||||
"constraint violation, in this case). You need to explicitly <literal>delete()"
|
||||
"</literal> the <literal>Child</literal>."
|
||||
msgstr ""
|
||||
"n'effacera pas <literal>c</literal> de la base de données, il enlèvera "
|
||||
"seulement le lien vers <literal>p</literal> (et causera une violation de "
|
||||
"contrainte <literal>NOT NULL</literal>, dans ce cas). Vous devez "
|
||||
"explicitement utiliser <literal>delete()</literal> sur <literal>Child</"
|
||||
"literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:210
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
|
||||
"Child c = (Child) p.getChildren().iterator().next();\n"
|
||||
"p.getChildren().remove(c);\n"
|
||||
"session.delete(c);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:212
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Now, in our case, a <literal>Child</literal> can't really exist without its "
|
||||
"parent. So if we remove a <literal>Child</literal> from the collection, we "
|
||||
"really do want it to be deleted. For this, we must use <literal>cascade="
|
||||
"\"all-delete-orphan\"</literal>."
|
||||
msgstr ""
|
||||
"Dans notre cas, un <literal>Child</literal> ne peut pas vraiment exister "
|
||||
"sans son père. Si nous effacons un <literal>Child</literal> de la "
|
||||
"collection, nous voulons vraiment qu'il soit effacé. Pour cela, nous devons "
|
||||
"utiliser <literal>cascade=\"all-delete-orphan\"</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:218
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all-delete-orphan"
|
||||
"\">\n"
|
||||
" <key column=\"parent_id\"/>\n"
|
||||
" <one-to-many class=\"Child\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:220
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note: even though the collection mapping specifies <literal>inverse=\"true"
|
||||
"\"</literal>, cascades are still processed by iterating the collection "
|
||||
"elements. So if you require that an object be saved, deleted or updated by "
|
||||
"cascade, you must add it to the collection. It is not enough to simply call "
|
||||
"<literal>setParent()</literal>."
|
||||
msgstr ""
|
||||
"A noter : même si le mapping de la collection spécifie <literal>inverse="
|
||||
"\"true\"</literal>, les cascades sont toujours assurées par l'itération sur "
|
||||
"les éléments de la collection. Donc, si vous avez besoin qu'un objet soit "
|
||||
"enregistré, effacé ou mis à jour par cascade, vous devez l'ajouter dans la "
|
||||
"colleciton. Il ne suffit pas d'appeler explicitement <literal>setParent()</"
|
||||
"literal>."
|
||||
|
||||
#. Tag: title
|
||||
#: example_parentchild.xml:230
|
||||
#, no-c-format
|
||||
msgid "Cascades and <literal>unsaved-value</literal>"
|
||||
msgstr "Cascades et <literal>unsaved-value</literal>"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:232
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Suppose we loaded up a <literal>Parent</literal> in one <literal>Session</"
|
||||
"literal>, made some changes in a UI action and wish to persist these changes "
|
||||
"in a new session by calling <literal>update()</literal>. The "
|
||||
"<literal>Parent</literal> will contain a collection of childen and, since "
|
||||
"cascading update is enabled, Hibernate needs to know which children are "
|
||||
"newly instantiated and which represent existing rows in the database. Lets "
|
||||
"assume that both <literal>Parent</literal> and <literal>Child</literal> have "
|
||||
"genenerated identifier properties of type <literal>Long</literal>. Hibernate "
|
||||
"will use the identifier and version/timestamp property value to determine "
|
||||
"which of the children are new. (See <xref linkend=\"objectstate-saveorupdate"
|
||||
"\"/>.) <emphasis>In Hibernate3, it is no longer necessary to specify an "
|
||||
"<literal>unsaved-value</literal> explicitly.</emphasis>"
|
||||
msgstr ""
|
||||
"Supposons que nous ayons chargé un <literal>Parent</literal> dans une "
|
||||
"<literal>Session</literal>, que nous l'ayons ensuite modifié et que voulions "
|
||||
"persiter ces modifications dans une nouvelle session en appelant "
|
||||
"<literal>update()</literal>. Le <literal>Parent</literal> contiendra une "
|
||||
"collection de fils et, puisque la cascade est activée, Hibernate a besoin de "
|
||||
"savoir quels fils viennent d'être instanciés et quels fils proviennent de la "
|
||||
"base de données. Supposons aussi que <literal>Parent</literal> et "
|
||||
"<literal>Child</literal> ont tous deux des identifiants du type "
|
||||
"<literal>Long</literal>. Hibernate utilisera la propriété de l'identifiant "
|
||||
"et la propriété de la version/horodatage pour déterminer quels fils sont "
|
||||
"nouveaux (vous pouvez aussi utiliser la propriété version ou timestamp, voir "
|
||||
"<xref linkend=\"manipulatingdata-updating-detached\"/>). <emphasis>Dans "
|
||||
"Hibernate3, il n'est plus nécessaire de spécifier une <literal>unsaved-"
|
||||
"value</literal> explicitement.</emphasis>"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:244
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The following code will update <literal>parent</literal> and <literal>child</"
|
||||
"literal> and insert <literal>newChild</literal>."
|
||||
msgstr ""
|
||||
"Le code suivant mettra à jour <literal>parent</literal> et <literal>child</"
|
||||
"literal> et insérera <literal>newChild</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_parentchild.xml:249
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[//parent and child were both loaded in a previous session\n"
|
||||
"parent.addChild(child);\n"
|
||||
"Child newChild = new Child();\n"
|
||||
"parent.addChild(newChild);\n"
|
||||
"session.update(parent);\n"
|
||||
"session.flush();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:251
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Well, that's all very well for the case of a generated identifier, but what "
|
||||
"about assigned identifiers and composite identifiers? This is more "
|
||||
"difficult, since Hibernate can't use the identifier property to distinguish "
|
||||
"between a newly instantiated object (with an identifier assigned by the "
|
||||
"user) and an object loaded in a previous session. In this case, Hibernate "
|
||||
"will either use the timestamp or version property, or will actually query "
|
||||
"the second-level cache or, worst case, the database, to see if the row "
|
||||
"exists."
|
||||
msgstr ""
|
||||
"Ceci est très bien pour des identifiants générés, mais qu'en est-il des "
|
||||
"identifiants assignés et des identifiants composés ? C'est plus difficile, "
|
||||
"puisqu'Hibernate ne peut pas utiliser la propriété de l'identifiant pour "
|
||||
"distinguer un objet nouvellement instancié (avec un identifiant assigné par "
|
||||
"l'utilisateur) d'un objet chargé dans une session précédente. Dans ce cas, "
|
||||
"Hibernate utilisera soit la propriété de version ou d'horodatage, soit "
|
||||
"effectuera vraiment une requête au cache de second niveau, soit, dans le "
|
||||
"pire des cas, à la base de données, pour voir si la ligne existe."
|
||||
|
||||
#. Tag: title
|
||||
#: example_parentchild.xml:284
|
||||
#, no-c-format
|
||||
msgid "Conclusion"
|
||||
msgstr "Conclusion"
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:286
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There is quite a bit to digest here and it might look confusing first time "
|
||||
"around. However, in practice, it all works out very nicely. Most Hibernate "
|
||||
"applications use the parent / child pattern in many places."
|
||||
msgstr ""
|
||||
"Il y a quelques principes à maîtriser dans ce chapitre et tout cela peut "
|
||||
"paraître déroutant la première fois. Cependant, dans la pratique, tout "
|
||||
"fonctionne parfaitement. La plupart des applications Hibernate utilisent le "
|
||||
"pattern père / fils."
|
||||
|
||||
#. Tag: para
|
||||
#: example_parentchild.xml:291
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"We mentioned an alternative in the first paragraph. None of the above issues "
|
||||
"exist in the case of <literal><composite-element></literal> mappings, "
|
||||
"which have exactly the semantics of a parent / child relationship. "
|
||||
"Unfortunately, there are two big limitations to composite element classes: "
|
||||
"composite elements may not own collections, and they should not be the child "
|
||||
"of any entity other than the unique parent."
|
||||
msgstr ""
|
||||
"Nous avons évoqué une alternative dans le premier paragraphe. Aucun des "
|
||||
"points traités précédemment n'existe dans le cas d'un mapping <literal><"
|
||||
"composite-element></literal> qui possède exactement la sémantique d'une "
|
||||
"relation père / fils. Malheureusement, il y a deux grandes limitations pour "
|
||||
"les classes éléments composites : les éléments composites ne peuvent "
|
||||
"contenir de collections, et ils ne peuvent être les fils d'entités autres "
|
||||
"que l'unique parent."
|
|
@ -0,0 +1,484 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: example_weblog.xml:29
|
||||
#, no-c-format
|
||||
msgid "Example: Weblog Application"
|
||||
msgstr "Exemple : application Weblog"
|
||||
|
||||
#. Tag: title
|
||||
#: example_weblog.xml:32
|
||||
#, no-c-format
|
||||
msgid "Persistent Classes"
|
||||
msgstr "Classes persistantes"
|
||||
|
||||
#. Tag: para
|
||||
#: example_weblog.xml:34
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The persistent classes represent a weblog, and an item posted in a weblog. "
|
||||
"They are to be modelled as a standard parent/child relationship, but we will "
|
||||
"use an ordered bag, instead of a set."
|
||||
msgstr ""
|
||||
"Les classes persistantes representent un weblog, et un article posté dans un "
|
||||
"weblog. Il seront modélisés comme une relation père/fils standard, mais nous "
|
||||
"allons utiliser un \"bag\" trié au lieu d'un set."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_weblog.xml:40
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.util.List;\n"
|
||||
"\n"
|
||||
"public class Blog {\n"
|
||||
" private Long _id;\n"
|
||||
" private String _name;\n"
|
||||
" private List _items;\n"
|
||||
"\n"
|
||||
" public Long getId() {\n"
|
||||
" return _id;\n"
|
||||
" }\n"
|
||||
" public List getItems() {\n"
|
||||
" return _items;\n"
|
||||
" }\n"
|
||||
" public String getName() {\n"
|
||||
" return _name;\n"
|
||||
" }\n"
|
||||
" public void setId(Long long1) {\n"
|
||||
" _id = long1;\n"
|
||||
" }\n"
|
||||
" public void setItems(List list) {\n"
|
||||
" _items = list;\n"
|
||||
" }\n"
|
||||
" public void setName(String string) {\n"
|
||||
" _name = string;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_weblog.xml:42
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.text.DateFormat;\n"
|
||||
"import java.util.Calendar;\n"
|
||||
"\n"
|
||||
"public class BlogItem {\n"
|
||||
" private Long _id;\n"
|
||||
" private Calendar _datetime;\n"
|
||||
" private String _text;\n"
|
||||
" private String _title;\n"
|
||||
" private Blog _blog;\n"
|
||||
"\n"
|
||||
" public Blog getBlog() {\n"
|
||||
" return _blog;\n"
|
||||
" }\n"
|
||||
" public Calendar getDatetime() {\n"
|
||||
" return _datetime;\n"
|
||||
" }\n"
|
||||
" public Long getId() {\n"
|
||||
" return _id;\n"
|
||||
" }\n"
|
||||
" public String getText() {\n"
|
||||
" return _text;\n"
|
||||
" }\n"
|
||||
" public String getTitle() {\n"
|
||||
" return _title;\n"
|
||||
" }\n"
|
||||
" public void setBlog(Blog blog) {\n"
|
||||
" _blog = blog;\n"
|
||||
" }\n"
|
||||
" public void setDatetime(Calendar calendar) {\n"
|
||||
" _datetime = calendar;\n"
|
||||
" }\n"
|
||||
" public void setId(Long long1) {\n"
|
||||
" _id = long1;\n"
|
||||
" }\n"
|
||||
" public void setText(String string) {\n"
|
||||
" _text = string;\n"
|
||||
" }\n"
|
||||
" public void setTitle(String string) {\n"
|
||||
" _title = string;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_weblog.xml:47
|
||||
#, no-c-format
|
||||
msgid "Hibernate Mappings"
|
||||
msgstr "Mappings Hibernate"
|
||||
|
||||
#. Tag: para
|
||||
#: example_weblog.xml:49
|
||||
#, no-c-format
|
||||
msgid "The XML mappings should now be quite straightforward."
|
||||
msgstr "Le mapping XML doit maintenant être relativement simple à vos yeux."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_weblog.xml:53
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE hibernate-mapping PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-mapping package=\"eg\">\n"
|
||||
"\n"
|
||||
" <class\n"
|
||||
" name=\"Blog\"\n"
|
||||
" table=\"BLOGS\">\n"
|
||||
"\n"
|
||||
" <id\n"
|
||||
" name=\"id\"\n"
|
||||
" column=\"BLOG_ID\">\n"
|
||||
"\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
"\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"name\"\n"
|
||||
" column=\"NAME\"\n"
|
||||
" not-null=\"true\"\n"
|
||||
" unique=\"true\"/>\n"
|
||||
"\n"
|
||||
" <bag\n"
|
||||
" name=\"items\"\n"
|
||||
" inverse=\"true\"\n"
|
||||
" order-by=\"DATE_TIME\"\n"
|
||||
" cascade=\"all\">\n"
|
||||
"\n"
|
||||
" <key column=\"BLOG_ID\"/>\n"
|
||||
" <one-to-many class=\"BlogItem\"/>\n"
|
||||
"\n"
|
||||
" </bag>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_weblog.xml:55
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE hibernate-mapping PUBLIC\n"
|
||||
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
|
||||
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
|
||||
"\n"
|
||||
"<hibernate-mapping package=\"eg\">\n"
|
||||
"\n"
|
||||
" <class\n"
|
||||
" name=\"BlogItem\"\n"
|
||||
" table=\"BLOG_ITEMS\"\n"
|
||||
" dynamic-update=\"true\">\n"
|
||||
"\n"
|
||||
" <id\n"
|
||||
" name=\"id\"\n"
|
||||
" column=\"BLOG_ITEM_ID\">\n"
|
||||
"\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
"\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"title\"\n"
|
||||
" column=\"TITLE\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"text\"\n"
|
||||
" column=\"TEXT\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <property\n"
|
||||
" name=\"datetime\"\n"
|
||||
" column=\"DATE_TIME\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" <many-to-one\n"
|
||||
" name=\"blog\"\n"
|
||||
" column=\"BLOG_ID\"\n"
|
||||
" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
"\n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: example_weblog.xml:60
|
||||
#, no-c-format
|
||||
msgid "Hibernate Code"
|
||||
msgstr "Code Hibernate"
|
||||
|
||||
#. Tag: para
|
||||
#: example_weblog.xml:62
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The following class demonstrates some of the kinds of things we can do with "
|
||||
"these classes, using Hibernate."
|
||||
msgstr ""
|
||||
"La classe suivante montre quelques utilisations que nous pouvons faire de "
|
||||
"ces classes."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: example_weblog.xml:67
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"import java.util.ArrayList;\n"
|
||||
"import java.util.Calendar;\n"
|
||||
"import java.util.Iterator;\n"
|
||||
"import java.util.List;\n"
|
||||
"\n"
|
||||
"import org.hibernate.HibernateException;\n"
|
||||
"import org.hibernate.Query;\n"
|
||||
"import org.hibernate.Session;\n"
|
||||
"import org.hibernate.SessionFactory;\n"
|
||||
"import org.hibernate.Transaction;\n"
|
||||
"import org.hibernate.cfg.Configuration;\n"
|
||||
"import org.hibernate.tool.hbm2ddl.SchemaExport;\n"
|
||||
"\n"
|
||||
"public class BlogMain {\n"
|
||||
" \n"
|
||||
" private SessionFactory _sessions;\n"
|
||||
" \n"
|
||||
" public void configure() throws HibernateException {\n"
|
||||
" _sessions = new Configuration()\n"
|
||||
" .addClass(Blog.class)\n"
|
||||
" .addClass(BlogItem.class)\n"
|
||||
" .buildSessionFactory();\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void exportTables() throws HibernateException {\n"
|
||||
" Configuration cfg = new Configuration()\n"
|
||||
" .addClass(Blog.class)\n"
|
||||
" .addClass(BlogItem.class);\n"
|
||||
" new SchemaExport(cfg).create(true, true);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public Blog createBlog(String name) throws HibernateException {\n"
|
||||
" \n"
|
||||
" Blog blog = new Blog();\n"
|
||||
" blog.setName(name);\n"
|
||||
" blog.setItems( new ArrayList() );\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.persist(blog);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return blog;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public BlogItem createBlogItem(Blog blog, String title, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" BlogItem item = new BlogItem();\n"
|
||||
" item.setTitle(title);\n"
|
||||
" item.setText(text);\n"
|
||||
" item.setBlog(blog);\n"
|
||||
" item.setDatetime( Calendar.getInstance() );\n"
|
||||
" blog.getItems().add(item);\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.update(blog);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return item;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public BlogItem createBlogItem(Long blogid, String title, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" BlogItem item = new BlogItem();\n"
|
||||
" item.setTitle(title);\n"
|
||||
" item.setText(text);\n"
|
||||
" item.setDatetime( Calendar.getInstance() );\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Blog blog = (Blog) session.load(Blog.class, blogid);\n"
|
||||
" item.setBlog(blog);\n"
|
||||
" blog.getItems().add(item);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return item;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void updateBlogItem(BlogItem item, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" item.setText(text);\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" session.update(item);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public void updateBlogItem(Long itemid, String text)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" BlogItem item = (BlogItem) session.load(BlogItem.class, "
|
||||
"itemid);\n"
|
||||
" item.setText(text);\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public List listAllBlogNamesAndItemCounts(int max)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" List result = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"select blog.id, blog.name, count(blogItem) \" +\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"left outer join blog.items as blogItem \" +\n"
|
||||
" \"group by blog.name, blog.id \" +\n"
|
||||
" \"order by max(blogItem.datetime)\"\n"
|
||||
" );\n"
|
||||
" q.setMaxResults(max);\n"
|
||||
" result = q.list();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public Blog getBlogAndAllItems(Long blogid)\n"
|
||||
" throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" Blog blog = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"left outer join fetch blog.items \" +\n"
|
||||
" \"where blog.id = :blogid\"\n"
|
||||
" );\n"
|
||||
" q.setParameter(\"blogid\", blogid);\n"
|
||||
" blog = (Blog) q.uniqueResult();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return blog;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" public List listBlogsAndRecentItems() throws HibernateException {\n"
|
||||
" \n"
|
||||
" Session session = _sessions.openSession();\n"
|
||||
" Transaction tx = null;\n"
|
||||
" List result = null;\n"
|
||||
" try {\n"
|
||||
" tx = session.beginTransaction();\n"
|
||||
" Query q = session.createQuery(\n"
|
||||
" \"from Blog as blog \" +\n"
|
||||
" \"inner join blog.items as blogItem \" +\n"
|
||||
" \"where blogItem.datetime > :minDate\"\n"
|
||||
" );\n"
|
||||
"\n"
|
||||
" Calendar cal = Calendar.getInstance();\n"
|
||||
" cal.roll(Calendar.MONTH, false);\n"
|
||||
" q.setCalendar(\"minDate\", cal);\n"
|
||||
" \n"
|
||||
" result = q.list();\n"
|
||||
" tx.commit();\n"
|
||||
" }\n"
|
||||
" catch (HibernateException he) {\n"
|
||||
" if (tx!=null) tx.rollback();\n"
|
||||
" throw he;\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" session.close();\n"
|
||||
" }\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
|
@ -0,0 +1,294 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: filters.xml:29
|
||||
#, no-c-format
|
||||
msgid "Filtering data"
|
||||
msgstr "Filtrer les données"
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate3 provides an innovative new approach to handling data with "
|
||||
"\"visibility\" rules. A <emphasis>Hibernate filter</emphasis> is a global, "
|
||||
"named, parameterized filter that may be enabled or disabled for a particular "
|
||||
"Hibernate session."
|
||||
msgstr ""
|
||||
"Hibernate3 fournit une nouvelle approche innovatrice pour gérer des données "
|
||||
"avec des règles de \"visibilité\". Un <emphasis>filtre Hibernate</emphasis> "
|
||||
"est un filtre global, nommé, paramétré qui peut être activé ou désactivé "
|
||||
"pour une session Hibernate particulière."
|
||||
|
||||
#. Tag: title
|
||||
#: filters.xml:38
|
||||
#, no-c-format
|
||||
msgid "Hibernate filters"
|
||||
msgstr "Filtres Hibernate"
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:40
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate3 adds the ability to pre-define filter criteria and attach those "
|
||||
"filters at both a class and a collection level. A filter criteria is the "
|
||||
"ability to define a restriction clause very similiar to the existing \"where"
|
||||
"\" attribute available on the class and various collection elements. Except "
|
||||
"these filter conditions can be parameterized. The application can then make "
|
||||
"the decision at runtime whether given filters should be enabled and what "
|
||||
"their parameter values should be. Filters can be used like database views, "
|
||||
"but parameterized inside the application."
|
||||
msgstr ""
|
||||
"Hibernate3 ajoute la capacité de prédéfinir des critères de filtre et "
|
||||
"d'attacher ces filtres à une classe ou à une collection. Un critère de "
|
||||
"filtre est la faculté de définir une clause de restriction très similaire à "
|
||||
"l'attribut \"where\" existant disponible sur une classe et divers éléments "
|
||||
"d'une collection. Mis à part que ces conditions de filtre peuvent être "
|
||||
"paramétrées. L'application peut alors prendre la décision à l'exécution si "
|
||||
"des filtres donnés devraient être activés et quels devraient être leurs "
|
||||
"paramètres. Des filtres peuvent être utilisés comme des vues de base de "
|
||||
"données, mais paramétrées dans l'application."
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:50
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"In order to use filters, they must first be defined and then attached to the "
|
||||
"appropriate mapping elements. To define a filter, use the <literal><"
|
||||
"filter-def/></literal> element within a <literal><hibernate-mapping/"
|
||||
"></literal> element:"
|
||||
msgstr ""
|
||||
"Afin d'utiliser des filtres, ils doivent d'abord être définis, puis attachés "
|
||||
"aux éléments de mapping appropriés. Pour définir un filtre, utilisez "
|
||||
"l'élément <literal><filter-def/></literal> dans un élément "
|
||||
"<literal><hibernate-mapping/></literal> :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: filters.xml:56
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<filter-def name=\"myFilter\">\n"
|
||||
" <filter-param name=\"myFilterParam\" type=\"string\"/>\n"
|
||||
"</filter-def>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:58
|
||||
#, no-c-format
|
||||
msgid "Then, this filter can be attached to a class:"
|
||||
msgstr "Puis, ce filtre peut être attaché à une classe :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: filters.xml:62
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"myClass\" ...>\n"
|
||||
" ...\n"
|
||||
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
|
||||
"\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:64
|
||||
#, no-c-format
|
||||
msgid "or, to a collection:"
|
||||
msgstr "ou à une collection :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: filters.xml:68
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<set ...>\n"
|
||||
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
|
||||
"\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:70
|
||||
#, no-c-format
|
||||
msgid "or, even to both (or multiples of each) at the same time."
|
||||
msgstr "ou même aux deux (ou à plusieurs de chaque) en même temps."
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:74
|
||||
#, fuzzy, no-c-format
|
||||
msgid ""
|
||||
"The methods on <literal>Session</literal> are: <literal>enableFilter(String "
|
||||
"filterName)</literal>, <literal>getEnabledFilter(String filterName)</"
|
||||
"literal>, and <literal>disableFilter(String filterName)</literal>. By "
|
||||
"default, filters are <emphasis>not</emphasis> enabled for a given session; "
|
||||
"they must be explcitly enabled through use of the <literal>Session."
|
||||
"enableFilter()</literal> method, which returns an instance of the "
|
||||
"<literal>Filter</literal> interface. Using the simple filter defined above, "
|
||||
"this would look like:"
|
||||
msgstr ""
|
||||
"Les méthodes sur <literal>Session</literal> sont : <literal>enableFilter"
|
||||
"(String filterName)</literal>, <literal>getEnabledFilter(String filterName)</"
|
||||
"literal>, et <literal>disableFilter(String filterName)</literal>. Par "
|
||||
"défaut, les filtres <emphasis>ne sont pas</emphasis> activés pour une "
|
||||
"session donnée ; ils doivent être explicitement activés en appelant la "
|
||||
"méthode <literal>Session.enableFilter()</literal>, laquelle retourne une "
|
||||
"instance de l'interface <literal>Filter</literal>. Utiliser le simple filtre "
|
||||
"défini au-dessus ressemblerait à :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: filters.xml:83
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[session.enableFilter(\"myFilter\").setParameter(\"myFilterParam\", "
|
||||
"\"some-value\");]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:85
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that methods on the org.hibernate.Filter interface do allow the method-"
|
||||
"chaining common to much of Hibernate."
|
||||
msgstr ""
|
||||
"Notez que des méthodes sur l'interface org.hibernate.Filter autorisent le "
|
||||
"chaînage de beaucoup de méthodes communes d'Hibernate."
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:89
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A full example, using temporal data with an effective record date pattern:"
|
||||
msgstr ""
|
||||
"Un exemple complet, utilisant des données temporelles avec une structure de "
|
||||
"date d'enregistrement effectif :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: filters.xml:93
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<filter-def name=\"effectiveDate\">\n"
|
||||
" <filter-param name=\"asOfDate\" type=\"date\"/>\n"
|
||||
"</filter-def>\n"
|
||||
"\n"
|
||||
"<class name=\"Employee\" ...>\n"
|
||||
"...\n"
|
||||
" <many-to-one name=\"department\" column=\"dept_id\" class=\"Department\"/"
|
||||
">\n"
|
||||
" <property name=\"effectiveStartDate\" type=\"date\" column=\"eff_start_dt"
|
||||
"\"/>\n"
|
||||
" <property name=\"effectiveEndDate\" type=\"date\" column=\"eff_end_dt\"/"
|
||||
">\n"
|
||||
"...\n"
|
||||
" <!--\n"
|
||||
" Note that this assumes non-terminal records have an eff_end_dt set "
|
||||
"to\n"
|
||||
" a max db date for simplicity-sake\n"
|
||||
" -->\n"
|
||||
" <filter name=\"effectiveDate\"\n"
|
||||
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"Department\" ...>\n"
|
||||
"...\n"
|
||||
" <set name=\"employees\" lazy=\"true\">\n"
|
||||
" <key column=\"dept_id\"/>\n"
|
||||
" <one-to-many class=\"Employee\"/>\n"
|
||||
" <filter name=\"effectiveDate\"\n"
|
||||
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/"
|
||||
">\n"
|
||||
" </set>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:95
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Then, in order to ensure that you always get back currently effective "
|
||||
"records, simply enable the filter on the session prior to retrieving "
|
||||
"employee data:"
|
||||
msgstr ""
|
||||
"Puis, afin de s'assurer que vous pouvez toujours récupérer les "
|
||||
"enregistrements actuellement effectifs, activez simplement le filtre sur la "
|
||||
"session avant de récupérer des données des employés :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: filters.xml:100
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = ...;\n"
|
||||
"session.enableFilter(\"effectiveDate\").setParameter(\"asOfDate\", new Date"
|
||||
"());\n"
|
||||
"List results = session.createQuery(\"from Employee as e where e.salary > :"
|
||||
"targetSalary\")\n"
|
||||
" .setLong(\"targetSalary\", new Long(1000000))\n"
|
||||
" .list();\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:102
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"In the HQL above, even though we only explicitly mentioned a salary "
|
||||
"constraint on the results, because of the enabled filter the query will "
|
||||
"return only currently active employees who have a salary greater than a "
|
||||
"million dollars."
|
||||
msgstr ""
|
||||
"Dans le HQL ci-dessus, bien que nous ayons seulement mentionné une "
|
||||
"contrainte de salaire sur les resultats, à cause du filtre activé, la "
|
||||
"requête retournera seulement les employés actuellement actifs qui ont un "
|
||||
"salaire supérieur à un million de dollars."
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:108
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note: if you plan on using filters with outer joining (either through HQL or "
|
||||
"load fetching) be careful of the direction of the condition expression. Its "
|
||||
"safest to set this up for left outer joining; in general, place the "
|
||||
"parameter first followed by the column name(s) after the operator."
|
||||
msgstr ""
|
||||
"A noter : si vous prévoyez d'utiliser des filtres avec des jointures "
|
||||
"externes (soit à travers HQL, soit par le chargement) faites attention à la "
|
||||
"direction de l'expression de condition. Il est plus sûr de la positionner "
|
||||
"pour les jointures externes à gauche ; en général, placez le paramètre "
|
||||
"d'abord, suivi du(des) nom(s) de colonne après l'opérateur."
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:115
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"After being defined a filter might be attached to multiple entities and/or "
|
||||
"collections each with its own condition. That can be tedious when the "
|
||||
"conditions are the same each time. Thus <literal><filter-def/></"
|
||||
"literal> allows defining a default condition, either as an attribute or "
|
||||
"CDATA:"
|
||||
msgstr "translator-credits"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: filters.xml:122
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<filter-def name=\"myFilter\" condition=\"abc > xyz\">...</filter-"
|
||||
"def>\n"
|
||||
"<filter-def name=\"myOtherFilter\">abc=xyz</filter-def>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: filters.xml:124
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This default condition will then be used whenever the filter is attached to "
|
||||
"something without specifying a condition. Note that this means you can give "
|
||||
"a specific condition as part of the attachment of the filter which overrides "
|
||||
"the default condition in that particular case."
|
||||
msgstr ""
|
|
@ -0,0 +1,864 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:29
|
||||
#, no-c-format
|
||||
msgid "Inheritance Mapping"
|
||||
msgstr "Mapping d'héritage de classe"
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:32
|
||||
#, no-c-format
|
||||
msgid "The Three Strategies"
|
||||
msgstr "Les trois stratégies"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:34
|
||||
#, no-c-format
|
||||
msgid "Hibernate supports the three basic inheritance mapping strategies:"
|
||||
msgstr "Hibernate supporte les trois stratégies d'héritage de base :"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:40
|
||||
#, no-c-format
|
||||
msgid "table per class hierarchy"
|
||||
msgstr "une table par hiérarchie de classe (table per class hierarchy)"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:45
|
||||
#, fuzzy, no-c-format
|
||||
msgid "<para>table per subclass</para>"
|
||||
msgstr ""
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"une table par classe fille (table per subclass)\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"une table par classe fille"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:50
|
||||
#, no-c-format
|
||||
msgid "table per concrete class"
|
||||
msgstr "une table par classe concrète (table per concrete class)"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:56
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"In addition, Hibernate supports a fourth, slightly different kind of "
|
||||
"polymorphism:"
|
||||
msgstr ""
|
||||
"Hibernate supporte en plus une quatrièmestratégie, légèrement différente, "
|
||||
"qui supporte le polymorphisme :"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:63
|
||||
#, no-c-format
|
||||
msgid "implicit polymorphism"
|
||||
msgstr "le polymorphisme implicite"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:69
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"It is possible to use different mapping strategies for different branches of "
|
||||
"the same inheritance hierarchy, and then make use of implicit polymorphism "
|
||||
"to achieve polymorphism across the whole hierarchy. However, Hibernate does "
|
||||
"not support mixing <literal><subclass></literal>, and <literal><"
|
||||
"joined-subclass></literal> and <literal><union-subclass></literal> "
|
||||
"mappings under the same root <literal><class></literal> element. It is "
|
||||
"possible to mix together the table per hierarchy and table per subclass "
|
||||
"strategies, under the the same <literal><class></literal> element, by "
|
||||
"combining the <literal><subclass></literal> and <literal><join></"
|
||||
"literal> elements (see below)."
|
||||
msgstr ""
|
||||
"Il est possible d'utiliser différentes stratégies de mapping pour "
|
||||
"différentes branches d'une même hiérarchie d'héritage, et alors d'employer "
|
||||
"le polymorphisme implicite pour réaliser le polymorphisme à travers toute la "
|
||||
"hiérarchie. Pourtant, Hibernate ne supporte pas de mélanger des mappings "
|
||||
"<literal><subclass></literal> et <literal><joined-subclass></"
|
||||
"literal> et <literal><union-subclass></literal> pour le même élément "
|
||||
"<literal><class></literal> racine. Il est possible de mélanger "
|
||||
"ensemble les stratégies d'une table par hiérarchie et d'une table par sous-"
|
||||
"classe, pour le même élément <literal><class></literal>, en combinant "
|
||||
"les éléments <literal><subclass></literal> et <literal><join></"
|
||||
"literal> (voir dessous)."
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:83
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"It is possible to define <literal>subclass</literal>, <literal>union-"
|
||||
"subclass</literal>, and <literal>joined-subclass</literal> mappings in "
|
||||
"separate mapping documents, directly beneath <literal>hibernate-mapping</"
|
||||
"literal>. This allows you to extend a class hierachy just by adding a new "
|
||||
"mapping file. You must specify an <literal>extends</literal> attribute in "
|
||||
"the subclass mapping, naming a previously mapped superclass. Note: "
|
||||
"Previously this feature made the ordering of the mapping documents "
|
||||
"important. Since Hibernate3, the ordering of mapping files does not matter "
|
||||
"when using the extends keyword. The ordering inside a single mapping file "
|
||||
"still needs to be defined as superclasses before subclasses."
|
||||
msgstr ""
|
||||
"Il est possible de définir des mappings de <literal>subclass</literal>, "
|
||||
"<literal>union-subclass</literal>, et <literal>joined-subclass</literal> "
|
||||
"dans des documents de mapping séparés, directement sous <literal>hibernate-"
|
||||
"mapping</literal>. Ceci vous permet d'étendre une hiérarchie de classe juste "
|
||||
"en ajoutant un nouveau fichier de mapping. Vous devez spécifier un attribut "
|
||||
"<literal>extends</literal> dans le mapping de la sous-classe, en nommant une "
|
||||
"super-classe précédemment mappée. Note : précédemment cette foncionnalité "
|
||||
"rendait l'ordre des documents de mapping important. Depuis Hibernate3, "
|
||||
"l'ordre des fichier de mapping n'importe plus lors de l'utilisation du mot-"
|
||||
"clef \"extends\". L'ordre à l'intérieur d'un simple fichier de mapping "
|
||||
"impose encore de définir les classes mères avant les classes filles."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:94
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
" <hibernate-mapping>\n"
|
||||
" <subclass name=\"DomesticCat\" extends=\"Cat\" discriminator-value=\"D"
|
||||
"\">\n"
|
||||
" <property name=\"name\" type=\"string\"/>\n"
|
||||
" </subclass>\n"
|
||||
" </hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:98
|
||||
#, no-c-format
|
||||
msgid "Table per class hierarchy"
|
||||
msgstr "Une table par hiérarchie de classe"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:100
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Suppose we have an interface <literal>Payment</literal>, with implementors "
|
||||
"<literal>CreditCardPayment</literal>, <literal>CashPayment</literal>, "
|
||||
"<literal>ChequePayment</literal>. The table per hierarchy mapping would look "
|
||||
"like:"
|
||||
msgstr ""
|
||||
"Supposons que nous ayons une interface <literal>Payment</literal>, "
|
||||
"implémentée par <literal>CreditCardPayment</literal>, <literal>CashPayment</"
|
||||
"literal>, <literal>ChequePayment</literal>. La stratégie une table par "
|
||||
"hiérarchie serait :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:107
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:109
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Exactly one table is required. There is one big limitation of this mapping "
|
||||
"strategy: columns declared by the subclasses, such as <literal>CCTYPE</"
|
||||
"literal>, may not have <literal>NOT NULL</literal> constraints."
|
||||
msgstr ""
|
||||
"Une seule table est requise. Une grande limitation de cette stratégie est "
|
||||
"que les colonnes déclarées par les classes filles, telles que "
|
||||
"<literal>CCTYPE</literal>, ne peuvent avoir de contrainte <literal>NOT NULL</"
|
||||
"literal>."
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:118
|
||||
#, no-c-format
|
||||
msgid "Table per subclass"
|
||||
msgstr "Une table par classe fille"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:120
|
||||
#, no-c-format
|
||||
msgid "A table per subclass mapping would look like:"
|
||||
msgstr "La stratégie une table par classe fille serait :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:124
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <joined-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:126
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Four tables are required. The three subclass tables have primary key "
|
||||
"associations to the superclass table (so the relational model is actually a "
|
||||
"one-to-one association)."
|
||||
msgstr ""
|
||||
"Quatre tables sont requises. Les trois tables des classes filles ont une clé "
|
||||
"primaire associée à la table classe mère (le modèle relationnel est une "
|
||||
"association un-vers-un)."
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:135
|
||||
#, no-c-format
|
||||
msgid "Table per subclass, using a discriminator"
|
||||
msgstr "Une table par classe fille, en utilisant un discriminant"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:137
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that Hibernate's implementation of table per subclass requires no "
|
||||
"discriminator column. Other object/relational mappers use a different "
|
||||
"implementation of table per subclass which requires a type discriminator "
|
||||
"column in the superclass table. The approach taken by Hibernate is much more "
|
||||
"difficult to implement but arguably more correct from a relational point of "
|
||||
"view. If you would like to use a discriminator column with the table per "
|
||||
"subclass strategy, you may combine the use of <literal><subclass></"
|
||||
"literal> and <literal><join></literal>, as follow:"
|
||||
msgstr ""
|
||||
"Notez que l'implémentation Hibernate de la stratégie un table par classe "
|
||||
"fille ne nécessite pas de colonne discriminante dans la table classe mère. "
|
||||
"D'autres implémentations de mappers Objet/Relationnel utilisent une autre "
|
||||
"implémentation de la stratégie une table par classe fille qui nécessite une "
|
||||
"colonne de type discriminant dans la table de la classe mère. L'approche "
|
||||
"prise par Hibernate est plus difficile à implémenter mais plus correcte "
|
||||
"d'une point de vue relationnel. Si vous aimeriez utiliser une colonne "
|
||||
"discriminante avec la stratégie d'une table par classe fille, vous pourriez "
|
||||
"combiner l'utilisation de <literal><subclass></literal> et "
|
||||
"<literal><join></literal>, comme suit :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:149
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <join table=\"CREDIT_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" <join table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" <join table=\"CHEQUE_PAYMENT\" fetch=\"select\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:151
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The optional <literal>fetch=\"select\"</literal> declaration tells Hibernate "
|
||||
"not to fetch the <literal>ChequePayment</literal> subclass data using an "
|
||||
"outer join when querying the superclass."
|
||||
msgstr ""
|
||||
"La déclaration optionnelle <literal>fetch=\"select\"</literal> indique à "
|
||||
"Hibernate de ne pas récupérer les données de la classe fille "
|
||||
"<literal>ChequePayment</literal> par une jointure externe lors des requêtes "
|
||||
"sur la classe mère."
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:160
|
||||
#, no-c-format
|
||||
msgid "Mixing table per class hierarchy with table per subclass"
|
||||
msgstr ""
|
||||
"Mélange d'une table par hiérarchie de classe avec une table par classe fille"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:162
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You may even mix the table per hierarchy and table per subclass strategies "
|
||||
"using this approach:"
|
||||
msgstr ""
|
||||
"Vous pouvez même mélanger les stratégies d'une table par hiérarchie de "
|
||||
"classe et d'une table par classe fille en utilisant cette approche :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:167
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n"
|
||||
" <join table=\"CREDIT_PAYMENT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </join>\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
" <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n"
|
||||
" ...\n"
|
||||
" </subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:169
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"For any of these mapping strategies, a polymorphic association to the root "
|
||||
"<literal>Payment</literal> class is mapped using <literal><many-to-one>"
|
||||
"</literal>."
|
||||
msgstr ""
|
||||
"Pour importe laquelle de ces stratégies, une association polymorphique vers "
|
||||
"la classe racine <literal>Payment</literal> est mappée en utilisant "
|
||||
"<literal><many-to-one></literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:175
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment"
|
||||
"\"/>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:180
|
||||
#, no-c-format
|
||||
msgid "Table per concrete class"
|
||||
msgstr "Une table par classe concrète"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:182
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There are two ways we could go about mapping the table per concrete class "
|
||||
"strategy. The first is to use <literal><union-subclass></literal>."
|
||||
msgstr ""
|
||||
"Il y a deux manières d'utiliser la stratégie d'une table par classe "
|
||||
"concrète. La première est d'employer <literal><union-subclass></"
|
||||
"literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:187
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Payment\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <union-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <property name=\"creditCardType\" column=\"CCTYPE\"/>\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
" <union-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
" <union-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" ...\n"
|
||||
" </union-subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:189
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Three tables are involved for the subclasses. Each table defines columns for "
|
||||
"all properties of the class, including inherited properties."
|
||||
msgstr ""
|
||||
"Trois tables sont nécessaires pour les classes filles. Chaque table définit "
|
||||
"des colonnes pour toutes les propriétés de la classe, incluant les "
|
||||
"propriétés héritéés."
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:194
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The limitation of this approach is that if a property is mapped on the "
|
||||
"superclass, the column name must be the same on all subclass tables. (We "
|
||||
"might relax this in a future release of Hibernate.) The identity generator "
|
||||
"strategy is not allowed in union subclass inheritance, indeed the primary "
|
||||
"key seed has to be shared accross all unioned subclasses of a hierarchy."
|
||||
msgstr ""
|
||||
"La limitation de cette approche est que si une propriété est mappée sur la "
|
||||
"classe mère, le nom de la colonne doit être le même pour toutes les classes "
|
||||
"filles. (Nous pourrions être plus souple dans une future version "
|
||||
"d'Hibernate). La stratégie du générateur d'identifiant n'est pas permise "
|
||||
"dans l'héritage de classes filles par union, en effet la valeur (NdT : seed) "
|
||||
"de la clef primaire doit être partagée par toutes les classes filles \"union"
|
||||
"\" d'une hiérarchie."
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:203
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If your superclass is abstract, map it with <literal>abstract=\"true\"</"
|
||||
"literal>. Of course, if it is not abstract, an additional table (defaults to "
|
||||
"<literal>PAYMENT</literal> in the example above) is needed to hold instances "
|
||||
"of the superclass."
|
||||
msgstr ""
|
||||
"Si votre classe mère est abstraite, mappez la avec <literal>abstract=\"true"
|
||||
"\"</literal>. Bien sûr, si elle n'est pas abstraite, une table "
|
||||
"supplémentaire (par défaut, <literal>PAYMENT</literal> dans l'exemple ci-"
|
||||
"dessus) est requise pour contenir des instances de la classe mère."
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:213
|
||||
#, no-c-format
|
||||
msgid "Table per concrete class, using implicit polymorphism"
|
||||
msgstr "Une table par classe concrète, en utilisant le polymorphisme implicite"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:215
|
||||
#, no-c-format
|
||||
msgid "An alternative approach is to make use of implicit polymorphism:"
|
||||
msgstr "Une approche alternative est l'emploi du polymorphisme implicite :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:219
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CREDIT_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CASH_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CASH_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CHEQUE_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"amount\" column=\"CHEQUE_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:221
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Notice that nowhere do we mention the <literal>Payment</literal> interface "
|
||||
"explicitly. Also notice that properties of <literal>Payment</literal> are "
|
||||
"mapped in each of the subclasses. If you want to avoid duplication, consider "
|
||||
"using XML entities (e.g. <literal>[ <!ENTITY allproperties SYSTEM "
|
||||
"\"allproperties.xml\"> ]</literal> in the <literal>DOCTYPE</literal> "
|
||||
"declartion and <literal>&allproperties;</literal> in the mapping)."
|
||||
msgstr ""
|
||||
"Notez que nulle part nous ne mentionnons l'interface <literal>Payment</"
|
||||
"literal> explicitement. Notez aussi que des propriétés de <literal>Payment</"
|
||||
"literal> sont mappées dans chaque classe fille. Si vous voulez éviter des "
|
||||
"duplications, considérez l'utilisation des entités XML (cf. <literal>[ <!"
|
||||
"ENTITY allproperties SYSTEM \"allproperties.xml\"> ]</literal> dans la "
|
||||
"déclaration du <literal>DOCTYPE</literal> et <literal>&allproperties;</"
|
||||
"literal> dans le mapping)."
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:231
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The disadvantage of this approach is that Hibernate does not generate SQL "
|
||||
"<literal>UNION</literal>s when performing polymorphic queries."
|
||||
msgstr ""
|
||||
"L'inconvénient de cette approche est qu'Hibernate ne génère pas "
|
||||
"d'<literal>UNION</literal>s SQL lors de l'exécution des requêtes "
|
||||
"polymorphiques."
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:236
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"For this mapping strategy, a polymorphic association to <literal>Payment</"
|
||||
"literal> is usually mapped using <literal><any></literal>."
|
||||
msgstr ""
|
||||
"Pour cette stratégie de mapping, une association polymorphique pour "
|
||||
"<literal>Payment</literal> est habituellement mappée en utilisant "
|
||||
"<literal><any></literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:241
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<any name=\"payment\" meta-type=\"string\" id-type=\"long\">\n"
|
||||
" <meta-value value=\"CREDIT\" class=\"CreditCardPayment\"/>\n"
|
||||
" <meta-value value=\"CASH\" class=\"CashPayment\"/>\n"
|
||||
" <meta-value value=\"CHEQUE\" class=\"ChequePayment\"/>\n"
|
||||
" <column name=\"PAYMENT_CLASS\"/>\n"
|
||||
" <column name=\"PAYMENT_ID\"/>\n"
|
||||
"</any>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:246
|
||||
#, no-c-format
|
||||
msgid "Mixing implicit polymorphism with other inheritance mappings"
|
||||
msgstr "Mélange du polymorphisme implicite avec d'autres mappings d'héritage"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:248
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There is one further thing to notice about this mapping. Since the "
|
||||
"subclasses are each mapped in their own <literal><class></literal> "
|
||||
"element (and since <literal>Payment</literal> is just an interface), each of "
|
||||
"the subclasses could easily be part of another inheritance hierarchy! (And "
|
||||
"you can still use polymorphic queries against the <literal>Payment</literal> "
|
||||
"interface.)"
|
||||
msgstr ""
|
||||
"Il y a une chose supplémentaire à noter à propos de ce mapping. Puisque les "
|
||||
"classes filles sont chacune mappées avec leur propre élément <literal><"
|
||||
"class></literal> (et puisque <literal>Payment</literal> est juste une "
|
||||
"interface), chaque classe fille pourrait facilement faire partie d'une autre "
|
||||
"hiérarchie d'héritage ! (Et vous pouvez encore faire des requêtes "
|
||||
"polymorphiques pour l'interface <literal>Payment</literal>)."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: inheritance_mapping.xml:256
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" <discriminator column=\"CREDIT_CARD\" type=\"string\"/>\n"
|
||||
" <property name=\"amount\" column=\"CREDIT_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" <subclass name=\"MasterCardPayment\" discriminator-value=\"MDC\"/>\n"
|
||||
" <subclass name=\"VisaPayment\" discriminator-value=\"VISA\"/>\n"
|
||||
"</class>\n"
|
||||
"\n"
|
||||
"<class name=\"NonelectronicTransaction\" table=\"NONELECTRONIC_TXN\">\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"TXN_ID\">\n"
|
||||
" <generator class=\"native\"/>\n"
|
||||
" </id>\n"
|
||||
" ...\n"
|
||||
" <joined-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"amount\" column=\"CASH_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
" <joined-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n"
|
||||
" <key column=\"PAYMENT_ID\"/>\n"
|
||||
" <property name=\"amount\" column=\"CHEQUE_AMOUNT\"/>\n"
|
||||
" ...\n"
|
||||
" </joined-subclass>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:258
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Once again, we don't mention <literal>Payment</literal> explicitly. If we "
|
||||
"execute a query against the <literal>Payment</literal> interface - for "
|
||||
"example, <literal>from Payment</literal> - Hibernate automatically returns "
|
||||
"instances of <literal>CreditCardPayment</literal> (and its subclasses, since "
|
||||
"they also implement <literal>Payment</literal>), <literal>CashPayment</"
|
||||
"literal> and <literal>ChequePayment</literal> but not instances of "
|
||||
"<literal>NonelectronicTransaction</literal>."
|
||||
msgstr ""
|
||||
"Encore une fois, nous ne mentionnons pas explicitement <literal>Payment</"
|
||||
"literal>. Si nous exécutons une requête sur l'interface <literal>Payment</"
|
||||
"literal> - par exemple, <literal>from Payment</literal> - Hibernate "
|
||||
"retournera automatiquement les instances de <literal>CreditCardPayment</"
|
||||
"literal> (et ses classes filles puisqu'elles implémentent aussi "
|
||||
"<literal>Payment</literal>), <literal>CashPayment</literal> et "
|
||||
"<literal>ChequePayment</literal> mais pas les instances de "
|
||||
"<literal>NonelectronicTransaction</literal>."
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:273
|
||||
#, no-c-format
|
||||
msgid "Limitations"
|
||||
msgstr "Limitations"
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:275
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There are certain limitations to the \"implicit polymorphism\" approach to "
|
||||
"the table per concrete-class mapping strategy. There are somewhat less "
|
||||
"restrictive limitations to <literal><union-subclass></literal> "
|
||||
"mappings."
|
||||
msgstr ""
|
||||
"Il y a certaines limitations à l'approche du \"polymorphisme implicite\" "
|
||||
"pour la stratégie de mapping d'une table par classe concrète. Il y a plutôt "
|
||||
"moins de limitations restrictives aux mappings <literal><union-"
|
||||
"subclass></literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: inheritance_mapping.xml:282
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The following table shows the limitations of table per concrete-class "
|
||||
"mappings, and of implicit polymorphism, in Hibernate."
|
||||
msgstr ""
|
||||
"La table suivante montre les limitations des mappings d'une table par classe "
|
||||
"concrète, et du polymorphisme implicite, dans Hibernate."
|
||||
|
||||
#. Tag: title
|
||||
#: inheritance_mapping.xml:288
|
||||
#, no-c-format
|
||||
msgid "Features of inheritance mappings"
|
||||
msgstr "Caractéristiques du mapping d'héritage"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:300
|
||||
#, no-c-format
|
||||
msgid "Inheritance strategy"
|
||||
msgstr "Stratégie d'héritage"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:301
|
||||
#, no-c-format
|
||||
msgid "Polymorphic many-to-one"
|
||||
msgstr "many-to-one polymorphique"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:302
|
||||
#, no-c-format
|
||||
msgid "Polymorphic one-to-one"
|
||||
msgstr "one-to-one polymorphique"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:303
|
||||
#, no-c-format
|
||||
msgid "Polymorphic one-to-many"
|
||||
msgstr "one-to-many polymorphique"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:304
|
||||
#, no-c-format
|
||||
msgid "Polymorphic many-to-many"
|
||||
msgstr "many-to-many polymorphique"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:305
|
||||
#, no-c-format
|
||||
msgid "Polymorphic <literal>load()/get()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:306
|
||||
#, no-c-format
|
||||
msgid "Polymorphic queries"
|
||||
msgstr "Requêtes polymorphiques"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:307
|
||||
#, no-c-format
|
||||
msgid "Polymorphic joins"
|
||||
msgstr "Jointures polymorphiques"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:308
|
||||
#, no-c-format
|
||||
msgid "Outer join fetching"
|
||||
msgstr "Récupération par jointure externe"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:313
|
||||
#, no-c-format
|
||||
msgid "table per class-hierarchy"
|
||||
msgstr "une table par hiérarchie de classe"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:314 inheritance_mapping.xml:325
|
||||
#: inheritance_mapping.xml:336
|
||||
#, no-c-format
|
||||
msgid "<many-to-one>"
|
||||
msgstr "<many-to-one>"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:315 inheritance_mapping.xml:326
|
||||
#: inheritance_mapping.xml:337
|
||||
#, no-c-format
|
||||
msgid "<one-to-one>"
|
||||
msgstr "<one-to-one>"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:316 inheritance_mapping.xml:327
|
||||
#, no-c-format
|
||||
msgid "<one-to-many>"
|
||||
msgstr "<one-to-many>"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:317 inheritance_mapping.xml:328
|
||||
#: inheritance_mapping.xml:339
|
||||
#, no-c-format
|
||||
msgid "<many-to-many>"
|
||||
msgstr "<many-to-many>"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:318 inheritance_mapping.xml:329
|
||||
#: inheritance_mapping.xml:340
|
||||
#, no-c-format
|
||||
msgid "s.get(Payment.class, id)"
|
||||
msgstr "s.get(Payment.class, id)"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:319 inheritance_mapping.xml:330
|
||||
#: inheritance_mapping.xml:341 inheritance_mapping.xml:352
|
||||
#, no-c-format
|
||||
msgid "from Payment p"
|
||||
msgstr "from Payment p"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:320 inheritance_mapping.xml:331
|
||||
#: inheritance_mapping.xml:342
|
||||
#, no-c-format
|
||||
msgid "from Order o join o.payment p"
|
||||
msgstr "from Order o join o.payment p"
|
||||
|
||||
#. Tag: emphasis
|
||||
#: inheritance_mapping.xml:321 inheritance_mapping.xml:332
|
||||
#: inheritance_mapping.xml:343
|
||||
#, no-c-format
|
||||
msgid "supported"
|
||||
msgstr "supportée"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:324
|
||||
#, fuzzy, no-c-format
|
||||
msgid "<entry>table per subclass</entry>"
|
||||
msgstr ""
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"une table par classe fille (table per subclass)\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"une table par classe fille"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:335
|
||||
#, no-c-format
|
||||
msgid "table per concrete-class (union-subclass)"
|
||||
msgstr "une table par classe concrète (union-subclass)"
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:338
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal><one-to-many></literal> (for <literal>inverse=\"true\"</"
|
||||
"literal> only)"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: entry
|
||||
#: inheritance_mapping.xml:346
|
||||
#, no-c-format
|
||||
msgid "table per concrete class (implicit polymorphism)"
|
||||
msgstr "une table par classe concrète (polymorphisme implicite)"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:347
|
||||
#, no-c-format
|
||||
msgid "<any>"
|
||||
msgstr "<any>"
|
||||
|
||||
#. Tag: emphasis
|
||||
#: inheritance_mapping.xml:348 inheritance_mapping.xml:349
|
||||
#: inheritance_mapping.xml:353 inheritance_mapping.xml:354
|
||||
#, fuzzy, no-c-format
|
||||
msgid "not supported"
|
||||
msgstr ""
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"non supporté\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"non supporté\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"non supportées\n"
|
||||
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
|
||||
"non supportée"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:350
|
||||
#, no-c-format
|
||||
msgid "<many-to-any>"
|
||||
msgstr "<many-to-any>"
|
||||
|
||||
#. Tag: literal
|
||||
#: inheritance_mapping.xml:351
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
|
||||
msgstr ""
|
||||
"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
|
||||
|
||||
#~ msgid "load()/get()"
|
||||
#~ msgstr "load()/get()"
|
||||
|
||||
#~ msgid "Polymorphic <placeholder-1/>"
|
||||
#~ msgstr "<placeholder-1/> polymorphique"
|
||||
|
||||
#~ msgid "inverse=\"true\""
|
||||
#~ msgstr "inverse=\"true\""
|
||||
|
||||
#~ msgid "<placeholder-1/> (for <placeholder-2/> only)"
|
||||
#~ msgstr "<placeholder-1/> (pour <placeholder-2/> seulement)"
|
|
@ -0,0 +1,889 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:29
|
||||
#, no-c-format
|
||||
msgid "Persistent Classes"
|
||||
msgstr "Classes persistantes"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Persistent classes are classes in an application that implement the entities "
|
||||
"of the business problem (e.g. Customer and Order in an E-commerce "
|
||||
"application). Not all instances of a persistent class are considered to be "
|
||||
"in the persistent state - an instance may instead be transient or detached."
|
||||
msgstr ""
|
||||
"Les classes persistantes sont les classes d'une application qui implémentent "
|
||||
"les entités d'un problème métier (ex. Client et Commande dans une "
|
||||
"application de commerce électronique). Toutes les instances d'une classe "
|
||||
"persistante ne sont pas forcément dans l'état persistant - au lieu de cela, "
|
||||
"une instance peut être éphémère (NdT : transient) ou détachée."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:38
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate works best if these classes follow some simple rules, also known "
|
||||
"as the Plain Old Java Object (POJO) programming model. However, none of "
|
||||
"these rules are hard requirements. Indeed, Hibernate3 assumes very little "
|
||||
"about the nature of your persistent objects. You may express a domain model "
|
||||
"in other ways: using trees of <literal>Map</literal> instances, for example."
|
||||
msgstr ""
|
||||
"Hibernate fonctionne de manière optimale lorsque ces classes suivent "
|
||||
"quelques règles simples, aussi connues comme le modèle de programmation "
|
||||
"Plain Old Java Object (POJO). Cependant, aucune de ces règles ne sont des "
|
||||
"besoins absolus. En effet, Hibernate3 suppose très peu de choses à propos de "
|
||||
"la nature de vos objets persistants. Vous pouvez exprimer un modèle de "
|
||||
"domaine par d'autres moyens : utiliser des arbres d'instances de "
|
||||
"<literal>Map</literal>, par exemple."
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:47
|
||||
#, no-c-format
|
||||
msgid "A simple POJO example"
|
||||
msgstr "Un exemple simple de POJO"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:49
|
||||
#, no-c-format
|
||||
msgid "Most Java applications require a persistent class representing felines."
|
||||
msgstr ""
|
||||
"Toute bonne application Java nécessite une classe persistante représentant "
|
||||
"les félins."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: persistent_classes.xml:53
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"import java.util.Set;\n"
|
||||
"import java.util.Date;\n"
|
||||
"\n"
|
||||
"public class Cat {\n"
|
||||
" private Long id; // identifier\n"
|
||||
"\n"
|
||||
" private Date birthdate;\n"
|
||||
" private Color color;\n"
|
||||
" private char sex;\n"
|
||||
" private float weight;\n"
|
||||
" private int litterId;\n"
|
||||
"\n"
|
||||
" private Cat mother;\n"
|
||||
" private Set kittens = new HashSet();\n"
|
||||
"\n"
|
||||
" private void setId(Long id) {\n"
|
||||
" this.id=id;\n"
|
||||
" }\n"
|
||||
" public Long getId() {\n"
|
||||
" return id;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setBirthdate(Date date) {\n"
|
||||
" birthdate = date;\n"
|
||||
" }\n"
|
||||
" public Date getBirthdate() {\n"
|
||||
" return birthdate;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setWeight(float weight) {\n"
|
||||
" this.weight = weight;\n"
|
||||
" }\n"
|
||||
" public float getWeight() {\n"
|
||||
" return weight;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public Color getColor() {\n"
|
||||
" return color;\n"
|
||||
" }\n"
|
||||
" void setColor(Color color) {\n"
|
||||
" this.color = color;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setSex(char sex) {\n"
|
||||
" this.sex=sex;\n"
|
||||
" }\n"
|
||||
" public char getSex() {\n"
|
||||
" return sex;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setLitterId(int id) {\n"
|
||||
" this.litterId = id;\n"
|
||||
" }\n"
|
||||
" public int getLitterId() {\n"
|
||||
" return litterId;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" void setMother(Cat mother) {\n"
|
||||
" this.mother = mother;\n"
|
||||
" }\n"
|
||||
" public Cat getMother() {\n"
|
||||
" return mother;\n"
|
||||
" }\n"
|
||||
" void setKittens(Set kittens) {\n"
|
||||
" this.kittens = kittens;\n"
|
||||
" }\n"
|
||||
" public Set getKittens() {\n"
|
||||
" return kittens;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // addKitten not needed by Hibernate\n"
|
||||
" public void addKitten(Cat kitten) {\n"
|
||||
" kitten.setMother(this);\n"
|
||||
" kitten.setLitterId( kittens.size() ); \n"
|
||||
" kittens.add(kitten);\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:55
|
||||
#, no-c-format
|
||||
msgid "There are four main rules to follow here:"
|
||||
msgstr "Il y a quatre règles à suivre ici :"
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:61
|
||||
#, no-c-format
|
||||
msgid "Implement a no-argument constructor"
|
||||
msgstr "Implémenter un constructeur sans argument"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:63
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal>Cat</literal> has a no-argument constructor. All persistent classes "
|
||||
"must have a default constructor (which may be non-public) so that Hibernate "
|
||||
"can instantiate them using <literal>Constructor.newInstance()</literal>. We "
|
||||
"strongly recommend having a default constructor with at least "
|
||||
"<emphasis>package</emphasis> visibility for runtime proxy generation in "
|
||||
"Hibernate."
|
||||
msgstr ""
|
||||
"<literal>Cat</literal> a un constructeur sans argument. Toutes les classes "
|
||||
"persistantes doivent avoir un constructeur par défaut (lequel peut ne pas "
|
||||
"être public) pour qu'Hibernate puissent les instancier en utilisant "
|
||||
"<literal>Constructor.newInstance()</literal>. Nous recommandons fortement "
|
||||
"d'avoir un constructeur par défaut avec au moins une visibilité "
|
||||
"<emphasis>paquet</emphasis> pour la génération du proxy à l'exécution dans "
|
||||
"Hibernate."
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:73
|
||||
#, no-c-format
|
||||
msgid "Provide an identifier property (optional)"
|
||||
msgstr "Fournir une propriété d'indentifiant (optionnel)"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:75
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal>Cat</literal> has a property called <literal>id</literal>. This "
|
||||
"property maps to the primary key column of a database table. The property "
|
||||
"might have been called anything, and its type might have been any primitive "
|
||||
"type, any primitive \"wrapper\" type, <literal>java.lang.String</literal> or "
|
||||
"<literal>java.util.Date</literal>. (If your legacy database table has "
|
||||
"composite keys, you can even use a user-defined class with properties of "
|
||||
"these types - see the section on composite identifiers later.)"
|
||||
msgstr ""
|
||||
"<literal>Cat</literal> possède une propriété appelée <literal>id</literal>. "
|
||||
"Cette propriété mappe la valeur de la colonne de clé primaire de la table "
|
||||
"d'une base de données.La propriété aurait pu s'appeler complètement "
|
||||
"autrement, et son type aurait pu être n'importe quel type primitif, "
|
||||
"n'importe quel \"encapsuleur\" de type primitif, <literal>java.lang.String</"
|
||||
"literal> ou <literal>java.util.Date</literal>. (Si votre base de données "
|
||||
"héritée possède des clés composites, elles peuvent être mappées en utilisant "
|
||||
"une classe définie par l'utilisateur et possédant les propriétés associées "
|
||||
"aux types de la clé composite - voir la section concernant les identifiants "
|
||||
"composites plus tard)."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:84
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The identifier property is strictly optional. You can leave them off and let "
|
||||
"Hibernate keep track of object identifiers internally. We do not recommend "
|
||||
"this, however."
|
||||
msgstr ""
|
||||
"La propriété d'identifiant est strictement optionnelle. Vous pouver "
|
||||
"l'oublier et laisser Hibernate s'occuper des identifiants de l'objet en "
|
||||
"interne. Toutefois, nous ne le recommandons pas."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:89
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"In fact, some functionality is available only to classes which declare an "
|
||||
"identifier property:"
|
||||
msgstr ""
|
||||
"En fait, quelques fonctionnalités ne sont disponibles que pour les classes "
|
||||
"déclarant un identifiant de propriété :"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:96
|
||||
#, fuzzy, no-c-format
|
||||
msgid ""
|
||||
"Transitive reattachment for detached objects (cascade update or cascade "
|
||||
"merge) - see"
|
||||
msgstr ""
|
||||
"Les réattachements transitifs pour les objets détachés (mise à jour en "
|
||||
"cascade ou fusion en cascade) - voir <xref linkend=\"objectstate-transitive"
|
||||
"\"/>"
|
||||
|
||||
#. Tag: literal
|
||||
#: persistent_classes.xml:103
|
||||
#, no-c-format
|
||||
msgid "Session.saveOrUpdate()"
|
||||
msgstr "Session.saveOrUpdate()"
|
||||
|
||||
#. Tag: literal
|
||||
#: persistent_classes.xml:108
|
||||
#, no-c-format
|
||||
msgid "Session.merge()"
|
||||
msgstr "Session.merge()"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:113
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"We recommend you declare consistently-named identifier properties on "
|
||||
"persistent classes. We further recommend that you use a nullable (ie. non-"
|
||||
"primitive) type."
|
||||
msgstr ""
|
||||
"Nous recommandons que vous déclariez les propriétés d'identifiant de manière "
|
||||
"uniforme. Nous recommandons également que vous utilisiez un type nullable "
|
||||
"(ie. non primitif)."
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:120
|
||||
#, no-c-format
|
||||
msgid "Prefer non-final classes (optional)"
|
||||
msgstr "Favoriser les classes non finales (optionnel)"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:121
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A central feature of Hibernate, <emphasis>proxies</emphasis>, depends upon "
|
||||
"the persistent class being either non-final, or the implementation of an "
|
||||
"interface that declares all public methods."
|
||||
msgstr ""
|
||||
"Une fonctionnalité clef d'Hibernate, les <emphasis>proxies</emphasis>, "
|
||||
"nécessitent que la classe persistente soit non finale ou qu'elle soit "
|
||||
"l'implémentation d'une interface qui déclare toutes les méthodes publiques."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:126
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You can persist <literal>final</literal> classes that do not implement an "
|
||||
"interface with Hibernate, but you won't be able to use proxies for lazy "
|
||||
"association fetching - which will limit your options for performance tuning."
|
||||
msgstr ""
|
||||
"Vous pouvez persister, grâce à Hibernate, les classes <literal>final</"
|
||||
"literal> qui n'implémentent pas d'interface, mais vous ne pourrez pas "
|
||||
"utiliser les proxies pour les chargements d'associations paresseuses - ce "
|
||||
"qui limitera vos possibilités d'ajustement des performances."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:131
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You should also avoid declaring <literal>public final</literal> methods on "
|
||||
"the non-final classes. If you want to use a class with a <literal>public "
|
||||
"final</literal> method, you must explicitly disable proxying by setting "
|
||||
"<literal>lazy=\"false\"</literal>."
|
||||
msgstr ""
|
||||
"Vous devriez aussi éviter de déclarer des méthodes <literal>public final</"
|
||||
"literal> sur des classes non-finales. Si vous voulez utiliser une classe "
|
||||
"avec une méthode <literal>public final</literal>, vous devez explicitement "
|
||||
"désactiver les proxies en paramétrant <literal>lazy=\"false\"</literal>."
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:139
|
||||
#, no-c-format
|
||||
msgid "Declare accessors and mutators for persistent fields (optional)"
|
||||
msgstr ""
|
||||
"Déclarer les accesseurs et mutateurs des attributs persistants (optionnel)"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:141
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal>Cat</literal> declares accessor methods for all its persistent "
|
||||
"fields. Many other ORM tools directly persist instance variables. We believe "
|
||||
"it is better to provide an indirection between the relational schema and "
|
||||
"internal data structures of the class. By default, Hibernate persists "
|
||||
"JavaBeans style properties, and recognizes method names of the form "
|
||||
"<literal>getFoo</literal>, <literal>isFoo</literal> and <literal>setFoo</"
|
||||
"literal>. You may switch to direct field access for particular properties, "
|
||||
"if needed."
|
||||
msgstr ""
|
||||
"<literal>Cat</literal> déclare des mutateurs pour toutes ses champs "
|
||||
"persistants. Beaucoup d'autres solutions de mapping Objet/relationnel "
|
||||
"persistent directement les variables d'instance. Nous pensons qu'il est bien "
|
||||
"mieux de fournir une indirection entre le schéma relationnel et les "
|
||||
"structures de données internes de la classe. Par défaut, Hibernate persiste "
|
||||
"les propriétés suivant le style JavaBean, et reconnaît les noms de méthodes "
|
||||
"de la forme <literal> getFoo</literal>, <literal>isFoo</literal> et "
|
||||
"<literal>setFoo</literal>. Nous pouvons changer pour un accès direct aux "
|
||||
"champs pour des propriétés particulières, si besoin est."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:151
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Properties need <emphasis>not</emphasis> be declared public - Hibernate can "
|
||||
"persist a property with a default, <literal>protected</literal> or "
|
||||
"<literal>private</literal> get / set pair."
|
||||
msgstr ""
|
||||
"Les propriétés <emphasis>n'ont pas</emphasis> à être déclarées publiques - "
|
||||
"Hibernate peut persister une propriété avec un paire de getter/setter de "
|
||||
"visibilité par défault, <literal>protected</literal> ou <literal> private</"
|
||||
"literal>."
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:162
|
||||
#, no-c-format
|
||||
msgid "Implementing inheritance"
|
||||
msgstr "Implémenter l'héritage"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:164
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A subclass must also observe the first and second rules. It inherits its "
|
||||
"identifier property from the superclass, <literal>Cat</literal>."
|
||||
msgstr ""
|
||||
"Une sous-classe doit également suivre la première et la seconde règle. Elle "
|
||||
"hérite sa propriété d'identifiant de <literal>Cat</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: persistent_classes.xml:169
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[package eg;\n"
|
||||
"\n"
|
||||
"public class DomesticCat extends Cat {\n"
|
||||
" private String name;\n"
|
||||
"\n"
|
||||
" public String getName() {\n"
|
||||
" return name;\n"
|
||||
" }\n"
|
||||
" protected void setName(String name) {\n"
|
||||
" this.name=name;\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:173
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Implementing <literal>equals()</literal> and <literal>hashCode()</literal>"
|
||||
msgstr ""
|
||||
"Implémenter <literal>equals()</literal> et <literal>hashCode()</literal>"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:175
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You have to override the <literal>equals()</literal> and <literal>hashCode()"
|
||||
"</literal> methods if you"
|
||||
msgstr ""
|
||||
"Vous devez surcharger les méthodes <literal>equals()</literal> et "
|
||||
"<literal>hashCode()</literal> si vous"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:181
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"intend to put instances of persistent classes in a <literal>Set</literal> "
|
||||
"(the recommended way to represent many-valued associations) <emphasis>and</"
|
||||
"emphasis>"
|
||||
msgstr ""
|
||||
"avez l'intention de mettre des instances de classes persistantes dans un "
|
||||
"<literal>Set</literal> (la manière recommandée pour représenter des "
|
||||
"associations pluri-valuées) <emphasis>et</emphasis>"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:188
|
||||
#, no-c-format
|
||||
msgid "intend to use reattachment of detached instances"
|
||||
msgstr "avez l'intention d'utiliser le réattachement d'instances détachées"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:194
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate guarantees equivalence of persistent identity (database row) and "
|
||||
"Java identity only inside a particular session scope. So as soon as we mix "
|
||||
"instances retrieved in different sessions, we must implement <literal>equals"
|
||||
"()</literal> and <literal>hashCode()</literal> if we wish to have meaningful "
|
||||
"semantics for <literal>Set</literal>s."
|
||||
msgstr ""
|
||||
"Hibernate garantit l'équivalence de l'identité persistante (ligne de base de "
|
||||
"données) et l'identité Java seulement à l'intérieur de la portée d'une "
|
||||
"session particulière. Donc dès que nous mélangeons des instances venant de "
|
||||
"différentes sessions, nous devons implémenter <literal>equals()</literal> et "
|
||||
"<literal>hashCode()</literal> si nous souhaitons avoir une sémantique "
|
||||
"correcte pour les <literal>Set</literal>s."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:202
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The most obvious way is to implement <literal>equals()</literal>/"
|
||||
"<literal>hashCode()</literal> by comparing the identifier value of both "
|
||||
"objects. If the value is the same, both must be the same database row, they "
|
||||
"are therefore equal (if both are added to a <literal>Set</literal>, we will "
|
||||
"only have one element in the <literal>Set</literal>). Unfortunately, we "
|
||||
"can't use that approach with generated identifiers! Hibernate will only "
|
||||
"assign identifier values to objects that are persistent, a newly created "
|
||||
"instance will not have any identifier value! Furthermore, if an instance is "
|
||||
"unsaved and currently in a <literal>Set</literal>, saving it will assign an "
|
||||
"identifier value to the object. If <literal>equals()</literal> and "
|
||||
"<literal>hashCode()</literal> are based on the identifier value, the hash "
|
||||
"code would change, breaking the contract of the <literal>Set</literal>. See "
|
||||
"the Hibernate website for a full discussion of this problem. Note that this "
|
||||
"is not a Hibernate issue, but normal Java semantics of object identity and "
|
||||
"equality."
|
||||
msgstr ""
|
||||
"La manière la plus évidente est d'implémenter <literal>equals()</literal>/"
|
||||
"<literal>hashCode()</literal> en comparant la valeur de l'identifiant des "
|
||||
"deux objets. Si cette valeur est identique, les deux doivent représenter la "
|
||||
"même ligne de base de données, ils sont donc égaux (si les deux sont ajoutés "
|
||||
"à un <literal>Set</literal>, nous n'aurons qu'un seul élément dans le "
|
||||
"<literal>Set</literal>). Malheureusement, nous ne pouvons pas utiliser cette "
|
||||
"approche avec des identifiants générés ! Hibernate n'assignera de valeur "
|
||||
"d'identifiant qu'aux objets qui sont persistants, une instance nouvellement "
|
||||
"créée n'aura donc pas de valeur d'identifiant ! De plus, si une instance est "
|
||||
"non sauvegardée et actuellement dans un <literal>Set</literal>, le "
|
||||
"sauvegarder assignera une valeur d'identifiant à l'objet. Si <literal>equals"
|
||||
"()</literal> et <literal>hashCode()</literal> sont basées sur la valeur de "
|
||||
"l'identifiant, le code de hachage devrait changer, rompant le contrat du "
|
||||
"<literal>Set</literal>. Regardez sur le site web d'Hibernate pour une "
|
||||
"discussion complète de ce problème. Notez que ceci n'est pas un problème "
|
||||
"d'Hibernate, mais la sémantique normale de Java pour l'identité d'un objet "
|
||||
"et l'égalité."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:216
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"We recommend implementing <literal>equals()</literal> and <literal>hashCode()"
|
||||
"</literal> using <emphasis>Business key equality</emphasis>. Business key "
|
||||
"equality means that the <literal>equals()</literal> method compares only the "
|
||||
"properties that form the business key, a key that would identify our "
|
||||
"instance in the real world (a <emphasis>natural</emphasis> candidate key):"
|
||||
msgstr ""
|
||||
"Nous recommandons donc d'implémenter <literal>equals()</literal> et "
|
||||
"<literal>hashCode()</literal> en utilisant <emphasis> l'égalité par clé "
|
||||
"métier</emphasis>.L'égalité par clé métier signifie que la méthode "
|
||||
"<literal>equals()</literal> compare uniquement les propriétés qui forment "
|
||||
"une clé métier, une clé qui identifierait notre instance dans le monde réel "
|
||||
"(une clé candidate <emphasis>naturelle</emphasis>) :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: persistent_classes.xml:224
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[public class Cat {\n"
|
||||
"\n"
|
||||
" ...\n"
|
||||
" public boolean equals(Object other) {\n"
|
||||
" if (this == other) return true;\n"
|
||||
" if ( !(other instanceof Cat) ) return false;\n"
|
||||
"\n"
|
||||
" final Cat cat = (Cat) other;\n"
|
||||
"\n"
|
||||
" if ( !cat.getLitterId().equals( getLitterId() ) ) return false;\n"
|
||||
" if ( !cat.getMother().equals( getMother() ) ) return false;\n"
|
||||
"\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" public int hashCode() {\n"
|
||||
" int result;\n"
|
||||
" result = getMother().hashCode();\n"
|
||||
" result = 29 * result + getLitterId();\n"
|
||||
" return result;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:226
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that a business key does not have to be as solid as a database primary "
|
||||
"key candidate (see <xref linkend=\"transactions-basics-identity\"/>). "
|
||||
"Immutable or unique properties are usually good candidates for a business "
|
||||
"key."
|
||||
msgstr ""
|
||||
"Notez qu'une clef métier ne doit pas être solide comme une clef primaire de "
|
||||
"base de données (voir <xref linkend=\"transactions-basics-identity\"/>). Les "
|
||||
"propriétés immuables ou uniques sont généralement de bonnes candidates pour "
|
||||
"une clef métier."
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:236
|
||||
#, no-c-format
|
||||
msgid "Dynamic models"
|
||||
msgstr "Modèles dynamiques"
|
||||
|
||||
#. Tag: emphasis
|
||||
#: persistent_classes.xml:239
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that the following features are currently considered experimental and "
|
||||
"may change in the near future."
|
||||
msgstr ""
|
||||
"Notez que la fonctionnalités suivantes sont actuellement considérées comme "
|
||||
"expérimentales et peuvent changer dans un futur proche."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:243
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Persistent entities don't necessarily have to be represented as POJO classes "
|
||||
"or as JavaBean objects at runtime. Hibernate also supports dynamic models "
|
||||
"(using <literal>Map</literal>s of <literal>Map</literal>s at runtime) and "
|
||||
"the representation of entities as DOM4J trees. With this approach, you don't "
|
||||
"write persistent classes, only mapping files."
|
||||
msgstr ""
|
||||
"Les entités persistantes ne doivent pas nécessairement être représentées "
|
||||
"comme des classes POJO ou des objets JavaBean à l'exécution. Hibernate "
|
||||
"supporte aussi les modèles dynamiques (en utilisant des <literal>Map</"
|
||||
"literal>s de <literal>Map</literal>s à l'exécution) et la représentation des "
|
||||
"entités comme des arbres DOM4J. Avec cette approche, vous n'écrivez pas de "
|
||||
"classes persistantes, seulement des fichiers de mapping."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:251
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"By default, Hibernate works in normal POJO mode. You may set a default "
|
||||
"entity representation mode for a particular <literal>SessionFactory</"
|
||||
"literal> using the <literal>default_entity_mode</literal> configuration "
|
||||
"option (see <xref linkend=\"configuration-optional-properties\"/>."
|
||||
msgstr ""
|
||||
"Par défaut, Hibernate fonctionne en mode POJO normal. Vous pouvez paramétrer "
|
||||
"un mode de représentation d'entité par défaut pour une "
|
||||
"<literal>SessionFactory</literal> particulière en utilisant l'option de "
|
||||
"configuration <literal>default_entity_mode</literal> (voir <xref linkend="
|
||||
"\"configuration-optional-properties\"/>)."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:258
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The following examples demonstrates the representation using <literal>Map</"
|
||||
"literal>s. First, in the mapping file, an <literal>entity-name</literal> has "
|
||||
"to be declared instead of (or in addition to) a class name:"
|
||||
msgstr ""
|
||||
"Les exemples suivants démontrent la représentation utilisant des "
|
||||
"<literal>Map</literal>s. D'abord, dans le fichier de mapping, un "
|
||||
"<literal>entity-name</literal> doit être déclaré au lieu (ou en plus) d'un "
|
||||
"nom de classe :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: persistent_classes.xml:264
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
"\n"
|
||||
" <class entity-name=\"Customer\">\n"
|
||||
"\n"
|
||||
" <id name=\"id\"\n"
|
||||
" type=\"long\"\n"
|
||||
" column=\"ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <property name=\"name\"\n"
|
||||
" column=\"NAME\"\n"
|
||||
" type=\"string\"/>\n"
|
||||
"\n"
|
||||
" <property name=\"address\"\n"
|
||||
" column=\"ADDRESS\"\n"
|
||||
" type=\"string\"/>\n"
|
||||
"\n"
|
||||
" <many-to-one name=\"organization\"\n"
|
||||
" column=\"ORGANIZATION_ID\"\n"
|
||||
" class=\"Organization\"/>\n"
|
||||
"\n"
|
||||
" <bag name=\"orders\"\n"
|
||||
" inverse=\"true\"\n"
|
||||
" lazy=\"false\"\n"
|
||||
" cascade=\"all\">\n"
|
||||
" <key column=\"CUSTOMER_ID\"/>\n"
|
||||
" <one-to-many class=\"Order\"/>\n"
|
||||
" </bag>\n"
|
||||
"\n"
|
||||
" </class>\n"
|
||||
" \n"
|
||||
"</hibernate-mapping>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:266
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that even though associations are declared using target class names, "
|
||||
"the target type of an associations may also be a dynamic entity instead of a "
|
||||
"POJO."
|
||||
msgstr ""
|
||||
"Notez que même si des associations sont déclarées en utilisant des noms de "
|
||||
"classe cible, le type de cible d'une association peut aussi être une entité "
|
||||
"dynamique au lieu d'un POJO."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:273
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"After setting the default entity mode to <literal>dynamic-map</literal> for "
|
||||
"the <literal>SessionFactory</literal>, we can at runtime work with "
|
||||
"<literal>Map</literal>s of <literal>Map</literal>s:"
|
||||
msgstr ""
|
||||
"Après avoir configuré le mode d'entité par défaut à <literal>dynamic-map</"
|
||||
"literal> pour la <literal>SessionFactory</literal>, nous pouvons lors de "
|
||||
"l'exécution fonctionner avec des <literal>Map</literal>s de <literal>Map</"
|
||||
"literal>s :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: persistent_classes.xml:279
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session s = openSession();\n"
|
||||
"Transaction tx = s.beginTransaction();\n"
|
||||
"Session s = openSession();\n"
|
||||
"\n"
|
||||
"// Create a customer\n"
|
||||
"Map david = new HashMap();\n"
|
||||
"david.put(\"name\", \"David\");\n"
|
||||
"\n"
|
||||
"// Create an organization\n"
|
||||
"Map foobar = new HashMap();\n"
|
||||
"foobar.put(\"name\", \"Foobar Inc.\");\n"
|
||||
"\n"
|
||||
"// Link both\n"
|
||||
"david.put(\"organization\", foobar);\n"
|
||||
"\n"
|
||||
"// Save both\n"
|
||||
"s.save(\"Customer\", david);\n"
|
||||
"s.save(\"Organization\", foobar);\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"s.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:281
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The advantages of a dynamic mapping are quick turnaround time for "
|
||||
"prototyping without the need for entity class implementation. However, you "
|
||||
"lose compile-time type checking and will very likely deal with many "
|
||||
"exceptions at runtime. Thanks to the Hibernate mapping, the database schema "
|
||||
"can easily be normalized and sound, allowing to add a proper domain model "
|
||||
"implementation on top later on."
|
||||
msgstr ""
|
||||
"Les avantages d'un mapping dynamique sont un gain de temps pour le "
|
||||
"prototypage sans la nécessité d'implémenter les classes d'entité. Pourtant, "
|
||||
"vous perdez la vérification du typage au moment de la compilation et aurez "
|
||||
"plus d'exceptions à gérer lors de l'exécution. Grâce au mapping d'Hibernate, "
|
||||
"le schéma de la base de données peut facilement être normalisé et solidifié, "
|
||||
"permettant de rajouter une implémentation propre du modèle de domaine plus "
|
||||
"tard."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:289
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Entity representation modes can also be set on a per <literal>Session</"
|
||||
"literal> basis:"
|
||||
msgstr ""
|
||||
"Les modes de représentation d'une entité peut aussi être configuré par "
|
||||
"<literal>Session</literal> :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: persistent_classes.xml:294
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);\n"
|
||||
"\n"
|
||||
"// Create a customer\n"
|
||||
"Map david = new HashMap();\n"
|
||||
"david.put(\"name\", \"David\");\n"
|
||||
"dynamicSession.save(\"Customer\", david);\n"
|
||||
"...\n"
|
||||
"dynamicSession.flush();\n"
|
||||
"dynamicSession.close()\n"
|
||||
"...\n"
|
||||
"// Continue on pojoSession\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:297
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Please note that the call to <literal>getSession()</literal> using an "
|
||||
"<literal>EntityMode</literal> is on the <literal>Session</literal> API, not "
|
||||
"the <literal>SessionFactory</literal>. That way, the new <literal>Session</"
|
||||
"literal> shares the underlying JDBC connection, transaction, and other "
|
||||
"context information. This means you don't have tocall <literal>flush()</"
|
||||
"literal> and <literal>close()</literal> on the secondary <literal>Session</"
|
||||
"literal>, and also leave the transaction and connection handling to the "
|
||||
"primary unit of work."
|
||||
msgstr ""
|
||||
"Veuillez noter que l'appel à <literal>getSession()</literal> en utilisant un "
|
||||
"<literal>EntityMode</literal> se fait sur l'API <literal>Session</literal>, "
|
||||
"pas <literal>SessionFactory</literal>. De cette manière, la nouvelle "
|
||||
"<literal>Session</literal> partage les connexions JDBC, transactions et "
|
||||
"autres informations de contexte sous-jacentes. Cela signifie que vous n'avez "
|
||||
"pas à appeler <literal>flush()</literal> et <literal>close()</literal> sur "
|
||||
"la <literal>Session</literal> secondaire, et laissez aussi la gestion de la "
|
||||
"transaction et de la connexion à l'unité de travail primaire."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:307
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"More information about the XML representation capabilities can be found in "
|
||||
"<xref linkend=\"xml\"/>."
|
||||
msgstr ""
|
||||
"Plus d'informations à propos de la représentation XML peuvent être trouvées "
|
||||
"dans <xref linkend=\"xml\"/>."
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:315
|
||||
#, no-c-format
|
||||
msgid "Tuplizers"
|
||||
msgstr "Tuplizers"
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:317
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal>org.hibernate.tuple.Tuplizer</literal>, and its sub-interfaces, are "
|
||||
"responsible for managing a particular representation of a piece of data, "
|
||||
"given that representation's <literal>org.hibernate.EntityMode</literal>. If "
|
||||
"a given piece of data is thought of as a data structure, then a tuplizer is "
|
||||
"the thing which knows how to create such a data structure and how to extract "
|
||||
"values from and inject values into such a data structure. For example, for "
|
||||
"the POJO entity mode, the correpsonding tuplizer knows how create the POJO "
|
||||
"through its constructor and how to access the POJO properties using the "
|
||||
"defined property accessors. There are two high-level types of Tuplizers, "
|
||||
"represented by the <literal>org.hibernate.tuple.entity.EntityTuplizer</"
|
||||
"literal> and <literal>org.hibernate.tuple.component.ComponentTuplizer</"
|
||||
"literal> interfaces. <literal>EntityTuplizer</literal>s are responsible for "
|
||||
"managing the above mentioned contracts in regards to entities, while "
|
||||
"<literal>ComponentTuplizer</literal>s do the same for components."
|
||||
msgstr ""
|
||||
"<literal>org.hibernate.tuple.Tuplizer</literal>, et ses sous-interfaces, "
|
||||
"sont responsables de la gestion d'une représentation particulière d'un "
|
||||
"morceau de données, en fonction du <literal>org.hibernate.EntityMode</"
|
||||
"literal> de réprésentation. Si un morceau donné de données est pensé comme "
|
||||
"une structure de données, alors un tuplizer est la chose qui sait comment "
|
||||
"créer une telle structure de données, comment extraire des valeurs et "
|
||||
"injecter des valeurs dans une telle structure de données. Par exemple, pour "
|
||||
"le mode d'entité POJO, le tuplizer correspondant sait comment créer le POJO "
|
||||
"à travers son constructeur et comment accéder aux propriétés du POJO "
|
||||
"utilisant les accesseurs de la propriété définie. Il y a deux types de "
|
||||
"Tuplizers haut niveau, représenté par les interfaces <literal>org.hibernate."
|
||||
"tuple.EntityTuplizer</literal> et <literal>org.hibernate.tuple."
|
||||
"ComponentTuplizer</literal>. Les <literal>EntityTuplizer</literal>s sont "
|
||||
"responsables de la gestion des contrats mentionnés ci-dessus pour les "
|
||||
"entités, alors que les <literal>ComponentTuplizer</literal>s s'occupent des "
|
||||
"composants."
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:332
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Users may also plug in their own tuplizers. Perhaps you require that a "
|
||||
"<literal>java.util.Map</literal> implementation other than <literal>java."
|
||||
"util.HashMap</literal> be used while in the dynamic-map entity-mode; or "
|
||||
"perhaps you need to define a different proxy generation strategy than the "
|
||||
"one used by default. Both would be achieved by defining a custom tuplizer "
|
||||
"implementation. Tuplizers definitions are attached to the entity or "
|
||||
"component mapping they are meant to manage. Going back to the example of our "
|
||||
"customer entity:"
|
||||
msgstr ""
|
||||
"Les utilisateurs peuvent aussi brancher leurs propres tuplizers. Peut-être "
|
||||
"vous est-il nécessaire qu'une implémentation de <literal>java.util.Map</"
|
||||
"literal> autre que <literal>java.util.HashMap</literal> soit utilisée dans "
|
||||
"le mode d'entité dynamic-map ; ou peut-être avez-vous besoin de définir une "
|
||||
"statégie de génération de proxy différente de celle utilisée par défaut. Les "
|
||||
"deux devraient être effectuées en définissant une implémentation de tuplizer "
|
||||
"utilisateur. Les définitions de tuplizers sont attachées au mapping de "
|
||||
"l'entité ou du composant qu'ils sont censés gérer. Retour à l'exemple de "
|
||||
"notre entité utilisateur :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: persistent_classes.xml:341
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<hibernate-mapping>\n"
|
||||
" <class entity-name=\"Customer\">\n"
|
||||
" <!--\n"
|
||||
" Override the dynamic-map entity-mode\n"
|
||||
" tuplizer for the customer entity\n"
|
||||
" -->\n"
|
||||
" <tuplizer entity-mode=\"dynamic-map\"\n"
|
||||
" class=\"CustomMapTuplizerImpl\"/>\n"
|
||||
"\n"
|
||||
" <id name=\"id\" type=\"long\" column=\"ID\">\n"
|
||||
" <generator class=\"sequence\"/>\n"
|
||||
" </id>\n"
|
||||
"\n"
|
||||
" <!-- other properties -->\n"
|
||||
" ...\n"
|
||||
" </class>\n"
|
||||
"</hibernate-mapping>\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"public class CustomMapTuplizerImpl\n"
|
||||
" extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {\n"
|
||||
" // override the buildInstantiator() method to plug in our custom map...\n"
|
||||
" protected final Instantiator buildInstantiator(\n"
|
||||
" org.hibernate.mapping.PersistentClass mappingInfo) {\n"
|
||||
" return new CustomMapInstantiator( mappingInfo );\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" private static final class CustomMapInstantiator\n"
|
||||
" extends org.hibernate.tuple.DynamicMapInstantitor {\n"
|
||||
" // override the generateMap() method to return our custom map...\n"
|
||||
" protected final Map generateMap() {\n"
|
||||
" return new CustomMap();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: persistent_classes.xml:347
|
||||
#, no-c-format
|
||||
msgid "Extentsions"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: persistent_classes.xml:348
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"TODO: Document user-extension framework in the property and proxy packages"
|
||||
msgstr ""
|
||||
"TODO: Document user-extension framework in the property and proxy packages"
|
|
@ -0,0 +1,206 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: preface.xml:29
|
||||
#, no-c-format
|
||||
msgid "Preface"
|
||||
msgstr "Préface"
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Travailler dans les deux univers que sont l'orienté objet et la base de "
|
||||
"données relationnelle peut être lourd et consommateur en temps dans le monde "
|
||||
"de l'entreprise d'aujourd'hui. Hibernate est un outil de mapping objet/"
|
||||
"relationnel pour le monde Java. Le terme mapping objet/relationnel (ORM) "
|
||||
"décrit la technique consistant à faire le lien entre la représentation objet "
|
||||
"des données et sa représentation relationnelle basée sur un schéma SQL."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:39
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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 and can significantly reduce development time "
|
||||
"otherwise spent with manual data handling in SQL and JDBC."
|
||||
msgstr ""
|
||||
"Non seulement, Hibernate s'occupe du transfert des classes Java dans les "
|
||||
"tables de la base de données (et des types de données Java dans les types de "
|
||||
"données SQL), mais il permet de requêter les données et propose des moyens "
|
||||
"de les récupérer. Il peut donc réduire de manière significative le temps de "
|
||||
"développement qui aurait été autrement perdu dans une manipulation manuelle "
|
||||
"des données via SQL et JDBC."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:46
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernates 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 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 encapsulate vendor-"
|
||||
"specific SQL code and will help with the common task of result set "
|
||||
"translation from a tabular representation to a graph of objects."
|
||||
msgstr ""
|
||||
"Le but d'Hibernate est de libérer le développeur de 95 pourcent des tâches "
|
||||
"de programmation liées à la persistance des données communes. Hibernate "
|
||||
"n'est probablement pas la meilleure solution pour les applications centrées "
|
||||
"sur les données qui n'utilisent que les procédures stockées pour implémenter "
|
||||
"la logique métier dans la base de données, il est le plus utile dans les "
|
||||
"modèles métier orientés objets dont la logique métier est implémentée dans "
|
||||
"la couche Java dite intermédiaire. Cependant, Hibernate vous aidera à "
|
||||
"supprimer ou à encapsuler le code SQL spécifique à votre base de données et "
|
||||
"vous aidera sur la tâche commune qu'est la transformation des données d'une "
|
||||
"représentation tabulaire à une représentation sous forme de graphe d'objets."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:56
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If you are new to Hibernate and Object/Relational Mapping or even Java, "
|
||||
"please follow these steps:"
|
||||
msgstr ""
|
||||
"Si vous êtes nouveau dans Hibernate et le mapping Objet/Relationnel voire "
|
||||
"même en Java, suivez ces quelques étapes :"
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:63
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Read <xref linkend=\"tutorial\"/> for a tutorial with step-by-step "
|
||||
"instructions. The source code for the tutorial is included in the "
|
||||
"distribution in the <literal>doc/reference/tutorial/</literal> directory."
|
||||
msgstr ""
|
||||
"Lisez <xref linkend=\"tutorial\"/> pour un didacticiel plus long avec plus "
|
||||
"d'instructions étape par étape."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:71
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Read <xref linkend=\"architecture\"/> to understand the environments where "
|
||||
"Hibernate can be used."
|
||||
msgstr ""
|
||||
"Lisez <xref linkend=\"architecture\"/> pour comprendre les environnements "
|
||||
"dans lesquels Hibernate peut être utilisé."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:77
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Have a look at the <literal>eg/</literal> directory in the Hibernate "
|
||||
"distribution, it contains a simple standalone application. Copy your JDBC "
|
||||
"driver to the <literal>lib/</literal> directory and edit <literal>etc/"
|
||||
"hibernate.properties</literal>, specifying correct values for your database. "
|
||||
"From a command prompt in the distribution directory, type <literal>ant eg</"
|
||||
"literal> (using Ant), or under Windows, type <literal>build eg</literal>."
|
||||
msgstr ""
|
||||
"Regardez le répertoire <literal>eg</literal> de la distribution Hibernate, "
|
||||
"il contient une application simple et autonome. Copiez votre pilote JDBC "
|
||||
"dans le répertoire <literal>lib/</literal> et éditez <literal>src/hibernate."
|
||||
"properties</literal>, en positionnant correctement les valeurs pour votre "
|
||||
"base de données. A partir d'une invite de commande dans le répertoire de la "
|
||||
"distribution, tapez <literal>ant eg</literal> (cela utilise Ant), ou sous "
|
||||
"Windows tapez <literal>build eg</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:88
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Use this reference documentation as your primary source of information. "
|
||||
"Consider reading <emphasis>Java Persistence with Hibernate</emphasis> "
|
||||
"(http://www.manning.com/bauer2) if you need more help with application "
|
||||
"design or if you prefer a step-by-step tutorial. Also visit http://"
|
||||
"caveatemptor.hibernate.org and download the example application for Java "
|
||||
"Persistence with Hibernate."
|
||||
msgstr ""
|
||||
"Faîtes de cette documentation de référence votre principale source "
|
||||
"d'information. Pensez à lire <emphasis>Java Persistence with Hibernate</"
|
||||
"emphasis> (http://www.manning.com/bauer2) si vous avez besoin de plus d'aide "
|
||||
"avec le design d'applications ou si vous préférez un tutoriel pas à pas. "
|
||||
"Visitez aussi http://caveatemptor.hibernate.org et téléchargez l'application "
|
||||
"exemple pour Java Persistence with Hibernate."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:98
|
||||
#, no-c-format
|
||||
msgid "FAQs are answered on the Hibernate website."
|
||||
msgstr ""
|
||||
"Les questions les plus fréquemment posées (FAQs) trouvent leur réponse sur "
|
||||
"le site web Hibernate."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:103
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Third party demos, examples, and tutorials are linked on the Hibernate "
|
||||
"website."
|
||||
msgstr ""
|
||||
"Des démos, exemples et tutoriaux de tierces personnes sont référencés sur le "
|
||||
"site web Hibernate."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:109
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The Community Area on the Hibernate website is a good resource for design "
|
||||
"patterns and various integration solutions (Tomcat, JBoss AS, Struts, EJB, "
|
||||
"etc.)."
|
||||
msgstr ""
|
||||
"La zone communautaire (Community Area) du site web Hibernate est une bonne "
|
||||
"source d'information sur les design patterns et sur différentes solutions "
|
||||
"d'intégration d'Hibernate (Tomcat, JBoss, Spring Framework, Struts, EJB, "
|
||||
"etc)."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:117
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If you have questions, use the user forum linked on the Hibernate website. "
|
||||
"We also provide a JIRA issue trackings 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."
|
||||
msgstr ""
|
||||
"Si vous avez des questions, utilisez le forum utilisateurs du site web "
|
||||
"Hibernate. Nous utilisons également l'outil de gestion des incidents JIRA "
|
||||
"pour tout ce qui est rapports de bogue et demandes d'évolution. Si vous êtes "
|
||||
"intéressé par le développement d'Hibernate, joignez-vous à la liste de "
|
||||
"diffusion de développement."
|
||||
|
||||
#. Tag: para
|
||||
#: preface.xml:125
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Le développement commercial, le support de production et les formations à "
|
||||
"Hibernate sont proposés par JBoss Inc (voir http://www.hibernate.org/"
|
||||
"SupportTraining/). Hibernate est un projet Open Source professionnel et un "
|
||||
"composant critique de la suite de produits JBoss Enterprise Middleware "
|
||||
"System (JEMS)."
|
|
@ -0,0 +1,785 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:29
|
||||
#, no-c-format
|
||||
msgid "Criteria Queries"
|
||||
msgstr "Requêtes par critères"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:31
|
||||
#, no-c-format
|
||||
msgid "Hibernate features an intuitive, extensible criteria query API."
|
||||
msgstr ""
|
||||
"Hibernate offre une API d'interrogation par critères intuitive et extensible."
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:36
|
||||
#, no-c-format
|
||||
msgid "Creating a <literal>Criteria</literal> instance"
|
||||
msgstr "Créer une instance de <literal>Criteria</literal>"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:38
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The interface <literal>org.hibernate.Criteria</literal> represents a query "
|
||||
"against a particular persistent class. The <literal>Session</literal> is a "
|
||||
"factory for <literal>Criteria</literal> instances."
|
||||
msgstr ""
|
||||
"L'interface <literal>net.sf.hibernate.Criteria</literal> représente une "
|
||||
"requête sur une classe persistente donnée. La <literal>Session</literal> "
|
||||
"fournit les instances de <literal>Criteria</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:44
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Criteria crit = sess.createCriteria(Cat.class);\n"
|
||||
"crit.setMaxResults(50);\n"
|
||||
"List cats = crit.list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:49
|
||||
#, no-c-format
|
||||
msgid "Narrowing the result set"
|
||||
msgstr "Restriction du résultat"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:51
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"An individual query criterion is an instance of the interface <literal>org."
|
||||
"hibernate.criterion.Criterion</literal>. The class <literal>org.hibernate."
|
||||
"criterion.Restrictions</literal> defines factory methods for obtaining "
|
||||
"certain built-in <literal>Criterion</literal> types."
|
||||
msgstr ""
|
||||
"Un criterion (critère de recherche) est une instance de l'interface "
|
||||
"<literal>org.hibernate.criterion.Criterion</literal>. La classe <literal>org."
|
||||
"hibernate.criterion.Restrictions</literal> définit des méthodes pour obtenir "
|
||||
"des types de <literal>Criterion</literal> pré-définis."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:59
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .add( Restrictions.between(\"weight\", minWeight, maxWeight) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:61
|
||||
#, no-c-format
|
||||
msgid "Restrictions may be grouped logically."
|
||||
msgstr "Les restrictions peuvent être goupées de manière logique."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:65
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .add( Restrictions.or(\n"
|
||||
" Restrictions.eq( \"age\", new Integer(0) ),\n"
|
||||
" Restrictions.isNull(\"age\")\n"
|
||||
" ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:67
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.in( \"name\", new String[] { \"Fritz\", \"Izi\", \"Pk"
|
||||
"\" } ) )\n"
|
||||
" .add( Restrictions.disjunction()\n"
|
||||
" .add( Restrictions.isNull(\"age\") )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(0) ) )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(1) ) )\n"
|
||||
" .add( Restrictions.eq(\"age\", new Integer(2) ) )\n"
|
||||
" ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:69
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There are quite a range of built-in criterion types (<literal>Restrictions</"
|
||||
"literal> subclasses), but one that is especially useful lets you specify SQL "
|
||||
"directly."
|
||||
msgstr ""
|
||||
"Il y a plusieurs types de criterion pré-définis (sous classes de "
|
||||
"<literal>Restriction</literal>), mais l'une d'entre elle particulièrement "
|
||||
"utile vous permet de spécifier directement du SQL."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:74
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.sqlRestriction(\"lower({alias}.name) like lower(?)\", "
|
||||
"\"Fritz%\", Hibernate.STRING) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:76
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal>{alias}</literal> placeholder with be replaced by the row alias "
|
||||
"of the queried entity."
|
||||
msgstr ""
|
||||
"La zone <literal>{alias}</literal> sera remplacée par l'alias de colonne de "
|
||||
"l'entité que l'on souhaite intérroger."
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:81
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"An alternative approach to obtaining a criterion is to get it from a "
|
||||
"<literal>Property</literal> instance. You can create a <literal>Property</"
|
||||
"literal> by calling <literal>Property.forName()</literal>."
|
||||
msgstr ""
|
||||
"Une autre approche pour obtenir un criterion est de le récupérer d'une "
|
||||
"instance de <literal>Property</literal>. Vous pouvez créer une "
|
||||
"<literal>Property</literal> en appelant <literal>Property.forName()</"
|
||||
"literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:87
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"Property age = Property.forName(\"age\");\n"
|
||||
"List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.disjunction()\n"
|
||||
" .add( age.isNull() )\n"
|
||||
" .add( age.eq( new Integer(0) ) )\n"
|
||||
" .add( age.eq( new Integer(1) ) )\n"
|
||||
" .add( age.eq( new Integer(2) ) )\n"
|
||||
" ) )\n"
|
||||
" .add( Property.forName(\"name\").in( new String[] { \"Fritz\", \"Izi\", "
|
||||
"\"Pk\" } ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:92
|
||||
#, no-c-format
|
||||
msgid "Ordering the results"
|
||||
msgstr "Trier les résultats"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:94
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You may order the results using <literal>org.hibernate.criterion.Order</"
|
||||
"literal>."
|
||||
msgstr ""
|
||||
"Vous pouvez trier les résultats en utilisant <literal>org.hibernate."
|
||||
"criterion.Order</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:98
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\")\n"
|
||||
" .addOrder( Order.asc(\"name\") )\n"
|
||||
" .addOrder( Order.desc(\"age\") )\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:100
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Property.forName(\"name\").like(\"F%\") )\n"
|
||||
" .addOrder( Property.forName(\"name\").asc() )\n"
|
||||
" .addOrder( Property.forName(\"age\").desc() )\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:105
|
||||
#, no-c-format
|
||||
msgid "Associations"
|
||||
msgstr "Associations"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:107
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You may easily specify constraints upon related entities by navigating "
|
||||
"associations using <literal>createCriteria()</literal>."
|
||||
msgstr ""
|
||||
"Vous pouvez facilement spécifier des contraintes sur des entités liées, par "
|
||||
"des associations en utilisant <literal>createCriteria()</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:112
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\") )\n"
|
||||
" .createCriteria(\"kittens\")\n"
|
||||
" .add( Restrictions.like(\"name\", \"F%\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:114
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"note that the second <literal>createCriteria()</literal> returns a new "
|
||||
"instance of <literal>Criteria</literal>, which refers to the elements of the "
|
||||
"<literal>kittens</literal> collection."
|
||||
msgstr ""
|
||||
"Notez que la seconde <literal>createCriteria()</literal> retourne une "
|
||||
"nouvelle instance de <literal>Criteria</literal>, qui se rapporte aux "
|
||||
"éléments de la collection <literal>kittens</literal>."
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:120
|
||||
#, no-c-format
|
||||
msgid "The following, alternate form is useful in certain circumstances."
|
||||
msgstr "La forme alternative suivante est utile dans certains cas."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:124
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .createAlias(\"kittens\", \"kt\")\n"
|
||||
" .createAlias(\"mate\", \"mt\")\n"
|
||||
" .add( Restrictions.eqProperty(\"kt.name\", \"mt.name\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:126
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"(<literal>createAlias()</literal> does not create a new instance of "
|
||||
"<literal>Criteria</literal>.)"
|
||||
msgstr ""
|
||||
"(<literal>createAlias()</literal> ne crée pas de nouvelle instance de "
|
||||
"<literal>Criteria</literal>.)"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:131
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that the kittens collections held by the <literal>Cat</literal> "
|
||||
"instances returned by the previous two queries are <emphasis>not</emphasis> "
|
||||
"pre-filtered by the criteria! If you wish to retrieve just the kittens that "
|
||||
"match the criteria, you must use a <literal>ResultTransformer</literal>."
|
||||
msgstr ""
|
||||
"Notez que les collections kittens contenues dans les instances de "
|
||||
"<literal>Cat</literal> retournées par les deux précédentes requêtes ne sont "
|
||||
"<emphasis>pas</emphasis> pré-filtrées par les critères ! Si vous souhaitez "
|
||||
"récupérer uniquement les kittens qui correspondent à la criteria, vous devez "
|
||||
"utiliser <literal>ResultTransformer</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:138
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .createCriteria(\"kittens\", \"kt\")\n"
|
||||
" .add( Restrictions.eq(\"name\", \"F%\") )\n"
|
||||
" .setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)\n"
|
||||
" .list();\n"
|
||||
"Iterator iter = cats.iterator();\n"
|
||||
"while ( iter.hasNext() ) {\n"
|
||||
" Map map = (Map) iter.next();\n"
|
||||
" Cat cat = (Cat) map.get(Criteria.ROOT_ALIAS);\n"
|
||||
" Cat kitten = (Cat) map.get(\"kt\");\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:143
|
||||
#, no-c-format
|
||||
msgid "Dynamic association fetching"
|
||||
msgstr "Peuplement d'associations de manière dynamique"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:145
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You may specify association fetching semantics at runtime using "
|
||||
"<literal>setFetchMode()</literal>."
|
||||
msgstr ""
|
||||
"Vous pouvez spéficier au moment de l'exécution le peuplement d'une "
|
||||
"association en utilisant <literal>setFetchMode()</literal> (c'est-à-dire le "
|
||||
"chargement de celle-ci). Cela permet de surcharger les valeurs \"lazy\" et "
|
||||
"\"outer-join\" du mapping."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:150
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
|
||||
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
|
||||
" .setFetchMode(\"mate\", FetchMode.EAGER)\n"
|
||||
" .setFetchMode(\"kittens\", FetchMode.EAGER)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:152
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This query will fetch both <literal>mate</literal> and <literal>kittens</"
|
||||
"literal> by outer join. See <xref linkend=\"performance-fetching\"/> for "
|
||||
"more information."
|
||||
msgstr ""
|
||||
"Cette requête recherchera <literal>mate</literal> et <literal>kittens</"
|
||||
"literal> via les jointures externes. Voir <xref linkend=\"performance-"
|
||||
"fetching\"/> pour plus d'informations."
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:160
|
||||
#, no-c-format
|
||||
msgid "Example queries"
|
||||
msgstr "Requêtes par l'exemple"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:162
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The class <literal>org.hibernate.criterion.Example</literal> allows you to "
|
||||
"construct a query criterion from a given instance."
|
||||
msgstr ""
|
||||
"La classe <literal>org.hibernate.criterion.Example</literal> vous permet de "
|
||||
"construire un critère suivant une instance d'objet donnée."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:167
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Cat cat = new Cat();\n"
|
||||
"cat.setSex('F');\n"
|
||||
"cat.setColor(Color.BLACK);\n"
|
||||
"List results = session.createCriteria(Cat.class)\n"
|
||||
" .add( Example.create(cat) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:169
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Version properties, identifiers and associations are ignored. By default, "
|
||||
"null valued properties are excluded."
|
||||
msgstr ""
|
||||
"Les propriétés de type version, identifiant et association sont ignorées. "
|
||||
"Par défaut, les valeurs null sont exclues."
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:174
|
||||
#, no-c-format
|
||||
msgid "You can adjust how the <literal>Example</literal> is applied."
|
||||
msgstr ""
|
||||
"Vous pouvez ajuster la stratégie d'utilisation de valeurs de "
|
||||
"l'<literal>Exemple</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:178
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Example example = Example.create(cat)\n"
|
||||
" .excludeZeroes() //exclude zero valued properties\n"
|
||||
" .excludeProperty(\"color\") //exclude the property named \"color\"\n"
|
||||
" .ignoreCase() //perform case insensitive string "
|
||||
"comparisons\n"
|
||||
" .enableLike(); //use like for string comparisons\n"
|
||||
"List results = session.createCriteria(Cat.class)\n"
|
||||
" .add(example)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:180
|
||||
#, no-c-format
|
||||
msgid "You can even use examples to place criteria upon associated objects."
|
||||
msgstr ""
|
||||
"Vous pouvez utiliser les \"exemples\" pour des critères sur les objets "
|
||||
"associés."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:184
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .add( Example.create(cat) )\n"
|
||||
" .createCriteria(\"mate\")\n"
|
||||
" .add( Example.create( cat.getMate() ) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:189
|
||||
#, no-c-format
|
||||
msgid "Projections, aggregation and grouping"
|
||||
msgstr "Projections, agrégation et regroupement"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:190
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The class <literal>org.hibernate.criterion.Projections</literal> is a "
|
||||
"factory for <literal>Projection</literal> instances. We apply a projection "
|
||||
"to a query by calling <literal>setProjection()</literal>."
|
||||
msgstr ""
|
||||
"La classe <literal>org.hibernate.criterion.Projections</literal> est une "
|
||||
"fabrique d'instances de <literal>Projection</literal>. Nous appliquons une "
|
||||
"projection sur une requête en appelant <literal>setProjection()</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:196
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.rowCount() )\n"
|
||||
" .add( Restrictions.eq(\"color\", Color.BLACK) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:198
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount() )\n"
|
||||
" .add( Projections.avg(\"weight\") )\n"
|
||||
" .add( Projections.max(\"weight\") )\n"
|
||||
" .add( Projections.groupProperty(\"color\") )\n"
|
||||
" )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:200
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"There is no explicit \"group by\" necessary in a criteria query. Certain "
|
||||
"projection types are defined to be <emphasis>grouping projections</"
|
||||
"emphasis>, which also appear in the SQL <literal>group by</literal> clause."
|
||||
msgstr ""
|
||||
"Il n'y a pas besoin de \"group by\" explicite dans une requête par critère. "
|
||||
"Certains types de projection sont définis pour être des "
|
||||
"<emphasis>projections de regroupement</emphasis>, lesquels apparaissent "
|
||||
"aussi dans la clause <literal>group by</literal> SQL."
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:206
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"An alias may optionally be assigned to a projection, so that the projected "
|
||||
"value may be referred to in restrictions or orderings. Here are two "
|
||||
"different ways to do this:"
|
||||
msgstr ""
|
||||
"Un alias peut optionnellement être assigné à une projection, ainsi la valeur "
|
||||
"projetée peut être référencée dans des restrictions ou des tris. Voici deux "
|
||||
"façons différentes de faire ça :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:212
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.alias( Projections.groupProperty(\"color\"), "
|
||||
"\"colr\" ) )\n"
|
||||
" .addOrder( Order.asc(\"colr\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:214
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.groupProperty(\"color\").as(\"colr\") )\n"
|
||||
" .addOrder( Order.asc(\"colr\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:216
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal>alias()</literal> and <literal>as()</literal> methods simply "
|
||||
"wrap a projection instance in another, aliased, instance of "
|
||||
"<literal>Projection</literal>. As a shortcut, you can assign an alias when "
|
||||
"you add the projection to a projection list:"
|
||||
msgstr ""
|
||||
"Les méthodes <literal>alias()</literal> et <literal>as()</literal> enveloppe "
|
||||
"simplement une instance de projection dans une autre instance (aliasée) de "
|
||||
"<literal>Projection</literal>. Comme un raccourci, vous pouvez assignez un "
|
||||
"alias lorsque vous ajoutez la projection à la liste de projections :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:223
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount(), \"catCountByColor\" )\n"
|
||||
" .add( Projections.avg(\"weight\"), \"avgWeight\" )\n"
|
||||
" .add( Projections.max(\"weight\"), \"maxWeight\" )\n"
|
||||
" .add( Projections.groupProperty(\"color\"), \"color\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.desc(\"catCountByColor\") )\n"
|
||||
" .addOrder( Order.desc(\"avgWeight\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:225
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Domestic.class, \"cat\")\n"
|
||||
" .createAlias(\"kittens\", \"kit\")\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.property(\"cat.name\"), \"catName\" )\n"
|
||||
" .add( Projections.property(\"kit.name\"), \"kitName\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.asc(\"catName\") )\n"
|
||||
" .addOrder( Order.asc(\"kitName\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:227
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You can also use <literal>Property.forName()</literal> to express "
|
||||
"projections:"
|
||||
msgstr ""
|
||||
"Vous pouvez aussi utiliser <literal>Property.forName()</literal> pour "
|
||||
"formuler des projections :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:231
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"name\") )\n"
|
||||
" .add( Property.forName(\"color\").eq(Color.BLACK) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:233
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[List results = session.createCriteria(Cat.class)\n"
|
||||
" .setProjection( Projections.projectionList()\n"
|
||||
" .add( Projections.rowCount().as(\"catCountByColor\") )\n"
|
||||
" .add( Property.forName(\"weight\").avg().as(\"avgWeight\") )\n"
|
||||
" .add( Property.forName(\"weight\").max().as(\"maxWeight\") )\n"
|
||||
" .add( Property.forName(\"color\").group().as(\"color\" )\n"
|
||||
" )\n"
|
||||
" .addOrder( Order.desc(\"catCountByColor\") )\n"
|
||||
" .addOrder( Order.desc(\"avgWeight\") )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:238
|
||||
#, no-c-format
|
||||
msgid "Detached queries and subqueries"
|
||||
msgstr "Requêtes et sous-requêtes détachées"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:239
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"The <literal>DetachedCriteria</literal> class lets you create a query "
|
||||
"outside the scope of a session, and then later execute it using some "
|
||||
"arbitrary <literal>Session</literal>."
|
||||
msgstr ""
|
||||
"La classe <literal>DetachedCriteria</literal> vous laisse créer une requête "
|
||||
"en dehors de la portée de la session, et puis l'exécuter plus tard en "
|
||||
"utilisant n'importe quelle <literal>Session</literal> arbitraire."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:244
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .add( Property.forName(\"sex\").eq('F') );\n"
|
||||
" \n"
|
||||
"Session session = ....;\n"
|
||||
"Transaction txn = session.beginTransaction();\n"
|
||||
"List results = query.getExecutableCriteria(session).setMaxResults(100).list"
|
||||
"();\n"
|
||||
"txn.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:246
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A <literal>DetachedCriteria</literal> may also be used to express a "
|
||||
"subquery. Criterion instances involving subqueries may be obtained via "
|
||||
"<literal>Subqueries</literal> or <literal>Property</literal>."
|
||||
msgstr ""
|
||||
"Une <literal>DetachedCriteria</literal> peut aussi être utilisée pour "
|
||||
"exprimer une sous-requête. Des instances de criterion impliquant des sous-"
|
||||
"requêtes peuvent être obtenues via <literal>Subqueries</literal> ou "
|
||||
"<literal>Property</literal>."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:252
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"weight\").avg() );\n"
|
||||
"session.createCriteria(Cat.class)\n"
|
||||
" .add( Property.forName(\"weight\").gt(avgWeight) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:254
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)\n"
|
||||
" .setProjection( Property.forName(\"weight\") );\n"
|
||||
"session.createCriteria(Cat.class)\n"
|
||||
" .add( Subqueries.geAll(\"weight\", weights) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:256
|
||||
#, no-c-format
|
||||
msgid "Even correlated subqueries are possible:"
|
||||
msgstr "Même des requêtes corrélées sont possibles :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:260
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat."
|
||||
"class, \"cat2\")\n"
|
||||
" .setProjection( Property.forName(\"weight\").avg() )\n"
|
||||
" .add( Property.forName(\"cat2.sex\").eqProperty(\"cat.sex\") );\n"
|
||||
"session.createCriteria(Cat.class, \"cat\")\n"
|
||||
" .add( Property.forName(\"weight\").gt(avgWeightForSex) )\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: query_criteria.xml:269
|
||||
#, no-c-format
|
||||
msgid "Queries by natural identifier"
|
||||
msgstr "Requêtes par identifiant naturel"
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:271
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"For most queries, including criteria queries, the query cache is not very "
|
||||
"efficient, because query cache invalidation occurs too frequently. However, "
|
||||
"there is one special kind of query where we can optimize the cache "
|
||||
"invalidation algorithm: lookups by a constant natural key. In some "
|
||||
"applications, this kind of query occurs frequently. The criteria API "
|
||||
"provides special provision for this use case."
|
||||
msgstr ""
|
||||
"Pour la plupart des requêtes, incluant les requêtes par critère, le cache de "
|
||||
"requêtes n'est pas très efficace, parce que l'invalidation du cache de "
|
||||
"requêtes arrive trop souvent. Cependant, il y a une sorte spéciale de "
|
||||
"requête où nous pouvons optimiser l'algorithme d'invalidation du cache : les "
|
||||
"recherches sur une clef naturelle constante. Dans certaines applications, "
|
||||
"cette sorte de requête se produit fréquemment. L'API de critère fournit une "
|
||||
"provision spéciale pour ce cas d'utilisation."
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:279
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"First, you should map the natural key of your entity using <literal><"
|
||||
"natural-id></literal>, and enable use of the second-level cache."
|
||||
msgstr ""
|
||||
"D'abord vous devriez mapper la clef naturelle de votre entité en utilisant "
|
||||
"<literal><natural-id></literal>, et activer l'utilisation du cache de "
|
||||
"second niveau."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:284
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"User\">\n"
|
||||
" <cache usage=\"read-write\"/>\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <natural-id>\n"
|
||||
" <property name=\"name\"/>\n"
|
||||
" <property name=\"org\"/>\n"
|
||||
" </natural-id>\n"
|
||||
" <property name=\"password\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:286
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that this functionality is not intended for use with entities with "
|
||||
"<emphasis>mutable</emphasis> natural keys."
|
||||
msgstr ""
|
||||
"Notez que cette fonctionnalité n'est pas prévue pour l'utilisation avec des "
|
||||
"entités avec des clefs naturelles <emphasis>mutables</emphasis>."
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:291
|
||||
#, no-c-format
|
||||
msgid "Next, enable the Hibernate query cache."
|
||||
msgstr "Ensuite, activez le cache de requête d'Hibernate."
|
||||
|
||||
#. Tag: para
|
||||
#: query_criteria.xml:295
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Now, <literal>Restrictions.naturalId()</literal> allows us to make use of "
|
||||
"the more efficient cache algorithm."
|
||||
msgstr ""
|
||||
"Maintenant <literal>Restrictions.naturalId()</literal> nous permet de rendre "
|
||||
"l'utilisation de l'algorithme de cache plus efficace."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: query_criteria.xml:300
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[session.createCriteria(User.class)\n"
|
||||
" .add( Restrictions.naturalId()\n"
|
||||
" .set(\"name\", \"gavin\")\n"
|
||||
" .set(\"org\", \"hb\") \n"
|
||||
" ).setCacheable(true)\n"
|
||||
" .uniqueResult();]]>"
|
||||
msgstr ""
|
|
@ -0,0 +1,12 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,451 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
|
||||
"POT-Creation-Date: 2008-08-14 15:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Tag: title
|
||||
#: xml.xml:29
|
||||
#, no-c-format
|
||||
msgid "XML Mapping"
|
||||
msgstr "Mapping XML"
|
||||
|
||||
#. Tag: emphasis
|
||||
#: xml.xml:31
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Note that this is an experimental feature in Hibernate 3.0 and is under "
|
||||
"extremely active development."
|
||||
msgstr ""
|
||||
"Notez que cette fonctionnalité est expérimentale dans Hibernate 3.0 et est "
|
||||
"en développement extrêmement actif."
|
||||
|
||||
#. Tag: title
|
||||
#: xml.xml:37
|
||||
#, no-c-format
|
||||
msgid "Working with XML data"
|
||||
msgstr "Travailler avec des données XML"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:39
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate lets you work with persistent XML data in much the same way you "
|
||||
"work with persistent POJOs. A parsed XML tree can be thought of as just "
|
||||
"another way to represent the relational data at the object level, instead of "
|
||||
"POJOs."
|
||||
msgstr ""
|
||||
"Hibernate vous laisse travailler avec des données XML persistantes de la "
|
||||
"même manière que vous travaillez avec des POJOs persistants. Un arbre XML "
|
||||
"peut être vu comme une autre manière de représenter les données "
|
||||
"relationnelles au niveau objet, à la place des POJOs."
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:46
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Hibernate supports dom4j as API for manipulating XML trees. You can write "
|
||||
"queries that retrieve dom4j trees from the database and have any "
|
||||
"modification you make to the tree automatically synchronized to the "
|
||||
"database. You can even take an XML document, parse it using dom4j, and write "
|
||||
"it to the database with any of Hibernate's basic operations: <literal>persist"
|
||||
"(), saveOrUpdate(), merge(), delete(), replicate()</literal> (merging is not "
|
||||
"yet supported)."
|
||||
msgstr ""
|
||||
"Hibernate supporte dom4j en tant qu'API pour la manipulation des arbres XML. "
|
||||
"Vous pouvez écrire des requêtes qui récupèrent des arbres dom4j à partie de "
|
||||
"la base de données, et avoir toutes les modifications que vous faites sur "
|
||||
"l'arbre automatiquement synchronisées dans la base de données. Vous pouvez "
|
||||
"même prendre un document XML, l'analyser en utilisant dom4j, et l'écrire "
|
||||
"dans la base de données via les opérations basiques d'Hibernate : "
|
||||
"<literal>persist(), saveOrUpdate(), merge(), delete(), replicate()</literal> "
|
||||
"(merge() n'est pas encore supporté)."
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:56
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This feature has many applications including data import/export, "
|
||||
"externalization of entity data via JMS or SOAP and XSLT-based reporting."
|
||||
msgstr ""
|
||||
"Cette fonctionnalité a plusieurs applications dont l'import/export de "
|
||||
"données, l'externalisation d'entités via JMS ou SOAP et les rapports XSLT."
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:61
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"A single mapping may be used to simultaneously map properties of a class and "
|
||||
"nodes of an XML document to the database, or, if there is no class to map, "
|
||||
"it may be used to map just the XML."
|
||||
msgstr ""
|
||||
"Un simple mapping peut être utilisé pour simultanément mapper les propriétés "
|
||||
"d'une classe et les noeuds d'un document XML vers la base de données, ou, si "
|
||||
"il n'y a pas de classe à mapper, il peut être utilisé juste pour mapper le "
|
||||
"XML."
|
||||
|
||||
#. Tag: title
|
||||
#: xml.xml:68
|
||||
#, no-c-format
|
||||
msgid "Specifying XML and class mapping together"
|
||||
msgstr "Spécifier le mapping XML et le mapping d'une classe ensemble"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:70
|
||||
#, no-c-format
|
||||
msgid "Here is an example of mapping a POJO and XML simultaneously:"
|
||||
msgstr "Voici un exemple de mapping d'un POJO et du XML simultanément :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:74
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Account\" \n"
|
||||
" table=\"ACCOUNTS\" \n"
|
||||
" node=\"account\">\n"
|
||||
" \n"
|
||||
" <id name=\"accountId\" \n"
|
||||
" column=\"ACCOUNT_ID\" \n"
|
||||
" node=\"@id\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"customer\" \n"
|
||||
" column=\"CUSTOMER_ID\" \n"
|
||||
" node=\"customer/@id\" \n"
|
||||
" embed-xml=\"false\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"balance\" \n"
|
||||
" column=\"BALANCE\" \n"
|
||||
" node=\"balance\"/>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: xml.xml:78
|
||||
#, no-c-format
|
||||
msgid "Specifying only an XML mapping"
|
||||
msgstr "Spécifier seulement un mapping XML"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:80
|
||||
#, no-c-format
|
||||
msgid "Here is an example where there is no POJO class:"
|
||||
msgstr "Voici un exemple dans lequel il n'y a pas de class POJO :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:84
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class entity-name=\"Account\" \n"
|
||||
" table=\"ACCOUNTS\" \n"
|
||||
" node=\"account\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\" \n"
|
||||
" column=\"ACCOUNT_ID\" \n"
|
||||
" node=\"@id\" \n"
|
||||
" type=\"string\"/>\n"
|
||||
" \n"
|
||||
" <many-to-one name=\"customerId\" \n"
|
||||
" column=\"CUSTOMER_ID\" \n"
|
||||
" node=\"customer/@id\" \n"
|
||||
" embed-xml=\"false\" \n"
|
||||
" entity-name=\"Customer\"/>\n"
|
||||
" \n"
|
||||
" <property name=\"balance\" \n"
|
||||
" column=\"BALANCE\" \n"
|
||||
" node=\"balance\" \n"
|
||||
" type=\"big_decimal\"/>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:86
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"This mapping allows you to access the data as a dom4j tree, or as a graph of "
|
||||
"property name/value pairs (java <literal>Map</literal>s). The property names "
|
||||
"are purely logical constructs that may be referred to in HQL queries."
|
||||
msgstr ""
|
||||
"Ce mapping vous permet d'accéder aux données comme un arbre dom4j, ou comme "
|
||||
"un graphe de paire nom de propriété/valeur (<literal>Map</literal>s java). "
|
||||
"Les noms des propriétés sont des constructions purement logiques qui peuvent "
|
||||
"être référées des dans requêtes HQL."
|
||||
|
||||
#. Tag: title
|
||||
#: xml.xml:97
|
||||
#, no-c-format
|
||||
msgid "XML mapping metadata"
|
||||
msgstr "Métadonnées du mapping XML"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:99
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Many Hibernate mapping elements accept the <literal>node</literal> "
|
||||
"attribute. This let's you specify the name of an XML attribute or element "
|
||||
"that holds the property or entity data. The format of the <literal>node</"
|
||||
"literal> attribute must be one of the following:"
|
||||
msgstr ""
|
||||
"Plusieurs éléments du mapping Hibernate acceptent l'attribut <literal>node</"
|
||||
"literal>. Ceci vous permet de spécifier le nom d'un attribut XML ou d'un "
|
||||
"élément qui contient la propriété ou les données de l'entité. Le format de "
|
||||
"l'attribut <literal>node</literal> doit être un des suivants :"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:108
|
||||
#, no-c-format
|
||||
msgid "<literal>\"element-name\"</literal> - map to the named XML element"
|
||||
msgstr "<literal>\"element-name\"</literal> - mappe vers l'élément XML nommé"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:111
|
||||
#, no-c-format
|
||||
msgid "<literal>\"@attribute-name\"</literal> - map to the named XML attribute"
|
||||
msgstr ""
|
||||
"<literal>\"@attribute-name\"</literal> - mappe vers l'attribut XML nommé"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:114
|
||||
#, no-c-format
|
||||
msgid "<literal>\".\"</literal> - map to the parent element"
|
||||
msgstr "<literal>\".\"</literal> - mappe vers le parent de l'élément"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:117
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<literal>\"element-name/@attribute-name\"</literal> - map to the named "
|
||||
"attribute of the named element"
|
||||
msgstr ""
|
||||
"<literal>\"element-name/@attribute-name\"</literal> - mappe vers l'élément "
|
||||
"nommé de l'attribut nommé"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:124
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"For collections and single valued associations, there is an additional "
|
||||
"<literal>embed-xml</literal> attribute. If <literal>embed-xml=\"true\"</"
|
||||
"literal>, the default, the XML tree for the associated entity (or collection "
|
||||
"of value type) will be embedded directly in the XML tree for the entity that "
|
||||
"owns the association. Otherwise, if <literal>embed-xml=\"false\"</literal>, "
|
||||
"then only the referenced identifier value will appear in the XML for single "
|
||||
"point associations and collections will simply not appear at all."
|
||||
msgstr ""
|
||||
"Pour des collections et de simples associations valuées, il y a un attribut "
|
||||
"<literal>embed-xml</literal> supplémentaire. Si <literal>embed-xml=\"true\"</"
|
||||
"literal>, qui est la valeur par défaut, l'arbre XML pour l'entité associée "
|
||||
"(ou la collection des types de valeurs) sera embarquée directement dans "
|
||||
"l'arbre XML pour l'entité qui possède l'association. Sinon, si "
|
||||
"<literal>embed-xml=\"false\"</literal>, alors seule la valeur de "
|
||||
"l'identifiant référencé apparaîtra dans le XML pour de simples associations "
|
||||
"de points, et les collections n'appraîtront simplement pas."
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:134
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"You should be careful not to leave <literal>embed-xml=\"true\"</literal> for "
|
||||
"too many associations, since XML does not deal well with circularity!"
|
||||
msgstr ""
|
||||
"Vous devriez faire attention à ne pas laisser <literal>embed-xml=\"true\"</"
|
||||
"literal> pour trop d'associations, puisque XML ne traite pas bien les liens "
|
||||
"circurlaires."
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:139
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Customer\" \n"
|
||||
" table=\"CUSTOMER\" \n"
|
||||
" node=\"customer\">\n"
|
||||
" \n"
|
||||
" <id name=\"id\" \n"
|
||||
" column=\"CUST_ID\" \n"
|
||||
" node=\"@id\"/>\n"
|
||||
" \n"
|
||||
" <map name=\"accounts\" \n"
|
||||
" node=\".\" \n"
|
||||
" embed-xml=\"true\">\n"
|
||||
" <key column=\"CUSTOMER_ID\" \n"
|
||||
" not-null=\"true\"/>\n"
|
||||
" <map-key column=\"SHORT_DESC\" \n"
|
||||
" node=\"@short-desc\" \n"
|
||||
" type=\"string\"/>\n"
|
||||
" <one-to-many entity-name=\"Account\"\n"
|
||||
" embed-xml=\"false\" \n"
|
||||
" node=\"account\"/>\n"
|
||||
" </map>\n"
|
||||
" \n"
|
||||
" <component name=\"name\" \n"
|
||||
" node=\"name\">\n"
|
||||
" <property name=\"firstName\" \n"
|
||||
" node=\"first-name\"/>\n"
|
||||
" <property name=\"initial\" \n"
|
||||
" node=\"initial\"/>\n"
|
||||
" <property name=\"lastName\" \n"
|
||||
" node=\"last-name\"/>\n"
|
||||
" </component>\n"
|
||||
" \n"
|
||||
" ...\n"
|
||||
" \n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:141
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"in this case, we have decided to embed the collection of account ids, but "
|
||||
"not the actual account data. The following HQL query:"
|
||||
msgstr ""
|
||||
"dans ce cas, nous avons décidé d'embarquer la collection d'identifiants de "
|
||||
"compte, mais pas les données actuelles du compte. La requête HQL suivante :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:146
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[from Customer c left join fetch c.accounts where c.lastName like :"
|
||||
"lastName]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:148
|
||||
#, no-c-format
|
||||
msgid "Would return datasets such as this:"
|
||||
msgstr "devrait retourner l'ensemble de données suivant :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:152
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<customer id=\"123456789\">\n"
|
||||
" <account short-desc=\"Savings\">987632567</account>\n"
|
||||
" <account short-desc=\"Credit Card\">985612323</account>\n"
|
||||
" <name>\n"
|
||||
" <first-name>Gavin</first-name>\n"
|
||||
" <initial>A</initial>\n"
|
||||
" <last-name>King</last-name>\n"
|
||||
" </name>\n"
|
||||
" ...\n"
|
||||
"</customer>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:154
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"If you set <literal>embed-xml=\"true\"</literal> on the <literal><one-to-"
|
||||
"many></literal> mapping, the data might look more like this:"
|
||||
msgstr ""
|
||||
"Si vous positionnez <literal>embed-xml=\"true\"</literal> sur le mapping "
|
||||
"<literal><one-to-many></literal>, les données pourraient ressembler "
|
||||
"plus à ça :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:159
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[<customer id=\"123456789\">\n"
|
||||
" <account id=\"987632567\" short-desc=\"Savings\">\n"
|
||||
" <customer id=\"123456789\"/>\n"
|
||||
" <balance>100.29</balance>\n"
|
||||
" </account>\n"
|
||||
" <account id=\"985612323\" short-desc=\"Credit Card\">\n"
|
||||
" <customer id=\"123456789\"/>\n"
|
||||
" <balance>-2370.34</balance>\n"
|
||||
" </account>\n"
|
||||
" <name>\n"
|
||||
" <first-name>Gavin</first-name>\n"
|
||||
" <initial>A</initial>\n"
|
||||
" <last-name>King</last-name>\n"
|
||||
" </name>\n"
|
||||
" ...\n"
|
||||
"</customer>]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: title
|
||||
#: xml.xml:165
|
||||
#, no-c-format
|
||||
msgid "Manipulating XML data"
|
||||
msgstr "Manipuler des données XML"
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:167
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"Let's rearead and update XML documents in the application. We do this by "
|
||||
"obtaining a dom4j session:"
|
||||
msgstr ""
|
||||
"Relisons et mettons à jour des documents XML dans l'application. Nous "
|
||||
"faisons ça en obtenant une session dom4j :"
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:172
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Document doc = ....;\n"
|
||||
" \n"
|
||||
"Session session = factory.openSession();\n"
|
||||
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"List results = dom4jSession\n"
|
||||
" .createQuery(\"from Customer c left join fetch c.accounts where c."
|
||||
"lastName like :lastName\")\n"
|
||||
" .list();\n"
|
||||
"for ( int i=0; i<results.size(); i++ ) {\n"
|
||||
" //add the customer data to the XML document\n"
|
||||
" Element customer = (Element) results.get(i);\n"
|
||||
" doc.add(customer);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: programlisting
|
||||
#: xml.xml:174
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"<![CDATA[Session session = factory.openSession();\n"
|
||||
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
|
||||
"Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"Element cust = (Element) dom4jSession.get(\"Customer\", customerId);\n"
|
||||
"for ( int i=0; i<results.size(); i++ ) {\n"
|
||||
" Element customer = (Element) results.get(i);\n"
|
||||
" //change the customer name in the XML and database\n"
|
||||
" Element name = customer.element(\"name\");\n"
|
||||
" name.element(\"first-name\").setText(firstName);\n"
|
||||
" name.element(\"initial\").setText(initial);\n"
|
||||
" name.element(\"last-name\").setText(lastName);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
#: xml.xml:176
|
||||
#, no-c-format
|
||||
msgid ""
|
||||
"It is extremely useful to combine this feature with Hibernate's "
|
||||
"<literal>replicate()</literal> operation to implement XML-based data import/"
|
||||
"export."
|
||||
msgstr ""
|
||||
"Il est extrêmement utile de combiner cette fonctionnalité avec l'opération "
|
||||
"<literal>replicate()</literal> d'Hibernate pour implémenter des imports/"
|
||||
"exports de données XML."
|