translation po/gettext conversion
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14128 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
fb39810294
commit
88dd39a0ac
|
@ -0,0 +1,34 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:23-0500\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"
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: ./Hibernate_Reference.xml:33(None) ./Hibernate_Reference.xml:36(None)
|
||||
msgid "@@image: 'images/hibernate_logo_a.png'; md5=38bd6cfd79e676660440f316f4ab452c"
|
||||
msgstr ""
|
||||
|
||||
#: ./Hibernate_Reference.xml:26(title)
|
||||
msgid "HIBERNATE - Relational Persistence for Idiomatic Java"
|
||||
msgstr ""
|
||||
|
||||
#: ./Hibernate_Reference.xml:27(subtitle)
|
||||
msgid "Hibernate Reference Documentation"
|
||||
msgstr ""
|
||||
|
||||
#: ./Hibernate_Reference.xml:30(issuenum)
|
||||
msgid "1"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: ./Hibernate_Reference.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,256 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:28-0500\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"
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: architecture.xml:32(None)
|
||||
msgid "@@image: '../images/overview.svg'; md5=2d9211eace02ecef615f7dd42beec14c"
|
||||
msgstr ""
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: architecture.xml:35(None)
|
||||
msgid "@@image: '../images/overview.png'; md5=a2b5f0f7dc75d9773305d4d824880e8c"
|
||||
msgstr ""
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: architecture.xml:54(None)
|
||||
msgid "@@image: '../images/lite.svg'; md5=2178e70b3b165736d33b085dcad93699"
|
||||
msgstr ""
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: architecture.xml:57(None)
|
||||
msgid "@@image: '../images/lite.png'; md5=7dd864188937e2dfef42a706235f74c3"
|
||||
msgstr ""
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: architecture.xml:68(None)
|
||||
msgid "@@image: '../images/full_cream.svg'; md5=4ef192f03e90e451e5dcb287d2709687"
|
||||
msgstr ""
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: architecture.xml:71(None)
|
||||
msgid "@@image: '../images/full_cream.png'; md5=c3ee197b49364a876bc5867d5c2c6db7"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:21(title)
|
||||
msgid "Architecture"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:24(title)
|
||||
msgid "Overview"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:26(para)
|
||||
msgid "A (very) high-level view of the Hibernate architecture:"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:39(para)
|
||||
msgid "This diagram shows Hibernate using the database and configuration data to provide persistence services (and persistent objects) to the application."
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:44(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:61(para)
|
||||
msgid "The \"full cream\" architecture abstracts the application away from the underlying JDBC/JTA APIs and lets Hibernate take care of the details."
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:80(term)
|
||||
msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:82(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:92(term)
|
||||
msgid "Session (<literal>org.hibernate.Session</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:94(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:104(term)
|
||||
msgid "Persistent objects and collections"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:106(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:117(term)
|
||||
msgid "Transient and detached objects and collections"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:119(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:128(term)
|
||||
msgid "Transaction (<literal>org.hibernate.Transaction</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:130(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:141(term)
|
||||
msgid "ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:143(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:151(term)
|
||||
msgid "TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:153(para)
|
||||
msgid "(Optional) A factory for <literal>Transaction</literal> instances. Not exposed to the application, but can be extended/implemented by the developer."
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:160(emphasis)
|
||||
msgid "Extension Interfaces"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:162(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:75(para)
|
||||
msgid "Heres some definitions of the objects in the diagrams: <placeholder-1/>"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:171(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:179(title)
|
||||
msgid "Instance states"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:180(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:188(term)
|
||||
msgid "transient"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:190(para)
|
||||
msgid "The instance is not, and has never been associated with any persistence context. It has no persistent identity (primary key value)."
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:198(term)
|
||||
msgid "persistent"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:200(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:212(term)
|
||||
msgid "detached"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:214(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:229(title)
|
||||
msgid "JMX Integration"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:231(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:237(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:245(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:257(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:268(para)
|
||||
msgid "Consult the JBoss AS user guide for more information about these options."
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:272(para)
|
||||
msgid "Another feature available as a JMX service are runtime Hibernate statistics. See <xref linkend=\"configuration-optional-statistics\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:279(title)
|
||||
msgid "JCA Support"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:280(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:287(title)
|
||||
msgid "Contextual Sessions"
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:288(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:297(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:307(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:314(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:324(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:332(para)
|
||||
msgid "<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current sessions are tracked by thread of execution. Again, see the Javadocs for details."
|
||||
msgstr ""
|
||||
|
||||
#: architecture.xml:338(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:347(para)
|
||||
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 ""
|
||||
|
||||
#: architecture.xml:359(para)
|
||||
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 ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: architecture.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:28-0500\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"
|
||||
|
||||
#: association_mapping.xml:6(title)
|
||||
msgid "Association Mappings"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:9(title)
|
||||
msgid "Introduction"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:11(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:19(para)
|
||||
msgid "We'll classify associations by whether or not they map to an intervening join table, and by multiplicity."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:24(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:34(title)
|
||||
msgid "Unidirectional associations"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:37(title) association_mapping.xml:195(title)
|
||||
msgid "many to one"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:39(para)
|
||||
msgid "A <emphasis>unidirectional many-to-one association</emphasis> is the most common kind of unidirectional association."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:66(title) association_mapping.xml:229(title) association_mapping.xml:373(title) association_mapping.xml:479(title)
|
||||
msgid "one to one"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:68(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:93(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:121(title) association_mapping.xml:161(title)
|
||||
msgid "one to many"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:123(para)
|
||||
msgid "A <emphasis>unidirectional one-to-many association on a foreign key</emphasis> is a very unusual case, and is not really recommended."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:149(para)
|
||||
msgid "We think it's better to use a join table for this kind of association."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:158(title)
|
||||
msgid "Unidirectional associations with join tables"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:163(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:197(para)
|
||||
msgid "A <emphasis>unidirectional many-to-one association on a join table</emphasis> is quite common when the association is optional."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:231(para)
|
||||
msgid "A <emphasis>unidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:265(title) association_mapping.xml:525(title)
|
||||
msgid "many to many"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:267(para)
|
||||
msgid "Finally, we have a <emphasis>unidirectional many-to-many association</emphasis>."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:298(title)
|
||||
msgid "Bidirectional associations"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:301(title) association_mapping.xml:436(title)
|
||||
msgid "one to many / many to one"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:303(para)
|
||||
msgid "A <emphasis>bidirectional many-to-one association</emphasis> is the most common kind of association. (This is the standard parent/child relationship.)"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:333(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:361(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:375(para)
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> is quite common."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:402(para)
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a primary key</emphasis> uses the special id generator."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:433(title)
|
||||
msgid "Bidirectional associations with join tables"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:438(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:481(para)
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:527(para)
|
||||
msgid "Finally, we have a <emphasis>bidirectional many-to-many association</emphasis>."
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:564(title)
|
||||
msgid "More complex association mappings"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:566(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:584(para)
|
||||
msgid "Then we can map an association to the <emphasis>current</emphasis> instance (the one with null <literal>effectiveEndDate</literal>) using:"
|
||||
msgstr ""
|
||||
|
||||
#: association_mapping.xml:596(para)
|
||||
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 ""
|
||||
|
||||
#: association_mapping.xml:617(para)
|
||||
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 ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: association_mapping.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,152 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:29-0500\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"
|
||||
|
||||
#: batch.xml:5(title)
|
||||
msgid "Batch processing"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:7(para)
|
||||
msgid "A naive approach to inserting 100 000 rows in the database using Hibernate might look like this:"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:21(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:27(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:36(para)
|
||||
msgid "Note that Hibernate disables insert batching at the JDBC level transparently if you use an <literal>identiy</literal> identifier generator."
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:41(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:48(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:54(title)
|
||||
msgid "Batch inserts"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:56(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:81(title)
|
||||
msgid "Batch updates"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:83(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:112(title)
|
||||
msgid "The StatelessSession interface"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:113(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:142(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:148(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:161(title)
|
||||
msgid "DML-style operations"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:163(para)
|
||||
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 (<xref linkend=\"queryhql\">HQL</xref>)."
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:173(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:181(para)
|
||||
msgid "In the from-clause, the FROM keyword is optional"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:186(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:194(para)
|
||||
msgid "No <xref linkend=\"queryhql-joins-forms\">joins</xref> (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 ""
|
||||
|
||||
#: batch.xml:201(para)
|
||||
msgid "The where-clause is also optional."
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:207(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:225(para)
|
||||
msgid "HQL <literal>UPDATE</literal> statements, by default do not effect the <xref linkend=\"mapping-declaration-version\">version</xref> or the <xref linkend=\"mapping-declaration-timestamp\">timestamp</xref> 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 ""
|
||||
|
||||
#: batch.xml:245(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:250(para)
|
||||
msgid "To execute an HQL <literal>DELETE</literal>, use the same <literal>Query.executeUpdate()</literal> method:"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:266(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:277(para)
|
||||
msgid "The pseudo-syntax for <literal>INSERT</literal> statements is: <literal>INSERT INTO EntityName properties_list select_statement</literal>. Some points to note:"
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:285(para)
|
||||
msgid "Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form."
|
||||
msgstr ""
|
||||
|
||||
#: batch.xml:288(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:298(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:310(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:325(para)
|
||||
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 ""
|
||||
|
||||
#: batch.xml:335(para)
|
||||
msgid "An example HQL <literal>INSERT</literal> statement execution:"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: batch.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:29-0500\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"
|
||||
|
||||
#: best_practices.xml:5(title)
|
||||
msgid "Best Practices"
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:9(term)
|
||||
msgid "Write fine-grained classes and map them using <literal><component></literal>."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:11(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:19(term)
|
||||
msgid "Declare identifier properties on persistent classes."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:21(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:29(term)
|
||||
msgid "Identify natural keys."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:31(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:39(term)
|
||||
msgid "Place each class mapping in its own file."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:41(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:49(term)
|
||||
msgid "Load mappings as resources."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:51(para)
|
||||
msgid "Deploy the mappings along with the classes they map."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:57(term)
|
||||
msgid "Consider externalising query strings."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:59(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:67(term)
|
||||
msgid "Use bind variables."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:69(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:77(term)
|
||||
msgid "Don't manage your own JDBC connections."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:79(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:87(term)
|
||||
msgid "Consider using a custom type."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:89(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:98(term)
|
||||
msgid "Use hand-coded JDBC in bottlenecks."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:100(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:110(term)
|
||||
msgid "Understand <literal>Session</literal> flushing."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:112(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:121(term)
|
||||
msgid "In a three tiered architecture, consider using detached objects."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:123(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:132(term)
|
||||
msgid "In a two tiered architecture, consider using long persistence contexts."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:134(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:148(term)
|
||||
msgid "Don't treat exceptions as recoverable."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:150(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:160(term)
|
||||
msgid "Prefer lazy fetching for associations."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:162(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:172(term)
|
||||
msgid "Use the <emphasis>open session in view</emphasis> pattern, or a disciplined <emphasis>assembly phase</emphasis> to avoid problems with unfetched data."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:177(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:191(term)
|
||||
msgid "Consider abstracting your business logic from Hibernate."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:193(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:203(term)
|
||||
msgid "Don't use exotic association mappings."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:205(para)
|
||||
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 ""
|
||||
|
||||
#: best_practices.xml:215(term)
|
||||
msgid "Prefer bidirectional associations."
|
||||
msgstr ""
|
||||
|
||||
#: best_practices.xml:217(para)
|
||||
msgid "Unidirectional associations are more difficult to query. In a large application, almost all associations must be navigable in both directions in queries."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: best_practices.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,492 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:30-0500\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"
|
||||
|
||||
#: collection_mapping.xml:5(title)
|
||||
msgid "Collection Mapping"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:8(title)
|
||||
msgid "Persistent collections"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:10(para)
|
||||
msgid "Hibernate requires that persistent collection-valued fields be declared as an interface type, for example:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:25(para)
|
||||
msgid "The actual interface might be <literal>java.util.Set</literal>, <literal>java.util.Collection</literal>, <literal>java.util.List</literal>, <literal>java.util.Map</literal>, <literal>java.util.SortedSet</literal>, <literal>java.util.SortedMap</literal> or ... anything you like! (Where \"anything you like\" means you will have to write an implementation of <literal>org.hibernate.usertype.UserCollectionType</literal>.)"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:34(para)
|
||||
msgid "Notice how we initialized the instance variable with an instance of <literal>HashSet</literal>. This is the best way to initialize collection valued properties of newly instantiated (non-persistent) instances. When you make the instance persistent - by calling <literal>persist()</literal>, for example - Hibernate will actually replace the <literal>HashSet</literal> with an instance of Hibernate's own implementation of <literal>Set</literal>. Watch out for errors like this:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:54(para)
|
||||
msgid "The persistent collections injected by Hibernate behave like <literal>HashMap</literal>, <literal>HashSet</literal>, <literal>TreeMap</literal>, <literal>TreeSet</literal> or <literal>ArrayList</literal>, depending upon the interface type."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:61(para)
|
||||
msgid "Collections instances have the usual behavior of value types. They are automatically persisted when referenced by a persistent object and automatically deleted when unreferenced. If a collection is passed from one persistent object to another, its elements might be moved from one table to another. Two entities may not share a reference to the same collection instance. Due to the underlying relational model, collection-valued properties do not support null value semantics; Hibernate does not distinguish between a null collection reference and an empty collection."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:72(para)
|
||||
msgid "You shouldn't have to worry much about any of this. Use persistent collections the same way you use ordinary Java collections. Just make sure you understand the semantics of bidirectional associations (discussed later)."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:81(title)
|
||||
msgid "Collection mappings"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:83(para)
|
||||
msgid "The Hibernate mapping element used for mapping a collection depends upon the type of the interface. For example, a <literal><set></literal> element is used for mapping properties of type <literal>Set</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:97(para)
|
||||
msgid "Apart from <literal><set></literal>, there is also <literal><list></literal>, <literal><map></literal>, <literal><bag></literal>, <literal><array></literal> and <literal><primitive-array></literal> mapping elements. The <literal><map></literal> element is representative:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:147(para)
|
||||
msgid "<literal>name</literal> the collection property name"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:152(para)
|
||||
msgid "<literal>table</literal> (optional - defaults to property name) the name of the collection table (not used for one-to-many associations)"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:158(para)
|
||||
msgid "<literal>schema</literal> (optional) the name of a table schema to override the schema declared on the root element"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:164(para)
|
||||
msgid "<literal>lazy</literal> (optional - defaults to <literal>true</literal>) may be used to disable lazy fetching and specify that the association is always eagerly fetched, or to enable \"extra-lazy\" fetching where most operations do not initialize the collection (suitable for very large collections)"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:173(para)
|
||||
msgid "<literal>inverse</literal> (optional - defaults to <literal>false</literal>) mark this collection as the \"inverse\" end of a bidirectional association"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:179(para)
|
||||
msgid "<literal>cascade</literal> (optional - defaults to <literal>none</literal>) enable operations to cascade to child entities"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:185(para)
|
||||
msgid "<literal>sort</literal> (optional) specify a sorted collection with <literal>natural</literal> sort order, or a given comparator class"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:191(para)
|
||||
msgid "<literal>order-by</literal> (optional, JDK1.4 only) specify a table column (or columns) that define the iteration order of the <literal>Map</literal>, <literal>Set</literal> or bag, together with an optional <literal>asc</literal> or <literal>desc</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:198(para)
|
||||
msgid "<literal>where</literal> (optional) specify an arbitrary SQL <literal>WHERE</literal> condition to be used when retrieving or removing the collection (useful if the collection should contain only a subset of the available data)"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:205(para)
|
||||
msgid "<literal>fetch</literal> (optional, defaults to <literal>select</literal>) Choose between outer-join fetching, fetching by sequential select, and fetching by sequential subselect."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:212(para)
|
||||
msgid "<literal>batch-size</literal> (optional, defaults to <literal>1</literal>) specify a \"batch size\" for lazily fetching instances of this collection."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:218(para)
|
||||
msgid "<literal>access</literal> (optional - defaults to <literal>property</literal>): The strategy Hibernate should use for accessing the collection property value."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:224(para)
|
||||
msgid "<literal>optimistic-lock</literal> (optional - defaults to <literal>true</literal>): Species that changes to the state of the collection results in increment of the owning entity's version. (For one to many associations, it is often reasonable to disable this setting.)"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:232(para)
|
||||
msgid "<literal>mutable</literal> (optional - defaults to <literal>true</literal>): A value of <literal>false</literal> specifies that the elements of the collection never change (a minor performance optimization in some cases)."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:242(title)
|
||||
msgid "Collection foreign keys"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:244(para)
|
||||
msgid "Collection instances are distinguished in the database by the foreign key of the entity that owns the collection. This foreign key is referred to as the <emphasis>collection key column</emphasis> (or columns) of the collection table. The collection key column is mapped by the <literal><key></literal> element."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:252(para)
|
||||
msgid "There may be a nullability constraint on the foreign key column. For most collections, this is implied. For unidirectional one to many associations, the foreign key column is nullable by default, so you might need to specify <literal>not-null=\"true\"</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:261(para)
|
||||
msgid "The foreign key constraint may use <literal>ON DELETE CASCADE</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:267(para)
|
||||
msgid "See the previous chapter for a full definition of the <literal><key></literal> element."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:275(title)
|
||||
msgid "Collection elements"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:277(para)
|
||||
msgid "Collections may contain almost any other Hibernate type, including all basic types, custom types, components, and of course, references to other entities. This is an important distinction: an object in a collection might be handled with \"value\" semantics (its life cycle fully depends on the collection owner) or it might be a reference to another entity, with its own life cycle. In the latter case, only the \"link\" between the two objects is considered to be state held by the collection."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:286(para)
|
||||
msgid "The contained type is referred to as the <emphasis>collection element type</emphasis>. Collection elements are mapped by <literal><element></literal> or <literal><composite-element></literal>, or in the case of entity references, with <literal><one-to-many></literal> or <literal><many-to-many></literal>. The first two map elements with value semantics, the next two are used to map entity associations."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:298(title)
|
||||
msgid "Indexed collections"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:300(para)
|
||||
msgid "All collection mappings, except those with set and bag semantics, need an <emphasis>index column</emphasis> in the collection table - a column that maps to an array index, or <literal>List</literal> index, or <literal>Map</literal> key. The index of a <literal>Map</literal> may be of any basic type, mapped with <literal><map-key></literal>, it may be an entity reference mapped with <literal><map-key-many-to-many></literal>, or it may be a composite type, mapped with <literal><composite-map-key></literal>. The index of an array or list is always of type <literal>integer</literal> and is mapped using the <literal><list-index></literal> element. The mapped column contains sequential integers (numbered from zero, by default)."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:323(para)
|
||||
msgid "<literal>column_name</literal> (required): The name of the column holding the collection index values."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:329(para)
|
||||
msgid "<literal>base</literal> (optional, defaults to <literal>0</literal>): The value of the index column that corresponds to the first element of the list or array."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:351(para)
|
||||
msgid "<literal>column</literal> (optional): The name of the column holding the collection index values."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:357(para)
|
||||
msgid "<literal>formula</literal> (optional): A SQL formula used to evaluate the key of the map."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:363(para)
|
||||
msgid "<literal>type</literal> (reguired): The type of the map keys."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:383(para)
|
||||
msgid "<literal>column</literal> (optional): The name of the foreign key column for the collection index values."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:389(para)
|
||||
msgid "<literal>formula</literal> (optional): A SQL formula used to evaluate the foreign key of the map key."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:395(para)
|
||||
msgid "<literal>class</literal> (required): The entity class used as the map key."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:403(para)
|
||||
msgid "If your table doesn't have an index column, and you still wish to use <literal>List</literal> as the property type, you should map the property as a Hibernate <emphasis><bag></emphasis>. A bag does not retain its order when it is retrieved from the database, but it may be optionally sorted or ordered."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:412(para)
|
||||
msgid "There are quite a range of mappings that can be generated for collections, covering many common relational models. We suggest you experiment with the schema generation tool to get a feeling for how various mapping declarations translate to database tables."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:419(title)
|
||||
msgid "Collections of values and many-to-many associations"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:421(para)
|
||||
msgid "Any collection of values or many-to-many association requires a dedicated <emphasis>collection table</emphasis> with a foreign key column or columns, <emphasis>collection element column</emphasis> or columns and possibly an index column or columns."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:428(para)
|
||||
msgid "For a collection of values, we use the <literal><element></literal> tag."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:451(para)
|
||||
msgid "<literal>column</literal> (optional): The name of the column holding the collection element values."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:457(para)
|
||||
msgid "<literal>formula</literal> (optional): An SQL formula used to evaluate the element."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:463(para)
|
||||
msgid "<literal>type</literal> (required): The type of the collection element."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:470(para)
|
||||
msgid "A <emphasis>many-to-many association</emphasis> is specified using the <literal><many-to-many></literal> element."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:500(para)
|
||||
msgid "<literal>column</literal> (optional): The name of the element foreign key column."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:505(para)
|
||||
msgid "<literal>formula</literal> (optional): An SQL formula used to evaluate the element foreign key value."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:511(para) collection_mapping.xml:665(para)
|
||||
msgid "<literal>class</literal> (required): The name of the associated class."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:516(para)
|
||||
msgid "<literal>fetch</literal> (optional - defaults to <literal>join</literal>): enables outer-join or sequential select fetching for this association. This is a special case; for full eager fetching (in a single <literal>SELECT</literal>) of an entity and its many-to-many relationships to other entities, you would enable <literal>join</literal> fetching not only of the collection itself, but also with this attribute on the <literal><many-to-many></literal> nested element."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:527(para)
|
||||
msgid "<literal>unique</literal> (optional): Enable the DDL generation of a unique constraint for the foreign-key column. This makes the association multiplicity effectively one to many."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:534(para)
|
||||
msgid "<literal>not-found</literal> (optional - defaults to <literal>exception</literal>): Specifies how foreign keys that reference missing rows will be handled: <literal>ignore</literal> will treat a missing row as a null association."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:541(para) collection_mapping.xml:677(para)
|
||||
msgid "<literal>entity-name</literal> (optional): The entity name of the associated class, as an alternative to <literal>class</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:547(para)
|
||||
msgid "<literal>property-ref</literal>: (optional) The name of a property of the associated class that is joined to this foreign key. If not specified, the primary key of the associated class is used."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:556(para)
|
||||
msgid "Some examples, first, a set of strings:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:565(para)
|
||||
msgid "A bag containing integers (with an iteration order determined by the <literal>order-by</literal> attribute):"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:577(para)
|
||||
msgid "An array of entities - in this case, a many to many association:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:589(para)
|
||||
msgid "A map from string indices to dates:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:602(para)
|
||||
msgid "A list of components (discussed in the next chapter):"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:620(title)
|
||||
msgid "One-to-many associations"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:622(para)
|
||||
msgid "A <emphasis>one to many association</emphasis> links the tables of two classes via a foreign key, with no intervening collection table. This mapping loses certain semantics of normal Java collections:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:630(para)
|
||||
msgid "An instance of the contained entity class may not belong to more than one instance of the collection"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:636(para)
|
||||
msgid "An instance of the contained entity class may not appear at more than one value of the collection index"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:643(para)
|
||||
msgid "An association from <literal>Product</literal> to <literal>Part</literal> requires existence of a foreign key column and possibly an index column to the <literal>Part</literal> table. A <literal><one-to-many></literal> tag indicates that this is a one to many association."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:670(para)
|
||||
msgid "<literal>not-found</literal> (optional - defaults to <literal>exception</literal>): Specifies how cached identifiers that reference missing rows will be handled: <literal>ignore</literal> will treat a missing row as a null association."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:685(para)
|
||||
msgid "Notice that the <literal><one-to-many></literal> element does not need to declare any columns. Nor is it necessary to specify the <literal>table</literal> name anywhere."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:691(para)
|
||||
msgid "<emphasis>Very important note:</emphasis> If the foreign key column of a <literal><one-to-many></literal> association is declared <literal>NOT NULL</literal>, you must declare the <literal><key></literal> mapping <literal>not-null=\"true\"</literal> or <emphasis>use a bidirectional association</emphasis> with the collection mapping marked <literal>inverse=\"true\"</literal>. See the discussion of bidirectional associations later in this chapter."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:700(para)
|
||||
msgid "This example shows a map of <literal>Part</literal> entities by name (where <literal>partName</literal> is a persistent property of <literal>Part</literal>). Notice the use of a formula-based index."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:717(title)
|
||||
msgid "Advanced collection mappings"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:720(title)
|
||||
msgid "Sorted collections"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:722(para)
|
||||
msgid "Hibernate supports collections implementing <literal>java.util.SortedMap</literal> and <literal>java.util.SortedSet</literal>. You must specify a comparator in the mapping file:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:740(para)
|
||||
msgid "Allowed values of the <literal>sort</literal> attribute are <literal>unsorted</literal>, <literal>natural</literal> and the name of a class implementing <literal>java.util.Comparator</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:746(para)
|
||||
msgid "Sorted collections actually behave like <literal>java.util.TreeSet</literal> or <literal>java.util.TreeMap</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:751(para)
|
||||
msgid "If you want the database itself to order the collection elements use the <literal>order-by</literal> attribute of <literal>set</literal>, <literal>bag</literal> or <literal>map</literal> mappings. This solution is only available under JDK 1.4 or higher (it is implemented using <literal>LinkedHashSet</literal> or <literal>LinkedHashMap</literal>). This performs the ordering in the SQL query, not in memory."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:771(para)
|
||||
msgid "Note that the value of the <literal>order-by</literal> attribute is an SQL ordering, not a HQL ordering!"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:776(para)
|
||||
msgid "Associations may even be sorted by some arbitrary criteria at runtime using a collection <literal>filter()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:786(title)
|
||||
msgid "Bidirectional associations"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:795(term)
|
||||
msgid "one-to-many"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:797(para)
|
||||
msgid "set or bag valued at one end, single-valued at the other"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:803(term)
|
||||
msgid "many-to-many"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:805(para)
|
||||
msgid "set or bag valued at both ends"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:788(para)
|
||||
msgid "A <emphasis>bidirectional association</emphasis> allows navigation from both \"ends\" of the association. Two kinds of bidirectional association are supported: <placeholder-1/>"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:814(para)
|
||||
msgid "You may specify a bidirectional many-to-many association simply by mapping two many-to-many associations to the same database table and declaring one end as <emphasis>inverse</emphasis> (which one is your choice, but it can not be an indexed collection)."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:821(para)
|
||||
msgid "Here's an example of a bidirectional many-to-many association; each category can have many items and each item can be in many categories:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:846(para)
|
||||
msgid "Changes made only to the inverse end of the association are <emphasis>not</emphasis> persisted. This means that Hibernate has two representations in memory for every bidirectional association, one link from A to B and another link from B to A. This is easier to understand if you think about the Java object model and how we create a many-to-many relationship in Java:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:861(para)
|
||||
msgid "The non-inverse side is used to save the in-memory representation to the database."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:865(para)
|
||||
msgid "You may define a bidirectional one-to-many association by mapping a one-to-many association to the same table column(s) as a many-to-one association and declaring the many-valued end <literal>inverse=\"true\"</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:889(para)
|
||||
msgid "Mapping one end of an association with <literal>inverse=\"true\"</literal> doesn't affect the operation of cascades, these are orthogonal concepts!"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:897(title)
|
||||
msgid "Bidirectional associations with indexed collections"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:898(para)
|
||||
msgid "A bidirectional association where one end is represented as a <literal><list></literal> or <literal><map></literal> requires special consideration. If there is a property of the child class which maps to the index column, no problem, we can continue using <literal>inverse=\"true\"</literal> on the collection mapping:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:927(para)
|
||||
msgid "But, if there is no such property on the child class, we can't think of the association as truly bidirectional (there is information available at one end of the association that is not available at the other end). In this case, we can't map the collection <literal>inverse=\"true\"</literal>. Instead, we could use the following mapping:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:957(para)
|
||||
msgid "Note that in this mapping, the collection-valued end of the association is responsible for updates to the foreign key. TODO: Does this really result in some unnecessary update statements?"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:965(title)
|
||||
msgid "Ternary associations"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:967(para)
|
||||
msgid "There are three possible approaches to mapping a ternary association. One is to use a <literal>Map</literal> with an association as its index:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:984(para)
|
||||
msgid "A second approach is to simply remodel the association as an entity class. This is the approach we use most commonly."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:989(para)
|
||||
msgid "A final alternative is to use composite elements, which we will discuss later."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:996(literal)
|
||||
msgid "Using an <idbag>"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:998(para)
|
||||
msgid "If you've fully embraced our view that composite keys are a bad thing and that entities should have synthetic identifiers (surrogate keys), then you might find it a bit odd that the many to many associations and collections of values that we've shown so far all map to tables with composite keys! Now, this point is quite arguable; a pure association table doesn't seem to benefit much from a surrogate key (though a collection of composite values <emphasis>might</emphasis>). Nevertheless, Hibernate provides a feature that allows you to map many to many associations and collections of values to a table with a surrogate key."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1009(para)
|
||||
msgid "The <literal><idbag></literal> element lets you map a <literal>List</literal> (or <literal>Collection</literal>) with bag semantics."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1022(para)
|
||||
msgid "As you can see, an <literal><idbag></literal> has a synthetic id generator, just like an entity class! A different surrogate key is assigned to each collection row. Hibernate does not provide any mechanism to discover the surrogate key value of a particular row, however."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1029(para)
|
||||
msgid "Note that the update performance of an <literal><idbag></literal> is <emphasis>much</emphasis> better than a regular <literal><bag></literal>! Hibernate can locate individual rows efficiently and update or delete them individually, just like a list, map or set."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1036(para)
|
||||
msgid "In the current implementation, the <literal>native</literal> identifier generation strategy is not supported for <literal><idbag></literal> collection identifiers."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1060(title)
|
||||
msgid "Collection examples"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1062(para)
|
||||
msgid "The previous sections are pretty confusing. So lets look at an example. This class:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1084(para)
|
||||
msgid "has a collection of <literal>Child</literal> instances. If each child has at most one parent, the most natural mapping is a one-to-many association:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1111(para)
|
||||
msgid "This maps to the following table definitions:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1119(para)
|
||||
msgid "If the parent is <emphasis>required</emphasis>, use a bidirectional one-to-many association:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1146(para)
|
||||
msgid "Notice the <literal>NOT NULL</literal> constraint:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1157(para)
|
||||
msgid "Alternatively, if you absolutely insist that this association should be unidirectional, you can declare the <literal>NOT NULL</literal> constraint on the <literal><key></literal> mapping:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1184(para)
|
||||
msgid "On the other hand, if a child might have multiple parents, a many-to-many association is appropriate:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1210(para)
|
||||
msgid "Table definitions:"
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1222(para)
|
||||
msgid "For more examples and a complete walk-through a parent/child relationship mapping, see <xref linkend=\"example-parentchild\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: collection_mapping.xml:1227(para)
|
||||
msgid "Even more exotic association mappings are possible, we will catalog all possibilities in the next chapter."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: collection_mapping.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:30-0500\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"
|
||||
|
||||
#: component_mapping.xml:5(title)
|
||||
msgid "Component Mapping"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:7(para)
|
||||
msgid "The notion of a <emphasis>component</emphasis> is re-used in several different contexts, for different purposes, throughout Hibernate."
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:13(title)
|
||||
msgid "Dependent objects"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:15(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:71(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:78(para)
|
||||
msgid "Our Hibernate mapping would look like:"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:94(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:102(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:111(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:118(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:140(title)
|
||||
msgid "Collections of dependent objects"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:142(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:158(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:164(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:176(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:187(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:210(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:218(para)
|
||||
msgid "Even ternary (or quaternary, etc) associations are possible:"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:231(para)
|
||||
msgid "Composite elements may appear in queries using the same syntax as associations to other entities."
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:239(title)
|
||||
msgid "Components as Map indices"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:241(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:250(title)
|
||||
msgid "Components as composite identifiers"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:252(para)
|
||||
msgid "You may use a component as an identifier of an entity class. Your component class must satisfy certain requirements:"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:259(para)
|
||||
msgid "It must implement <literal>java.io.Serializable</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:264(para)
|
||||
msgid "It must re-implement <literal>equals()</literal> and <literal>hashCode()</literal>, consistently with the database's notion of composite key equality."
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:273(emphasis)
|
||||
msgid "Note: in Hibernate3, the second requirement is not an absolutely hard requirement of Hibernate. But do it anyway."
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:277(para)
|
||||
msgid "You can't use an <literal>IdentifierGenerator</literal> to generate composite keys. Instead the application must assign its own identifiers."
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:282(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:309(para)
|
||||
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 ""
|
||||
|
||||
#: component_mapping.xml:322(para)
|
||||
msgid "(Note that the <literal><column></literal> tag is an alternative to the <literal>column</literal> attribute everywhere.)"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:327(para)
|
||||
msgid "A <literal>many-to-many</literal> association to <literal>OrderLine</literal> also uses the composite foreign key:"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:341(para)
|
||||
msgid "The collection of <literal>OrderLine</literal>s in <literal>Order</literal> would use:"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:354(para)
|
||||
msgid "(The <literal><one-to-many></literal> element, as usual, declares no columns.)"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:358(para)
|
||||
msgid "If <literal>OrderLine</literal> itself owns a collection, it also has a composite foreign key."
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:382(title)
|
||||
msgid "Dynamic components"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:384(para)
|
||||
msgid "You may even map a property of type <literal>Map</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: component_mapping.xml:394(para)
|
||||
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 ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: component_mapping.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,108 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:31-0500\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"
|
||||
|
||||
#: events.xml:5(title)
|
||||
msgid "Interceptors and events"
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:7(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:14(title)
|
||||
msgid "Interceptors"
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:16(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:27(para)
|
||||
msgid "You may either implement <literal>Interceptor</literal> directly or (better) extend <literal>EmptyInterceptor</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:115(para)
|
||||
msgid "Interceptors come in two flavors: <literal>Session</literal>-scoped and <literal>SessionFactory</literal>-scoped."
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:120(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:128(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:142(title)
|
||||
msgid "Event system"
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:144(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:150(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:165(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:170(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:190(para)
|
||||
msgid "You also need a configuration entry telling Hibernate to use the listener in addition to the default listener:"
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:205(para)
|
||||
msgid "Instead, you may register it programmatically:"
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:213(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:221(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:231(title)
|
||||
msgid "Hibernate declarative security"
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:232(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:238(para)
|
||||
msgid "First, you must configure the appropriate event listeners, to enable the use of JAAS authorization."
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:248(para)
|
||||
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 ""
|
||||
|
||||
#: events.xml:254(para)
|
||||
msgid "Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:"
|
||||
msgstr ""
|
||||
|
||||
#: events.xml:261(para)
|
||||
msgid "The role names are the roles understood by your JACC provider."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: events.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:31-0500\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"
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: example_mappings.xml:39(None) example_mappings.xml:42(None)
|
||||
msgid "@@image: '../images/EmployerEmployee.png'; md5=51e3da273e772b7defc753746eb5223f"
|
||||
msgstr ""
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: example_mappings.xml:153(None) example_mappings.xml:156(None)
|
||||
msgid "@@image: '../images/AuthorWork.png'; md5=fdbc5f105890c04d206674e7df6af6cf"
|
||||
msgstr ""
|
||||
|
||||
#. When image changes, this message will be marked fuzzy or untranslated for you.
|
||||
#. It doesn't matter what you translate it to: it's not used at all.
|
||||
#: example_mappings.xml:277(None) example_mappings.xml:280(None)
|
||||
msgid "@@image: '../images/CustomerOrderProduct.png'; md5=39dcb639a197684dc020904a3f9a4b3d"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:20(title)
|
||||
msgid "Example: Various Mappings"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:22(para)
|
||||
msgid "This chapters shows off some more complex association mappings."
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:27(title)
|
||||
msgid "Employer/Employee"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:29(para)
|
||||
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 ""
|
||||
|
||||
#: example_mappings.xml:46(para)
|
||||
msgid "Heres a possible mapping document:"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:99(para)
|
||||
msgid "And heres the table schema generated by <literal>SchemaExport</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:140(title)
|
||||
msgid "Author/Work"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:142(para)
|
||||
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 ""
|
||||
|
||||
#: example_mappings.xml:160(para)
|
||||
msgid "The following mapping document correctly represents these relationships:"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:216(para)
|
||||
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 ""
|
||||
|
||||
#: example_mappings.xml:262(title)
|
||||
msgid "Customer/Order/Product"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:264(para)
|
||||
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 ""
|
||||
|
||||
#: example_mappings.xml:284(para)
|
||||
msgid "The mapping document:"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:326(para)
|
||||
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 ""
|
||||
|
||||
#: example_mappings.xml:370(title)
|
||||
msgid "Miscellaneous example mappings"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:372(para)
|
||||
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 ""
|
||||
|
||||
#: example_mappings.xml:378(para)
|
||||
msgid "TODO: put words around this stuff"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:381(title)
|
||||
msgid "\"Typed\" one-to-one association"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:411(title)
|
||||
msgid "Composite key example"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:528(title)
|
||||
msgid "Many-to-many with shared composite key attribute"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:567(title)
|
||||
msgid "Content based discrimination"
|
||||
msgstr ""
|
||||
|
||||
#: example_mappings.xml:621(title)
|
||||
msgid "Associations on alternate keys"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: example_mappings.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:31-0500\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"
|
||||
|
||||
#: example_parentchild.xml:5(title)
|
||||
msgid "Example: Parent/Child"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:7(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:21(title)
|
||||
msgid "A note about collections"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:23(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:30(para)
|
||||
msgid "When we remove / add an object from / to a collection, the version number of the collection owner is incremented."
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:36(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:44(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:54(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:64(title)
|
||||
msgid "Bidirectional one-to-many"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:66(para)
|
||||
msgid "Suppose we start with a simple <literal><one-to-many></literal> association from <literal>Parent</literal> to <literal>Child</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:76(para)
|
||||
msgid "If we were to execute the following code"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:86(para)
|
||||
msgid "Hibernate would issue two SQL statements:"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:92(para)
|
||||
msgid "an <literal>INSERT</literal> to create the record for <literal>c</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:95(para)
|
||||
msgid "an <literal>UPDATE</literal> to create the link from <literal>p</literal> to <literal>c</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:102(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:113(para)
|
||||
msgid "However, this is not the recommended solution."
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:116(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:125(para)
|
||||
msgid "(We also need to add the <literal>parent</literal> property to the <literal>Child</literal> class.)"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:129(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:139(para)
|
||||
msgid "The following code would be used to add a new <literal>Child</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:150(para)
|
||||
msgid "And now, only one SQL <literal>INSERT</literal> would be issued!"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:154(para)
|
||||
msgid "To tighten things up a bit, we could create an <literal>addChild()</literal> method of <literal>Parent</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:164(para)
|
||||
msgid "Now, the code to add a <literal>Child</literal> looks like"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:177(title)
|
||||
msgid "Cascading life cycle"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:179(para)
|
||||
msgid "The explicit call to <literal>save()</literal> is still annoying. We will address this by using cascades."
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:189(para)
|
||||
msgid "This simplifies the code above to"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:198(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:207(para)
|
||||
msgid "However, this code"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:217(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:229(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:240(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:250(title)
|
||||
msgid "Cascades and <literal>unsaved-value</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:252(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:264(para)
|
||||
msgid "The following code will update <literal>parent</literal> and <literal>child</literal> and insert <literal>newChild</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:276(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:348(title)
|
||||
msgid "Conclusion"
|
||||
msgstr ""
|
||||
|
||||
#: example_parentchild.xml:350(para)
|
||||
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 ""
|
||||
|
||||
#: example_parentchild.xml:355(para)
|
||||
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 ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: example_parentchild.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:32-0500\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"
|
||||
|
||||
#: example_weblog.xml:5(title)
|
||||
msgid "Example: Weblog Application"
|
||||
msgstr ""
|
||||
|
||||
#: example_weblog.xml:8(title)
|
||||
msgid "Persistent Classes"
|
||||
msgstr ""
|
||||
|
||||
#: example_weblog.xml:10(para)
|
||||
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 ""
|
||||
|
||||
#: example_weblog.xml:92(title)
|
||||
msgid "Hibernate Mappings"
|
||||
msgstr ""
|
||||
|
||||
#: example_weblog.xml:94(para)
|
||||
msgid "The XML mappings should now be quite straightforward."
|
||||
msgstr ""
|
||||
|
||||
#: example_weblog.xml:185(title)
|
||||
msgid "Hibernate Code"
|
||||
msgstr ""
|
||||
|
||||
#: example_weblog.xml:187(para)
|
||||
msgid "The following class demonstrates some of the kinds of things we can do with these classes, using Hibernate."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: example_weblog.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:32-0500\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"
|
||||
|
||||
#: filters.xml:5(title)
|
||||
msgid "Filtering data"
|
||||
msgstr ""
|
||||
|
||||
#: filters.xml:7(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:14(title)
|
||||
msgid "Hibernate filters"
|
||||
msgstr ""
|
||||
|
||||
#: filters.xml:16(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:26(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:36(para)
|
||||
msgid "Then, this filter can be attached to a class:"
|
||||
msgstr ""
|
||||
|
||||
#: filters.xml:45(para)
|
||||
msgid "or, to a collection:"
|
||||
msgstr ""
|
||||
|
||||
#: filters.xml:53(para)
|
||||
msgid "or, even to both (or multiples of each) at the same time."
|
||||
msgstr ""
|
||||
|
||||
#: filters.xml:57(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:68(para)
|
||||
msgid "Note that methods on the org.hibernate.Filter interface do allow the method-chaining common to much of Hibernate."
|
||||
msgstr ""
|
||||
|
||||
#: filters.xml:72(para)
|
||||
msgid "A full example, using temporal data with an effective record date pattern:"
|
||||
msgstr ""
|
||||
|
||||
#: filters.xml:104(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:116(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:122(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:129(para)
|
||||
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 ""
|
||||
|
||||
#: filters.xml:139(para)
|
||||
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 ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: filters.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,280 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:32-0500\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"
|
||||
|
||||
#: inheritance_mapping.xml:5(title)
|
||||
msgid "Inheritance Mapping"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:8(title)
|
||||
msgid "The Three Strategies"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:10(para)
|
||||
msgid "Hibernate supports the three basic inheritance mapping strategies:"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:16(para)
|
||||
msgid "table per class hierarchy"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:21(para) inheritance_mapping.xml:456(entry)
|
||||
msgid "table per subclass"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:26(para)
|
||||
msgid "table per concrete class"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:32(para)
|
||||
msgid "In addition, Hibernate supports a fourth, slightly different kind of polymorphism:"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:39(para)
|
||||
msgid "implicit polymorphism"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:45(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:59(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:79(title)
|
||||
msgid "Table per class hierarchy"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:81(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:107(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:116(title)
|
||||
msgid "Table per subclass"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:118(para)
|
||||
msgid "A table per subclass mapping would look like:"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:143(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:152(title)
|
||||
msgid "Table per subclass, using a discriminator"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:154(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:194(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:203(title)
|
||||
msgid "Mixing table per class hierarchy with table per subclass"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:205(para)
|
||||
msgid "You may even mix the table per hierarchy and table per subclass strategies using this approach:"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:231(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:242(title)
|
||||
msgid "Table per concrete class"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:244(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:267(para)
|
||||
msgid "Three tables are involved for the subclasses. Each table defines columns for all properties of the class, including inherited properties."
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:272(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:281(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:291(title)
|
||||
msgid "Table per concrete class, using implicit polymorphism"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:293(para)
|
||||
msgid "An alternative approach is to make use of implicit polymorphism:"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:321(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:331(para)
|
||||
msgid "The disadvantage of this approach is that Hibernate does not generate SQL <literal>UNION</literal>s when performing polymorphic queries."
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:336(para)
|
||||
msgid "For this mapping strategy, a polymorphic association to <literal>Payment</literal> is usually mapped using <literal><any></literal>."
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:352(title)
|
||||
msgid "Mixing implicit polymorphism with other inheritance mappings"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:354(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:390(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:405(title)
|
||||
msgid "Limitations"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:407(para)
|
||||
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 ""
|
||||
|
||||
#: inheritance_mapping.xml:414(para)
|
||||
msgid "The following table shows the limitations of table per concrete-class mappings, and of implicit polymorphism, in Hibernate."
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:420(title)
|
||||
msgid "Features of inheritance mappings"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:432(entry)
|
||||
msgid "Inheritance strategy"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:433(entry)
|
||||
msgid "Polymorphic many-to-one"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:434(entry)
|
||||
msgid "Polymorphic one-to-one"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:435(entry)
|
||||
msgid "Polymorphic one-to-many"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:436(entry)
|
||||
msgid "Polymorphic many-to-many"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:437(literal)
|
||||
msgid "load()/get()"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:437(entry)
|
||||
msgid "Polymorphic <placeholder-1/>"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:438(entry)
|
||||
msgid "Polymorphic queries"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:439(entry)
|
||||
msgid "Polymorphic joins"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:440(entry)
|
||||
msgid "Outer join fetching"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:445(entry)
|
||||
msgid "table per class-hierarchy"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:446(literal) inheritance_mapping.xml:457(literal) inheritance_mapping.xml:468(literal)
|
||||
msgid "<many-to-one>"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:447(literal) inheritance_mapping.xml:458(literal) inheritance_mapping.xml:469(literal)
|
||||
msgid "<one-to-one>"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:448(literal) inheritance_mapping.xml:459(literal) inheritance_mapping.xml:470(literal)
|
||||
msgid "<one-to-many>"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:449(literal) inheritance_mapping.xml:460(literal) inheritance_mapping.xml:471(literal)
|
||||
msgid "<many-to-many>"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:450(literal) inheritance_mapping.xml:461(literal) inheritance_mapping.xml:472(literal)
|
||||
msgid "s.get(Payment.class, id)"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:451(literal) inheritance_mapping.xml:462(literal) inheritance_mapping.xml:473(literal) inheritance_mapping.xml:484(literal)
|
||||
msgid "from Payment p"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:452(literal) inheritance_mapping.xml:463(literal) inheritance_mapping.xml:474(literal)
|
||||
msgid "from Order o join o.payment p"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:453(emphasis) inheritance_mapping.xml:464(emphasis) inheritance_mapping.xml:475(emphasis)
|
||||
msgid "supported"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:467(entry)
|
||||
msgid "table per concrete-class (union-subclass)"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:470(literal)
|
||||
msgid "inverse=\"true\""
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:470(entry)
|
||||
msgid "<placeholder-1/> (for <placeholder-2/> only)"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:478(entry)
|
||||
msgid "table per concrete class (implicit polymorphism)"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:479(literal)
|
||||
msgid "<any>"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:480(emphasis) inheritance_mapping.xml:481(emphasis) inheritance_mapping.xml:485(emphasis) inheritance_mapping.xml:486(emphasis)
|
||||
msgid "not supported"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:482(literal)
|
||||
msgid "<many-to-any>"
|
||||
msgstr ""
|
||||
|
||||
#: inheritance_mapping.xml:483(literal)
|
||||
msgid "s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: inheritance_mapping.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,808 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:32-0500\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"
|
||||
|
||||
#: performance.xml:5(title)
|
||||
msgid "Improving performance"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:8(title)
|
||||
msgid "Fetching strategies"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:10(para)
|
||||
msgid "A <emphasis>fetching strategy</emphasis> is the strategy Hibernate will use for retrieving associated objects if the application needs to navigate the association. Fetch strategies may be declared in the O/R mapping metadata, or over-ridden by a particular HQL or <literal>Criteria</literal> query."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:17(para)
|
||||
msgid "Hibernate3 defines the following fetching strategies:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:23(para)
|
||||
msgid "<emphasis>Join fetching</emphasis> - Hibernate retrieves the associated instance or collection in the same <literal>SELECT</literal>, using an <literal>OUTER JOIN</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:30(para)
|
||||
msgid "<emphasis>Select fetching</emphasis> - a second <literal>SELECT</literal> is used to retrieve the associated entity or collection. Unless you explicitly disable lazy fetching by specifying <literal>lazy=\"false\"</literal>, this second select will only be executed when you actually access the association."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:39(para)
|
||||
msgid "<emphasis>Subselect fetching</emphasis> - a second <literal>SELECT</literal> is used to retrieve the associated collections for all entities retrieved in a previous query or fetch. Unless you explicitly disable lazy fetching by specifying <literal>lazy=\"false\"</literal>, this second select will only be executed when you actually access the association."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:48(para)
|
||||
msgid "<emphasis>Batch fetching</emphasis> - an optimization strategy for select fetching - Hibernate retrieves a batch of entity instances or collections in a single <literal>SELECT</literal>, by specifying a list of primary keys or foreign keys."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:57(para)
|
||||
msgid "Hibernate also distinguishes between:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:63(para)
|
||||
msgid "<emphasis>Immediate fetching</emphasis> - an association, collection or attribute is fetched immediately, when the owner is loaded."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:69(para)
|
||||
msgid "<emphasis>Lazy collection fetching</emphasis> - a collection is fetched when the application invokes an operation upon that collection. (This is the default for collections.)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:76(para)
|
||||
msgid "<emphasis>\"Extra-lazy\" collection fetching</emphasis> - individual elements of the collection are accessed from the database as needed. Hibernate tries not to fetch the whole collection into memory unless absolutely needed (suitable for very large collections)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:84(para)
|
||||
msgid "<emphasis>Proxy fetching</emphasis> - a single-valued association is fetched when a method other than the identifier getter is invoked upon the associated object."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:91(para)
|
||||
msgid "<emphasis>\"No-proxy\" fetching</emphasis> - a single-valued association is fetched when the instance variable is accessed. Compared to proxy fetching, this approach is less lazy (the association is fetched even when only the identifier is accessed) but more transparent, since no proxy is visible to the application. This approach requires buildtime bytecode instrumentation and is rarely necessary."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:101(para)
|
||||
msgid "<emphasis>Lazy attribute fetching</emphasis> - an attribute or single valued association is fetched when the instance variable is accessed. This approach requires buildtime bytecode instrumentation and is rarely necessary."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:110(para)
|
||||
msgid "We have two orthogonal notions here: <emphasis>when</emphasis> is the association fetched, and <emphasis>how</emphasis> is it fetched (what SQL is used). Don't confuse them! We use <literal>fetch</literal> to tune performance. We may use <literal>lazy</literal> to define a contract for what data is always available in any detached instance of a particular class."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:119(title)
|
||||
msgid "Working with lazy associations"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:121(para)
|
||||
msgid "By default, Hibernate3 uses lazy select fetching for collections and lazy proxy fetching for single-valued associations. These defaults make sense for almost all associations in almost all applications."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:127(para)
|
||||
msgid "<emphasis>Note:</emphasis> if you set <literal>hibernate.default_batch_fetch_size</literal>, Hibernate will use the batch fetch optimization for lazy fetching (this optimization may also be enabled at a more granular level)."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:134(para)
|
||||
msgid "However, lazy fetching poses one problem that you must be aware of. Access to a lazy association outside of the context of an open Hibernate session will result in an exception. For example:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:152(para)
|
||||
msgid "Since the permissions collection was not initialized when the <literal>Session</literal> was closed, the collection will not be able to load its state. <emphasis>Hibernate does not support lazy initialization for detached objects</emphasis>. The fix is to move the code that reads from the collection to just before the transaction is committed."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:160(para)
|
||||
msgid "Alternatively, we could use a non-lazy collection or association, by specifying <literal>lazy=\"false\"</literal> for the association mapping. However, it is intended that lazy initialization be used for almost all collections and associations. If you define too many non-lazy associations in your object model, Hibernate will end up needing to fetch the entire database into memory in every transaction!"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:169(para)
|
||||
msgid "On the other hand, we often want to choose join fetching (which is non-lazy by nature) instead of select fetching in a particular transaction. We'll now see how to customize the fetching strategy. In Hibernate3, the mechanisms for choosing a fetch strategy are identical for single-valued associations and collections."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:180(title)
|
||||
msgid "Tuning fetch strategies"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:182(para)
|
||||
msgid "Select fetching (the default) is extremely vulnerable to N+1 selects problems, so we might want to enable join fetching in the mapping document:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:195(para)
|
||||
msgid "The <literal>fetch</literal> strategy defined in the mapping document affects:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:201(para)
|
||||
msgid "retrieval via <literal>get()</literal> or <literal>load()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:206(para)
|
||||
msgid "retrieval that happens implicitly when an association is navigated"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:211(para)
|
||||
msgid "<literal>Criteria</literal> queries"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:216(para)
|
||||
msgid "HQL queries if <literal>subselect</literal> fetching is used"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:222(para)
|
||||
msgid "No matter what fetching strategy you use, the defined non-lazy graph is guaranteed to be loaded into memory. Note that this might result in several immediate selects being used to execute a particular HQL query."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:228(para)
|
||||
msgid "Usually, we don't use the mapping document to customize fetching. Instead, we keep the default behavior, and override it for a particular transaction, using <literal>left join fetch</literal> in HQL. This tells Hibernate to fetch the association eagerly in the first select, using an outer join. In the <literal>Criteria</literal> query API, you would use <literal>setFetchMode(FetchMode.JOIN)</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:237(para)
|
||||
msgid "If you ever feel like you wish you could change the fetching strategy used by <literal>get()</literal> or <literal>load()</literal>, simply use a <literal>Criteria</literal> query, for example:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:248(para)
|
||||
msgid "(This is Hibernate's equivalent of what some ORM solutions call a \"fetch plan\".)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:252(para)
|
||||
msgid "A completely different way to avoid problems with N+1 selects is to use the second-level cache."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:260(title)
|
||||
msgid "Single-ended association proxies"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:262(para)
|
||||
msgid "Lazy fetching for collections is implemented using Hibernate's own implementation of persistent collections. However, a different mechanism is needed for lazy behavior in single-ended associations. The target entity of the association must be proxied. Hibernate implements lazy initializing proxies for persistent objects using runtime bytecode enhancement (via the excellent CGLIB library)."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:270(para)
|
||||
msgid "By default, Hibernate3 generates proxies (at startup) for all persistent classes and uses them to enable lazy fetching of <literal>many-to-one</literal> and <literal>one-to-one</literal> associations."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:276(para)
|
||||
msgid "The mapping file may declare an interface to use as the proxy interface for that class, with the <literal>proxy</literal> attribute. By default, Hibernate uses a subclass of the class. <emphasis>Note that the proxied class must implement a default constructor with at least package visibility. We recommend this constructor for all persistent classes!</emphasis>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:283(para)
|
||||
msgid "There are some gotchas to be aware of when extending this approach to polymorphic classes, eg."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:295(para)
|
||||
msgid "Firstly, instances of <literal>Cat</literal> will never be castable to <literal>DomesticCat</literal>, even if the underlying instance is an instance of <literal>DomesticCat</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:307(para)
|
||||
msgid "Secondly, it is possible to break proxy <literal>==</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:316(para)
|
||||
msgid "However, the situation is not quite as bad as it looks. Even though we now have two references to different proxy objects, the underlying instance will still be the same object:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:324(para)
|
||||
msgid "Third, you may not use a CGLIB proxy for a <literal>final</literal> class or a class with any <literal>final</literal> methods."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:329(para)
|
||||
msgid "Finally, if your persistent object acquires any resources upon instantiation (eg. in initializers or default constructor), then those resources will also be acquired by the proxy. The proxy class is an actual subclass of the persistent class."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:335(para)
|
||||
msgid "These problems are all due to fundamental limitations in Java's single inheritance model. If you wish to avoid these problems your persistent classes must each implement an interface that declares its business methods. You should specify these interfaces in the mapping file. eg."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:348(para)
|
||||
msgid "where <literal>CatImpl</literal> implements the interface <literal>Cat</literal> and <literal>DomesticCatImpl</literal> implements the interface <literal>DomesticCat</literal>. Then proxies for instances of <literal>Cat</literal> and <literal>DomesticCat</literal> may be returned by <literal>load()</literal> or <literal>iterate()</literal>. (Note that <literal>list()</literal> does not usually return proxies.)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:360(para)
|
||||
msgid "Relationships are also lazily initialized. This means you must declare any properties to be of type <literal>Cat</literal>, not <literal>CatImpl</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:365(para)
|
||||
msgid "Certain operations do <emphasis>not</emphasis> require proxy initialization"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:371(para)
|
||||
msgid "<literal>equals()</literal>, if the persistent class does not override <literal>equals()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:377(para)
|
||||
msgid "<literal>hashCode()</literal>, if the persistent class does not override <literal>hashCode()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:383(para)
|
||||
msgid "The identifier getter method"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:389(para)
|
||||
msgid "Hibernate will detect persistent classes that override <literal>equals()</literal> or <literal>hashCode()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:394(para)
|
||||
msgid "By choosing <literal>lazy=\"no-proxy\"</literal> instead of the default <literal>lazy=\"proxy\"</literal>, we can avoid the problems associated with typecasting. However, we will require buildtime bytecode instrumentation, and all operations will result in immediate proxy initialization."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:404(title)
|
||||
msgid "Initializing collections and proxies"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:406(para)
|
||||
msgid "A <literal>LazyInitializationException</literal> will be thrown by Hibernate if an uninitialized collection or proxy is accessed outside of the scope of the <literal>Session</literal>, ie. when the entity owning the collection or having the reference to the proxy is in the detached state."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:412(para)
|
||||
msgid "Sometimes we need to ensure that a proxy or collection is initialized before closing the <literal>Session</literal>. Of course, we can alway force initialization by calling <literal>cat.getSex()</literal> or <literal>cat.getKittens().size()</literal>, for example. But that is confusing to readers of the code and is not convenient for generic code."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:419(para)
|
||||
msgid "The static methods <literal>Hibernate.initialize()</literal> and <literal>Hibernate.isInitialized()</literal> provide the application with a convenient way of working with lazily initialized collections or proxies. <literal>Hibernate.initialize(cat)</literal> will force the initialization of a proxy, <literal>cat</literal>, as long as its <literal>Session</literal> is still open. <literal>Hibernate.initialize( cat.getKittens() )</literal> has a similar effect for the collection of kittens."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:428(para)
|
||||
msgid "Another option is to keep the <literal>Session</literal> open until all needed collections and proxies have been loaded. In some application architectures, particularly where the code that accesses data using Hibernate, and the code that uses it are in different application layers or different physical processes, it can be a problem to ensure that the <literal>Session</literal> is open when a collection is initialized. There are two basic ways to deal with this issue:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:439(para)
|
||||
msgid "In a web-based application, a servlet filter can be used to close the <literal>Session</literal> only at the very end of a user request, once the rendering of the view is complete (the <emphasis>Open Session in View</emphasis> pattern). Of course, this places heavy demands on the correctness of the exception handling of your application infrastructure. It is vitally important that the <literal>Session</literal> is closed and the transaction ended before returning to the user, even when an exception occurs during rendering of the view. See the Hibernate Wiki for examples of this \"Open Session in View\" pattern."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:452(para)
|
||||
msgid "In an application with a separate business tier, the business logic must \"prepare\" all collections that will be needed by the web tier before returning. This means that the business tier should load all the data and return all the data already initialized to the presentation/web tier that is required for a particular use case. Usually, the application calls <literal>Hibernate.initialize()</literal> for each collection that will be needed in the web tier (this call must occur before the session is closed) or retrieves the collection eagerly using a Hibernate query with a <literal>FETCH</literal> clause or a <literal>FetchMode.JOIN</literal> in <literal>Criteria</literal>. This is usually easier if you adopt the <emphasis>Command</emphasis> pattern instead of a <emphasis>Session Facade</emphasis>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:467(para)
|
||||
msgid "You may also attach a previously loaded object to a new <literal>Session</literal> with <literal>merge()</literal> or <literal>lock()</literal> before accessing uninitialized collections (or other proxies). No, Hibernate does not, and certainly <emphasis>should</emphasis> not do this automatically, since it would introduce ad hoc transaction semantics!"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:477(para)
|
||||
msgid "Sometimes you don't want to initialize a large collection, but still need some information about it (like its size) or a subset of the data."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:482(para)
|
||||
msgid "You can use a collection filter to get the size of a collection without initializing it:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:488(para)
|
||||
msgid "The <literal>createFilter()</literal> method is also used to efficiently retrieve subsets of a collection without needing to initialize the whole collection:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:498(title)
|
||||
msgid "Using batch fetching"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:500(para)
|
||||
msgid "Hibernate can make efficient use of batch fetching, that is, Hibernate can load several uninitialized proxies if one proxy is accessed (or collections. Batch fetching is an optimization of the lazy select fetching strategy. There are two ways you can tune batch fetching: on the class and the collection level."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:506(para)
|
||||
msgid "Batch fetching for classes/entities is easier to understand. Imagine you have the following situation at runtime: You have 25 <literal>Cat</literal> instances loaded in a <literal>Session</literal>, each <literal>Cat</literal> has a reference to its <literal>owner</literal>, a <literal>Person</literal>. The <literal>Person</literal> class is mapped with a proxy, <literal>lazy=\"true\"</literal>. If you now iterate through all cats and call <literal>getOwner()</literal> on each, Hibernate will by default execute 25 <literal>SELECT</literal> statements, to retrieve the proxied owners. You can tune this behavior by specifying a <literal>batch-size</literal> in the mapping of <literal>Person</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:518(para)
|
||||
msgid "Hibernate will now execute only three queries, the pattern is 10, 10, 5."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:522(para)
|
||||
msgid "You may also enable batch fetching of collections. For example, if each <literal>Person</literal> has a lazy collection of <literal>Cat</literal>s, and 10 persons are currently loaded in the <literal>Sesssion</literal>, iterating through all persons will generate 10 <literal>SELECT</literal>s, one for every call to <literal>getCats()</literal>. If you enable batch fetching for the <literal>cats</literal> collection in the mapping of <literal>Person</literal>, Hibernate can pre-fetch collections:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:537(para)
|
||||
msgid "With a <literal>batch-size</literal> of 3, Hibernate will load 3, 3, 3, 1 collections in four <literal>SELECT</literal>s. Again, the value of the attribute depends on the expected number of uninitialized collections in a particular <literal>Session</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:543(para)
|
||||
msgid "Batch fetching of collections is particularly useful if you have a nested tree of items, ie. the typical bill-of-materials pattern. (Although a <emphasis>nested set</emphasis> or a <emphasis>materialized path</emphasis> might be a better option for read-mostly trees.)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:552(title)
|
||||
msgid "Using subselect fetching"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:554(para)
|
||||
msgid "If one lazy collection or single-valued proxy has to be fetched, Hibernate loads all of them, re-running the original query in a subselect. This works in the same way as batch-fetching, without the piecemeal loading."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:565(title)
|
||||
msgid "Using lazy property fetching"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:567(para)
|
||||
msgid "Hibernate3 supports the lazy fetching of individual properties. This optimization technique is also known as <emphasis>fetch groups</emphasis>. Please note that this is mostly a marketing feature, as in practice, optimizing row reads is much more important than optimization of column reads. However, only loading some properties of a class might be useful in extreme cases, when legacy tables have hundreds of columns and the data model can not be improved."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:576(para)
|
||||
msgid "To enable lazy property loading, set the <literal>lazy</literal> attribute on your particular property mappings:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:590(para)
|
||||
msgid "Lazy property loading requires buildtime bytecode instrumentation! If your persistent classes are not enhanced, Hibernate will silently ignore lazy property settings and fall back to immediate fetching."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:596(para)
|
||||
msgid "For bytecode instrumentation, use the following Ant task:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:614(para)
|
||||
msgid "A different (better?) way to avoid unnecessary column reads, at least for read-only transactions is to use the projection features of HQL or Criteria queries. This avoids the need for buildtime bytecode processing and is certainly a prefered solution."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:621(para)
|
||||
msgid "You may force the usual eager fetching of properties using <literal>fetch all properties</literal> in HQL."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:631(title)
|
||||
msgid "The Second Level Cache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:633(para)
|
||||
msgid "A Hibernate <literal>Session</literal> is a transaction-level cache of persistent data. It is possible to configure a cluster or JVM-level (<literal>SessionFactory</literal>-level) cache on a class-by-class and collection-by-collection basis. You may even plug in a clustered cache. Be careful. Caches are never aware of changes made to the persistent store by another application (though they may be configured to regularly expire cached data)."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:641(para)
|
||||
msgid "You have the option to tell Hibernate which caching implementation to use by specifying the name of a class that implements <literal>org.hibernate.cache.CacheProvider</literal> using the property <literal>hibernate.cache.provider_class</literal>. Hibernate comes bundled with a number of built-in integrations with open-source cache providers (listed below); additionally, you could implement your own and plug it in as outlined above. Note that versions prior to 3.2 defaulted to use EhCache as the default cache provider; that is no longer the case as of 3.2."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:652(title)
|
||||
msgid "Cache Providers"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:661(entry) performance.xml:848(entry)
|
||||
msgid "Cache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:662(entry)
|
||||
msgid "Provider class"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:663(entry)
|
||||
msgid "Type"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:664(entry)
|
||||
msgid "Cluster Safe"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:665(entry)
|
||||
msgid "Query Cache Supported"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:670(entry) performance.xml:857(entry)
|
||||
msgid "Hashtable (not intended for production use)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:671(literal)
|
||||
msgid "org.hibernate.cache.HashtableCacheProvider"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:672(entry)
|
||||
msgid "memory"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:674(entry) performance.xml:681(entry) performance.xml:688(entry) performance.xml:858(entry) performance.xml:859(entry) performance.xml:860(entry) performance.xml:865(entry) performance.xml:866(entry) performance.xml:867(entry) performance.xml:872(entry) performance.xml:873(entry) performance.xml:874(entry) performance.xml:879(entry) performance.xml:880(entry) performance.xml:886(entry) performance.xml:889(entry)
|
||||
msgid "yes"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:677(entry) performance.xml:864(entry)
|
||||
msgid "EHCache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:678(literal)
|
||||
msgid "org.hibernate.cache.EhCacheProvider"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:679(entry) performance.xml:686(entry)
|
||||
msgid "memory, disk"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:684(entry) performance.xml:871(entry)
|
||||
msgid "OSCache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:685(literal)
|
||||
msgid "org.hibernate.cache.OSCacheProvider"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:691(entry) performance.xml:878(entry)
|
||||
msgid "SwarmCache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:692(literal)
|
||||
msgid "org.hibernate.cache.SwarmCacheProvider"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:693(entry)
|
||||
msgid "clustered (ip multicast)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:694(entry)
|
||||
msgid "yes (clustered invalidation)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:698(entry) performance.xml:885(entry)
|
||||
msgid "JBoss TreeCache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:699(literal)
|
||||
msgid "org.hibernate.cache.TreeCacheProvider"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:700(entry)
|
||||
msgid "clustered (ip multicast), transactional"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:701(entry)
|
||||
msgid "yes (replication)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:702(entry)
|
||||
msgid "yes (clock sync req.)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:709(title)
|
||||
msgid "Cache mappings"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:711(para)
|
||||
msgid "The <literal><cache></literal> element of a class or collection mapping has the following form:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:729(para)
|
||||
msgid "<literal>usage</literal> (required) specifies the caching strategy: <literal>transactional</literal>, <literal>read-write</literal>, <literal>nonstrict-read-write</literal> or <literal>read-only</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:738(para)
|
||||
msgid "<literal>region</literal> (optional, defaults to the class or collection role name) specifies the name of the second level cache region"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:745(para)
|
||||
msgid "<literal>include</literal> (optional, defaults to <literal>all</literal>) <literal>non-lazy</literal> specifies that properties of the entity mapped with <literal>lazy=\"true\"</literal> may not be cached when attribute-level lazy fetching is enabled"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:755(para)
|
||||
msgid "Alternatively (preferrably?), you may specify <literal><class-cache></literal> and <literal><collection-cache></literal> elements in <literal>hibernate.cfg.xml</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:760(para)
|
||||
msgid "The <literal>usage</literal> attribute specifies a <emphasis>cache concurrency strategy</emphasis>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:767(title)
|
||||
msgid "Strategy: read only"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:769(para)
|
||||
msgid "If your application needs to read but never modify instances of a persistent class, a <literal>read-only</literal> cache may be used. This is the simplest and best performing strategy. It's even perfectly safe for use in a cluster."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:784(title)
|
||||
msgid "Strategy: read/write"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:786(para)
|
||||
msgid "If the application needs to update data, a <literal>read-write</literal> cache might be appropriate. This cache strategy should never be used if serializable transaction isolation level is required. If the cache is used in a JTA environment, you must specify the property <literal>hibernate.transaction.manager_lookup_class</literal>, naming a strategy for obtaining the JTA <literal>TransactionManager</literal>. In other environments, you should ensure that the transaction is completed when <literal>Session.close()</literal> or <literal>Session.disconnect()</literal> is called. If you wish to use this strategy in a cluster, you should ensure that the underlying cache implementation supports locking. The built-in cache providers do <emphasis>not</emphasis>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:809(title)
|
||||
msgid "Strategy: nonstrict read/write"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:811(para)
|
||||
msgid "If the application only occasionally needs to update data (ie. if it is extremely unlikely that two transactions would try to update the same item simultaneously) and strict transaction isolation is not required, a <literal>nonstrict-read-write</literal> cache might be appropriate. If the cache is used in a JTA environment, you must specify <literal>hibernate.transaction.manager_lookup_class</literal>. In other environments, you should ensure that the transaction is completed when <literal>Session.close()</literal> or <literal>Session.disconnect()</literal> is called."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:823(title)
|
||||
msgid "Strategy: transactional"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:825(para)
|
||||
msgid "The <literal>transactional</literal> cache strategy provides support for fully transactional cache providers such as JBoss TreeCache. Such a cache may only be used in a JTA environment and you must specify <literal>hibernate.transaction.manager_lookup_class</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:833(para)
|
||||
msgid "None of the cache providers support all of the cache concurrency strategies. The following table shows which providers are compatible with which concurrency strategies."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:839(title)
|
||||
msgid "Cache Concurrency Strategy Support"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:849(entry)
|
||||
msgid "read-only"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:850(entry)
|
||||
msgid "nonstrict-read-write"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:851(entry)
|
||||
msgid "read-write"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:852(entry)
|
||||
msgid "transactional"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:898(title)
|
||||
msgid "Managing the caches"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:900(para)
|
||||
msgid "Whenever you pass an object to <literal>save()</literal>, <literal>update()</literal> or <literal>saveOrUpdate()</literal> and whenever you retrieve an object using <literal>load()</literal>, <literal>get()</literal>, <literal>list()</literal>, <literal>iterate()</literal> or <literal>scroll()</literal>, that object is added to the internal cache of the <literal>Session</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:907(para)
|
||||
msgid "When <literal>flush()</literal> is subsequently called, the state of that object will be synchronized with the database. If you do not want this synchronization to occur or if you are processing a huge number of objects and need to manage memory efficiently, the <literal>evict()</literal> method may be used to remove the object and its collections from the first-level cache."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:922(para)
|
||||
msgid "The <literal>Session</literal> also provides a <literal>contains()</literal> method to determine if an instance belongs to the session cache."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:927(para)
|
||||
msgid "To completely evict all objects from the session cache, call <literal>Session.clear()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:931(para)
|
||||
msgid "For the second-level cache, there are methods defined on <literal>SessionFactory</literal> for evicting the cached state of an instance, entire class, collection instance or entire collection role."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:942(para)
|
||||
msgid "The <literal>CacheMode</literal> controls how a particular session interacts with the second-level cache."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:949(para)
|
||||
msgid "<literal>CacheMode.NORMAL</literal> - read items from and write items to the second-level cache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:954(para)
|
||||
msgid "<literal>CacheMode.GET</literal> - read items from the second-level cache, but don't write to the second-level cache except when updating data"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:960(para)
|
||||
msgid "<literal>CacheMode.PUT</literal> - write items to the second-level cache, but don't read from the second-level cache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:966(para)
|
||||
msgid "<literal>CacheMode.REFRESH</literal> - write items to the second-level cache, but don't read from the second-level cache, bypass the effect of <literal>hibernate.cache.use_minimal_puts</literal>, forcing a refresh of the second-level cache for all items read from the database"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:974(para)
|
||||
msgid "To browse the contents of a second-level or query cache region, use the <literal>Statistics</literal> API:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:983(para)
|
||||
msgid "You'll need to enable statistics, and, optionally, force Hibernate to keep the cache entries in a more human-understandable format:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:994(title)
|
||||
msgid "The Query Cache"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:996(para)
|
||||
msgid "Query result sets may also be cached. This is only useful for queries that are run frequently with the same parameters. To use the query cache you must first enable it:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1003(para)
|
||||
msgid "This setting causes the creation of two new cache regions - one holding cached query result sets (<literal>org.hibernate.cache.StandardQueryCache</literal>), the other holding timestamps of the most recent updates to queryable tables (<literal>org.hibernate.cache.UpdateTimestampsCache</literal>). Note that the query cache does not cache the state of the actual entities in the result set; it caches only identifier values and results of value type. So the query cache should always be used in conjunction with the second-level cache."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1013(para)
|
||||
msgid "Most queries do not benefit from caching, so by default queries are not cached. To enable caching, call <literal>Query.setCacheable(true)</literal>. This call allows the query to look for existing cache results or add its results to the cache when it is executed."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1020(para)
|
||||
msgid "If you require fine-grained control over query cache expiration policies, you may specify a named cache region for a particular query by calling <literal>Query.setCacheRegion()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1033(para)
|
||||
msgid "If the query should force a refresh of its query cache region, you should call <literal>Query.setCacheMode(CacheMode.REFRESH)</literal>. This is particularly useful in cases where underlying data may have been updated via a separate process (i.e., not modified through Hibernate) and allows the application to selectively refresh particular query result sets. This is a more efficient alternative to eviction of a query cache region via <literal>SessionFactory.evictQueries()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1045(title)
|
||||
msgid "Understanding Collection performance"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1047(para)
|
||||
msgid "We've already spent quite some time talking about collections. In this section we will highlight a couple more issues about how collections behave at runtime."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1054(title)
|
||||
msgid "Taxonomy"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1056(para)
|
||||
msgid "Hibernate defines three basic kinds of collections:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1060(para)
|
||||
msgid "collections of values"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1063(para)
|
||||
msgid "one to many associations"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1066(para)
|
||||
msgid "many to many associations"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1070(para)
|
||||
msgid "This classification distinguishes the various table and foreign key relationships but does not tell us quite everything we need to know about the relational model. To fully understand the relational structure and performance characteristics, we must also consider the structure of the primary key that is used by Hibernate to update or delete collection rows. This suggests the following classification:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1081(para)
|
||||
msgid "indexed collections"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1084(para)
|
||||
msgid "sets"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1087(para)
|
||||
msgid "bags"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1091(para)
|
||||
msgid "All indexed collections (maps, lists, arrays) have a primary key consisting of the <literal><key></literal> and <literal><index></literal> columns. In this case collection updates are usually extremely efficient - the primary key may be efficiently indexed and a particular row may be efficiently located when Hibernate tries to update or delete it."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1099(para)
|
||||
msgid "Sets have a primary key consisting of <literal><key></literal> and element columns. This may be less efficient for some types of collection element, particularly composite elements or large text or binary fields; the database may not be able to index a complex primary key as efficently. On the other hand, for one to many or many to many associations, particularly in the case of synthetic identifiers, it is likely to be just as efficient. (Side-note: if you want <literal>SchemaExport</literal> to actually create the primary key of a <literal><set></literal> for you, you must declare all columns as <literal>not-null=\"true\"</literal>.)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1110(para)
|
||||
msgid "<literal><idbag></literal> mappings define a surrogate key, so they are always very efficient to update. In fact, they are the best case."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1115(para)
|
||||
msgid "Bags are the worst case. Since a bag permits duplicate element values and has no index column, no primary key may be defined. Hibernate has no way of distinguishing between duplicate rows. Hibernate resolves this problem by completely removing (in a single <literal>DELETE</literal>) and recreating the collection whenever it changes. This might be very inefficient."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1123(para)
|
||||
msgid "Note that for a one-to-many association, the \"primary key\" may not be the physical primary key of the database table - but even in this case, the above classification is still useful. (It still reflects how Hibernate \"locates\" individual rows of the collection.)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1133(title)
|
||||
msgid "Lists, maps, idbags and sets are the most efficient collections to update"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1135(para)
|
||||
msgid "From the discussion above, it should be clear that indexed collections and (usually) sets allow the most efficient operation in terms of adding, removing and updating elements."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1141(para)
|
||||
msgid "There is, arguably, one more advantage that indexed collections have over sets for many to many associations or collections of values. Because of the structure of a <literal>Set</literal>, Hibernate doesn't ever <literal>UPDATE</literal> a row when an element is \"changed\". Changes to a <literal>Set</literal> always work via <literal>INSERT</literal> and <literal>DELETE</literal> (of individual rows). Once again, this consideration does not apply to one to many associations."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1150(para)
|
||||
msgid "After observing that arrays cannot be lazy, we would conclude that lists, maps and idbags are the most performant (non-inverse) collection types, with sets not far behind. Sets are expected to be the most common kind of collection in Hibernate applications. This is because the \"set\" semantics are most natural in the relational model."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1158(para)
|
||||
msgid "However, in well-designed Hibernate domain models, we usually see that most collections are in fact one-to-many associations with <literal>inverse=\"true\"</literal>. For these associations, the update is handled by the many-to-one end of the association, and so considerations of collection update performance simply do not apply."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1168(title)
|
||||
msgid "Bags and lists are the most efficient inverse collections"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1170(para)
|
||||
msgid "Just before you ditch bags forever, there is a particular case in which bags (and also lists) are much more performant than sets. For a collection with <literal>inverse=\"true\"</literal> (the standard bidirectional one-to-many relationship idiom, for example) we can add elements to a bag or list without needing to initialize (fetch) the bag elements! This is because <literal>Collection.add()</literal> or <literal>Collection.addAll()</literal> must always return true for a bag or <literal>List</literal> (unlike a <literal>Set</literal>). This can make the following common code much faster."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1189(title)
|
||||
msgid "One shot delete"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1191(para)
|
||||
msgid "Occasionally, deleting collection elements one by one can be extremely inefficient. Hibernate isn't completely stupid, so it knows not to do that in the case of an newly-empty collection (if you called <literal>list.clear()</literal>, for example). In this case, Hibernate will issue a single <literal>DELETE</literal> and we are done!"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1198(para)
|
||||
msgid "Suppose we add a single element to a collection of size twenty and then remove two elements. Hibernate will issue one <literal>INSERT</literal> statement and two <literal>DELETE</literal> statements (unless the collection is a bag). This is certainly desirable."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1204(para)
|
||||
msgid "However, suppose that we remove eighteen elements, leaving two and then add thee new elements. There are two possible ways to proceed"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1211(para)
|
||||
msgid "delete eighteen rows one by one and then insert three rows"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1214(para)
|
||||
msgid "remove the whole collection (in one SQL <literal>DELETE</literal>) and insert all five current elements (one by one)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1219(para)
|
||||
msgid "Hibernate isn't smart enough to know that the second option is probably quicker in this case. (And it would probably be undesirable for Hibernate to be that smart; such behaviour might confuse database triggers, etc.)"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1225(para)
|
||||
msgid "Fortunately, you can force this behaviour (ie. the second strategy) at any time by discarding (ie. dereferencing) the original collection and returning a newly instantiated collection with all the current elements. This can be very useful and powerful from time to time."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1231(para)
|
||||
msgid "Of course, one-shot-delete does not apply to collections mapped <literal>inverse=\"true\"</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1240(title)
|
||||
msgid "Monitoring performance"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1242(para)
|
||||
msgid "Optimization is not much use without monitoring and access to performance numbers. Hibernate provides a full range of figures about its internal operations. Statistics in Hibernate are available per <literal>SessionFactory</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1249(title)
|
||||
msgid "Monitoring a SessionFactory"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1251(para)
|
||||
msgid "You can access <literal>SessionFactory</literal> metrics in two ways. Your first option is to call <literal>sessionFactory.getStatistics()</literal> and read or display the <literal>Statistics</literal> yourself."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1257(para)
|
||||
msgid "Hibernate can also use JMX to publish metrics if you enable the <literal>StatisticsService</literal> MBean. You may enable a single MBean for all your <literal>SessionFactory</literal> or one per factory. See the following code for minimalistic configuration examples:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1284(para)
|
||||
msgid "TODO: This doesn't make sense: In the first case, we retrieve and use the MBean directly. In the second one, we must give the JNDI name in which the session factory is held before using it. Use <literal>hibernateStatsBean.setSessionFactoryJNDIName(\"my/JNDI/Name\")</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1289(para)
|
||||
msgid "You can (de)activate the monitoring for a <literal>SessionFactory</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1294(para)
|
||||
msgid "at configuration time, set <literal>hibernate.generate_statistics</literal> to <literal>false</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1301(para)
|
||||
msgid "at runtime: <literal>sf.getStatistics().setStatisticsEnabled(true)</literal> or <literal>hibernateStatsBean.setStatisticsEnabled(true)</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1308(para)
|
||||
msgid "Statistics can be reset programatically using the <literal>clear()</literal> method. A summary can be sent to a logger (info level) using the <literal>logSummary()</literal> method."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1317(title)
|
||||
msgid "Metrics"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1319(para)
|
||||
msgid "Hibernate provides a number of metrics, from very basic to the specialized information only relevant in certain scenarios. All available counters are described in the <literal>Statistics</literal> interface API, in three categories:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1326(para)
|
||||
msgid "Metrics related to the general <literal>Session</literal> usage, such as number of open sessions, retrieved JDBC connections, etc."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1332(para)
|
||||
msgid "Metrics related to he entities, collections, queries, and caches as a whole (aka global metrics),"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1338(para)
|
||||
msgid "Detailed metrics related to a particular entity, collection, query or cache region."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1345(para)
|
||||
msgid "For exampl,e you can check the cache hit, miss, and put ratio of entities, collections and queries, and the average time a query needs. Beware that the number of milliseconds is subject to approximation in Java. Hibernate is tied to the JVM precision, on some platforms this might even only be accurate to 10 seconds."
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1352(para)
|
||||
msgid "Simple getters are used to access the global metrics (i.e. not tied to a particular entity, collection, cache region, etc.). You can access the metrics of a particular entity, collection or cache region through its name, and through its HQL or SQL representation for queries. Please refer to the <literal>Statistics</literal>, <literal>EntityStatistics</literal>, <literal>CollectionStatistics</literal>, <literal>SecondLevelCacheStatistics</literal>, and <literal>QueryStatistics</literal> API Javadoc for more information. The following code shows a simple example:"
|
||||
msgstr ""
|
||||
|
||||
#: performance.xml:1379(para)
|
||||
msgid "To work on all entities, collections, queries and region caches, you can retrieve the list of names of entities, collections, queries and region caches with the following methods: <literal>getQueries()</literal>, <literal>getEntityNames()</literal>, <literal>getCollectionRoleNames()</literal>, and <literal>getSecondLevelCacheRegionNames()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: performance.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:33-0500\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"
|
||||
|
||||
#: persistent_classes.xml:5(title)
|
||||
msgid "Persistent Classes"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:7(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:14(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:23(title)
|
||||
msgid "A simple POJO example"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:25(para)
|
||||
msgid "Most Java applications require a persistent class representing felines."
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:108(para)
|
||||
msgid "There are four main rules to follow here:"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:114(title)
|
||||
msgid "Implement a no-argument constructor"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:116(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:126(title)
|
||||
msgid "Provide an identifier property (optional)"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:128(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:137(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:142(para)
|
||||
msgid "In fact, some functionality is available only to classes which declare an identifier property:"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:149(para)
|
||||
msgid "Transitive reattachment for detached objects (cascade update or cascade merge) - see <xref linkend=\"objectstate-transitive\"/>"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:156(literal)
|
||||
msgid "Session.saveOrUpdate()"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:161(literal)
|
||||
msgid "Session.merge()"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:166(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:173(title)
|
||||
msgid "Prefer non-final classes (optional)"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:174(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:179(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:184(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:192(title)
|
||||
msgid "Declare accessors and mutators for persistent fields (optional)"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:194(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:204(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:215(title)
|
||||
msgid "Implementing inheritance"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:217(para)
|
||||
msgid "A subclass must also observe the first and second rules. It inherits its identifier property from the superclass, <literal>Cat</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:237(title)
|
||||
msgid "Implementing <literal>equals()</literal> and <literal>hashCode()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:239(para)
|
||||
msgid "You have to override the <literal>equals()</literal> and <literal>hashCode()</literal> methods if you"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:245(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:252(para)
|
||||
msgid "intend to use reattachment of detached instances"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:258(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:266(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:280(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:312(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:322(title)
|
||||
msgid "Dynamic models"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:325(emphasis)
|
||||
msgid "Note that the following features are currently considered experimental and may change in the near future."
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:329(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:337(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:344(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:384(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:391(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:419(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:427(para)
|
||||
msgid "Entity representation modes can also be set on a per <literal>Session</literal> basis:"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:446(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:456(para)
|
||||
msgid "More information about the XML representation capabilities can be found in <xref linkend=\"xml\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:464(title)
|
||||
msgid "Tuplizers"
|
||||
msgstr ""
|
||||
|
||||
#: persistent_classes.xml:466(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:481(para)
|
||||
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 ""
|
||||
|
||||
#: persistent_classes.xml:529(para)
|
||||
msgid "TODO: Document user-extension framework in the property and proxy packages"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: persistent_classes.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:33-0500\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"
|
||||
|
||||
#: preface.xml:21(title)
|
||||
msgid "Preface"
|
||||
msgstr ""
|
||||
|
||||
#: preface.xml:23(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:31(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:38(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:48(para)
|
||||
msgid "If you are new to Hibernate and Object/Relational Mapping or even Java, please follow these steps:"
|
||||
msgstr ""
|
||||
|
||||
#: preface.xml:55(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:63(para)
|
||||
msgid "Read <xref linkend=\"architecture\"/> to understand the environments where Hibernate can be used."
|
||||
msgstr ""
|
||||
|
||||
#: preface.xml:69(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:80(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:90(para)
|
||||
msgid "FAQs are answered on the Hibernate website."
|
||||
msgstr ""
|
||||
|
||||
#: preface.xml:95(para)
|
||||
msgid "Third party demos, examples, and tutorials are linked on the Hibernate website."
|
||||
msgstr ""
|
||||
|
||||
#: preface.xml:101(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:109(para)
|
||||
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 ""
|
||||
|
||||
#: preface.xml:117(para)
|
||||
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 ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: preface.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:33-0500\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"
|
||||
|
||||
#: query_criteria.xml:5(title)
|
||||
msgid "Criteria Queries"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:7(para)
|
||||
msgid "Hibernate features an intuitive, extensible criteria query API."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:12(title)
|
||||
msgid "Creating a <literal>Criteria</literal> instance"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:14(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:27(title)
|
||||
msgid "Narrowing the result set"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:29(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:42(para)
|
||||
msgid "Restrictions may be grouped logically."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:64(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:73(para)
|
||||
msgid "The <literal>{alias}</literal> placeholder with be replaced by the row alias of the queried entity."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:78(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:99(title)
|
||||
msgid "Ordering the results"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:101(para)
|
||||
msgid "You may order the results using <literal>org.hibernate.criterion.Order</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:122(title)
|
||||
msgid "Associations"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:124(para)
|
||||
msgid "You may easily specify constraints upon related entities by navigating associations using <literal>createCriteria()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:135(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:141(para)
|
||||
msgid "The following, alternate form is useful in certain circumstances."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:151(para)
|
||||
msgid "(<literal>createAlias()</literal> does not create a new instance of <literal>Criteria</literal>.)"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:156(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:178(title)
|
||||
msgid "Dynamic association fetching"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:180(para)
|
||||
msgid "You may specify association fetching semantics at runtime using <literal>setFetchMode()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:191(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:199(title)
|
||||
msgid "Example queries"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:201(para)
|
||||
msgid "The class <literal>org.hibernate.criterion.Example</literal> allows you to construct a query criterion from a given instance."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:213(para)
|
||||
msgid "Version properties, identifiers and associations are ignored. By default, null valued properties are excluded."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:218(para)
|
||||
msgid "You can adjust how the <literal>Example</literal> is applied."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:231(para)
|
||||
msgid "You can even use examples to place criteria upon associated objects."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:244(title)
|
||||
msgid "Projections, aggregation and grouping"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:245(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:265(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:271(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:287(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:315(para)
|
||||
msgid "You can also use <literal>Property.forName()</literal> to express projections:"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:338(title)
|
||||
msgid "Detached queries and subqueries"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:339(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:353(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:371(para)
|
||||
msgid "Even correlated subqueries are possible:"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:389(title)
|
||||
msgid "Queries by natural identifier"
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:391(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:399(para)
|
||||
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 ""
|
||||
|
||||
#: query_criteria.xml:416(para)
|
||||
msgid "Note that this functionality is not intended for use with entities with <emphasis>mutable</emphasis> natural keys."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:421(para)
|
||||
msgid "Next, enable the Hibernate query cache."
|
||||
msgstr ""
|
||||
|
||||
#: query_criteria.xml:425(para)
|
||||
msgid "Now, <literal>Restrictions.naturalId()</literal> allows us to make use of the more efficient cache algorithm."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: query_criteria.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,644 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:34-0500\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"
|
||||
|
||||
#: query_hql.xml:5(title)
|
||||
msgid "HQL: The Hibernate Query Language"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:7(para)
|
||||
msgid "Hibernate is equipped with an extremely powerful query language that (quite intentionally) looks very much like SQL. But don't be fooled by the syntax; HQL is fully object-oriented, understanding notions like inheritence, polymorphism and association."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:14(title)
|
||||
msgid "Case Sensitivity"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:16(para)
|
||||
msgid "Queries are case-insensitive, except for names of Java classes and properties. So <literal>SeLeCT</literal> is the same as <literal>sELEct</literal> is the same as <literal>SELECT</literal> but <literal>org.hibernate.eg.FOO</literal> is not <literal>org.hibernate.eg.Foo</literal> and <literal>foo.barSet</literal> is not <literal>foo.BARSET</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:27(para)
|
||||
msgid "This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable, but we find this convention ugly when embedded in Java code."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:35(title)
|
||||
msgid "The from clause"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:37(para)
|
||||
msgid "The simplest possible Hibernate query is of the form:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:43(para)
|
||||
msgid "which simply returns all instances of the class <literal>eg.Cat</literal>. We don't usually need to qualify the class name, since <literal>auto-import</literal> is the default. So we almost always just write:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:51(para)
|
||||
msgid "Most of the time, you will need to assign an <emphasis>alias</emphasis>, since you will want to refer to the <literal>Cat</literal> in other parts of the query."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:59(para)
|
||||
msgid "This query assigns the alias <literal>cat</literal> to <literal>Cat</literal> instances, so we could use that alias later in the query. The <literal>as</literal> keyword is optional; we could also write:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:67(para)
|
||||
msgid "Multiple classes may appear, resulting in a cartesian product or \"cross\" join."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:74(para)
|
||||
msgid "It is considered good practice to name query aliases using an initial lowercase, consistent with Java naming standards for local variables (eg. <literal>domesticCat</literal>)."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:83(title)
|
||||
msgid "Associations and joins"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:85(para)
|
||||
msgid "We may also assign aliases to associated entities, or even to elements of a collection of values, using a <literal>join</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:98(para)
|
||||
msgid "The supported join types are borrowed from ANSI SQL"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:105(literal)
|
||||
msgid "inner join"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:110(literal)
|
||||
msgid "left outer join"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:115(literal)
|
||||
msgid "right outer join"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:119(para)
|
||||
msgid "<literal>full join</literal> (not usually useful)"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:125(para)
|
||||
msgid "The <literal>inner join</literal>, <literal>left outer join</literal> and <literal>right outer join</literal> constructs may be abbreviated."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:134(para)
|
||||
msgid "You may supply extra join conditions using the HQL <literal>with</literal> keyword."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:143(para)
|
||||
msgid "In addition, a \"fetch\" join allows associations or collections of values to be initialized along with their parent objects, using a single select. This is particularly useful in the case of a collection. It effectively overrides the outer join and lazy declarations of the mapping file for associations and collections. See <xref linkend=\"performance-fetching\"/> for more information."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:155(para)
|
||||
msgid "A fetch join does not usually need to assign an alias, because the associated objects should not be used in the <literal>where</literal> clause (or any other clause). Also, the associated objects are not returned directly in the query results. Instead, they may be accessed via the parent object. The only reason we might need an alias is if we are recursively join fetching a further collection:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:168(para)
|
||||
msgid "Note that the <literal>fetch</literal> construct may not be used in queries called using <literal>iterate()</literal> (though <literal>scroll()</literal> can be used). Nor should <literal>fetch</literal> be used together with <literal>setMaxResults()</literal> or <literal>setFirstResult()</literal> as these operations are based on the result rows, which usually contain duplicates for eager collection fetching, hence, the number of rows is not what you'd expect. Nor may <literal>fetch</literal> be used together with an ad hoc <literal>with</literal> condition. It is possible to create a cartesian product by join fetching more than one collection in a query, so take care in this case. Join fetching multiple collection roles also sometimes gives unexpected results for bag mappings, so be careful about how you formulate your queries in this case. Finally, note that <literal>full join fetch</literal> and <literal>right join fetch</literal> are not meaningful."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:183(para)
|
||||
msgid "If you are using property-level lazy fetching (with bytecode instrumentation), it is possible to force Hibernate to fetch the lazy properties immediately (in the first query) using <literal>fetch all properties</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:195(title)
|
||||
msgid "Forms of join syntax"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:197(para)
|
||||
msgid "HQL supports two forms of association joining: <literal>implicit</literal> and <literal>explicit</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:201(para)
|
||||
msgid "The queries shown in the previous section all use the <literal>explicit</literal> form where the join keyword is explicitly used in the from clause. This is the recommended form."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:206(para)
|
||||
msgid "The <literal>implicit</literal> form does not use the join keyword. Instead, the associations are \"dereferenced\" using dot-notation. <literal>implicit</literal> joins can appear in any of the HQL clauses. <literal>implicit</literal> join result in inner joins in the resulting SQL statement."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:217(title)
|
||||
msgid "Refering to identifier property"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:219(para)
|
||||
msgid "There are, generally speaking, 2 ways to refer to an entity's identifier property:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:224(para)
|
||||
msgid "The special property (lowercase) <literal>id</literal> may be used to reference the identifier property of an entity <emphasis>provided that entity does not define a non-identifier property named id</emphasis>."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:231(para)
|
||||
msgid "If the entity defines a named identifier property, you may use that property name."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:237(para)
|
||||
msgid "References to composite identifier properties follow the same naming rules. If the entity has a non-identifier property named id, the composite identifier property can only be referenced by its defined named; otherwise, the special <literal>id</literal> property can be used to rerference the identifier property."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:244(para)
|
||||
msgid "Note: this has changed significantly starting in version 3.2.2. In previous versions, <literal>id</literal><emphasis>always</emphasis> referred to the identifier property no matter what its actual name. A ramification of that decision was that non-identifier properties named <literal>id</literal> could never be referenced in Hibernate queries."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:253(title)
|
||||
msgid "The select clause"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:255(para)
|
||||
msgid "The <literal>select</literal> clause picks which objects and properties to return in the query result set. Consider:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:264(para)
|
||||
msgid "The query will select <literal>mate</literal>s of other <literal>Cat</literal>s. Actually, you may express this query more compactly as:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:271(para)
|
||||
msgid "Queries may return properties of any value type including properties of component type:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:280(para)
|
||||
msgid "Queries may return multiple objects and/or properties as an array of type <literal>Object[]</literal>,"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:290(para)
|
||||
msgid "or as a <literal>List</literal>,"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:299(para)
|
||||
msgid "or as an actual typesafe Java object,"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:308(para)
|
||||
msgid "assuming that the class <literal>Family</literal> has an appropriate constructor."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:312(para)
|
||||
msgid "You may assign aliases to selected expressions using <literal>as</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:319(para)
|
||||
msgid "This is most useful when used together with <literal>select new map</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:326(para)
|
||||
msgid "This query returns a <literal>Map</literal> from aliases to selected values."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:333(title)
|
||||
msgid "Aggregate functions"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:335(para)
|
||||
msgid "HQL queries may even return the results of aggregate functions on properties:"
|
||||
msgstr ""
|
||||
|
||||
#. NO LONGER SUPPORTED
|
||||
#. <para>
|
||||
#. Collections may also appear inside aggregate functions in the <literal>select</literal>
|
||||
#. clause.
|
||||
#. </para>
|
||||
#.
|
||||
#. <programlisting><![CDATA[select cat, count( elements(cat.kittens) )
|
||||
#. from Cat cat group by cat]]></programlisting>
|
||||
#: query_hql.xml:352(para)
|
||||
msgid "The supported aggregate functions are"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:359(literal)
|
||||
msgid "avg(...), sum(...), min(...), max(...)"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:364(literal)
|
||||
msgid "count(*)"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:369(literal)
|
||||
msgid "count(...), count(distinct ...), count(all...)"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:374(para)
|
||||
msgid "You may use arithmetic operators, concatenation, and recognized SQL functions in the select clause:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:386(para)
|
||||
msgid "The <literal>distinct</literal> and <literal>all</literal> keywords may be used and have the same semantics as in SQL."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:398(title)
|
||||
msgid "Polymorphic queries"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:400(para)
|
||||
msgid "A query like:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:406(para)
|
||||
msgid "returns instances not only of <literal>Cat</literal>, but also of subclasses like <literal>DomesticCat</literal>. Hibernate queries may name <emphasis>any</emphasis> Java class or interface in the <literal>from</literal> clause. The query will return instances of all persistent classes that extend that class or implement the interface. The following query would return all persistent objects:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:416(para)
|
||||
msgid "The interface <literal>Named</literal> might be implemented by various persistent classes:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:423(para)
|
||||
msgid "Note that these last two queries will require more than one SQL <literal>SELECT</literal>. This means that the <literal>order by</literal> clause does not correctly order the whole result set. (It also means you can't call these queries using <literal>Query.scroll()</literal>.)"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:432(title)
|
||||
msgid "The where clause"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:434(para)
|
||||
msgid "The <literal>where</literal> clause allows you to narrow the list of instances returned. If no alias exists, you may refer to properties by name:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:441(para)
|
||||
msgid "If there is an alias, use a qualified property name:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:447(para)
|
||||
msgid "returns instances of <literal>Cat</literal> named 'Fritz'."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:455(para)
|
||||
msgid "will return all instances of <literal>Foo</literal> for which there exists an instance of <literal>bar</literal> with a <literal>date</literal> property equal to the <literal>startDate</literal> property of the <literal>Foo</literal>. Compound path expressions make the <literal>where</literal> clause extremely powerful. Consider:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:466(para)
|
||||
msgid "This query translates to an SQL query with a table (inner) join. If you were to write something like"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:474(para)
|
||||
msgid "you would end up with a query that would require four table joins in SQL."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:478(para)
|
||||
msgid "The <literal>=</literal> operator may be used to compare not only properties, but also instances:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:489(para)
|
||||
msgid "The special property (lowercase) <literal>id</literal> may be used to reference the unique identifier of an object. See <xref linkend=\"queryhql-identifier-property\"/> for more information."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:499(para)
|
||||
msgid "The second query is efficient. No table join is required!"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:503(para)
|
||||
msgid "Properties of composite identifiers may also be used. Suppose <literal>Person</literal> has a composite identifier consisting of <literal>country</literal> and <literal>medicareNumber</literal>. Again, see <xref linkend=\"queryhql-identifier-property\"/> for more information regarding referencing identifier properties."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:518(para)
|
||||
msgid "Once again, the second query requires no table join."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:522(para)
|
||||
msgid "Likewise, the special property <literal>class</literal> accesses the discriminator value of an instance in the case of polymorphic persistence. A Java class name embedded in the where clause will be translated to its discriminator value."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:530(para)
|
||||
msgid "You may also use components or composite user types, or properties of said component types. See <xref linkend=\"queryhql-coomponents\"/> for more details."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:535(para)
|
||||
msgid "An \"any\" type has the special properties <literal>id</literal> and <literal>class</literal>, allowing us to express a join in the following way (where <literal>AuditLog.item</literal> is a property mapped with <literal><any></literal>)."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:544(para)
|
||||
msgid "Notice that <literal>log.item.class</literal> and <literal>payment.class</literal> would refer to the values of completely different database columns in the above query."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:552(title)
|
||||
msgid "Expressions"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:554(para)
|
||||
msgid "Expressions allowed in the <literal>where</literal> clause include most of the kind of things you could write in SQL:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:561(para)
|
||||
msgid "mathematical operators <literal>+, -, *, /</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:566(para)
|
||||
msgid "binary comparison operators <literal>=, >=, <=, <>, !=, like</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:571(para)
|
||||
msgid "logical operations <literal>and, or, not</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:576(para)
|
||||
msgid "Parentheses <literal>( )</literal>, indicating grouping"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:581(para)
|
||||
msgid "<literal>in</literal>, <literal>not in</literal>, <literal>between</literal>, <literal>is null</literal>, <literal>is not null</literal>, <literal>is empty</literal>, <literal>is not empty</literal>, <literal>member of</literal> and <literal>not member of</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:594(para)
|
||||
msgid "\"Simple\" case, <literal>case ... when ... then ... else ... end</literal>, and \"searched\" case, <literal>case when ... then ... else ... end</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:600(para)
|
||||
msgid "string concatenation <literal>...||...</literal> or <literal>concat(...,...)</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:605(para)
|
||||
msgid "<literal>current_date()</literal>, <literal>current_time()</literal>, <literal>current_timestamp()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:611(para)
|
||||
msgid "<literal>second(...)</literal>, <literal>minute(...)</literal>, <literal>hour(...)</literal>, <literal>day(...)</literal>, <literal>month(...)</literal>, <literal>year(...)</literal>,"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:618(para)
|
||||
msgid "Any function or operator defined by EJB-QL 3.0: <literal>substring(), trim(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:624(para)
|
||||
msgid "<literal>coalesce()</literal> and <literal>nullif()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:629(para)
|
||||
msgid "<literal>str()</literal> for converting numeric or temporal values to a readable string"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:635(para)
|
||||
msgid "<literal>cast(... as ...)</literal>, where the second argument is the name of a Hibernate type, and <literal>extract(... from ...)</literal> if ANSI <literal>cast()</literal> and <literal>extract()</literal> is supported by the underlying database"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:643(para)
|
||||
msgid "the HQL <literal>index()</literal> function, that applies to aliases of a joined indexed collection"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:649(para)
|
||||
msgid "HQL functions that take collection-valued path expressions: <literal>size(), minelement(), maxelement(), minindex(), maxindex()</literal>, along with the special <literal>elements()</literal> and <literal>indices</literal> functions which may be quantified using <literal>some, all, exists, any, in</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:657(para)
|
||||
msgid "Any database-supported SQL scalar function like <literal>sign()</literal>, <literal>trunc()</literal>, <literal>rtrim()</literal>, <literal>sin()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:663(para)
|
||||
msgid "JDBC-style positional parameters <literal>?</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:668(para)
|
||||
msgid "named parameters <literal>:name</literal>, <literal>:start_date</literal>, <literal>:x1</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:673(para)
|
||||
msgid "SQL literals <literal>'foo'</literal>, <literal>69</literal>, <literal>6.66E+2</literal>, <literal>'1970-01-01 10:00:01.0'</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:679(para)
|
||||
msgid "Java <literal>public static final</literal> constants <literal>eg.Color.TABBY</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:685(para)
|
||||
msgid "<literal>in</literal> and <literal>between</literal> may be used as follows:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:693(para)
|
||||
msgid "and the negated forms may be written"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:701(para)
|
||||
msgid "Likewise, <literal>is null</literal> and <literal>is not null</literal> may be used to test for null values."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:706(para)
|
||||
msgid "Booleans may be easily used in expressions by declaring HQL query substitutions in Hibernate configuration:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:713(para)
|
||||
msgid "This will replace the keywords <literal>true</literal> and <literal>false</literal> with the literals <literal>1</literal> and <literal>0</literal> in the translated SQL from this HQL:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:720(para)
|
||||
msgid "You may test the size of a collection with the special property <literal>size</literal>, or the special <literal>size()</literal> function."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:729(para)
|
||||
msgid "For indexed collections, you may refer to the minimum and maximum indices using <literal>minindex</literal> and <literal>maxindex</literal> functions. Similarly, you may refer to the minimum and maximum elements of a collection of basic type using the <literal>minelement</literal> and <literal>maxelement</literal> functions."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:743(para)
|
||||
msgid "The SQL functions <literal>any, some, all, exists, in</literal> are supported when passed the element or index set of a collection (<literal>elements</literal> and <literal>indices</literal> functions) or the result of a subquery (see below)."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:761(para)
|
||||
msgid "Note that these constructs - <literal>size</literal>, <literal>elements</literal>, <literal>indices</literal>, <literal>minindex</literal>, <literal>maxindex</literal>, <literal>minelement</literal>, <literal>maxelement</literal> - may only be used in the where clause in Hibernate3."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:768(para)
|
||||
msgid "Elements of indexed collections (arrays, lists, maps) may be referred to by index (in a where clause only):"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:785(para)
|
||||
msgid "The expression inside <literal>[]</literal> may even be an arithmetic expression."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:792(para)
|
||||
msgid "HQL also provides the built-in <literal>index()</literal> function, for elements of a one-to-many association or collection of values."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:801(para)
|
||||
msgid "Scalar SQL functions supported by the underlying database may be used"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:807(para)
|
||||
msgid "If you are not yet convinced by all this, think how much longer and less readable the following query would be in SQL:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:820(para)
|
||||
msgid "<emphasis>Hint:</emphasis> something like"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:845(title)
|
||||
msgid "The order by clause"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:847(para)
|
||||
msgid "The list returned by a query may be ordered by any property of a returned class or components:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:854(para)
|
||||
msgid "The optional <literal>asc</literal> or <literal>desc</literal> indicate ascending or descending order respectively."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:861(title)
|
||||
msgid "The group by clause"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:863(para)
|
||||
msgid "A query that returns aggregate values may be grouped by any property of a returned class or components:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:875(para)
|
||||
msgid "A <literal>having</literal> clause is also allowed."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:884(para)
|
||||
msgid "SQL functions and aggregate functions are allowed in the <literal>having</literal> and <literal>order by</literal> clauses, if supported by the underlying database (eg. not in MySQL)."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:897(para)
|
||||
msgid "Note that neither the <literal>group by</literal> clause nor the <literal>order by</literal> clause may contain arithmetic expressions. Also note that Hibernate currently does not expand a grouped entity, so you can't write <literal>group by cat</literal> if all properties of <literal>cat</literal> are non-aggregated. You have to list all non-aggregated properties explicitly."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:909(title)
|
||||
msgid "Subqueries"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:911(para)
|
||||
msgid "For databases that support subselects, Hibernate supports subqueries within queries. A subquery must be surrounded by parentheses (often by an SQL aggregate function call). Even correlated subqueries (subqueries that refer to an alias in the outer query) are allowed."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:940(para)
|
||||
msgid "Note that HQL subqueries may occur only in the select or where clauses."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:944(para)
|
||||
msgid "Note that subqueries can also utilize <literal>row value constructor</literal> syntax. See <xref linkend=\"queryhql-tuple\"/> for more details."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:952(title)
|
||||
msgid "HQL examples"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:954(para)
|
||||
msgid "Hibernate queries can be quite powerful and complex. In fact, the power of the query language is one of Hibernate's main selling points. Here are some example queries very similar to queries that I used on a recent project. Note that most queries you will write are much simpler than these!"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:960(para)
|
||||
msgid "The following query returns the order id, number of items and total value of the order for all unpaid orders for a particular customer and given minimum total value, ordering the results by total value. In determining the prices, it uses the current catalog. The resulting SQL query, against the <literal>ORDER</literal>, <literal>ORDER_LINE</literal>, <literal>PRODUCT</literal>, <literal>CATALOG</literal> and <literal>PRICE</literal> tables has four inner joins and an (uncorrelated) subselect."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:988(para)
|
||||
msgid "What a monster! Actually, in real life, I'm not very keen on subqueries, so my query was really more like this:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1007(para)
|
||||
msgid "The next query counts the number of payments in each status, excluding all payments in the <literal>AWAITING_APPROVAL</literal> status where the most recent status change was made by the current user. It translates to an SQL query with two inner joins and a correlated subselect against the <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal> and <literal>PAYMENT_STATUS_CHANGE</literal> tables."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1031(para)
|
||||
msgid "If I would have mapped the <literal>statusChanges</literal> collection as a list, instead of a set, the query would have been much simpler to write."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1044(para)
|
||||
msgid "The next query uses the MS SQL Server <literal>isNull()</literal> function to return all the accounts and unpaid payments for the organization to which the current user belongs. It translates to an SQL query with three inner joins, an outer join and a subselect against the <literal>ACCOUNT</literal>, <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal>, <literal>ACCOUNT_TYPE</literal>, <literal>ORGANIZATION</literal> and <literal>ORG_USER</literal> tables."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1060(para)
|
||||
msgid "For some databases, we would need to do away with the (correlated) subselect."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1075(title)
|
||||
msgid "Bulk update and delete"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1077(para)
|
||||
msgid "HQL now supports <literal>update</literal>, <literal>delete</literal> and <literal>insert ... select ...</literal> statements. See <xref linkend=\"batch-direct\"/> for details."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1085(title)
|
||||
msgid "Tips & Tricks"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1087(para)
|
||||
msgid "You can count the number of query results without actually returning them:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1093(para)
|
||||
msgid "To order a result by the size of a collection, use the following query:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1103(para)
|
||||
msgid "If your database supports subselects, you can place a condition upon selection size in the where clause of your query:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1110(para)
|
||||
msgid "If your database doesn't support subselects, use the following query:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1120(para)
|
||||
msgid "As this solution can't return a <literal>User</literal> with zero messages because of the inner join, the following form is also useful:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1131(para)
|
||||
msgid "Properties of a JavaBean can be bound to named query parameters:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1139(para)
|
||||
msgid "Collections are pageable by using the <literal>Query</literal> interface with a filter:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1148(para)
|
||||
msgid "Collection elements may be ordered or grouped using a query filter:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1155(para)
|
||||
msgid "You can find the size of a collection without initializing it:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1164(title)
|
||||
msgid "Components"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1166(para)
|
||||
msgid "Components might be used in just about every way that simple value types can be used in HQL queries. They can appear in the <literal>select</literal> clause:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1174(para)
|
||||
msgid "where the Person's name property is a component. Components can also be used in the <literal>where</literal> clause:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1182(para)
|
||||
msgid "Components can also be used in the <literal>order by</literal> clause:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1189(para)
|
||||
msgid "Another common use of components is in <xref linkend=\"queryhql-tuple\">row value constructors</xref>."
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1195(title)
|
||||
msgid "Row value constructor syntax"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1197(para)
|
||||
msgid "HQL supports the use of ANSI SQL <literal>row value constructor</literal> syntax (sometimes called <literal>tuple</literal> syntax), even though the underlying database may not support that notion. Here we are generally referring to multi-valued comparisons, typically associated with components. Consider an entity Person which defines a name component:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1206(para)
|
||||
msgid "That's valid syntax, although a little verbose. It be nice to make this a bit more concise and use <literal>row value constructor</literal> syntax:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1213(para)
|
||||
msgid "It can also be useful to specify this in the <literal>select</literal> clause:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1219(para)
|
||||
msgid "Another time using <literal>row value constructor</literal> syntax can be beneficial is when using subqueries needing to compare against multiple values:"
|
||||
msgstr ""
|
||||
|
||||
#: query_hql.xml:1229(para)
|
||||
msgid "One thing to consider when deciding if you want to use this syntax is that the query will be dependent upon the ordering of the component sub-properties in the metadata."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: query_hql.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,476 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:34-0500\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"
|
||||
|
||||
#: query_sql.xml:5(title)
|
||||
msgid "Native SQL"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:7(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:13(para)
|
||||
msgid "Hibernate3 allows you to specify handwritten SQL (including stored procedures) for all create, update, delete, and load operations."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:17(title)
|
||||
msgid "Using a <literal>SQLQuery</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:19(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:25(title)
|
||||
msgid "Scalar queries"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:27(para)
|
||||
msgid "The most basic SQL query is to get a list of scalars (values)."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:34(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:39(para)
|
||||
msgid "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>."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:49(para) query_sql.xml:101(para) query_sql.xml:195(para) query_sql.xml:354(para)
|
||||
msgid "This query specified:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:53(para) query_sql.xml:105(para) query_sql.xml:358(para)
|
||||
msgid "the SQL query string"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:57(para)
|
||||
msgid "the columns and types to return"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:61(para)
|
||||
msgid "This will still return Object arrays, but now it will not use <literal>ResultSetMetdata</literal> but will instead explicitly get the ID, NAME and BIRTHDATE column as respectively a Long, String and a Short from the underlying resultset. This also means that only these three columns will be returned, even though the query is using <literal>*</literal> and could return more than the three listed columns."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:69(para)
|
||||
msgid "It is possible to leave out the type information for all or some of the scalars."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:78(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:82(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:90(title)
|
||||
msgid "Entity queries"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:92(para)
|
||||
msgid "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>."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:109(para)
|
||||
msgid "the entity returned by the query"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:113(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:117(para)
|
||||
msgid "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>:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:128(para)
|
||||
msgid "This will allow cat.getDog() to function properly."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:132(title)
|
||||
msgid "Handling associations and collections"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:134(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:144(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:157(p)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:165(title)
|
||||
msgid "Returning multiple entities"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:167(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:172(para)
|
||||
msgid "Column alias injection is needed in the following query (which most likely will fail):"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:180(para)
|
||||
msgid "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 specificed in the mappings (\"ID\" and \"NAME\")."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:187(para)
|
||||
msgid "The following form is not vulnerable to column name duplication:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:199(para)
|
||||
msgid "the SQL query string, with placeholders for Hibernate to inject column aliases"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:204(para)
|
||||
msgid "the entities returned by the query"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:208(para)
|
||||
msgid "The {cat.*} and {mother.*} notation used above is a shorthand for \"all properties\". Alternatively, you may list the columns explicity, 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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:227(title)
|
||||
msgid "Alias and property references"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:229(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:234(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:240(title)
|
||||
msgid "Alias injection names"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:251(entry)
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:253(entry)
|
||||
msgid "Syntax"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:255(entry)
|
||||
msgid "Example"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:261(entry)
|
||||
msgid "A simple property"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:263(literal)
|
||||
msgid "{[aliasname].[propertyname]"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:265(literal)
|
||||
msgid "A_NAME as {item.name}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:269(entry)
|
||||
msgid "A composite property"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:271(literal)
|
||||
msgid "{[aliasname].[componentname].[propertyname]}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:273(literal)
|
||||
msgid "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:278(entry)
|
||||
msgid "Discriminator of an entity"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:280(literal)
|
||||
msgid "{[aliasname].class}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:282(literal)
|
||||
msgid "DISC as {item.class}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:286(entry)
|
||||
msgid "All properties of an entity"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:288(literal) query_sql.xml:336(literal)
|
||||
msgid "{[aliasname].*}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:290(literal)
|
||||
msgid "{item.*}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:294(entry)
|
||||
msgid "A collection key"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:296(literal)
|
||||
msgid "{[aliasname].key}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:298(literal)
|
||||
msgid "ORGID as {coll.key}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:302(entry)
|
||||
msgid "The id of an collection"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:304(literal)
|
||||
msgid "{[aliasname].id}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:306(literal)
|
||||
msgid "EMPID as {coll.id}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:310(entry)
|
||||
msgid "The element of an collection"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:312(literal)
|
||||
msgid "{[aliasname].element}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:314(literal)
|
||||
msgid "XID as {coll.element}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:318(entry)
|
||||
msgid "roperty of the element in the collection"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:320(literal)
|
||||
msgid "{[aliasname].element.[propertyname]}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:322(literal)
|
||||
msgid "NAME as {coll.element.name}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:326(entry)
|
||||
msgid "All properties of the element in the collection"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:328(literal)
|
||||
msgid "{[aliasname].element.*}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:330(literal)
|
||||
msgid "{coll.element.*}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:334(entry)
|
||||
msgid "All properties of the the collection"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:338(literal)
|
||||
msgid "{coll.*}"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:347(title)
|
||||
msgid "Returning non-managed entities"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:349(para)
|
||||
msgid "It is possible to apply a ResultTransformer to native sql queries. Allowing it to e.g. return non-managed entities."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:362(para)
|
||||
msgid "a result transformer"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:366(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:373(title)
|
||||
msgid "Handling inheritance"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:375(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:381(title)
|
||||
msgid "Parameters"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:383(para)
|
||||
msgid "Native sql queries support positional as well as named parameters:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:398(title)
|
||||
msgid "Named SQL queries"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:400(para)
|
||||
msgid "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>."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:419(para)
|
||||
msgid "The <literal><return-join></literal> and <literal><load-collection></literal> elements are used to join associations and define queries which initialize collections, respectively."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:440(para)
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:452(para)
|
||||
msgid "You can externalize the resultset mapping informations in a <literal><resultset></literal> element to either reuse them accross several named queries or through the <literal>setResultSetMapping()</literal> API."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:476(para)
|
||||
msgid "You can alternatively use the resultset mapping information in your hbm files directly in java code."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:486(title)
|
||||
msgid "Using return-property to explicitly specify column/alias names"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:489(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:507(para)
|
||||
msgid "<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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:528(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:533(para)
|
||||
msgid "If your mapping has a discriminator you must use <literal><return-discriminator></literal> to specify the discriminator column."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:539(title)
|
||||
msgid "Using stored procedures for querying"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:541(para)
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:560(para)
|
||||
msgid "To use this query in Hibernate you need to map it via a named query."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:579(para)
|
||||
msgid "Notice stored procedures currently only return scalars and entities. <literal><return-join></literal> and <literal><load-collection></literal> are not supported."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:584(title)
|
||||
msgid "Rules/limitations for using stored procedures"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:586(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:593(para)
|
||||
msgid "Stored procedure queries can't be paged with <literal>setFirstResult()/setMaxResults()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:596(para)
|
||||
msgid "Recommended call form is standard SQL92: <literal>{ ? = call functionName(<parameters>) }</literal> or <literal>{ ? = call procedureName(<parameters>}</literal>. Native call syntax is not supported."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:601(para)
|
||||
msgid "For Oracle the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:605(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:614(para)
|
||||
msgid "For Sybase or MS SQL server the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:618(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:626(para)
|
||||
msgid "If you can enable <literal>SET NOCOUNT ON</literal> in your procedure it will probably be more efficient, but this is not a requirement."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:636(title)
|
||||
msgid "Custom SQL for create, update and delete"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:638(para)
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:656(para)
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:660(para)
|
||||
msgid "Stored procedures are supported if the <literal>callable</literal> attribute is set:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:673(para)
|
||||
msgid "The order of the positional parameters are currently vital, as they must be in the same sequence as Hibernate expects them."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:676(para)
|
||||
msgid "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.)"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:683(para)
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:705(title)
|
||||
msgid "Custom SQL for loading"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:707(para)
|
||||
msgid "You may also declare your own SQL (or HQL) queries for entity loading:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:718(para)
|
||||
msgid "This is just a named query declaration, as discussed earlier. You may reference this named query in a class mapping:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:729(para)
|
||||
msgid "This even works with stored procedures."
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:731(para)
|
||||
msgid "You may even define a query for collection loading:"
|
||||
msgstr ""
|
||||
|
||||
#: query_sql.xml:747(para)
|
||||
msgid "You could even define an entity loader that loads a collection by join fetching:"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: query_sql.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,636 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:34-0500\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"
|
||||
|
||||
#: session_api.xml:5(title)
|
||||
msgid "Working with objects"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:7(para)
|
||||
msgid "Hibernate is a full object/relational mapping solution that not only shields the developer from the details of the underlying database management system, but also offers <emphasis>state management</emphasis> of objects. This is, contrary to the management of SQL <literal>statements</literal> in common JDBC/SQL persistence layers, a very natural object-oriented view of persistence in Java applications."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:16(para)
|
||||
msgid "In other words, Hibernate application developers should always think about the <emphasis>state</emphasis> of their objects, and not necessarily about the execution of SQL statements. This part is taken care of by Hibernate and is only relevant for the application developer when tuning the performance of the system."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:24(title)
|
||||
msgid "Hibernate object states"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:26(para)
|
||||
msgid "Hibernate defines and supports the following object states:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:32(para)
|
||||
msgid "<emphasis>Transient</emphasis> - an object is transient if it has just been instantiated using the <literal>new</literal> operator, and it is not associated with a Hibernate <literal>Session</literal>. It has no persistent representation in the database and no identifier value has been assigned. Transient instances will be destroyed by the garbage collector if the application doesn't hold a reference anymore. Use the Hibernate <literal>Session</literal> to make an object persistent (and let Hibernate take care of the SQL statements that need to be executed for this transition)."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:44(para)
|
||||
msgid "<emphasis>Persistent</emphasis> - a persistent instance has a representation in the database and an identifier value. It might just have been saved or loaded, however, it is by definition in the scope of a <literal>Session</literal>. Hibernate will detect any changes made to an object in persistent state and synchronize the state with the database when the unit of work completes. Developers don't execute manual <literal>UPDATE</literal> statements, or <literal>DELETE</literal> statements when an object should be made transient."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:55(para)
|
||||
msgid "<emphasis>Detached</emphasis> - a detached instance is an object that has been persistent, but its <literal>Session</literal> has been closed. The reference to the object is still valid, of course, and the detached instance might even be modified in this state. A detached instance can be reattached to a new <literal>Session</literal> at a later point in time, making it (and all the modifications) persistent again. This feature enables a programming model for long running units of work that require user think-time. We call them <emphasis>application transactions</emphasis>, i.e. a unit of work from the point of view of the user."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:69(para)
|
||||
msgid "We'll now discuss the states and state transitions (and the Hibernate methods that trigger a transition) in more detail."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:77(title)
|
||||
msgid "Making objects persistent"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:79(para)
|
||||
msgid "Newly instantiated instances of a a persistent class are considered <emphasis>transient</emphasis> by Hibernate. We can make a transient instance <emphasis>persistent</emphasis> by associating it with a session:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:92(para)
|
||||
msgid "If <literal>Cat</literal> has a generated identifier, the identifier is generated and assigned to the <literal>cat</literal> when <literal>save()</literal> is called. If <literal>Cat</literal> has an <literal>assigned</literal> identifier, or a composite key, the identifier should be assigned to the <literal>cat</literal> instance before calling <literal>save()</literal>. You may also use <literal>persist()</literal> instead of <literal>save()</literal>, with the semantics defined in the EJB3 early draft."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:104(para)
|
||||
msgid "<literal>persist()</literal> makes a transient instance persistent. However, it doesn't guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time. <literal>persist()</literal> also guarantees that it will not execute an <literal>INSERT</literal> statement if it is called outside of transaction boundaries. This is useful in long-running conversations with an extended Session/persistence context."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:115(para)
|
||||
msgid "<literal>save()</literal> does guarantee to return an identifier. If an INSERT has to be executed to get the identifier ( e.g. \"identity\" generator, not \"sequence\"), this INSERT happens immediately, no matter if you are inside or outside of a transaction. This is problematic in a long-running conversation with an extended Session/persistence context."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:125(para)
|
||||
msgid "Alternatively, you may assign the identifier using an overloaded version of <literal>save()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:138(para)
|
||||
msgid "If the object you make persistent has associated objects (e.g. the <literal>kittens</literal> collection in the previous example), these objects may be made persistent in any order you like unless you have a <literal>NOT NULL</literal> constraint upon a foreign key column. There is never a risk of violating foreign key constraints. However, you might violate a <literal>NOT NULL</literal> constraint if you <literal>save()</literal> the objects in the wrong order."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:148(para)
|
||||
msgid "Usually you don't bother with this detail, as you'll very likely use Hibernate's <emphasis>transitive persistence</emphasis> feature to save the associated objects automatically. Then, even <literal>NOT NULL</literal> constraint violations don't occur - Hibernate will take care of everything. Transitive persistence is discussed later in this chapter."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:159(title)
|
||||
msgid "Loading an object"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:161(para)
|
||||
msgid "The <literal>load()</literal> methods of <literal>Session</literal> gives you a way to retrieve a persistent instance if you already know its identifier. <literal>load()</literal> takes a class object and will load the state into a newly instantiated instance of that class, in persistent state."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:174(para)
|
||||
msgid "Alternatively, you can load state into a given instance:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:183(para)
|
||||
msgid "Note that <literal>load()</literal> will throw an unrecoverable exception if there is no matching database row. If the class is mapped with a proxy, <literal>load()</literal> just returns an uninitialized proxy and does not actually hit the database until you invoke a method of the proxy. This behaviour is very useful if you wish to create an association to an object without actually loading it from the database. It also allows multiple instances to be loaded as a batch if <literal>batch-size</literal> is defined for the class mapping."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:194(para)
|
||||
msgid "If you are not certain that a matching row exists, you should use the <literal>get()</literal> method, which hits the database immediately and returns null if there is no matching row."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:207(para)
|
||||
msgid "You may even load an object using an SQL <literal>SELECT ... FOR UPDATE</literal>, using a <literal>LockMode</literal>. See the API documentation for more information."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:214(para)
|
||||
msgid "Note that any associated instances or contained collections are <emphasis>not</emphasis> selected <literal>FOR UPDATE</literal>, unless you decide to specify <literal>lock</literal> or <literal>all</literal> as a cascade style for the association."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:221(para)
|
||||
msgid "It is possible to re-load an object and all its collections at any time, using the <literal>refresh()</literal> method. This is useful when database triggers are used to initialize some of the properties of the object."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:231(para)
|
||||
msgid "An important question usually appears at this point: How much does Hibernate load from the database and how many SQL <literal>SELECT</literal>s will it use? This depends on the <emphasis>fetching strategy</emphasis> and is explained in <xref linkend=\"performance-fetching\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:241(title)
|
||||
msgid "Querying"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:243(para)
|
||||
msgid "If you don't know the identifiers of the objects you are looking for, you need a query. Hibernate supports an easy-to-use but powerful object oriented query language (HQL). For programmatic query creation, Hibernate supports a sophisticated Criteria and Example query feature (QBC and QBE). You may also express your query in the native SQL of your database, with optional support from Hibernate for result set conversion into objects."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:253(title)
|
||||
msgid "Executing queries"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:255(para)
|
||||
msgid "HQL and native SQL queries are represented with an instance of <literal>org.hibernate.Query</literal>. This interface offers methods for parameter binding, result set handling, and for the execution of the actual query. You always obtain a <literal>Query</literal> using the current <literal>Session</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:286(para)
|
||||
msgid "A query is usually executed by invoking <literal>list()</literal>, the result of the query will be loaded completely into a collection in memory. Entity instances retrieved by a query are in persistent state. The <literal>uniqueResult()</literal> method offers a shortcut if you know your query will only return a single object. Note that queries that make use of eager fetching of collections usually return duplicates of the root objects (but with their collections initialized). You can filter these duplicates simply through a <literal>Set</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:298(title)
|
||||
msgid "Iterating results"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:300(para)
|
||||
msgid "Occasionally, you might be able to achieve better performance by executing the query using the <literal>iterate()</literal> method. This will only usually be the case if you expect that the actual entity instances returned by the query will already be in the session or second-level cache. If they are not already cached, <literal>iterate()</literal> will be slower than <literal>list()</literal> and might require many database hits for a simple query, usually <emphasis>1</emphasis> for the initial select which only returns identifiers, and <emphasis>n</emphasis> additional selects to initialize the actual instances."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:327(title)
|
||||
msgid "Queries that return tuples"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:329(para)
|
||||
msgid "Hibernate queries sometimes return tuples of objects, in which case each tuple is returned as an array:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:349(title)
|
||||
msgid "Scalar results"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:351(para)
|
||||
msgid "Queries may specify a property of a class in the <literal>select</literal> clause. They may even call SQL aggregate functions. Properties or aggregates are considered \"scalar\" results (and not entities in persistent state)."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:374(title)
|
||||
msgid "Bind parameters"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:376(para)
|
||||
msgid "Methods on <literal>Query</literal> are provided for binding values to named parameters or JDBC-style <literal>?</literal> parameters. <emphasis>Contrary to JDBC, Hibernate numbers parameters from zero.</emphasis> Named parameters are identifiers of the form <literal>:name</literal> in the query string. The advantages of named parameters are:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:386(para)
|
||||
msgid "named parameters are insensitive to the order they occur in the query string"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:392(para)
|
||||
msgid "they may occur multiple times in the same query"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:397(para)
|
||||
msgid "they are self-documenting"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:424(title)
|
||||
msgid "Pagination"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:426(para)
|
||||
msgid "If you need to specify bounds upon your result set (the maximum number of rows you want to retrieve and / or the first row you want to retrieve) you should use methods of the <literal>Query</literal> interface:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:437(para)
|
||||
msgid "Hibernate knows how to translate this limit query into the native SQL of your DBMS."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:445(title)
|
||||
msgid "Scrollable iteration"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:447(para)
|
||||
msgid "If your JDBC driver supports scrollable <literal>ResultSet</literal>s, the <literal>Query</literal> interface may be used to obtain a <literal>ScrollableResults</literal> object, which allows flexible navigation of the query results."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:476(para)
|
||||
msgid "Note that an open database connection (and cursor) is required for this functionality, use <literal>setMaxResult()</literal>/<literal>setFirstResult()</literal> if you need offline pagination functionality."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:485(title)
|
||||
msgid "Externalizing named queries"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:487(para)
|
||||
msgid "You may also define named queries in the mapping document. (Remember to use a <literal>CDATA</literal> section if your query contains characters that could be interpreted as markup.)"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:499(para)
|
||||
msgid "Parameter binding and executing is done programatically:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:508(para)
|
||||
msgid "Note that the actual program code is independent of the query language that is used, you may also define native SQL queries in metadata, or migrate existing queries to Hibernate by placing them in mapping files."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:514(para)
|
||||
msgid "Also note that a query declaration inside a <literal><hibernate-mapping></literal> element requires a global unique name for the query, while a query declaration inside a <literal><class></literal> element is made unique automatically by prepending the fully qualified name of the class, for example <literal>eg.Cat.ByNameAndMaximumWeight</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:527(title)
|
||||
msgid "Filtering collections"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:528(para)
|
||||
msgid "A collection <emphasis>filter</emphasis> is a special type of query that may be applied to a persistent collection or array. The query string may refer to <literal>this</literal>, meaning the current collection element."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:541(para)
|
||||
msgid "The returned collection is considered a bag, and it's a copy of the given collection. The original collection is not modified (this is contrary to the implication of the name \"filter\", but consistent with expected behavior)."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:547(para)
|
||||
msgid "Observe that filters do not require a <literal>from</literal> clause (though they may have one if required). Filters are not limited to returning the collection elements themselves."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:557(para)
|
||||
msgid "Even an empty filter query is useful, e.g. to load a subset of elements in a huge collection:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:570(title)
|
||||
msgid "Criteria queries"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:572(para)
|
||||
msgid "HQL is extremely powerful but some developers prefer to build queries dynamically, using an object-oriented API, rather than building query strings. Hibernate provides an intuitive <literal>Criteria</literal> query API for these cases:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:583(para)
|
||||
msgid "The <literal>Criteria</literal> and the associated <literal>Example</literal> API are discussed in more detail in <xref linkend=\"querycriteria\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:591(title)
|
||||
msgid "Queries in native SQL"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:593(para)
|
||||
msgid "You may express a query in SQL, using <literal>createSQLQuery()</literal> and let Hibernate take care of the mapping from result sets to objects. Note that you may at any time call <literal>session.connection()</literal> and use the JDBC <literal>Connection</literal> directly. If you chose to use the Hibernate API, you must enclose SQL aliases in braces:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:612(para)
|
||||
msgid "SQL queries may contain named and positional parameters, just like Hibernate queries. More information about native SQL queries in Hibernate can be found in <xref linkend=\"querysql\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:623(title)
|
||||
msgid "Modifying persistent objects"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:625(para)
|
||||
msgid "<emphasis>Transactional persistent instances</emphasis> (ie. objects loaded, saved, created or queried by the <literal>Session</literal>) may be manipulated by the application and any changes to persistent state will be persisted when the <literal>Session</literal> is <emphasis>flushed</emphasis> (discussed later in this chapter). There is no need to call a particular method (like <literal>update()</literal>, which has a different purpose) to make your modifications persistent. So the most straightforward way to update the state of an object is to <literal>load()</literal> it, and then manipulate it directly, while the <literal>Session</literal> is open:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:640(para)
|
||||
msgid "Sometimes this programming model is inefficient since it would require both an SQL <literal>SELECT</literal> (to load an object) and an SQL <literal>UPDATE</literal> (to persist its updated state) in the same session. Therefore Hibernate offers an alternate approach, using detached instances."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:649(literal)
|
||||
msgid "UPDATE"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:649(literal)
|
||||
msgid "DELETE"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:650(emphasis)
|
||||
msgid "state management"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:651(emphasis)
|
||||
msgid "statements"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:652(literal)
|
||||
msgid "Connection"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:653(literal)
|
||||
msgid "session.connection()"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:648(emphasis)
|
||||
msgid "Note that Hibernate does not offer its own API for direct execution of <placeholder-1/> or <placeholder-2/> statements. Hibernate is a <placeholder-3/> service, you don't have to think in <placeholder-4/> to use it. JDBC is a perfect API for executing SQL statements, you can get a JDBC <placeholder-5/> at any time by calling <placeholder-6/>. Furthermore, the notion of mass operations conflicts with object/relational mapping for online transaction processing-oriented applications. Future versions of Hibernate may however provide special mass operation functions. See <xref linkend=\"batch\"/> for some possible batch operation tricks."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:663(title)
|
||||
msgid "Modifying detached objects"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:665(para)
|
||||
msgid "Many applications need to retrieve an object in one transaction, send it to the UI layer for manipulation, then save the changes in a new transaction. Applications that use this kind of approach in a high-concurrency environment usually use versioned data to ensure isolation for the \"long\" unit of work."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:672(para)
|
||||
msgid "Hibernate supports this model by providing for reattachment of detached instances using the <literal>Session.update()</literal> or <literal>Session.merge()</literal> methods:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:690(para)
|
||||
msgid "If the <literal>Cat</literal> with identifier <literal>catId</literal> had already been loaded by <literal>secondSession</literal> when the application tried to reattach it, an exception would have been thrown."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:696(para)
|
||||
msgid "Use <literal>update()</literal> if you are sure that the session does not contain an already persistent instance with the same identifier, and <literal>merge()</literal> if you want to merge your modifications at any time without consideration of the state of the session. In other words, <literal>update()</literal> is usually the first method you would call in a fresh session, ensuring that reattachment of your detached instances is the first operation that is executed."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:705(para)
|
||||
msgid "The application should individually <literal>update()</literal> detached instances reachable from the given detached instance if and <emphasis>only</emphasis> if it wants their state also updated. This can be automated of course, using <emphasis>transitive persistence</emphasis>, see <xref linkend=\"objectstate-transitive\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:712(para)
|
||||
msgid "The <literal>lock()</literal> method also allows an application to reassociate an object with a new session. However, the detached instance has to be unmodified!"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:724(para)
|
||||
msgid "Note that <literal>lock()</literal> can be used with various <literal>LockMode</literal>s, see the API documentation and the chapter on transaction handling for more information. Reattachment is not the only usecase for <literal>lock()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:731(para)
|
||||
msgid "Other models for long units of work are discussed in <xref linkend=\"transactions-optimistic\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:738(title)
|
||||
msgid "Automatic state detection"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:740(para)
|
||||
msgid "Hibernate users have requested a general purpose method that either saves a transient instance by generating a new identifier or updates/reattaches the detached instances associated with its current identifier. The <literal>saveOrUpdate()</literal> method implements this functionality."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:758(para)
|
||||
msgid "The usage and semantics of <literal>saveOrUpdate()</literal> seems to be confusing for new users. Firstly, so long as you are not trying to use instances from one session in another new session, you should not need to use <literal>update()</literal>, <literal>saveOrUpdate()</literal>, or <literal>merge()</literal>. Some whole applications will never use either of these methods."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:766(para)
|
||||
msgid "Usually <literal>update()</literal> or <literal>saveOrUpdate()</literal> are used in the following scenario:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:773(para)
|
||||
msgid "the application loads an object in the first session"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:778(para)
|
||||
msgid "the object is passed up to the UI tier"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:783(para)
|
||||
msgid "some modifications are made to the object"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:788(para)
|
||||
msgid "the object is passed back down to the business logic tier"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:793(para)
|
||||
msgid "the application persists these modifications by calling <literal>update()</literal> in a second session"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:800(para)
|
||||
msgid "<literal>saveOrUpdate()</literal> does the following:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:806(para)
|
||||
msgid "if the object is already persistent in this session, do nothing"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:811(para)
|
||||
msgid "if another object associated with the session has the same identifier, throw an exception"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:817(para)
|
||||
msgid "if the object has no identifier property, <literal>save()</literal> it"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:822(para)
|
||||
msgid "if the object's identifier has the value assigned to a newly instantiated object, <literal>save()</literal> it"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:828(para)
|
||||
msgid "if the object is versioned (by a <literal><version></literal> or <literal><timestamp></literal>), and the version property value is the same value assigned to a newly instantiated object, <literal>save()</literal> it"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:836(para)
|
||||
msgid "otherwise <literal>update()</literal> the object"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:842(para)
|
||||
msgid "and <literal>merge()</literal> is very different:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:848(para)
|
||||
msgid "if there is a persistent instance with the same identifier currently associated with the session, copy the state of the given object onto the persistent instance"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:855(para)
|
||||
msgid "if there is no persistent instance currently associated with the session, try to load it from the database, or create a new persistent instance"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:861(para)
|
||||
msgid "the persistent instance is returned"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:866(para)
|
||||
msgid "the given instance does not become associated with the session, it remains detached"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:876(title)
|
||||
msgid "Deleting persistent objects"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:878(para)
|
||||
msgid "<literal>Session.delete()</literal> will remove an object's state from the database. Of course, your application might still hold a reference to a deleted object. It's best to think of <literal>delete()</literal> as making a persistent instance transient."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:887(para)
|
||||
msgid "You may delete objects in any order you like, without risk of foreign key constraint violations. It is still possible to violate a <literal>NOT NULL</literal> constraint on a foreign key column by deleting objects in the wrong order, e.g. if you delete the parent, but forget to delete the children."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:898(title)
|
||||
msgid "Replicating object between two different datastores"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:900(para)
|
||||
msgid "It is occasionally useful to be able to take a graph of persistent instances and make them persistent in a different datastore, without regenerating identifier values."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:920(para)
|
||||
msgid "The <literal>ReplicationMode</literal> determines how <literal>replicate()</literal> will deal with conflicts with existing rows in the database."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:927(para)
|
||||
msgid "<literal>ReplicationMode.IGNORE</literal> - ignore the object when there is an existing database row with the same identifier"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:933(para)
|
||||
msgid "<literal>ReplicationMode.OVERWRITE</literal> - overwrite any existing database row with the same identifier"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:939(para)
|
||||
msgid "<literal>ReplicationMode.EXCEPTION</literal> - throw an exception if there is an existing database row with the same identifier"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:945(para)
|
||||
msgid "<literal>ReplicationMode.LATEST_VERSION</literal> - overwrite the row if its version number is earlier than the version number of the object, or ignore the object otherwise"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:953(para)
|
||||
msgid "Usecases for this feature include reconciling data entered into different database instances, upgrading system configuration information during product upgrades, rolling back changes made during non-ACID transactions and more."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:962(title)
|
||||
msgid "Flushing the Session"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:964(para)
|
||||
msgid "From time to time the <literal>Session</literal> will execute the SQL statements needed to synchronize the JDBC connection's state with the state of objects held in memory. This process, <emphasis>flush</emphasis>, occurs by default at the following points"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:973(para)
|
||||
msgid "before some query executions"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:978(para)
|
||||
msgid "from <literal>org.hibernate.Transaction.commit()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:983(para)
|
||||
msgid "from <literal>Session.flush()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:989(para)
|
||||
msgid "The SQL statements are issued in the following order"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:995(para)
|
||||
msgid "all entity insertions, in the same order the corresponding objects were saved using <literal>Session.save()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1001(para)
|
||||
msgid "all entity updates"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1006(para)
|
||||
msgid "all collection deletions"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1011(para)
|
||||
msgid "all collection element deletions, updates and insertions"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1016(para)
|
||||
msgid "all collection insertions"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1021(para)
|
||||
msgid "all entity deletions, in the same order the corresponding objects were deleted using <literal>Session.delete()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1028(para)
|
||||
msgid "(An exception is that objects using <literal>native</literal> ID generation are inserted when they are saved.)"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1033(para)
|
||||
msgid "Except when you explicity <literal>flush()</literal>, there are absolutely no guarantees about <emphasis>when</emphasis> the <literal>Session</literal> executes the JDBC calls, only the <emphasis>order</emphasis> in which they are executed. However, Hibernate does guarantee that the <literal>Query.list(..)</literal> will never return stale data; nor will they return the wrong data."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1041(para)
|
||||
msgid "It is possible to change the default behavior so that flush occurs less frequently. The <literal>FlushMode</literal> class defines three different modes: only flush at commit time (and only when the Hibernate <literal>Transaction</literal> API is used), flush automatically using the explained routine, or never flush unless <literal>flush()</literal> is called explicitly. The last mode is useful for long running units of work, where a <literal>Session</literal> is kept open and disconnected for a long time (see <xref linkend=\"transactions-optimistic-longsession\"/>)."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1066(para)
|
||||
msgid "During flush, an exception might occur (e.g. if a DML operation violates a constraint). Since handling exceptions involves some understanding of Hibernate's transactional behavior, we discuss it in <xref linkend=\"transactions\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1075(title)
|
||||
msgid "Transitive persistence"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1077(para)
|
||||
msgid "It is quite cumbersome to save, delete, or reattach individual objects, especially if you deal with a graph of associated objects. A common case is a parent/child relationship. Consider the following example:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1083(para)
|
||||
msgid "If the children in a parent/child relationship would be value typed (e.g. a collection of addresses or strings), their life cycle would depend on the parent and no further action would be required for convenient \"cascading\" of state changes. When the parent is saved, the value-typed child objects are saved as well, when the parent is deleted, the children will be deleted, etc. This even works for operations such as the removal of a child from the collection; Hibernate will detect this and, since value-typed objects can't have shared references, delete the child from the database."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1094(para)
|
||||
msgid "Now consider the same scenario with parent and child objects being entities, not value-types (e.g. categories and items, or parent and child cats). Entities have their own life cycle, support shared references (so removing an entity from the collection does not mean it can be deleted), and there is by default no cascading of state from one entity to any other associated entities. Hibernate does not implement <emphasis>persistence by reachability</emphasis> by default."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1103(para)
|
||||
msgid "For each basic operation of the Hibernate session - including <literal>persist(), merge(), saveOrUpdate(), delete(), lock(), refresh(), evict(), replicate()</literal> - there is a corresponding cascade style. Respectively, the cascade styles are named <literal>create, merge, save-update, delete, lock, refresh, evict, replicate</literal>. If you want an operation to be cascaded along an association, you must indicate that in the mapping document. For example:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1114(para)
|
||||
msgid "Cascade styles my be combined:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1120(para)
|
||||
msgid "You may even use <literal>cascade=\"all\"</literal> to specify that <emphasis>all</emphasis> operations should be cascaded along the association. The default <literal>cascade=\"none\"</literal> specifies that no operations are to be cascaded."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1126(para)
|
||||
msgid "A special cascade style, <literal>delete-orphan</literal>, applies only to one-to-many associations, and indicates that the <literal>delete()</literal> operation should be applied to any child object that is removed from the association."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1133(para)
|
||||
msgid "Recommendations:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1139(para)
|
||||
msgid "It doesn't usually make sense to enable cascade on a <literal><many-to-one></literal> or <literal><many-to-many></literal> association. Cascade is often useful for <literal><one-to-one></literal> and <literal><one-to-many></literal> associations."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1147(para)
|
||||
msgid "If the child object's lifespan is bounded by the lifespan of the parent object, make it a <emphasis>life cycle object</emphasis> by specifying <literal>cascade=\"all,delete-orphan\"</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1154(para)
|
||||
msgid "Otherwise, you might not need cascade at all. But if you think that you will often be working with the parent and children together in the same transaction, and you want to save yourself some typing, consider using <literal>cascade=\"persist,merge,save-update\"</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1162(para)
|
||||
msgid "Mapping an association (either a single valued association, or a collection) with <literal>cascade=\"all\"</literal> marks the association as a <emphasis>parent/child</emphasis> style relationship where save/update/delete of the parent results in save/update/delete of the child or children."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1168(para)
|
||||
msgid "Futhermore, a mere reference to a child from a persistent parent will result in save/update of the child. This metaphor is incomplete, however. A child which becomes unreferenced by its parent is <emphasis>not</emphasis> automatically deleted, except in the case of a <literal><one-to-many></literal> association mapped with <literal>cascade=\"delete-orphan\"</literal>. The precise semantics of cascading operations for a parent/child relationship are as follows:"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1179(para)
|
||||
msgid "If a parent is passed to <literal>persist()</literal>, all children are passed to <literal>persist()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1185(para)
|
||||
msgid "If a parent is passed to <literal>merge()</literal>, all children are passed to <literal>merge()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1191(para)
|
||||
msgid "If a parent is passed to <literal>save()</literal>, <literal>update()</literal> or <literal>saveOrUpdate()</literal>, all children are passed to <literal>saveOrUpdate()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1197(para)
|
||||
msgid "If a transient or detached child becomes referenced by a persistent parent, it is passed to <literal>saveOrUpdate()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1203(para)
|
||||
msgid "If a parent is deleted, all children are passed to <literal>delete()</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1208(para)
|
||||
msgid "If a child is dereferenced by a persistent parent, <emphasis>nothing special happens</emphasis> - the application should explicitly delete the child if necessary - unless <literal>cascade=\"delete-orphan\"</literal>, in which case the \"orphaned\" child is deleted."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1217(para)
|
||||
msgid "Finally, note that cascading of operations can be applied to an object graph at <emphasis>call time</emphasis> or at <emphasis>flush time</emphasis>. All operations, if enabled, are cascaded to associated entities reachable when the operation is executed. However, <literal>save-upate</literal> and <literal>delete-orphan</literal> are transitive for all associated entities reachable during flush of the <literal>Session</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1229(title)
|
||||
msgid "Using metadata"
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1231(para)
|
||||
msgid "Hibernate requires a very rich meta-level model of all entity and value types. From time to time, this model is very useful to the application itself. For example, the application might use Hibernate's metadata to implement a \"smart\" deep-copy algorithm that understands which objects should be copied (eg. mutable value types) and which should not (eg. immutable value types and, possibly, associated entities)."
|
||||
msgstr ""
|
||||
|
||||
#: session_api.xml:1238(para)
|
||||
msgid "Hibernate exposes metadata via the <literal>ClassMetadata</literal> and <literal>CollectionMetadata</literal> interfaces and the <literal>Type</literal> hierarchy. Instances of the metadata interfaces may be obtained from the <literal>SessionFactory</literal>."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: session_api.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,548 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:34-0500\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"
|
||||
|
||||
#: toolset_guide.xml:5(title)
|
||||
msgid "Toolset Guide"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:7(para)
|
||||
msgid "Roundtrip engineering with Hibernate is possible using a set of Eclipse plugins, commandline tools, as well as Ant tasks."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:12(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:18(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:23(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:30(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:38(emphasis)
|
||||
msgid "Ant Tasks:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:43(para)
|
||||
msgid "Please refer to the <emphasis>Hibernate Tools</emphasis> package and it's documentation for more information."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:48(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:55(title)
|
||||
msgid "Automatic schema generation"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:57(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:64(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:70(para)
|
||||
msgid "First, customize your mapping files to improve the generated schema."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:75(title)
|
||||
msgid "Customizing the schema"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:77(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:87(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:97(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:108(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:117(para)
|
||||
msgid "A <literal>foreign-key</literal> attribute may be used to override the name of any generated foreign key constraint."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:124(para)
|
||||
msgid "Many mapping elements also accept a child <literal><column></literal> element. This is particularly useful for mapping multi-column types:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:135(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:149(para)
|
||||
msgid "The <literal>sql-type</literal> attribute allows the user to override the default mapping of a Hibernate type to SQL datatype."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:158(para)
|
||||
msgid "The <literal>check</literal> attribute allows you to specify a check constraint."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:173(title)
|
||||
msgid "Summary"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:180(entry)
|
||||
msgid "Attribute"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:181(entry)
|
||||
msgid "Values"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:182(entry)
|
||||
msgid "Interpretation"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:187(literal)
|
||||
msgid "length"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:188(entry) toolset_guide.xml:193(entry) toolset_guide.xml:198(entry)
|
||||
msgid "number"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:189(entry)
|
||||
msgid "column length"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:192(literal)
|
||||
msgid "precision"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:194(entry)
|
||||
msgid "column decimal precision"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:197(literal)
|
||||
msgid "scale"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:199(entry)
|
||||
msgid "column decimal scale"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:202(literal)
|
||||
msgid "not-null"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:203(literal) toolset_guide.xml:208(literal)
|
||||
msgid "true|false"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:204(entry)
|
||||
msgid "specfies that the column should be non-nullable"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:207(literal)
|
||||
msgid "unique"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:209(entry)
|
||||
msgid "specifies that the column should have a unique constraint"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:212(literal)
|
||||
msgid "index"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:213(literal)
|
||||
msgid "index_name"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:214(entry)
|
||||
msgid "specifies the name of a (multi-column) index"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:217(literal)
|
||||
msgid "unique-key"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:218(literal)
|
||||
msgid "unique_key_name"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:219(entry)
|
||||
msgid "specifies the name of a multi-column unique constraint"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:222(literal)
|
||||
msgid "foreign-key"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:223(literal)
|
||||
msgid "foreign_key_name"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:226(literal)
|
||||
msgid "<one-to-one>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:227(literal)
|
||||
msgid "<many-to-one>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:227(literal)
|
||||
msgid "<key>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:228(literal)
|
||||
msgid "<many-to-many>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:229(literal)
|
||||
msgid "inverse=\"true\""
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:230(literal)
|
||||
msgid "SchemaExport"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:224(entry)
|
||||
msgid "specifies the name of the foreign key constraint generated for an association, for a <placeholder-1/>, <placeholder-2/>, <placeholder-3/>, or <placeholder-4/> mapping element. Note that <placeholder-5/> sides will not be considered by <placeholder-6/>."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:234(literal)
|
||||
msgid "sql-type"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:235(literal)
|
||||
msgid "SQL column type"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:238(literal)
|
||||
msgid "<column>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:236(entry)
|
||||
msgid "overrides the default column type (attribute of <placeholder-1/> element only)"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:242(literal)
|
||||
msgid "default"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:243(entry) toolset_guide.xml:250(entry)
|
||||
msgid "SQL expression"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:244(entry)
|
||||
msgid "specify a default value for the column"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:249(literal)
|
||||
msgid "check"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:251(entry)
|
||||
msgid "create an SQL check constraint on either column or table"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:259(para)
|
||||
msgid "The <literal><comment></literal> element allows you to specify comments for the generated schema."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:275(para)
|
||||
msgid "This results in a <literal>comment on table</literal> or <literal>comment on column</literal> statement in the generated DDL (where supported)."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:284(title)
|
||||
msgid "Running the tool"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:286(para)
|
||||
msgid "The <literal>SchemaExport</literal> tool writes a DDL script to standard out and/or executes the DDL statements."
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:292(literal) toolset_guide.xml:459(literal) toolset_guide.xml:541(literal)
|
||||
msgid "java -cp"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:292(emphasis) toolset_guide.xml:459(emphasis) toolset_guide.xml:541(emphasis)
|
||||
msgid "hibernate_classpaths"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:293(literal)
|
||||
msgid "org.hibernate.tool.hbm2ddl.SchemaExport"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:293(emphasis) toolset_guide.xml:460(emphasis) toolset_guide.xml:542(emphasis)
|
||||
msgid "options mapping_files"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:297(title)
|
||||
msgid "<literal>SchemaExport</literal> Command Line Options"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:303(entry) toolset_guide.xml:470(entry) toolset_guide.xml:552(entry)
|
||||
msgid "Option"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:304(entry) toolset_guide.xml:392(entry) toolset_guide.xml:471(entry) toolset_guide.xml:553(entry)
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:309(literal) toolset_guide.xml:476(literal)
|
||||
msgid "--quiet"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:310(entry) toolset_guide.xml:477(entry)
|
||||
msgid "don't output the script to stdout"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:313(literal)
|
||||
msgid "--drop"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:314(entry)
|
||||
msgid "only drop the tables"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:317(literal)
|
||||
msgid "--create"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:318(entry)
|
||||
msgid "only create the tables"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:321(literal) toolset_guide.xml:480(literal)
|
||||
msgid "--text"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:322(entry)
|
||||
msgid "don't export to the database"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:325(literal)
|
||||
msgid "--output=my_schema.ddl"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:326(entry)
|
||||
msgid "output the ddl script to a file"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:329(literal) toolset_guide.xml:484(literal) toolset_guide.xml:558(literal)
|
||||
msgid "--naming=eg.MyNamingStrategy"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:330(literal) toolset_guide.xml:485(literal) toolset_guide.xml:559(literal)
|
||||
msgid "NamingStrategy"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:330(entry) toolset_guide.xml:485(entry) toolset_guide.xml:559(entry)
|
||||
msgid "select a <placeholder-1/>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:333(literal) toolset_guide.xml:492(literal) toolset_guide.xml:566(literal)
|
||||
msgid "--config=hibernate.cfg.xml"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:334(entry)
|
||||
msgid "read Hibernate configuration from an XML file"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:337(literal) toolset_guide.xml:488(literal) toolset_guide.xml:562(literal)
|
||||
msgid "--properties=hibernate.properties"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:338(entry) toolset_guide.xml:489(entry) toolset_guide.xml:563(entry)
|
||||
msgid "read database properties from a file"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:341(literal)
|
||||
msgid "--format"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:342(entry)
|
||||
msgid "format the generated SQL nicely in the script"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:345(literal)
|
||||
msgid "--delimiter=;"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:346(entry)
|
||||
msgid "set an end of line delimiter for the script"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:352(para)
|
||||
msgid "You may even embed <literal>SchemaExport</literal> in your application:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:362(title)
|
||||
msgid "Properties"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:364(para)
|
||||
msgid "Database properties may be specified"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:370(para)
|
||||
msgid "as system properties with <literal>-D</literal><emphasis><property></emphasis>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:373(para)
|
||||
msgid "in <literal>hibernate.properties</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:376(para)
|
||||
msgid "in a named properties file with <literal>--properties</literal>"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:380(para)
|
||||
msgid "The needed properties are:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:385(title)
|
||||
msgid "SchemaExport Connection Properties"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:391(entry)
|
||||
msgid "Property Name"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:397(literal)
|
||||
msgid "hibernate.connection.driver_class"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:398(entry)
|
||||
msgid "jdbc driver class"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:401(literal)
|
||||
msgid "hibernate.connection.url"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:402(entry)
|
||||
msgid "jdbc url"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:405(literal)
|
||||
msgid "hibernate.connection.username"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:406(entry)
|
||||
msgid "database user"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:409(literal)
|
||||
msgid "hibernate.connection.password"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:410(entry)
|
||||
msgid "user password"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:413(literal)
|
||||
msgid "hibernate.dialect"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:414(entry)
|
||||
msgid "dialect"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:423(title)
|
||||
msgid "Using Ant"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:425(para)
|
||||
msgid "You can call <literal>SchemaExport</literal> from your Ant build script:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:450(title)
|
||||
msgid "Incremental schema updates"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:452(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:460(literal)
|
||||
msgid "org.hibernate.tool.hbm2ddl.SchemaUpdate"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:464(title)
|
||||
msgid "<literal>SchemaUpdate</literal> Command Line Options"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:481(entry)
|
||||
msgid "don't export the script to the database"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:493(literal) toolset_guide.xml:567(literal)
|
||||
msgid ".cfg.xml"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:493(entry) toolset_guide.xml:567(entry)
|
||||
msgid "specify a <placeholder-1/> file"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:499(para)
|
||||
msgid "You may embed <literal>SchemaUpdate</literal> in your application:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:509(title)
|
||||
msgid "Using Ant for incremental schema updates"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:511(para)
|
||||
msgid "You can call <literal>SchemaUpdate</literal> from the Ant script:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:532(title)
|
||||
msgid "Schema validation"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:534(para)
|
||||
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 ""
|
||||
|
||||
#: toolset_guide.xml:542(literal)
|
||||
msgid "org.hibernate.tool.hbm2ddl.SchemaValidator"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:546(title)
|
||||
msgid "<literal>SchemaValidator</literal> Command Line Options"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:573(para)
|
||||
msgid "You may embed <literal>SchemaValidator</literal> in your application:"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:583(title)
|
||||
msgid "Using Ant for schema validation"
|
||||
msgstr ""
|
||||
|
||||
#: toolset_guide.xml:585(para)
|
||||
msgid "You can call <literal>SchemaValidator</literal> from the Ant script:"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: toolset_guide.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,524 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:35-0500\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"
|
||||
|
||||
#: transactions.xml:5(title)
|
||||
msgid "Transactions And Concurrency"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:7(para)
|
||||
msgid "The most important point about Hibernate and concurrency control is that it is very easy to understand. Hibernate directly uses JDBC connections and JTA resources without adding any additional locking behavior. We highly recommend you spend some time with the JDBC, ANSI, and transaction isolation specification of your database management system."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:14(para)
|
||||
msgid "Hibernate does not lock objects in memory. Your application can expect the behavior as defined by the isolation level of your database transactions. Note that thanks to the <literal>Session</literal>, which is also a transaction-scoped cache, Hibernate provides repeatable reads for lookup by identifier and entity queries (not reporting queries that return scalar values)."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:22(para)
|
||||
msgid "In addition to versioning for automatic optimistic concurrency control, Hibernate also offers a (minor) API for pessimistic locking of rows, using the <literal>SELECT FOR UPDATE</literal> syntax. Optimistic concurrency control and this API are discussed later in this chapter."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:29(para)
|
||||
msgid "We start the discussion of concurrency control in Hibernate with the granularity of <literal>Configuration</literal>, <literal>SessionFactory</literal>, and <literal>Session</literal>, as well as database transactions and long conversations."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:36(title)
|
||||
msgid "Session and transaction scopes"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:38(para)
|
||||
msgid "A <literal>SessionFactory</literal> is an expensive-to-create, threadsafe object intended to be shared by all application threads. It is created once, usually on application startup, from a <literal>Configuration</literal> instance."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:44(para)
|
||||
msgid "A <literal>Session</literal> is an inexpensive, non-threadsafe object that should be used once, for a single request, a conversation, single unit of work, and then discarded. A <literal>Session</literal> will not obtain a JDBC <literal>Connection</literal> (or a <literal>Datasource</literal>) unless it is needed, hence consume no resources until used."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:52(para)
|
||||
msgid "To complete this picture you also have to think about database transactions. A database transaction has to be as short as possible, to reduce lock contention in the database. Long database transactions will prevent your application from scaling to highly concurrent load. Hence, it is almost never good design to hold a database transaction open during user think time, until the unit of work is complete."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:61(para)
|
||||
msgid "What is the scope of a unit of work? Can a single Hibernate <literal>Session</literal> span several database transactions or is this a one-to-one relationship of scopes? When should you open and close a <literal>Session</literal> and how do you demarcate the database transaction boundaries?"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:69(title)
|
||||
msgid "Unit of work"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:71(para)
|
||||
msgid "First, don't use the <emphasis>session-per-operation</emphasis> antipattern, that is, don't open and close a <literal>Session</literal> for every simple database call in a single thread! Of course, the same is true for database transactions. Database calls in an application are made using a planned sequence, they are grouped into atomic units of work. (Note that this also means that auto-commit after every single SQL statement is useless in an application, this mode is intended for ad-hoc SQL console work. Hibernate disables, or expects the application server to do so, auto-commit mode immediately.) Database transactions are never optional, all communication with a database has to occur inside a transaction, no matter if you read or write data. As explained, auto-commit behavior for reading data should be avoided, as many small transactions are unlikely to perform better than one clearly defined unit of work. The latter is also much more maintainable and extensible."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:87(para)
|
||||
msgid "The most common pattern in a multi-user client/server application is <emphasis>session-per-request</emphasis>. In this model, a request from the client is send to the server (where the Hibernate persistence layer runs), a new Hibernate <literal>Session</literal> is opened, and all database operations are executed in this unit of work. Once the work has been completed (and the response for the client has been prepared), the session is flushed and closed. You would also use a single database transaction to serve the clients request, starting and committing it when you open and close the <literal>Session</literal>. The relationship between the two is one-to-one and this model is a perfect fit for many applications."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:99(para)
|
||||
msgid "The challenge lies in the implementation. Hibernate provides built-in management of the \"current session\" to simplify this pattern. All you have to do is start a transaction when a server request has to be processed, and end the transaction before the response is send to the client. You can do this in any way you like, common solutions are <literal>ServletFilter</literal>, AOP interceptor with a pointcut on the service methods, or a proxy/interception container. An EJB container is a standardized way to implement cross-cutting aspects such as transaction demarcation on EJB session beans, declaratively with CMT. If you decide to use programmatic transaction demarcation, prefer the Hibernate <literal>Transaction</literal> API shown later in this chapter, for ease of use and code portability."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:112(para)
|
||||
msgid "Your application code can access a \"current session\" to process the request by simply calling <literal>sessionFactory.getCurrentSession()</literal> anywhere and as often as needed. You will always get a <literal>Session</literal> scoped to the current database transaction. This has to be configured for either resource-local or JTA environments, see <xref linkend=\"architecture-current-session\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:120(para)
|
||||
msgid "Sometimes it is convenient to extend the scope of a <literal>Session</literal> and database transaction until the \"view has been rendered\". This is especially useful in servlet applications that utilize a separate rendering phase after the request has been processed. Extending the database transaction until view rendering is complete is easy to do if you implement your own interceptor. However, it is not easily doable if you rely on EJBs with container-managed transactions, as a transaction will be completed when an EJB method returns, before rendering of any view can start. See the Hibernate website and forum for tips and examples around this <emphasis>Open Session in View</emphasis> pattern."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:135(title)
|
||||
msgid "Long conversations"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:137(para)
|
||||
msgid "The session-per-request pattern is not the only useful concept you can use to design units of work. Many business processes require a whole series of interactions with the user interleaved with database accesses. In web and enterprise applications it is not acceptable for a database transaction to span a user interaction. Consider the following example:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:147(para)
|
||||
msgid "The first screen of a dialog opens, the data seen by the user has been loaded in a particular <literal>Session</literal> and database transaction. The user is free to modify the objects."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:154(para)
|
||||
msgid "The user clicks \"Save\" after 5 minutes and expects his modifications to be made persistent; he also expects that he was the only person editing this information and that no conflicting modification can occur."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:162(para)
|
||||
msgid "We call this unit of work, from the point of view of the user, a long running <emphasis>conversation</emphasis> (or <emphasis>application transaction</emphasis>). There are many ways how you can implement this in your application."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:168(para)
|
||||
msgid "A first naive implementation might keep the <literal>Session</literal> and database transaction open during user think time, with locks held in the database to prevent concurrent modification, and to guarantee isolation and atomicity. This is of course an anti-pattern, since lock contention would not allow the application to scale with the number of concurrent users."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:176(para)
|
||||
msgid "Clearly, we have to use several database transactions to implement the converastion. In this case, maintaining isolation of business processes becomes the partial responsibility of the application tier. A single conversation usually spans several database transactions. It will be atomic if only one of these database transactions (the last one) stores the updated data, all others simply read data (e.g. in a wizard-style dialog spanning several request/response cycles). This is easier to implement than it might sound, especially if you use Hibernate's features:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:189(para)
|
||||
msgid "<emphasis>Automatic Versioning</emphasis> - Hibernate can do automatic optimistic concurrency control for you, it can automatically detect if a concurrent modification occured during user think time. Usually we only check at the end of the conversation."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:197(para)
|
||||
msgid "<emphasis>Detached Objects</emphasis> - If you decide to use the already discussed <emphasis>session-per-request</emphasis> pattern, all loaded instances will be in detached state during user think time. Hibernate allows you to reattach the objects and persist the modifications, the pattern is called <emphasis>session-per-request-with-detached-objects</emphasis>. Automatic versioning is used to isolate concurrent modifications."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:207(para)
|
||||
msgid "<emphasis>Extended (or Long) Session</emphasis> - The Hibernate <literal>Session</literal> may be disconnected from the underlying JDBC connection after the database transaction has been committed, and reconnected when a new client request occurs. This pattern is known as <emphasis>session-per-conversation</emphasis> and makes even reattachment unnecessary. Automatic versioning is used to isolate concurrent modifications and the <literal>Session</literal> is usually not allowed to be flushed automatically, but explicitely."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:220(para)
|
||||
msgid "Both <emphasis>session-per-request-with-detached-objects</emphasis> and <emphasis>session-per-conversation</emphasis> have advantages and disadvantages, we discuss them later in this chapter in the context of optimistic concurrency control."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:229(title)
|
||||
msgid "Considering object identity"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:231(para)
|
||||
msgid "An application may concurrently access the same persistent state in two different <literal>Session</literal>s. However, an instance of a persistent class is never shared between two <literal>Session</literal> instances. Hence there are two different notions of identity:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:240(term)
|
||||
msgid "Database Identity"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:243(literal)
|
||||
msgid "foo.getId().equals( bar.getId() )"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:248(term)
|
||||
msgid "JVM Identity"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:251(literal)
|
||||
msgid "foo==bar"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:257(para)
|
||||
msgid "Then for objects attached to a <emphasis>particular</emphasis><literal>Session</literal> (i.e. in the scope of a <literal>Session</literal>) the two notions are equivalent, and JVM identity for database identity is guaranteed by Hibernate. However, while the application might concurrently access the \"same\" (persistent identity) business object in two different sessions, the two instances will actually be \"different\" (JVM identity). Conflicts are resolved using (automatic versioning) at flush/commit time, using an optimistic approach."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:266(para)
|
||||
msgid "This approach leaves Hibernate and the database to worry about concurrency; it also provides the best scalability, since guaranteeing identity in single-threaded units of work only doesn't need expensive locking or other means of synchronization. The application never needs to synchronize on any business object, as long as it sticks to a single thread per <literal>Session</literal>. Within a <literal>Session</literal> the application may safely use <literal>==</literal> to compare objects."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:275(para)
|
||||
msgid "However, an application that uses <literal>==</literal> outside of a <literal>Session</literal>, might see unexpected results. This might occur even in some unexpected places, for example, if you put two detached instances into the same <literal>Set</literal>. Both might have the same database identity (i.e. they represent the same row), but JVM identity is by definition not guaranteed for instances in detached state. The developer has to override the <literal>equals()</literal> and <literal>hashCode()</literal> methods in persistent classes and implement his own notion of object equality. There is one caveat: Never use the database identifier to implement equality, use a business key, a combination of unique, usually immutable, attributes. The database identifier will change if a transient object is made persistent. If the transient instance (usually together with detached instances) is held in a <literal>Set</literal>, changing the hashcode breaks the contract of the <literal>Set</literal>. Attributes for business keys don't have to be as stable as database primary keys, you only have to guarantee stability as long as the objects are in the same <literal>Set</literal>. See the Hibernate website for a more thorough discussion of this issue. Also note that this is not a Hibernate issue, but simply how Java object identity and equality has to be implemented."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:296(title)
|
||||
msgid "Common issues"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:298(para)
|
||||
msgid "Never use the anti-patterns <emphasis>session-per-user-session</emphasis> or <emphasis>session-per-application</emphasis> (of course, there are rare exceptions to this rule). Note that some of the following issues might also appear with the recommended patterns, make sure you understand the implications before making a design decision:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:307(para)
|
||||
msgid "A <literal>Session</literal> is not thread-safe. Things which are supposed to work concurrently, like HTTP requests, session beans, or Swing workers, will cause race conditions if a <literal>Session</literal> instance would be shared. If you keep your Hibernate <literal>Session</literal> in your <literal>HttpSession</literal> (discussed later), you should consider synchronizing access to your Http session. Otherwise, a user that clicks reload fast enough may use the same <literal>Session</literal> in two concurrently running threads."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:318(para)
|
||||
msgid "An exception thrown by Hibernate means you have to rollback your database transaction and close the <literal>Session</literal> immediately (discussed later in more detail). If your <literal>Session</literal> is bound to the application, you have to stop the application. Rolling back the database transaction doesn't put your business objects back into the state they were at the start of the transaction. This means the database state and the business objects do get out of sync. Usually this is not a problem, because exceptions are not recoverable and you have to start over after rollback anyway."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:330(para)
|
||||
msgid "The <literal>Session</literal> caches every object that is in persistent state (watched and checked for dirty state by Hibernate). This means it grows endlessly until you get an OutOfMemoryException, if you keep it open for a long time or simply load too much data. One solution for this is to call <literal>clear()</literal> and <literal>evict()</literal> to manage the <literal>Session</literal> cache, but you most likely should consider a Stored Procedure if you need mass data operations. Some solutions are shown in <xref linkend=\"batch\"/>. Keeping a <literal>Session</literal> open for the duration of a user session also means a high probability of stale data."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:348(title)
|
||||
msgid "Database transaction demarcation"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:350(para)
|
||||
msgid "Datatabase (or system) transaction boundaries are always necessary. No communication with the database can occur outside of a database transaction (this seems to confuse many developers who are used to the auto-commit mode). Always use clear transaction boundaries, even for read-only operations. Depending on your isolation level and database capabilities this might not be required but there is no downside if you always demarcate transactions explicitly. Certainly, a single database transaction is going to perform better than many small transactions, even for reading data."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:360(para)
|
||||
msgid "A Hibernate application can run in non-managed (i.e. standalone, simple Web- or Swing applications) and managed J2EE environments. In a non-managed environment, Hibernate is usually responsible for its own database connection pool. The application developer has to manually set transaction boundaries, in other words, begin, commit, or rollback database transactions himself. A managed environment usually provides container-managed transactions (CMT), with the transaction assembly defined declaratively in deployment descriptors of EJB session beans, for example. Programmatic transaction demarcation is then no longer necessary."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:370(para)
|
||||
msgid "However, it is often desirable to keep your persistence layer portable between non-managed resource-local environments, and systems that can rely on JTA but use BMT instead of CMT. In both cases you'd use programmatic transaction demaracation. Hibernate offers a wrapper API called <literal>Transaction</literal> that translates into the native transaction system of your deployment environment. This API is actually optional, but we strongly encourage its use unless you are in a CMT session bean."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:379(para)
|
||||
msgid "Usually, ending a <literal>Session</literal> involves four distinct phases:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:385(para)
|
||||
msgid "flush the session"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:390(para)
|
||||
msgid "commit the transaction"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:395(para)
|
||||
msgid "close the session"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:400(para)
|
||||
msgid "handle exceptions"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:406(para)
|
||||
msgid "Flushing the session has been discussed earlier, we'll now have a closer look at transaction demarcation and exception handling in both managed- and non-managed environments."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:413(title)
|
||||
msgid "Non-managed environment"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:415(para)
|
||||
msgid "If a Hibernate persistence layer runs in a non-managed environment, database connections are usually handled by simple (i.e. non-DataSource) connection pools from which Hibernate obtains connections as needed. The session/transaction handling idiom looks like this:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:441(para)
|
||||
msgid "You don't have to <literal>flush()</literal> the <literal>Session</literal> explicitly - the call to <literal>commit()</literal> automatically triggers the synchronization (depending upon the <xref linkend=\"objectstate-flushing\">FlushMode</xref> for the session. A call to <literal>close()</literal> marks the end of a session. The main implication of <literal>close()</literal> is that the JDBC connection will be relinquished by the session. This Java code is portable and runs in both non-managed and JTA environments."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:450(para)
|
||||
msgid "A much more flexible solution is Hibernate's built-in \"current session\" context management, as described earlier:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:469(para)
|
||||
msgid "You will very likely never see these code snippets in a regular application; fatal (system) exceptions should always be caught at the \"top\". In other words, the code that executes Hibernate calls (in the persistence layer) and the code that handles <literal>RuntimeException</literal> (and usually can only clean up and exit) are in different layers. The current context management by Hibernate can significantly simplify this design, as all you need is access to a <literal>SessionFactory</literal>. Exception handling is discussed later in this chapter."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:479(para)
|
||||
msgid "Note that you should select <literal>org.hibernate.transaction.JDBCTransactionFactory</literal> (which is the default), and for the second example <literal>\"thread\"</literal> as your <literal>hibernate.current_session_context_class</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:488(title)
|
||||
msgid "Using JTA"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:490(para)
|
||||
msgid "If your persistence layer runs in an application server (e.g. behind EJB session beans), every datasource connection obtained by Hibernate will automatically be part of the global JTA transaction. You can also install a standalone JTA implementation and use it without EJB. Hibernate offers two strategies for JTA integration."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:497(para)
|
||||
msgid "If you use bean-managed transactions (BMT) Hibernate will tell the application server to start and end a BMT transaction if you use the <literal>Transaction</literal> API. So, the transaction management code is identical to the non-managed environment."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:522(para)
|
||||
msgid "If you want to use a transaction-bound <literal>Session</literal>, that is, the <literal>getCurrentSession()</literal> functionality for easy context propagation, you will have to use the JTA <literal>UserTransaction</literal> API directly:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:546(para)
|
||||
msgid "With CMT, transaction demarcation is done in session bean deployment descriptors, not programatically, hence, the code is reduced to:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:558(para)
|
||||
msgid "In a CMT/EJB even rollback happens automatically, since an unhandled <literal>RuntimeException</literal> thrown by a session bean method tells the container to set the global transaction to rollback. <emphasis>This means you do not need to use the Hibernate <literal>Transaction</literal> API at all with BMT or CMT, and you get automatic propagation of the \"current\" Session bound to the transaction.</emphasis>"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:566(para)
|
||||
msgid "Note that you should choose <literal>org.hibernate.transaction.JTATransactionFactory</literal> if you use JTA directly (BMT), and <literal>org.hibernate.transaction.CMTTransactionFactory</literal> in a CMT session bean, when you configure Hibernate's transaction factory. Remember to also set <literal>hibernate.transaction.manager_lookup_class</literal>. Furthermore, make sure that your <literal>hibernate.current_session_context_class</literal> is either unset (backwards compatiblity), or set to <literal>\"jta\"</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:575(para)
|
||||
msgid "The <literal>getCurrentSession()</literal> operation has one downside in a JTA environment. There is one caveat to the use of <literal>after_statement</literal> connection release mode, which is then used by default. Due to a silly limitation of the JTA spec, it is not possible for Hibernate to automatically clean up any unclosed <literal>ScrollableResults</literal> or <literal>Iterator</literal> instances returned by <literal>scroll()</literal> or <literal>iterate()</literal>. You <emphasis>must</emphasis> release the underlying database cursor by calling <literal>ScrollableResults.close()</literal> or <literal>Hibernate.close(Iterator)</literal> explicity from a <literal>finally</literal> block. (Of course, most applications can easily avoid using <literal>scroll()</literal> or <literal>iterate()</literal> at all from the JTA or CMT code.)"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:591(title)
|
||||
msgid "Exception handling"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:593(para)
|
||||
msgid "If the <literal>Session</literal> throws an exception (including any <literal>SQLException</literal>), you should immediately rollback the database transaction, call <literal>Session.close()</literal> and discard the <literal>Session</literal> instance. Certain methods of <literal>Session</literal> will <emphasis>not</emphasis> leave the session in a consistent state. No exception thrown by Hibernate can be treated as recoverable. Ensure that the <literal>Session</literal> will be closed by calling <literal>close()</literal> in a <literal>finally</literal> block."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:604(para)
|
||||
msgid "The <literal>HibernateException</literal>, which wraps most of the errors that can occur in a Hibernate persistence layer, is an unchecked exception (it wasn't in older versions of Hibernate). In our opinion, we shouldn't force the application developer to catch an unrecoverable exception at a low layer. In most systems, unchecked and fatal exceptions are handled in one of the first frames of the method call stack (i.e. in higher layers) and an error message is presented to the application user (or some other appropriate action is taken). Note that Hibernate might also throw other unchecked exceptions which are not a <literal>HibernateException</literal>. These are, again, not recoverable and appropriate action should be taken."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:616(para)
|
||||
msgid "Hibernate wraps <literal>SQLException</literal>s thrown while interacting with the database in a <literal>JDBCException</literal>. In fact, Hibernate will attempt to convert the eexception into a more meningful subclass of <literal>JDBCException</literal>. The underlying <literal>SQLException</literal> is always available via <literal>JDBCException.getCause()</literal>. Hibernate converts the <literal>SQLException</literal> into an appropriate <literal>JDBCException</literal> subclass using the <literal>SQLExceptionConverter</literal> attached to the <literal>SessionFactory</literal>. By default, the <literal>SQLExceptionConverter</literal> is defined by the configured dialect; however, it is also possible to plug in a custom implementation (see the javadocs for the <literal>SQLExceptionConverterFactory</literal> class for details). The standard <literal>JDBCException</literal> subtypes are:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:632(para)
|
||||
msgid "<literal>JDBCConnectionException</literal> - indicates an error with the underlying JDBC communication."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:638(para)
|
||||
msgid "<literal>SQLGrammarException</literal> - indicates a grammar or syntax problem with the issued SQL."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:644(para)
|
||||
msgid "<literal>ConstraintViolationException</literal> - indicates some form of integrity constraint violation."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:650(para)
|
||||
msgid "<literal>LockAcquisitionException</literal> - indicates an error acquiring a lock level necessary to perform the requested operation."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:656(para)
|
||||
msgid "<literal>GenericJDBCException</literal> - a generic exception which did not fall into any of the other categories."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:666(title)
|
||||
msgid "Transaction timeout"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:668(para)
|
||||
msgid "One extremely important feature provided by a managed environment like EJB that is never provided for non-managed code is transaction timeout. Transaction timeouts ensure that no misbehaving transaction can indefinitely tie up resources while returning no response to the user. Outside a managed (JTA) environment, Hibernate cannot fully provide this functionality. However, Hibernate can at least control data access operations, ensuring that database level deadlocks and queries with huge result sets are limited by a defined timeout. In a managed environment, Hibernate can delegate transaction timeout to JTA. This functioanlity is abstracted by the Hibernate <literal>Transaction</literal> object."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:701(para)
|
||||
msgid "Note that <literal>setTimeout()</literal> may not be called in a CMT bean, where transaction timeouts must be defined declaratively."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:711(title)
|
||||
msgid "Optimistic concurrency control"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:713(para)
|
||||
msgid "The only approach that is consistent with high concurrency and high scalability is optimistic concurrency control with versioning. Version checking uses version numbers, or timestamps, to detect conflicting updates (and to prevent lost updates). Hibernate provides for three possible approaches to writing application code that uses optimistic concurrency. The use cases we show are in the context of long conversations, but version checking also has the benefit of preventing lost updates in single database transactions."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:724(title)
|
||||
msgid "Application version checking"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:726(para)
|
||||
msgid "In an implementation without much help from Hibernate, each interaction with the database occurs in a new <literal>Session</literal> and the developer is responsible for reloading all persistent instances from the database before manipulating them. This approach forces the application to carry out its own version checking to ensure conversation transaction isolation. This approach is the least efficient in terms of database access. It is the approach most similar to entity EJBs."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:747(para)
|
||||
msgid "The <literal>version</literal> property is mapped using <literal><version></literal>, and Hibernate will automatically increment it during flush if the entity is dirty."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:753(para)
|
||||
msgid "Of course, if you are operating in a low-data-concurrency environment and don't require version checking, you may use this approach and just skip the version check. In that case, <emphasis>last commit wins</emphasis> will be the default strategy for your long conversations. Keep in mind that this might confuse the users of the application, as they might experience lost updates without error messages or a chance to merge conflicting changes."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:762(para)
|
||||
msgid "Clearly, manual version checking is only feasible in very trivial circumstances and not practical for most applications. Often not only single instances, but complete graphs of modified ojects have to be checked. Hibernate offers automatic version checking with either an extended <literal>Session</literal> or detached instances as the design paradigm."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:773(title)
|
||||
msgid "Extended session and automatic versioning"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:775(para)
|
||||
msgid "A single <literal>Session</literal> instance and its persistent instances are used for the whole conversation, known as <emphasis>session-per-conversation</emphasis>. Hibernate checks instance versions at flush time, throwing an exception if concurrent modification is detected. It's up to the developer to catch and handle this exception (common options are the opportunity for the user to merge changes or to restart the business conversation with non-stale data)."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:784(para)
|
||||
msgid "The <literal>Session</literal> is disconnected from any underlying JDBC connection when waiting for user interaction. This approach is the most efficient in terms of database access. The application need not concern itself with version checking or with reattaching detached instances, nor does it have to reload instances in every database transaction."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:800(para)
|
||||
msgid "The <literal>foo</literal> object still knows which <literal>Session</literal> it was loaded in. Beginning a new database transaction on an old session obtains a new connection and resumes the session. Committing a database transaction disconnects a session from the JDBC connection and returns the connection to the pool. After reconnection, to force a version check on data you aren't updating, you may call <literal>Session.lock()</literal> with <literal>LockMode.READ</literal> on any objects that might have been updated by another transaction. You don't need to lock any data that you <emphasis>are</emphasis> updating. Usually you would set <literal>FlushMode.MANUAL</literal> on an extended <literal>Session</literal>, so that only the last database transaction cycle is allowed to actually persist all modifications made in this conversation. Hence, only this last database transaction would include the <literal>flush()</literal> operation, and then also <literal>close()</literal> the session to end the conversation."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:815(para)
|
||||
msgid "This pattern is problematic if the <literal>Session</literal> is too big to be stored during user think time, e.g. an <literal>HttpSession</literal> should be kept as small as possible. As the <literal>Session</literal> is also the (mandatory) first-level cache and contains all loaded objects, we can probably use this strategy only for a few request/response cycles. You should use a <literal>Session</literal> only for a single conversation, as it will soon also have stale data."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:825(para)
|
||||
msgid "(Note that earlier Hibernate versions required explicit disconnection and reconnection of a <literal>Session</literal>. These methods are deprecated, as beginning and ending a transaction has the same effect.)"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:831(para)
|
||||
msgid "Also note that you should keep the disconnected <literal>Session</literal> close to the persistence layer. In other words, use an EJB stateful session bean to hold the <literal>Session</literal> in a three-tier environment, and don't transfer it to the web layer (or even serialize it to a separate tier) to store it in the <literal>HttpSession</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:839(para)
|
||||
msgid "The extended session pattern, or <emphasis>session-per-conversation</emphasis>, is more difficult to implement with automatic current session context management. You need to supply your own implementation of the <literal>CurrentSessionContext</literal> for this, see the Hibernate Wiki for examples."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:849(title)
|
||||
msgid "Detached objects and automatic versioning"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:851(para)
|
||||
msgid "Each interaction with the persistent store occurs in a new <literal>Session</literal>. However, the same persistent instances are reused for each interaction with the database. The application manipulates the state of detached instances originally loaded in another <literal>Session</literal> and then reattaches them using <literal>Session.update()</literal>, <literal>Session.saveOrUpdate()</literal>, or <literal>Session.merge()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:867(para)
|
||||
msgid "Again, Hibernate will check instance versions during flush, throwing an exception if conflicting updates occured."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:872(para)
|
||||
msgid "You may also call <literal>lock()</literal> instead of <literal>update()</literal> and use <literal>LockMode.READ</literal> (performing a version check, bypassing all caches) if you are sure that the object has not been modified."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:881(title)
|
||||
msgid "Customizing automatic versioning"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:883(para)
|
||||
msgid "You may disable Hibernate's automatic version increment for particular properties and collections by setting the <literal>optimistic-lock</literal> mapping attribute to <literal>false</literal>. Hibernate will then no longer increment versions if the property is dirty."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:890(para)
|
||||
msgid "Legacy database schemas are often static and can't be modified. Or, other applications might also access the same database and don't know how to handle version numbers or even timestamps. In both cases, versioning can't rely on a particular column in a table. To force a version check without a version or timestamp property mapping, with a comparison of the state of all fields in a row, turn on <literal>optimistic-lock=\"all\"</literal> in the <literal><class></literal> mapping. Note that this concepetually only works if Hibernate can compare the old and new state, i.e. if you use a single long <literal>Session</literal> and not session-per-request-with-detached-objects."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:901(para)
|
||||
msgid "Sometimes concurrent modification can be permitted as long as the changes that have been made don't overlap. If you set <literal>optimistic-lock=\"dirty\"</literal> when mapping the <literal><class></literal>, Hibernate will only compare dirty fields during flush."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:907(para)
|
||||
msgid "In both cases, with dedicated version/timestamp columns or with full/dirty field comparison, Hibernate uses a single <literal>UPDATE</literal> statement (with an appropriate <literal>WHERE</literal> clause) per entity to execute the version check and update the information. If you use transitive persistence to cascade reattachment to associated entities, Hibernate might execute uneccessary updates. This is usually not a problem, but <emphasis>on update</emphasis> triggers in the database might be executed even when no changes have been made to detached instances. You can customize this behavior by setting <literal>select-before-update=\"true\"</literal> in the <literal><class></literal> mapping, forcing Hibernate to <literal>SELECT</literal> the instance to ensure that changes did actually occur, before updating the row."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:925(title)
|
||||
msgid "Pessimistic Locking"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:927(para)
|
||||
msgid "It is not intended that users spend much time worring about locking strategies. Its usually enough to specify an isolation level for the JDBC connections and then simply let the database do all the work. However, advanced users may sometimes wish to obtain exclusive pessimistic locks, or re-obtain locks at the start of a new transaction."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:934(para)
|
||||
msgid "Hibernate will always use the locking mechanism of the database, never lock objects in memory!"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:939(para)
|
||||
msgid "The <literal>LockMode</literal> class defines the different lock levels that may be acquired by Hibernate. A lock is obtained by the following mechanisms:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:946(para)
|
||||
msgid "<literal>LockMode.WRITE</literal> is acquired automatically when Hibernate updates or inserts a row."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:952(para)
|
||||
msgid "<literal>LockMode.UPGRADE</literal> may be acquired upon explicit user request using <literal>SELECT ... FOR UPDATE</literal> on databases which support that syntax."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:958(para)
|
||||
msgid "<literal>LockMode.UPGRADE_NOWAIT</literal> may be acquired upon explicit user request using a <literal>SELECT ... FOR UPDATE NOWAIT</literal> under Oracle."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:964(para)
|
||||
msgid "<literal>LockMode.READ</literal> is acquired automatically when Hibernate reads data under Repeatable Read or Serializable isolation level. May be re-acquired by explicit user request."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:971(para)
|
||||
msgid "<literal>LockMode.NONE</literal> represents the absence of a lock. All objects switch to this lock mode at the end of a <literal>Transaction</literal>. Objects associated with the session via a call to <literal>update()</literal> or <literal>saveOrUpdate()</literal> also start out in this lock mode."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:980(para)
|
||||
msgid "The \"explicit user request\" is expressed in one of the following ways:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:986(para)
|
||||
msgid "A call to <literal>Session.load()</literal>, specifying a <literal>LockMode</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:991(para)
|
||||
msgid "A call to <literal>Session.lock()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:996(para)
|
||||
msgid "A call to <literal>Query.setLockMode()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1002(para)
|
||||
msgid "If <literal>Session.load()</literal> is called with <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>, and the requested object was not yet loaded by the session, the object is loaded using <literal>SELECT ... FOR UPDATE</literal>. If <literal>load()</literal> is called for an object that is already loaded with a less restrictive lock than the one requested, Hibernate calls <literal>lock()</literal> for that object."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1011(para)
|
||||
msgid "<literal>Session.lock()</literal> performs a version number check if the specified lock mode is <literal>READ</literal>, <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>. (In the case of <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>, <literal>SELECT ... FOR UPDATE</literal> is used.)"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1018(para)
|
||||
msgid "If the database does not support the requested lock mode, Hibernate will use an appropriate alternate mode (instead of throwing an exception). This ensures that applications will be portable."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1027(title)
|
||||
msgid "Connection Release Modes"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1029(para)
|
||||
msgid "The legacy (2.x) behavior of Hibernate in regards to JDBC connection management was that a <literal>Session</literal> would obtain a connection when it was first needed and then hold unto that connection until the session was closed. Hibernate 3.x introduced the notion of connection release modes to tell a session how to handle its JDBC connections. Note that the following discussion is pertinent only to connections provided through a configured <literal>ConnectionProvider</literal>; user-supplied connections are outside the breadth of this discussion. The different release modes are identified by the enumerated values of <literal>org.hibernate.ConnectionReleaseMode</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1043(para)
|
||||
msgid "<literal>ON_CLOSE</literal> - is essentially the legacy behavior described above. The Hibernate session obatins a connection when it first needs to perform some JDBC access and holds unto that connection until the session is closed."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1050(para)
|
||||
msgid "<literal>AFTER_TRANSACTION</literal> - says to release connections after a <literal>org.hibernate.Transaction</literal> has completed."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1056(para)
|
||||
msgid "<literal>AFTER_STATEMENT</literal> (also referred to as aggressive release) - says to release connections after each and every statement execution. This aggressive releasing is skipped if that statement leaves open resources associated with the given session; currently the only situation where this occurs is through the use of <literal>org.hibernate.ScrollableResults</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1066(para)
|
||||
msgid "The configuration parameter <literal>hibernate.connection.release_mode</literal> is used to specify which release mode to use. The possible values:"
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1073(para)
|
||||
msgid "<literal>auto</literal> (the default) - this choice delegates to the release mode returned by the <literal>org.hibernate.transaction.TransactionFactory.getDefaultReleaseMode()</literal> method. For JTATransactionFactory, this returns ConnectionReleaseMode.AFTER_STATEMENT; for JDBCTransactionFactory, this returns ConnectionReleaseMode.AFTER_TRANSACTION. It is rarely a good idea to change this default behavior as failures due to the value of this setting tend to indicate bugs and/or invalid assumptions in user code."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1083(para)
|
||||
msgid "<literal>on_close</literal> - says to use ConnectionReleaseMode.ON_CLOSE. This setting is left for backwards compatibility, but its use is highly discouraged."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1089(para)
|
||||
msgid "<literal>after_transaction</literal> - says to use ConnectionReleaseMode.AFTER_TRANSACTION. This setting should not be used in JTA environments. Also note that with ConnectionReleaseMode.AFTER_TRANSACTION, if a session is considered to be in auto-commit mode connections will be released as if the release mode were AFTER_STATEMENT."
|
||||
msgstr ""
|
||||
|
||||
#: transactions.xml:1097(para)
|
||||
msgid "<literal>after_statement</literal> - says to use ConnectionReleaseMode.AFTER_STATEMENT. Additionally, the configured <literal>ConnectionProvider</literal> is consulted to see if it supports this setting (<literal>supportsAggressiveRelease()</literal>). If not, the release mode is reset to ConnectionReleaseMode.AFTER_TRANSACTION. This setting is only safe in environments where we can either re-acquire the same underlying JDBC connection each time we make a call into <literal>ConnectionProvider.getConnection()</literal> or in auto-commit environments where it does not matter whether we get back the same connection."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: transactions.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,568 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:35-0500\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"
|
||||
|
||||
#: tutorial.xml:7(title)
|
||||
msgid "Introduction to Hibernate"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:10(title)
|
||||
msgid "Preface"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:12(para)
|
||||
msgid "This chapter is an introductory tutorial for new users of Hibernate. We start with a simple command line application using an in-memory database and develop it in easy to understand steps."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:18(para)
|
||||
msgid "This tutorial is intended for new users of Hibernate but requires Java and SQL knowledge. It is based on a tutorial by Michael Gloegl, the third-party libraries we name are for JDK 1.4 and 5.0. You might need others for JDK 1.3."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:24(para)
|
||||
msgid "The source code for the tutorial is included in the distribution in the <literal>doc/reference/tutorial/</literal> directory."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:32(title)
|
||||
msgid "Part 1 - The first Hibernate Application"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:34(para)
|
||||
msgid "First, we'll create a simple console-based Hibernate application. We use an Java database (HSQL DB), so we do not have to install any database server."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:39(para)
|
||||
msgid "Let's assume we need a small database application that can store events we want to attend, and information about the hosts of these events."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:44(para)
|
||||
msgid "The first thing we do, is set up our development directory and put all the Java libraries we need into it. Download the Hibernate distribution from the Hibernate website. Extract the package and place all required libraries found in <literal>/lib</literal> into into the <literal>/lib</literal> directory of your new development working directory. It should look like this:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:65(para)
|
||||
msgid "This is the minimum set of required libraries (note that we also copied hibernate3.jar, the main archive) for Hibernate <emphasis>at the time of writing</emphasis>. The Hibernate release you are using might require more or less libraries. See the <literal>README.txt</literal> file in the <literal>lib/</literal> directory of the Hibernate distribution for more information about required and optional third-party libraries. (Actually, Log4j is not required but preferred by many developers.)"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:74(para)
|
||||
msgid "Next we create a class that represents the event we want to store in database."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:79(title)
|
||||
msgid "The first class"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:81(para)
|
||||
msgid "Our first persistent class is a simple JavaBean class with some properties:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:122(para)
|
||||
msgid "You can see that this class uses standard JavaBean naming conventions for property getter and setter methods, as well as private visibility for the fields. This is a recommended design - but not required. Hibernate can also access fields directly, the benefit of accessor methods is robustness for refactoring. The no-argument constructor is required to instantiate an object of this class through reflection."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:130(para)
|
||||
msgid "The <literal>id</literal> property holds a unique identifier value for a particular event. All persistent entity classes (there are less important dependent classes as well) will need such an identifier property if we want to use the full feature set of Hibernate. In fact, most applications (esp. web applications) need to distinguish objects by identifier, so you should consider this a feature rather than a limitation. However, we usually don't manipulate the identity of an object, hence the setter method should be private. Only Hibernate will assign identifiers when an object is saved. You can see that Hibernate can access public, private, and protected accessor methods, as well as (public, private, protected) fields directly. The choice is up to you and you can match it to fit your application design."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:142(para)
|
||||
msgid "The no-argument constructor is a requirement for all persistent classes; Hibernate has to create objects for you, using Java Reflection. The constructor can be private, however, package visibility is required for runtime proxy generation and efficient data retrieval without bytecode instrumentation."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:149(para)
|
||||
msgid "Place this Java source file in a directory called <literal>src</literal> in the development folder, and in its correct package. The directory should now look like this:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:161(para)
|
||||
msgid "In the next step, we tell Hibernate about this persistent class."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:168(title)
|
||||
msgid "The mapping file"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:170(para)
|
||||
msgid "Hibernate needs to know how to load and store objects of the persistent class. This is where the Hibernate mapping file comes into play. The mapping file tells Hibernate what table in the database it has to access, and what columns in that table it should use."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:177(para)
|
||||
msgid "The basic structure of a mapping file looks like this:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:190(para)
|
||||
msgid "Note that the Hibernate DTD is very sophisticated. You can use it for auto-completion of XML mapping elements and attributes in your editor or IDE. You also should open up the DTD file in your text editor - it's the easiest way to get an overview of all elements and attributes and to see the defaults, as well as some comments. Note that Hibernate will not load the DTD file from the web, but first look it up from the classpath of the application. The DTD file is included in <literal>hibernate3.jar</literal> as well as in the <literal>src/</literal> directory of the Hibernate distribution."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:201(para)
|
||||
msgid "We will omit the DTD declaration in future examples to shorten the code. It is of course not optional."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:206(para)
|
||||
msgid "Between the two <literal>hibernate-mapping</literal> tags, include a <literal>class</literal> element. All persistent entity classes (again, there might be dependent classes later on, which are not first-class entities) need such a mapping, to a table in the SQL database:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:221(para)
|
||||
msgid "So far we told Hibernate how to persist and load object of class <literal>Event</literal> to the table <literal>EVENTS</literal>, each instance represented by a row in that table. Now we continue with a mapping of the unique identifier property to the tables primary key. In addition, as we don't want to care about handling this identifier, we configure Hibernate's identifier generation strategy for a surrogate primary key column:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:239(para)
|
||||
msgid "The <literal>id</literal> element is the declaration of the identifer property, <literal>name=\"id\"</literal> declares the name of the Java property - Hibernate will use the getter and setter methods to access the property. The column attribute tells Hibernate which column of the <literal>EVENTS</literal> table we use for this primary key. The nested <literal>generator</literal> element specifies the identifier generation strategy, in this case we used <literal>native</literal>, which picks the best strategy depending on the configured database (dialect). Hibernate supports database generated, globally unique, as well as application assigned identifiers (or any strategy you have written an extension for)."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:252(para)
|
||||
msgid "Finally we include declarations for the persistent properties of the class in the mapping file. By default, no properties of the class are considered persistent:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:271(para)
|
||||
msgid "Just as with the <literal>id</literal> element, the <literal>name</literal> attribute of the <literal>property</literal> element tells Hibernate which getter and setter methods to use. So, in this case, Hibernate will look for <literal>getDate()/setDate()</literal>, as well as <literal>getTitle()/setTitle()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:278(para)
|
||||
msgid "Why does the <literal>date</literal> property mapping include the <literal>column</literal> attribute, but the <literal>title</literal> doesn't? Without the <literal>column</literal> attribute Hibernate by default uses the property name as the column name. This works fine for <literal>title</literal>. However, <literal>date</literal> is a reserved keyword in most database, so we better map it to a different name."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:287(para)
|
||||
msgid "The next interesting thing is that the <literal>title</literal> mapping also lacks a <literal>type</literal> attribute. The types we declare and use in the mapping files are not, as you might expect, Java data types. They are also not SQL database types. These types are so called <emphasis>Hibernate mapping types</emphasis>, converters which can translate from Java to SQL data types and vice versa. Again, Hibernate will try to determine the correct conversion and mapping type itself if the <literal>type</literal> attribute is not present in the mapping. In some cases this automatic detection (using Reflection on the Java class) might not have the default you expect or need. This is the case with the <literal>date</literal> property. Hibernate can't know if the property (which is of <literal>java.util.Date</literal>) should map to a SQL <literal>date</literal>, <literal>timestamp</literal>, or <literal>time</literal> column. We preserve full date and time information by mapping the property with a <literal>timestamp</literal> converter."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:303(para)
|
||||
msgid "This mapping file should be saved as <literal>Event.hbm.xml</literal>, right in the directory next to the <literal>Event</literal> Java class source file. The naming of mapping files can be arbitrary, however the <literal>hbm.xml</literal> suffix is a convention in the Hibernate developer community. The directory structure should now look like this:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:319(para)
|
||||
msgid "We continue with the main configuration of Hibernate."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:326(title)
|
||||
msgid "Hibernate configuration"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:328(para)
|
||||
msgid "We now have a persistent class and its mapping file in place. It is time to configure Hibernate. Before we do this, we will need a database. HSQL DB, a java-based SQL DBMS, can be downloaded from the HSQL DB website(http://hsqldb.org/). Actually, you only need the <literal>hsqldb.jar</literal> from this download. Place this file in the <literal>lib/</literal> directory of the development folder."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:336(para)
|
||||
msgid "Create a directory called <literal>data</literal> in the root of the development directory - this is where HSQL DB will store its data files. Now start the database by running <literal>java -classpath ../lib/hsqldb.jar org.hsqldb.Server</literal> in this data directory. You can see it start up and bind to a TCP/IP socket, this is where our application will connect later. If you want to start with a fresh database during this tutorial, shutdown HSQL DB (press <literal>CTRL + C</literal> in the window), delete all files in the <literal>data/</literal> directory, and start HSQL DB again."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:346(para)
|
||||
msgid "Hibernate is the layer in your application which connects to this database, so it needs connection information. The connections are made through a JDBC connection pool, which we also have to configure. The Hibernate distribution contains several open source JDBC connection pooling tools, but will use the Hibernate built-in connection pool for this tutorial. Note that you have to copy the required library into your classpath and use different connection pooling settings if you want to use a production-quality third party JDBC pooling software."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:356(para)
|
||||
msgid "For Hibernate's configuration, we can use a simple <literal>hibernate.properties</literal> file, a slightly more sophisticated <literal>hibernate.cfg.xml</literal> file, or even complete programmatic setup. Most users prefer the XML configuration file:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:401(para)
|
||||
msgid "Note that this XML configuration uses a different DTD. We configure Hibernate's <literal>SessionFactory</literal> - a global factory responsible for a particular database. If you have several databases, use several <literal><session-factory></literal> configurations, usually in several configuration files (for easier startup)."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:409(para)
|
||||
msgid "The first four <literal>property</literal> elements contain the necessary configuration for the JDBC connection. The dialect <literal>property</literal> element specifies the particular SQL variant Hibernate generates. Hibernate's automatic session management for persistence contexts will come in handy as you will soon see. The <literal>hbm2ddl.auto</literal> option turns on automatic generation of database schemas - directly into the database. This can of course also be turned off (by removing the config option) or redirected to a file with the help of the <literal>SchemaExport</literal> Ant task. Finally, we add the mapping file(s) for persistent classes to the configuration."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:422(para)
|
||||
msgid "Copy this file into the source directory, so it will end up in the root of the classpath. Hibernate automatically looks for a file called <literal>hibernate.cfg.xml</literal> in the root of the classpath, on startup."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:431(title)
|
||||
msgid "Building with Ant"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:433(para)
|
||||
msgid "We'll now build the tutorial with Ant. You will need to have Ant installed - get it from the <ulink url=\"http://ant.apache.org/bindownload.cgi\">Ant download page</ulink>. How to install Ant will not be covered here. Please refer to the <ulink url=\"http://ant.apache.org/manual/index.html\">Ant manual</ulink>. After you have installed Ant, we can start to create the buildfile. It will be called <literal>build.xml</literal> and placed directly in the development directory."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:442(para)
|
||||
msgid "A basic build file looks like this:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:479(para)
|
||||
msgid "This will tell Ant to add all files in the lib directory ending with <literal>.jar</literal> to the classpath used for compilation. It will also copy all non-Java source files to the target directory, e.g. configuration and Hibernate mapping files. If you now run Ant, you should get this output:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:501(title)
|
||||
msgid "Startup and helpers"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:503(para)
|
||||
msgid "It's time to load and store some <literal>Event</literal> objects, but first we have to complete the setup with some infrastructure code. We have to startup Hibernate. This startup includes building a global <literal>SessionFactory</literal> object and to store it somewhere for easy access in application code. A <literal>SessionFactory</literal> can open up new <literal>Session</literal>'s. A <literal>Session</literal> represents a single-threaded unit of work, the <literal>SessionFactory</literal> is a thread-safe global object, instantiated once."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:513(para)
|
||||
msgid "We'll create a <literal>HibernateUtil</literal> helper class which takes care of startup and makes accessing a <literal>SessionFactory</literal> convenient. Let's have a look at the implementation:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:545(para)
|
||||
msgid "This class does not only produce the global <literal>SessionFactory</literal> in its static initializer (called once by the JVM when the class is loaded), but also hides the fact that it uses a static singleton. It might as well lookup the <literal>SessionFactory</literal> from JNDI in an application server."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:552(para)
|
||||
msgid "If you give the <literal>SessionFactory</literal> a name in your configuration file, Hibernate will in fact try to bind it to JNDI after it has been built. To avoid this code completely you could also use JMX deployment and let the JMX-capable container instantiate and bind a <literal>HibernateService</literal> to JNDI. These advanced options are discussed in the Hibernate reference documentation."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:561(para)
|
||||
msgid "Place <literal>HibernateUtil.java</literal> in the development source directory, in a package next to <literal>events</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:579(para)
|
||||
msgid "This should again compile without problems. We finally need to configure a logging system - Hibernate uses commons logging and leaves you the choice between Log4j and JDK 1.4 logging. Most developers prefer Log4j: copy <literal>log4j.properties</literal> from the Hibernate distribution (it's in the <literal>etc/</literal> directory) to your <literal>src</literal> directory, next to <literal>hibernate.cfg.xml</literal>. Have a look at the example configuration and change the settings if you like to have more verbose output. By default, only Hibernate startup message are shown on stdout."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:589(para)
|
||||
msgid "The tutorial infrastructure is complete - and we are ready to do some real work with Hibernate."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:597(title)
|
||||
msgid "Loading and storing objects"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:599(para)
|
||||
msgid "Finally, we can use Hibernate to load and store objects. We write an <literal>EventManager</literal> class with a <literal>main()</literal> method:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:640(para)
|
||||
msgid "We create a new <literal>Event</literal> object, and hand it over to Hibernate. Hibernate now takes care of the SQL and executes <literal>INSERT</literal>s on the database. Let's have a look at the <literal>Session</literal> and <literal>Transaction</literal>-handling code before we run this."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:647(para)
|
||||
msgid "A <literal>Session</literal> is a single unit of work. For now we'll keep things simple and assume a one-to-one granularity between a Hibernate <literal>Session</literal> and a database transaction. To shield our code from the actual underlying transaction system (in this case plain JDBC, but it could also run with JTA) we use the <literal>Transaction</literal> API that is available on the Hibernate <literal>Session</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:655(para)
|
||||
msgid "What does <literal>sessionFactory.getCurrentSession()</literal> do? First, you can call it as many times and anywhere you like, once you get hold of your <literal>SessionFactory</literal> (easy thanks to <literal>HibernateUtil</literal>). The <literal>getCurrentSession()</literal> method always returns the \"current\" unit of work. Remember that we switched the configuration option for this mechanism to \"thread\" in <literal>hibernate.cfg.xml</literal>? Hence, the current unit of work is bound to the current Java thread that executes our application. However, this is not the full picture, you also have to consider scope, when a unit of work begins and when it ends."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:666(para)
|
||||
msgid "A <literal>Session</literal> begins when it is first needed, when the first call to <literal>getCurrentSession()</literal> is made. It is then bound by Hibernate to the current thread. When the transaction ends, either through commit or rollback, Hibernate automatically unbinds the <literal>Session</literal> from the thread and closes it for you. If you call <literal>getCurrentSession()</literal> again, you get a new <literal>Session</literal> and can start a new unit of work. This <emphasis>thread-bound</emphasis> programming model is the most popular way of using Hibernate, as it allows flexible layering of your code (transaction demarcation code can be separated from data access code, we'll do this later in this tutorial)."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:677(para)
|
||||
msgid "Related to the unit of work scope, should the Hibernate <literal>Session</literal> be used to execute one or several database operations? The above example uses one <literal>Session</literal> for one operation. This is pure coincidence, the example is just not complex enough to show any other approach. The scope of a Hibernate <literal>Session</literal> is flexible but you should never design your application to use a new Hibernate <literal>Session</literal> for <emphasis>every</emphasis> database operation. So even if you see it a few more times in the following (very trivial) examples, consider <emphasis>session-per-operation</emphasis> an anti-pattern. A real (web) application is shown later in this tutorial."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:688(para)
|
||||
msgid "Have a look at <xref linkend=\"transactions\"/> for more information about transaction handling and demarcation. We also skipped any error handling and rollback in the previous example."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:694(para)
|
||||
msgid "To run this first routine we have to add a callable target to the Ant build file:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:705(para)
|
||||
msgid "The value of the <literal>action</literal> argument is set on the command line when calling the target:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:712(para)
|
||||
msgid "You should see, after compilation, Hibernate starting up and, depending on your configuration, lots of log output. At the end you will find the following line:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:719(para)
|
||||
msgid "This is the <literal>INSERT</literal> executed by Hibernate, the question marks represent JDBC bind parameters. To see the values bound as arguments, or to reduce the verbosity of the log, check your <literal>log4j.properties</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:725(para)
|
||||
msgid "Now we'd like to list stored events as well, so we add an option to the main method:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:741(para)
|
||||
msgid "We also add a new <literal>listEvents() method</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:758(para)
|
||||
msgid "What we do here is use an HQL (Hibernate Query Language) query to load all existing <literal>Event</literal> objects from the database. Hibernate will generate the appropriate SQL, send it to the database and populate <literal>Event</literal> objects with the data. You can create more complex queries with HQL, of course."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:765(para)
|
||||
msgid "Now, to execute and test all of this, follow these steps:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:771(para)
|
||||
msgid "Run <literal>ant run -Daction=store</literal> to store something into the database and, of course, to generate the database schema before through hbm2ddl."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:777(para)
|
||||
msgid "Now disable hbm2ddl by commenting out the property in your <literal>hibernate.cfg.xml</literal> file. Usually you only leave it turned on in continous unit testing, but another run of hbm2ddl would <emphasis>drop</emphasis> everything you have stored - the <literal>create</literal> configuration setting actually translates into \"drop all tables from the schema, then re-create all tables, when the SessionFactory is build\"."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:787(para)
|
||||
msgid "If you now call Ant with <literal>-Daction=list</literal>, you should see the events you have stored so far. You can of course also call the <literal>store</literal> action a few times more."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:793(para)
|
||||
msgid "Note: Most new Hibernate users fail at this point and we see questions about <emphasis>Table not found</emphasis> error messages regularly. However, if you follow the steps outlined above you will not have this problem, as hbm2ddl creates the database schema on the first run, and subsequent application restarts will use this schema. If you change the mapping and/or database schema, you have to re-enable hbm2ddl once again."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:806(title)
|
||||
msgid "Part 2 - Mapping associations"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:808(para)
|
||||
msgid "We mapped a persistent entity class to a table. Let's build on this and add some class associations. First we'll add people to our application, and store a list of events they participate in."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:814(title)
|
||||
msgid "Mapping the Person class"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:816(para)
|
||||
msgid "The first cut of the <literal>Person</literal> class is simple:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:835(para)
|
||||
msgid "Create a new mapping file called <literal>Person.hbm.xml</literal> (don't forget the DTD reference at the top):"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:853(para)
|
||||
msgid "Finally, add the new mapping to Hibernate's configuration:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:860(para)
|
||||
msgid "We'll now create an association between these two entities. Obviously, persons can participate in events, and events have participants. The design questions we have to deal with are: directionality, multiplicity, and collection behavior."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:870(title)
|
||||
msgid "A unidirectional Set-based association"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:872(para)
|
||||
msgid "We'll add a collection of events to the <literal>Person</literal> class. That way we can easily navigate to the events for a particular person, without executing an explicit query - by calling <literal>aPerson.getEvents()</literal>. We use a Java collection, a <literal>Set</literal>, because the collection will not contain duplicate elements and the ordering is not relevant for us."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:879(para)
|
||||
msgid "We need a unidirectional, many-valued associations, implemented with a <literal>Set</literal>. Let's write the code for this in the Java classes and then map it:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:897(para)
|
||||
msgid "Before we map this association, think about the other side. Clearly, we could just keep this unidirectional. Or, we could create another collection on the <literal>Event</literal>, if we want to be able to navigate it bi-directional, i.e. <literal>anEvent.getParticipants()</literal>. This is not necessary, from a functional perspective. You could always execute an explicit query to retrieve the participants for a particular event. This is a design choice left to you, but what is clear from this discussion is the multiplicity of the association: \"many\" valued on both sides, we call this a <emphasis>many-to-many</emphasis> association. Hence, we use Hibernate's many-to-many mapping:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:923(para)
|
||||
msgid "Hibernate supports all kinds of collection mappings, a <literal><set></literal> being most common. For a many-to-many association (or <emphasis>n:m</emphasis> entity relationship), an association table is needed. Each row in this table represents a link between a person and an event. The table name is configured with the <literal>table</literal> attribute of the <literal>set</literal> element. The identifier column name in the association, for the person's side, is defined with the <literal><key></literal> element, the column name for the event's side with the <literal>column</literal> attribute of the <literal><many-to-many></literal>. You also have to tell Hibernate the class of the objects in your collection (correct: the class on the other side of the collection of references)."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:935(para)
|
||||
msgid "The database schema for this mapping is therefore:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:956(title)
|
||||
msgid "Working the association"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:958(para)
|
||||
msgid "Let's bring some people and events together in a new method in <literal>EventManager</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:975(para)
|
||||
msgid "After loading a <literal>Person</literal> and an <literal>Event</literal>, simply modify the collection using the normal collection methods. As you can see, there is no explicit call to <literal>update()</literal> or <literal>save()</literal>, Hibernate automatically detects that the collection has been modified and needs to be updated. This is called <emphasis>automatic dirty checking</emphasis>, and you can also try it by modifying the name or the date property of any of your objects. As long as they are in <emphasis>persistent</emphasis> state, that is, bound to a particular Hibernate <literal>Session</literal> (i.e. they have been just loaded or saved in a unit of work), Hibernate monitors any changes and executes SQL in a write-behind fashion. The process of synchronizing the memory state with the database, usually only at the end of a unit of work, is called <emphasis>flushing</emphasis>. In our code, the unit of work ends with a commit (or rollback) of the database transaction - as defined by the <literal>thread</literal> configuration option for the <literal>CurrentSessionContext</literal> class."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:990(para)
|
||||
msgid "You might of course load person and event in different units of work. Or you modify an object outside of a <literal>Session</literal>, when it is not in persistent state (if it was persistent before, we call this state <emphasis>detached</emphasis>). You can even modify a collection when it is detached:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1025(para)
|
||||
msgid "The call to <literal>update</literal> makes a detached object persistent again, you could say it binds it to a new unit of work, so any modifications you made to it while detached can be saved to the database. This includes any modifications (additions/deletions) you made to a collection of that entity object."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1032(para)
|
||||
msgid "Well, this is not much use in our current situation, but it's an important concept you can design into your own application. For now, complete this exercise by adding a new action to the <literal>EventManager</literal>'s main method and call it from the command line. If you need the identifiers of a person and an event - the <literal>save()</literal> method returns it (you might have to modify some of the previous methods to return that identifier):"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1047(para)
|
||||
msgid "This was an example of an association between two equally important classes, two entities. As mentioned earlier, there are other classes and types in a typical model, usually \"less important\". Some you have already seen, like an <literal>int</literal> or a <literal>String</literal>. We call these classes <emphasis>value types</emphasis>, and their instances <emphasis>depend</emphasis> on a particular entity. Instances of these types don't have their own identity, nor are they shared between entities (two persons don't reference the same <literal>firstname</literal> object, even if they have the same first name). Of course, value types can not only be found in the JDK (in fact, in a Hibernate application all JDK classes are considered value types), but you can also write dependent classes yourself, <literal>Address</literal> or <literal>MonetaryAmount</literal>, for example."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1060(para)
|
||||
msgid "You can also design a collection of value types. This is conceptually very different from a collection of references to other entities, but looks almost the same in Java."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1068(title)
|
||||
msgid "Collection of values"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1070(para)
|
||||
msgid "We add a collection of value typed objects to the <literal>Person</literal> entity. We want to store email addresses, so the type we use is <literal>String</literal>, and the collection is again a <literal>Set</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1085(para)
|
||||
msgid "The mapping of this <literal>Set</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1094(para)
|
||||
msgid "The difference compared with the earlier mapping is the <literal>element</literal> part, which tells Hibernate that the collection does not contain references to another entity, but a collection of elements of type <literal>String</literal> (the lowercase name tells you it's a Hibernate mapping type/converter). Once again, the <literal>table</literal> attribute of the <literal>set</literal> element determines the table name for the collection. The <literal>key</literal> element defines the foreign-key column name in the collection table. The <literal>column</literal> attribute in the <literal>element</literal> element defines the column name where the <literal>String</literal> values will actually be stored."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1104(para)
|
||||
msgid "Have a look at the updated schema:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1122(para)
|
||||
msgid "You can see that the primary key of the collection table is in fact a composite key, using both columns. This also implies that there can't be duplicate email addresses per person, which is exactly the semantics we need for a set in Java."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1128(para)
|
||||
msgid "You can now try and add elements to this collection, just like we did before by linking persons and events. It's the same code in Java:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1146(para)
|
||||
msgid "This time we didnt' use a <emphasis>fetch</emphasis> query to initialize the collection. Hence, the call to its getter method will trigger an additional select to initialize it, so we can add an element to it. Monitor the SQL log and try to optimize this with an eager fetch."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1156(title)
|
||||
msgid "Bi-directional associations"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1158(para)
|
||||
msgid "Next we are going to map a bi-directional association - making the association between person and event work from both sides in Java. Of course, the database schema doesn't change, we still have many-to-many multiplicity. A relational database is more flexible than a network programming language, so it doesn't need anything like a navigation direction - data can be viewed and retrieved in any possible way."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1166(para)
|
||||
msgid "First, add a collection of participants to the <literal>Event</literal> Event class:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1180(para)
|
||||
msgid "Now map this side of the association too, in <literal>Event.hbm.xml</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1189(para)
|
||||
msgid "As you see, these are normal <literal>set</literal> mappings in both mapping documents. Notice that the column names in <literal>key</literal> and <literal>many-to-many</literal> are swapped in both mapping documents. The most important addition here is the <literal>inverse=\"true\"</literal> attribute in the <literal>set</literal> element of the <literal>Event</literal>'s collection mapping."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1197(para)
|
||||
msgid "What this means is that Hibernate should take the other side - the <literal>Person</literal> class - when it needs to find out information about the link between the two. This will be a lot easier to understand once you see how the bi-directional link between our two entities is created ."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1206(title)
|
||||
msgid "Working bi-directional links"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1208(para)
|
||||
msgid "First, keep in mind that Hibernate does not affect normal Java semantics. How did we create a link between a <literal>Person</literal> and an <literal>Event</literal> in the unidirectional example? We added an instance of <literal>Event</literal> to the collection of event references, of an instance of <literal>Person</literal>. So, obviously, if we want to make this link working bi-directional, we have to do the same on the other side - adding a <literal>Person</literal> reference to the collection in an <literal>Event</literal>. This \"setting the link on both sides\" is absolutely necessary and you should never forget doing it."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1218(para)
|
||||
msgid "Many developers program defensive and create link management methods to correctly set both sides, e.g. in <literal>Person</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1241(para)
|
||||
msgid "Notice that the get and set methods for the collection are now protected - this allows classes in the same package and subclasses to still access the methods, but prevents everybody else from messing with the collections directly (well, almost). You should probably do the same with the collection on the other side."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1248(para)
|
||||
msgid "What about the <literal>inverse</literal> mapping attribute? For you, and for Java, a bi-directional link is simply a matter of setting the references on both sides correctly. Hibernate however doesn't have enough information to correctly arrange SQL <literal>INSERT</literal> and <literal>UPDATE</literal> statements (to avoid constraint violations), and needs some help to handle bi-directional associations properly. Making one side of the association <literal>inverse</literal> tells Hibernate to basically ignore it, to consider it a <emphasis>mirror</emphasis> of the other side. That's all that is necessary for Hibernate to work out all of the issues when transformation a directional navigation model to a SQL database schema. The rules you have to remember are straightforward: All bi-directional associations need one side as <literal>inverse</literal>. In a one-to-many association it has to be the many-side, in many-to-many association you can pick either side, there is no difference."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1263(para)
|
||||
msgid "Let's turn this into a small web application."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1270(title)
|
||||
msgid "Part 3 - The EventManager web application"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1272(para)
|
||||
msgid "A Hibernate web application uses <literal>Session</literal> and <literal>Transaction</literal> almost like a standalone application. However, some common patterns are useful. We now write an <literal>EventManagerServlet</literal>. This servlet can list all events stored in the database, and it provides an HTML form to enter new events."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1280(title)
|
||||
msgid "Writing the basic servlet"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1282(para)
|
||||
msgid "Create a new class in your source directory, in the <literal>events</literal> package:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1296(para)
|
||||
msgid "The servlet handles HTTP <literal>GET</literal> requests only, hence, the method we implement is <literal>doGet()</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1326(para)
|
||||
msgid "The pattern we are applying here is called <emphasis>session-per-request</emphasis>. When a request hits the servlet, a new Hibernate <literal>Session</literal> is opened through the first call to <literal>getCurrentSession()</literal> on the <literal>SessionFactory</literal>. Then a database transaction is started-all data access as to occur inside a transaction, no matter if data is read or written (we don't use the auto-commit mode in applications)."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1335(para)
|
||||
msgid "Do <emphasis>not</emphasis> use a new Hibernate <literal>Session</literal> for every database operation. Use one Hibernate <literal>Session</literal> that is scoped to the whole request. Use <literal>getCurrentSession()</literal>, so that it is automatically bound to the current Java thread."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1342(para)
|
||||
msgid "Next, the possible actions of the request are processed and the response HTML is rendered. We'll get to that part soon."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1347(para)
|
||||
msgid "Finally, the unit of work ends when processing and rendering is complete. If any problem occured during processing or rendering, an exception will be thrown and the database transaction rolled back. This completes the <literal>session-per-request</literal> pattern. Instead of the transaction demarcation code in every servlet you could also write a servlet filter. See the Hibernate website and Wiki for more information about this pattern, called <emphasis>Open Session in View</emphasis>-you'll need it as soon as you consider rendering your view in JSP, not in a servlet."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1361(title)
|
||||
msgid "Processing and rendering"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1363(para)
|
||||
msgid "Let's implement the processing of the request and rendering of the page."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1394(para)
|
||||
msgid "Granted, this coding style with a mix of Java and HTML would not scale in a more complex application-keep in mind that we are only illustrating basic Hibernate concepts in this tutorial. The code prints an HTML header and a footer. Inside this page, an HTML form for event entry and a list of all events in the database are printed. The first method is trivial and only outputs HTML:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1412(para)
|
||||
msgid "The <literal>listEvents()</literal> method uses the Hibernate <literal>Session</literal> bound to the current thread to execute a query:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1440(para)
|
||||
msgid "Finally, the <literal>store</literal> action is dispatched to the <literal>createAndStoreEvent()</literal> method, which also uses the <literal>Session</literal> of the current thread:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1455(para)
|
||||
msgid "That's it, the servlet is complete. A request to the servlet will be processed in a single <literal>Session</literal> and <literal>Transaction</literal>. As earlier in the standalone application, Hibernate can automatically bind these ojects to the current thread of execution. This gives you the freedom to layer your code and access the <literal>SessionFactory</literal> in any way you like. Usually you'd use a more sophisticated design and move the data access code into data access objects (the DAO pattern). See the Hibernate Wiki for more examples."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1469(title)
|
||||
msgid "Deploying and testing"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1471(para)
|
||||
msgid "To deploy this application you have to create a web archive, a WAR. Add the following Ant target to your <literal>build.xml</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1486(para)
|
||||
msgid "This target creates a file called <literal>hibernate-tutorial.war</literal> in your project directory. It packages all libraries and the <literal>web.xml</literal> descriptor, which is expected in the base directory of your project:"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1509(para)
|
||||
msgid "Before you compile and deploy the web application, note that an additional library is required: <literal>jsdk.jar</literal>. This is the Java servlet development kit, if you don't have this library already, get it from the Sun website and copy it to your library directory. However, it will be only used for compliation and excluded from the WAR package."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1517(para)
|
||||
msgid "To build and deploy call <literal>ant war</literal> in your project directory and copy the <literal>hibernate-tutorial.war</literal> file into your Tomcat <literal>webapp</literal> directory. If you don't have Tomcat installed, download it and follow the installation instructions. You don't have to change any Tomcat configuration to deploy this application though."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1525(para)
|
||||
msgid "Once deployed and Tomcat is running, access the application at <literal>http://localhost:8080/hibernate-tutorial/eventmanager</literal>. Make sure you watch the Tomcat log to see Hibernate initialize when the first request hits your servlet (the static initializer in <literal>HibernateUtil</literal> is called) and to get the detailed output if any exceptions occurs."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1538(title)
|
||||
msgid "Summary"
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1540(para)
|
||||
msgid "This tutorial covered the basics of writing a simple standalone Hibernate application and a small web application."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1545(para)
|
||||
msgid "If you already feel confident with Hibernate, continue browsing through the reference documentation table of contents for topics you find interesting - most asked are transactional processing (<xref linkend=\"transactions\"/>), fetch performance (<xref linkend=\"performance\"/>), or the usage of the API (<xref linkend=\"objectstate\"/>) and the query features (<xref linkend=\"objectstate-querying\"/>)."
|
||||
msgstr ""
|
||||
|
||||
#: tutorial.xml:1553(para)
|
||||
msgid "Don't forget to check the Hibernate website for more (specialized) tutorials."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: tutorial.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:35-0500\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"
|
||||
|
||||
#: xml.xml:5(title)
|
||||
msgid "XML Mapping"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:7(emphasis)
|
||||
msgid "Note that this is an experimental feature in Hibernate 3.0 and is under extremely active development."
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:13(title)
|
||||
msgid "Working with XML data"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:15(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:22(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:32(para)
|
||||
msgid "This feature has many applications including data import/export, externalization of entity data via JMS or SOAP and XSLT-based reporting."
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:37(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:44(title)
|
||||
msgid "Specifying XML and class mapping together"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:46(para)
|
||||
msgid "Here is an example of mapping a POJO and XML simultaneously:"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:73(title)
|
||||
msgid "Specifying only an XML mapping"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:75(para)
|
||||
msgid "Here is an example where there is no POJO class:"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:103(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:114(title)
|
||||
msgid "XML mapping metadata"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:116(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:125(para)
|
||||
msgid "<literal>\"element-name\"</literal> - map to the named XML element"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:128(para)
|
||||
msgid "<literal>\"@attribute-name\"</literal> - map to the named XML attribute"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:131(para)
|
||||
msgid "<literal>\".\"</literal> - map to the parent element"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:134(para)
|
||||
msgid "<literal>\"element-name/@attribute-name\"</literal> - map to the named attribute of the named element"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:141(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:151(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:191(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:198(para)
|
||||
msgid "Would return datasets such as this:"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:213(para)
|
||||
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 ""
|
||||
|
||||
#: xml.xml:239(title)
|
||||
msgid "Manipulating XML data"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:241(para)
|
||||
msgid "Let's rearead and update XML documents in the application. We do this by obtaining a dom4j session:"
|
||||
msgstr ""
|
||||
|
||||
#: xml.xml:281(para)
|
||||
msgid "It is extremely useful to combine this feature with Hibernate's <literal>replicate()</literal> operation to implement XML-based data import/export."
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: xml.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2007-10-19 10:26-0500\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"
|
||||
|
||||
#: ./legal_notice.xml:20(title)
|
||||
msgid "Legal Notice"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:23(street)
|
||||
msgid "1801 Varsity Drive"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:24(city)
|
||||
msgid "Raleigh"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:24(state) ./legal_notice.xml:28(state)
|
||||
msgid "NC"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:24(postcode)
|
||||
msgid "27606-2072"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:24(country) ./legal_notice.xml:28(country)
|
||||
msgid "USA"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:25(phone)
|
||||
msgid "Phone: +1 919 754 3700"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:26(phone)
|
||||
msgid "Phone: 888 733 4281"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:27(fax)
|
||||
msgid "Fax: +1 919 754 3701"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:28(pob)
|
||||
msgid "PO Box 13588"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:28(city)
|
||||
msgid "Research Triangle Park"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:28(postcode)
|
||||
msgid "27709"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:22(address)
|
||||
msgid "<placeholder-1/><placeholder-2/>, <placeholder-3/><placeholder-4/><placeholder-5/><placeholder-6/><placeholder-7/><placeholder-8/><placeholder-9/><placeholder-10/>, <placeholder-11/><placeholder-12/><placeholder-13/>"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:31(para)
|
||||
msgid "Copyright <trademark class=\"copyright\"/> 2007 by Red Hat, Inc. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, V1.0 or later (the latest version is presently available at <ulink url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/openpub/</ulink>)."
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:34(para)
|
||||
msgid "Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder."
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:37(para)
|
||||
msgid "Distribution of the work or derivative of the work in any standard (paper) book form for commercial purposes is prohibited unless prior permission is obtained from the copyright holder."
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:40(para)
|
||||
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 ""
|
||||
|
||||
#: ./legal_notice.xml:43(para)
|
||||
msgid "All other trademarks referenced herein are the property of their respective owners."
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:46(para)
|
||||
msgid "The GPG fingerprint of the security@redhat.com key is:"
|
||||
msgstr ""
|
||||
|
||||
#: ./legal_notice.xml:49(para)
|
||||
msgid "CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E"
|
||||
msgstr ""
|
||||
|
||||
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2.
|
||||
#: ./legal_notice.xml:0(None)
|
||||
msgid "translator-credits"
|
||||
msgstr ""
|
||||
|
|
@ -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,216 @@
|
|||
#, 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,881 @@
|
|||
#, 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:6
|
||||
msgid "Association Mappings"
|
||||
msgstr "Mapeos de Asociación"
|
||||
|
||||
#: index.docbook:9
|
||||
msgid "Introduction"
|
||||
msgstr "Introducción"
|
||||
|
||||
#: index.docbook:11
|
||||
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 "Los mapeos de asociación son frecuentemente las cosas mas difíciles de hacer correctamente. En esta sección iremos a través de los casos canónicos uno a uno, comenzando con los mapeos unidireccionales, y considerando luego los casos bidireccionales. Usaremos <literal>Person</literal> y <literal>Address</literal> en todos los ejemplos."
|
||||
|
||||
#: index.docbook:19
|
||||
msgid "We'll classify associations by whether or not they map to an intervening join table, and by multiplicity."
|
||||
msgstr "Clasificaremos las asociaciones por cuanto mapeen o no a una tabla de unión interviniente, y por su multiplicidad."
|
||||
|
||||
#: index.docbook:24
|
||||
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 "Las claves foráneas que aceptan valores nulos (en adelante, nullables) no son consideradas una buena práctica en el modelado tradicional de datos, así que todos nuestros ejemplos usan claves foráneas no nullables. Esto no es un requerimiento de Hibernate, y todos los mapeos funcionarán si quitas las restricciones de nulabilidad."
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Unidirectional associations"
|
||||
msgstr "Asociaciones Unidireccionales"
|
||||
|
||||
#: index.docbook:37, index.docbook:108
|
||||
msgid "many to one"
|
||||
msgstr "muchos a uno"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "A <emphasis>unidirectional many-to-one association</emphasis> is the most common kind of unidirectional association."
|
||||
msgstr "Una <emphasis>asociación unidireccional muchos-a-uno</emphasis> es el tipo más común de asociaciones unidireccionales."
|
||||
|
||||
#: index.docbook:44
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:45, index.docbook:161
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:50, index.docbook:121, index.docbook:185, index.docbook:225
|
||||
msgid "one to one"
|
||||
msgstr "uno a uno"
|
||||
|
||||
#: index.docbook:52
|
||||
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 "Una <emphasis>asociación unidireccional uno-a-uno en una clave primaria</emphasis> es casi idéntica. La única diferencia es la restricción de unicidad de la columna."
|
||||
|
||||
#: index.docbook:57
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:58, index.docbook:193
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:60
|
||||
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 "Usualmente, una <emphasis>asociación unidireccional uno-a-uno en una clave primaria</emphasis> usa un generador de id especial. (Observa que hemos invertido el sentido de la asociación en este ejemplo)."
|
||||
|
||||
#: index.docbook:66
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:67, index.docbook:201
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( personId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( personId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:72, index.docbook:94
|
||||
msgid "one to many"
|
||||
msgstr "uno a muchos"
|
||||
|
||||
#: index.docbook:74
|
||||
msgid "A <emphasis>unidirectional one-to-many association on a foreign key</emphasis> is a very unusual case, and is not really recommended."
|
||||
msgstr "Una <emphasis>asociación unidireccional uno-a-muchos en una clave foránea</emphasis> es un caso muy inusual, y realmente no está recomendada."
|
||||
|
||||
#: index.docbook:79
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:80
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:82
|
||||
msgid "We think it's better to use a join table for this kind of association."
|
||||
msgstr "Creemos que es mejor usar una tabla de unión para este tipo de asociación."
|
||||
|
||||
#: index.docbook:91
|
||||
msgid "Unidirectional associations with join tables"
|
||||
msgstr "Asociaciones unidireccionales con tablas de unión"
|
||||
|
||||
#: index.docbook:96
|
||||
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 "Una <emphasis>asociación unidireccional uno-a-muchos en una tabla de unión</emphasis> es más preferible. Observa que especificando <literal>unique=\"true\"</literal>, hemos cambiado la multiplicidad de muchos-a-muchos a uno-a-muchos."
|
||||
|
||||
#: index.docbook:102
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:103
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "A <emphasis>unidirectional many-to-one association on a join table</emphasis> is quite common when the association is optional."
|
||||
msgstr "Una <emphasis>asociación unidireccional muchos-a-uno en una tabla de unión</emphasis> es bastante común cuando la asociación es opcional."
|
||||
|
||||
#: index.docbook:115
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:116
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:123
|
||||
msgid "A <emphasis>unidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."
|
||||
msgstr "Una <emphasis>asociación unidireccional uno-a-uno en una tabla de unión</emphasis> es inusual en extremo, pero posible."
|
||||
|
||||
#: index.docbook:128
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:129, index.docbook:233
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:134, index.docbook:238
|
||||
msgid "many to many"
|
||||
msgstr "muchos a muchos"
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "Finally, we have a <emphasis>unidirectional many-to-many association</emphasis>."
|
||||
msgstr "Finalmente, tenemos una <emphasis>asociación unidireccional muchos-a-muchos</emphasis>"
|
||||
|
||||
#: index.docbook:140
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:141, index.docbook:246
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:148
|
||||
msgid "Bidirectional associations"
|
||||
msgstr "Asociaciones Bidireccionales"
|
||||
|
||||
#: index.docbook:151, index.docbook:211
|
||||
msgid "one to many / many to one"
|
||||
msgstr "uno a muchos / muchos a uno"
|
||||
|
||||
#: index.docbook:153
|
||||
msgid "A <emphasis>bidirectional many-to-one association</emphasis> is the most common kind of association. (This is the standard parent/child relationship.)"
|
||||
msgstr "Una <emphasis>asociación bidireccional muchos-a-uno</emphasis> es el tipo más común de asociación. (Esta es la relación estándar padre/hijo.)"
|
||||
|
||||
#: index.docbook:159
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:163
|
||||
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 "uno a uno"
|
||||
|
||||
#: index.docbook:171
|
||||
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 "Una <emphasis>asociación bidireccional uno-a-uno en una clave foránea</emphasis> es bastante común."
|
||||
|
||||
#: index.docbook:173
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:187
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> is quite common."
|
||||
msgstr "Una <emphasis>asociación bidireccional uno-a-uno en una clave primaria</emphasis> usa el generador de id especial."
|
||||
|
||||
#: index.docbook:192
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:195
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a primary key</emphasis> uses the special id generator."
|
||||
msgstr "Asociaciones bidireccionales con tablas de unión"
|
||||
|
||||
#: index.docbook:200
|
||||
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 "uno a muchos / muchos a uno"
|
||||
|
||||
#: index.docbook:208
|
||||
msgid "Bidirectional associations with join tables"
|
||||
msgstr ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:213
|
||||
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 "uno a uno"
|
||||
|
||||
#: index.docbook:219
|
||||
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 "Una <emphasis>asociación bidireccional uno-a-uno en una tabla de unión</emphasis> es inusual en extremo, pero posible."
|
||||
|
||||
#: index.docbook:220
|
||||
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 ""
|
||||
"<![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=\"address\"\n"
|
||||
" column=\"personId\" \n"
|
||||
" not-null=\"true\"\n"
|
||||
" unique=\"true\"/>\n"
|
||||
" </join>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:227
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."
|
||||
msgstr "muchos a muchos"
|
||||
|
||||
#: index.docbook:232
|
||||
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 "Finalmente, tenemos una <emphasis>asociación bidireccional muchos-a-muchos</emphasis>."
|
||||
|
||||
#: index.docbook:240
|
||||
msgid "Finally, we have a <emphasis>bidirectional many-to-many association</emphasis>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:244
|
||||
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 ""
|
||||
|
||||
#: index.docbook:253
|
||||
msgid "More complex association mappings"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:255
|
||||
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 ""
|
||||
|
||||
#: index.docbook:264
|
||||
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 ""
|
||||
|
||||
#: index.docbook:266
|
||||
msgid "Then we can map an association to the <emphasis>current</emphasis> instance (the one with null <literal>effectiveEndDate</literal>) using:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:271
|
||||
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 ""
|
||||
|
||||
#: index.docbook:273
|
||||
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 ""
|
||||
|
||||
#: index.docbook:281
|
||||
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 ""
|
||||
|
||||
#: index.docbook:283
|
||||
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 ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,342 @@
|
|||
#, 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 "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: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 "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
msgstr "Inserciones en lote"
|
||||
|
||||
#: 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 "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:47
|
||||
msgid "Batch inserts"
|
||||
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: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 "Actualizaciones en lote"
|
||||
|
||||
#: 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 "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:60
|
||||
msgid "Batch updates"
|
||||
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: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 "update/delete en masa"
|
||||
|
||||
#: 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 "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:73
|
||||
msgid "The StatelessSession interface"
|
||||
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: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 "En la cláusula-from, la palabra clave FROM es opcional"
|
||||
|
||||
#: 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 "Puede haber sólo una clase mencionada en la cláusula-from, y <emphasis>no puede</emphasis> tener un alias."
|
||||
|
||||
#: 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 "No puede especificarse ningún join (bien implícito o explícito) en una consulta masiva de HQL. Pueden usarse subconsultas en la cláusula-where."
|
||||
|
||||
#: 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 "La cláusula-where es también opcional."
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "DML-style operations"
|
||||
msgstr "Como un ejemplo, para ejecutar un <literal>UPDATE</literal> HQL, usa el método <literal>Query.executeUpdate()</literal>:"
|
||||
|
||||
#: 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 (<xref linkend=\"queryhql\"/>HQL)."
|
||||
msgstr ""
|
||||
"<![CDATA[Session session = sessionFactory.openSession();\n"
|
||||
" Transaction tx = session.beginTransaction();\n"
|
||||
"\n"
|
||||
" 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: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 "Para ejecutar un <literal>DELETE</literal> HQL, usa el mismo método <literal>Query.executeUpdate()</literal> (el método está nombrado para aquellos familiarizados con <literal>PreparedStatement.executeUpdate()</literal> de JDBC):"
|
||||
|
||||
#: index.docbook:130
|
||||
msgid "In the from-clause, the FROM keyword is optional"
|
||||
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: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 "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:143
|
||||
msgid "No <xref linkend=\"queryhql-joins-forms\"/>joins (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 "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:150
|
||||
msgid "The where-clause is also optional."
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "HQL <literal>UPDATE</literal> statements, by default do not effect the <xref linkend=\"mapping-declaration-version\"/>version or the <xref linkend=\"mapping-declaration-timestamp\"/>timestamp 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:181
|
||||
msgid "To execute an HQL <literal>DELETE</literal>, use the same <literal>Query.executeUpdate()</literal> method:"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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,168 @@
|
|||
#, 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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,532 @@
|
|||
#, 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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,348 @@
|
|||
#, 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 ""
|
||||
"<![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: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 "El interceptor podría ser especificado cuando se crea la sesión:"
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Interceptors come in two flavors: <literal>Session</literal>-scoped and <literal>SessionFactory</literal>-scoped."
|
||||
msgstr "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
|
||||
|
||||
#: 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 "Puedes además establecer un interceptor a un nivel global, usando la <literal>Configuration</literal>:"
|
||||
|
||||
#: index.docbook:45
|
||||
msgid "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
|
||||
msgstr "<![CDATA[new Configuration().setInterceptor( 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 "Sistema de eventos"
|
||||
|
||||
#: index.docbook:56
|
||||
msgid "<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
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:61
|
||||
msgid "Event system"
|
||||
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: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 "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: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 "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: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 ""
|
||||
"<![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: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 "Necesitas además una entrada de configuración diciéndole a Hibernate que use el oyente en vez del oyente por defecto:"
|
||||
|
||||
#: 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[<hibernate-configuration>\n"
|
||||
" <session-factory>\n"
|
||||
" ...\n"
|
||||
" <listener type=\"load\" class=\"MyLoadListener\"/>\n"
|
||||
" </session-factory>\n"
|
||||
"</hibernate-configuration>]]>"
|
||||
|
||||
#: index.docbook:101
|
||||
msgid "You also need a configuration entry telling Hibernate to use the listener in addition to the default listener:"
|
||||
msgstr "En cambio, puedes registrarlo programáticamente:"
|
||||
|
||||
#: 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[Configuration cfg = new Configuration();\n"
|
||||
"cfg.getSessionEventListenerConfig().setLoadEventListener( new MyLoadListener() );]]>"
|
||||
|
||||
#: index.docbook:108
|
||||
msgid "Instead, you may register it programmatically:"
|
||||
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:112
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = new Configuration();\n"
|
||||
"LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };\n"
|
||||
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
|
||||
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: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 "Seguridad declarativa de Hibernate"
|
||||
|
||||
#: 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 "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:132
|
||||
msgid "Hibernate declarative security"
|
||||
msgstr "Primero, debes configurar los oyentes de eventos apropiados, para habilitar el uso de autorización JAAS."
|
||||
|
||||
#: 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 ""
|
||||
"<![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:139
|
||||
msgid "First, you must configure the appropriate event listeners, to enable the use of JAAS authorization."
|
||||
msgstr "Seguido, aún en <literal>hibernate.cfg.xml</literal>, liga los permisos a roles:"
|
||||
|
||||
#: 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[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,read\"/>\n"
|
||||
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
|
||||
|
||||
#: 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 "Los nombres de role son los roles entendidos por tu proveedor de JACC."
|
||||
|
||||
#: index.docbook:152
|
||||
msgid "Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:156
|
||||
msgid ""
|
||||
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,read\"/>\n"
|
||||
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:158
|
||||
msgid "The role names are the roles understood by your JACC provider."
|
||||
msgstr ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,350 @@
|
|||
#, 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,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 "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,192 @@
|
|||
#, 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.enabledFilter(\"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.enabledFilter(\"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,636 @@
|
|||
#, 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 "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: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 "Tabla por jerarquía de clases"
|
||||
|
||||
#: 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 "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:74
|
||||
msgid "Table per class hierarchy"
|
||||
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: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 "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: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 "Tabla por subclase"
|
||||
|
||||
#: 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 "Un mapeo de tabla por sublclase se vería así:"
|
||||
|
||||
#: index.docbook:94
|
||||
msgid "Table per subclass"
|
||||
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:96
|
||||
msgid "A table per subclass mapping would look like:"
|
||||
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: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 "Tabla por subclase, usando un discriminador"
|
||||
|
||||
#: 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 "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:111
|
||||
msgid "Table per subclass, using a discriminator"
|
||||
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: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 "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: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 "Mezclando tabla por jerarquía de clases con tabla por subclase"
|
||||
|
||||
#: 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 "Puedes incluso mezclar las estrategias de tabla po jerarquía y tabla por subclase usando este enfoque:"
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "Mixing table per class hierarchy with table per subclass"
|
||||
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:138
|
||||
msgid "You may even mix the table per hierarchy and table per subclass strategies using this approach:"
|
||||
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: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[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment\"/>]]>"
|
||||
|
||||
#: 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 "Tabla por clase concreta"
|
||||
|
||||
#: index.docbook:151
|
||||
msgid "<![CDATA[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment\"/>]]>"
|
||||
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:156
|
||||
msgid "Table per concrete 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: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 "Están implicadas tres tablas. Cada tabla define columnas para todas las propiedades de la clase, inccluyendo las propiedades heredadas."
|
||||
|
||||
#: 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 "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:165
|
||||
msgid "Three tables are involved for the subclasses. Each table defines columns for all properties of the class, including inherited properties."
|
||||
msgstr "Tabla por clase concreta, usando polimorfismo implícito"
|
||||
|
||||
#: 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 "Un enfoque alternativo es hacer uso de polimorfismo implícito:"
|
||||
|
||||
#: 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 ""
|
||||
"<![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:189
|
||||
msgid "Table per concrete class, using implicit polymorphism"
|
||||
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:191
|
||||
msgid "An alternative approach is to make use of implicit polymorphism:"
|
||||
msgstr "La desventaja de este enfoque es que Hibernate no genera <literal>UNION</literal>s de SQL al realizar consultas polimórficas."
|
||||
|
||||
#: 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 "Para esta estrategia de mapeo, una asociación polimórfica a <literal>Payment</literal> es mapeada generalmente usando <literal><any></literal>."
|
||||
|
||||
#: 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 ""
|
||||
"<![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:207
|
||||
msgid "The disadvantage of this approach is that Hibernate does not generate SQL <literal>UNION</literal>s when performing polymorphic queries."
|
||||
msgstr "Mezclando polimorfismo implícito con otros mapeos de herencia"
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "For this mapping strategy, a polymorphic association to <literal>Payment</literal> is usually mapped using <literal><any></literal>."
|
||||
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: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[<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:222
|
||||
msgid "Mixing implicit polymorphism with other inheritance mappings"
|
||||
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: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 "Limitaciones"
|
||||
|
||||
#: 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 "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: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 "La siguiente tabla muestra las limitaciones de mapeos de tabla por clase concreta, y de polmorfismo implícito, en Hibernate."
|
||||
|
||||
#: index.docbook:249
|
||||
msgid "Limitations"
|
||||
msgstr "Funcionalidades de mapeo de herencia"
|
||||
|
||||
#: 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 "Estrategia de herencia"
|
||||
|
||||
#: index.docbook:258
|
||||
msgid "The following table shows the limitations of table per concrete-class mappings, and of implicit polymorphism, in Hibernate."
|
||||
msgstr "muchos-a-uno polimórfica"
|
||||
|
||||
#: index.docbook:264
|
||||
msgid "Features of inheritance mappings"
|
||||
msgstr "uno-a-uno polimórfica"
|
||||
|
||||
#: index.docbook:276
|
||||
msgid "Inheritance strategy"
|
||||
msgstr "uno-a-muchos polimórfica"
|
||||
|
||||
#: index.docbook:277
|
||||
msgid "Polymorphic many-to-one"
|
||||
msgstr "mushos-a-muchos polimórfica"
|
||||
|
||||
#: index.docbook:278
|
||||
msgid "Polymorphic one-to-one"
|
||||
msgstr "<literal>load()/get()</literal> polimórficos"
|
||||
|
||||
#: index.docbook:279
|
||||
msgid "Polymorphic one-to-many"
|
||||
msgstr "Consultas polimórficas"
|
||||
|
||||
#: index.docbook:280
|
||||
msgid "Polymorphic many-to-many"
|
||||
msgstr "Uniones polimórficas"
|
||||
|
||||
#: index.docbook:281
|
||||
msgid "Polymorphic <literal>load()/get()</literal>"
|
||||
msgstr "Recuperación por unión externa (outer join)"
|
||||
|
||||
#: index.docbook:282
|
||||
msgid "Polymorphic queries"
|
||||
msgstr "<entry>tabla por jerarquía de clases</entry>"
|
||||
|
||||
#: index.docbook:283
|
||||
msgid "Polymorphic joins"
|
||||
msgstr "<many-to-one>"
|
||||
|
||||
#: index.docbook:284
|
||||
msgid "Outer join fetching"
|
||||
msgstr "<one-to-one>"
|
||||
|
||||
#: index.docbook:289
|
||||
msgid "table per class-hierarchy"
|
||||
msgstr "<one-to-many>"
|
||||
|
||||
#: index.docbook:290, index.docbook:301, index.docbook:312
|
||||
msgid "<many-to-one>"
|
||||
msgstr "<many-to-many>"
|
||||
|
||||
#: index.docbook:291, index.docbook:302, index.docbook:313
|
||||
msgid "<one-to-one>"
|
||||
msgstr "s.get(Payment.class, id)"
|
||||
|
||||
#: index.docbook:292, index.docbook:303
|
||||
msgid "<one-to-many>"
|
||||
msgstr "from Payment p"
|
||||
|
||||
#: index.docbook:293, index.docbook:304, index.docbook:315
|
||||
msgid "<many-to-many>"
|
||||
msgstr "from Order o join o.payment p"
|
||||
|
||||
#: index.docbook:294, index.docbook:305, index.docbook:316
|
||||
msgid "s.get(Payment.class, id)"
|
||||
msgstr "soportada"
|
||||
|
||||
#: index.docbook:295, index.docbook:306, index.docbook:317, index.docbook:328
|
||||
msgid "from Payment p"
|
||||
msgstr "<entry>tabla por subclase</entry>"
|
||||
|
||||
#: index.docbook:296, index.docbook:307, index.docbook:318
|
||||
msgid "from Order o join o.payment p"
|
||||
msgstr "<many-to-one>"
|
||||
|
||||
#: index.docbook:297, index.docbook:308, index.docbook:319
|
||||
msgid "supported"
|
||||
msgstr "<one-to-one>"
|
||||
|
||||
#: index.docbook:300
|
||||
msgid "<entry>table per subclass</entry>"
|
||||
msgstr "<one-to-many>"
|
||||
|
||||
#: index.docbook:311
|
||||
msgid "table per concrete-class (union-subclass)"
|
||||
msgstr "<literal><one-to-many></literal> (para <literal>inverse=\"true\"</literal> solamente)"
|
||||
|
||||
#: index.docbook:314
|
||||
msgid "<literal><one-to-many></literal> (for <literal>inverse=\"true\"</literal> only)"
|
||||
msgstr "from Payment p"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "table per concrete class (implicit polymorphism)"
|
||||
msgstr "no soportada"
|
||||
|
||||
#: index.docbook:323
|
||||
msgid "<any>"
|
||||
msgstr "<many-to-any>"
|
||||
|
||||
#: index.docbook:324, index.docbook:325, index.docbook:329, index.docbook:330
|
||||
msgid "not supported"
|
||||
msgstr "s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
|
||||
|
||||
#: index.docbook:326
|
||||
msgid "<many-to-any>"
|
||||
msgstr "no suportadas"
|
||||
|
||||
#: index.docbook:327
|
||||
msgid "s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
|
||||
msgstr "no soportada"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,625 @@
|
|||
#, 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 "PORHACER: Documentar el framework de extensiones del usuario en los paquetes de propiedad y proxies."
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "TODO: Document user-extension framework in the property and proxy packages"
|
||||
msgstr ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
#, 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,672 @@
|
|||
#, 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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,990 @@
|
|||
#, 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 "Native SQL"
|
||||
msgstr "SQL Nativo"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "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."
|
||||
msgstr "Puedes también expresar consultas en el dialecto SQL nativo de tu base de datos. Esto es útil si quieres utilizar aspectos específicos de base de datos tal como consejos (hints) de consulta o la palabra clave <literal>CONNECT</literal> en Oracle. Provee además una clara ruta de migración desde una aplicación basada en SQL/JDBC directo a Hibernate."
|
||||
|
||||
#: index.docbook:13
|
||||
msgid "Hibernate3 allows you to specify handwritten SQL (including stored procedures) for all create, update, delete, and load operations."
|
||||
msgstr "Hibernate3 te permite especificar SQL escrito a mano (incluyendo procedimientos almacenados) para todas las operaciones de creación, actualización, borrado y carga."
|
||||
|
||||
#: index.docbook:17
|
||||
msgid "Using a <literal>SQLQuery</literal>"
|
||||
msgstr "Creando una <literal>Query</literal> de SQL nativo"
|
||||
|
||||
#: index.docbook:19
|
||||
msgid "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."
|
||||
msgstr "Las consultas SQL se controlan por medio de la interface <literal>SQLQuery</literal>, que se obtiene llamando a <literal>Session.createSQLQuery()</literal>."
|
||||
|
||||
#: index.docbook:25
|
||||
msgid "Scalar queries"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createSQLQuery(\"select {cat.*} from cats cat\")\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:27
|
||||
msgid "The most basic SQL query is to get a list of scalars (values)."
|
||||
msgstr "Esta consulta especificada:"
|
||||
|
||||
#: index.docbook:30
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\").list();\n"
|
||||
"sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE FROM CATS\").list();\n"
|
||||
"]]>"
|
||||
msgstr "la cadena de consulta SQL, con un lugar para que Hibernate inyecte los alias de columnas"
|
||||
|
||||
#: index.docbook:32
|
||||
msgid "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."
|
||||
msgstr "la entidad devuelta por la consulta, y sus alias de tablas SQL"
|
||||
|
||||
#: index.docbook:37
|
||||
msgid "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>."
|
||||
msgstr "El método <literal>addEntity()</literal> asocia alias de tablas SQL con clases de entidad, y determina la forma del conjunto resultado de la consulta."
|
||||
|
||||
#: index.docbook:41
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\")\n"
|
||||
" .addScalar(\"ID\", Hibernate.LONG)\n"
|
||||
" .addScalar(\"NAME\", Hibernate.STRING)\n"
|
||||
" .addScalar(\"BIRTHDATE\", Hibernate.DATE)\n"
|
||||
"]]>"
|
||||
msgstr "El método <literal>addJoin()</literal> puede ser usado para cargar asociaciones a otras entidades y colecciones."
|
||||
|
||||
#: index.docbook:43, index.docbook:89, index.docbook:170, index.docbook:321
|
||||
msgid "This query specified:"
|
||||
msgstr ""
|
||||
"<![CDATA[List cats = sess.createSQLQuery(\n"
|
||||
" \"select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id\"\n"
|
||||
" )\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .addJoin(\"kitten\", \"cat.kittens\")\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:47, index.docbook:93, index.docbook:325
|
||||
msgid "the SQL query string"
|
||||
msgstr "Una consulta SQL nativa podría devolver un valor escalar simple o una combinación de escalares y entidades."
|
||||
|
||||
#: index.docbook:51
|
||||
msgid "the columns and types to return"
|
||||
msgstr ""
|
||||
"<![CDATA[Double max = (Double) sess.createSQLQuery(\"select max(cat.weight) as maxWeight from cats cat\")\n"
|
||||
" .addScalar(\"maxWeight\", Hibernate.DOUBLE);\n"
|
||||
" .uniqueResult();]]>"
|
||||
|
||||
#: index.docbook:55
|
||||
msgid "This will still return Object arrays, but now it will not use <literal>ResultSetMetdata</literal> but will instead explicitly get the ID, NAME and BIRTHDATE column as respectively a Long, String and a Short from the underlying resultset. This also means that only these three columns will be returned, even though the query is using <literal>*</literal> and could return more than the three listed columns."
|
||||
msgstr "Alias y referencias de propiedad"
|
||||
|
||||
#: index.docbook:63
|
||||
msgid "It is possible to leave out the type information for all or some of the scalars."
|
||||
msgstr "La notación <literal>{cat.*}</literal> usada arriba es un atajo para \"todas las propiedades\". Alternativamente, puedes listar las columnas explícitamente, pero incluso en este caso dejamos que Hibernate inyecte los alias de columnas SQL para cada propiedad. El lugar para un alias de columna es sólo el nombre de propiedad cualificado por el alias de la tabla. En el siguiente ejemplo, recuperamos <literal>Cat</literal>s de una tabla diferente (<literal>cat_log</literal>) a una declarada en los metadatos de mapeo. Nota que podríamos incluso usar los alias de propiedad en la cláusula where si quisieramos."
|
||||
|
||||
#: index.docbook:66
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\")\n"
|
||||
" .addScalar(\"ID\", Hibernate.LONG)\n"
|
||||
" .addScalar(\"NAME\")\n"
|
||||
" .addScalar(\"BIRTHDATE\")\n"
|
||||
"]]>"
|
||||
msgstr "La sintáxis <literal>{}</literal> <emphasis>no</emphasis> es requerida para consultas con nombre. Ver"
|
||||
|
||||
#: index.docbook:68
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
"<![CDATA[String sql = \"select cat.originalId as {cat.id}, \" +\n"
|
||||
" \"cat.mateid as {cat.mate}, cat.sex as {cat.sex}, \" +\n"
|
||||
" \"cat.weight*10 as {cat.weight}, cat.name as {cat.name} \" +\n"
|
||||
" \"from cat_log cat where {cat.mate} = :catId\"\n"
|
||||
" \n"
|
||||
"List loggedCats = sess.createSQLQuery(sql)\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .setLong(\"catId\", catId)\n"
|
||||
" .list();]]>"
|
||||
|
||||
#: index.docbook:72
|
||||
msgid "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."
|
||||
msgstr "<emphasis>Nota:</emphasis> si listas cada propiedad explícitamente, ¡debes incluir todas las propiedades de la clase <emphasis>y sus subclases</emphasis>!"
|
||||
|
||||
#: index.docbook:80
|
||||
msgid "Entity queries"
|
||||
msgstr "Consultas SQL con nombre"
|
||||
|
||||
#: index.docbook:82
|
||||
msgid "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>."
|
||||
msgstr "Las consultas SQL con nombre pueden definirse en el documento de mapeo y llamadas exactamente en la misma forma en que a una consulta HQL con nombre. En este caso, <emphasis>no</emphasis> necesitamos llamar a <literal>addEntity()</literal>."
|
||||
|
||||
#: index.docbook:87
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\").addEntity(Cat.class);\n"
|
||||
"sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE FROM CATS\").addEntity(Cat.class);\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"persons\">\n"
|
||||
" <return alias=\"person\" class=\"eg.Person\"/>\n"
|
||||
" SELECT person.NAME AS {person.name},\n"
|
||||
" person.AGE AS {person.age},\n"
|
||||
" person.SEX AS {person.sex}\n"
|
||||
" FROM PERSON person \n"
|
||||
" WHERE person.NAME LIKE :namePattern\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:97
|
||||
msgid "the entity returned by the query"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"personsWith\">\n"
|
||||
" <return alias=\"person\" class=\"eg.Person\"/>\n"
|
||||
" <return-join alias=\"address\" property=\"person.mailingAddress\"/>\n"
|
||||
" SELECT person.NAME AS {person.name},\n"
|
||||
" person.AGE AS {person.age},\n"
|
||||
" person.SEX AS {person.sex},\n"
|
||||
" address.STREET AS {address.street},\n"
|
||||
" address.CITY AS {address.city},\n"
|
||||
" address.STATE AS {address.state},\n"
|
||||
" address.ZIP AS {address.zip}\n"
|
||||
" FROM PERSON person \n"
|
||||
" JOIN ADDRESS address\n"
|
||||
" ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'\n"
|
||||
" WHERE person.NAME LIKE :namePattern\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:101
|
||||
msgid "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."
|
||||
msgstr "Una consulta SQL con nombre puede devolver un valor escalar. Debes especificar el alias de columna y tipo Hibernate usando el elementp <literal><return-scalar></literal>:"
|
||||
|
||||
#: index.docbook:105
|
||||
msgid "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>:"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"mySqlQuery\">\n"
|
||||
" <return-scalar column=\"name\" type=\"string\"/>\n"
|
||||
" <return-scalar column=\"age\" type=\"long\"/>\n"
|
||||
" SELECT p.NAME AS name,\n"
|
||||
" p.AGE AS age,\n"
|
||||
" FROM PERSON p WHERE p.NAME LIKE 'Hiber%'\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:113
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS\").addEntity(Cat.class);\n"
|
||||
"]]>"
|
||||
msgstr "Usando return-property para especificar explícitamente nombres de columna/alias"
|
||||
|
||||
#: index.docbook:115
|
||||
msgid "This will allow cat.getDog() to function properly."
|
||||
msgstr "Con <literal><return-property></literal> puedes decirle explícitamente a Hibernate qué alias de columna usar, en vez de usar la sintáxis <literal>{}</literal> para dejar que Hibernate inyecte sus propios alias."
|
||||
|
||||
#: index.docbook:119
|
||||
msgid "Handling associations and collections"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"mySqlQuery\">\n"
|
||||
" <return alias=\"person\" class=\"eg.Person\">\n"
|
||||
" <return-property name=\"name\" column=\"myName\"/>\n"
|
||||
" <return-property name=\"age\" column=\"myAge\"/>\n"
|
||||
" <return-property name=\"sex\" column=\"mySex\"/>\n"
|
||||
" </return>\n"
|
||||
" SELECT person.NAME AS myName,\n"
|
||||
" person.AGE AS myAge,\n"
|
||||
" person.SEX AS mySex,\n"
|
||||
" FROM PERSON person WHERE person.NAME LIKE :name\n"
|
||||
"</sql-query>\n"
|
||||
"]]>"
|
||||
|
||||
#: index.docbook:121
|
||||
msgid "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."
|
||||
msgstr "<literal><return-property></literal> también trabaja con múltiples columnas. Esto resuelve una limitación de la sintáxis <literal>{}</literal>, la cual no puede permitir un control fino de propiedades multi-columna."
|
||||
|
||||
#: index.docbook:126
|
||||
msgid ""
|
||||
"<![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\")\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .addJoin(\"cat.dog\");\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"organizationCurrentEmployments\">\n"
|
||||
" <return alias=\"emp\" class=\"Employment\"> \n"
|
||||
" <return-property name=\"salary\"> \n"
|
||||
" <return-column name=\"VALUE\"/>\n"
|
||||
" <return-column name=\"CURRENCY\"/> \n"
|
||||
" </return-property>\n"
|
||||
" <return-property name=\"endDate\" column=\"myEndDate\"/>\n"
|
||||
" </return>\n"
|
||||
" SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer}, \n"
|
||||
" STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},\n"
|
||||
" REGIONCODE as {emp.regionCode}, EID AS {emp.id}, VALUE, CURRENCY\n"
|
||||
" FROM EMPLOYMENT\n"
|
||||
" WHERE EMPLOYER = :id AND ENDDATE IS NULL\n"
|
||||
" ORDER BY STARTDATE ASC\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:128
|
||||
msgid "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."
|
||||
msgstr "Nota que en este ejemplo hemos usado <literal><return-property></literal> en combinación con la sintáxis <literal>{}</literal> para inyección, permitiendo a los usuarios elejir cómo quieren referirse a las columnas y propiedades."
|
||||
|
||||
#: index.docbook:136
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, CAT_ID FROM CATS c, DOGS d WHERE c.ID = d.CAT_ID\")\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .addJoin(\"cat.dogs\");\n"
|
||||
"]]>"
|
||||
msgstr "Si tu mapeo tiene un discriminador debes usar <literal><return-discriminator></literal> para especificar la columna discriminadora."
|
||||
|
||||
#: index.docbook:138
|
||||
msgid "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."
|
||||
msgstr "Usando procedimientos almacenados para consultar"
|
||||
|
||||
#: index.docbook:146
|
||||
msgid "Returning multiple entities"
|
||||
msgstr "Hibernate3 introduce soporte para consultas vía procedimientos almacenados. Los procedimientos almacenados deben devolver un conjunto resultado como el primer parámetro de salida para ser capaces de funcionar con Hibernate. Un ejemplo de uno procedimiento almacenado en Oracle 9 o superior es así:"
|
||||
|
||||
#: index.docbook:148
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
"<![CDATA[CREATE OR REPLACE FUNCTION selectAllEmployments \n"
|
||||
" RETURN SYS_REFCURSOR \n"
|
||||
"AS \n"
|
||||
" st_cursor SYS_REFCURSOR; \n"
|
||||
"BEGIN \n"
|
||||
" OPEN st_cursor FOR \n"
|
||||
" SELECT EMPLOYEE, EMPLOYER, \n"
|
||||
" STARTDATE, ENDDATE, \n"
|
||||
" REGIONCODE, EID, VALUE, CURRENCY \n"
|
||||
" FROM EMPLOYMENT; \n"
|
||||
" RETURN st_cursor; \n"
|
||||
" END;]]>"
|
||||
|
||||
#: index.docbook:153
|
||||
msgid "Column alias injection is needed in the following query (which most likely will fail):"
|
||||
msgstr "Para usar esta consulta en Hibernate necesitas mapearla por medio de una consulta con nombre."
|
||||
|
||||
#: index.docbook:156
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT c.*, m.* FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID\")\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .addEntity(\"mother\", Cat.class)\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"selectAllEmployees_SP\" callable=\"true\">\n"
|
||||
" <return alias=\"emp\" class=\"Employment\">\n"
|
||||
" <return-property name=\"employee\" column=\"EMPLOYEE\"/>\n"
|
||||
" <return-property name=\"employer\" column=\"EMPLOYER\"/> \n"
|
||||
" <return-property name=\"startDate\" column=\"STARTDATE\"/>\n"
|
||||
" <return-property name=\"endDate\" column=\"ENDDATE\"/> \n"
|
||||
" <return-property name=\"regionCode\" column=\"REGIONCODE\"/> \n"
|
||||
" <return-property name=\"id\" column=\"EID\"/> \n"
|
||||
" <return-property name=\"salary\"> \n"
|
||||
" <return-column name=\"VALUE\"/>\n"
|
||||
" <return-column name=\"CURRENCY\"/> \n"
|
||||
" </return-property>\n"
|
||||
" </return>\n"
|
||||
" { ? = call selectAllEmployments() }\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:158
|
||||
msgid "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 specificed in the mappings (\"ID\" and \"NAME\")."
|
||||
msgstr "Nota que los procedimientos almacenados sólo devuelven escalares y entidades. No están soportados <literal><return-join></literal> y <literal><load-collection></literal>."
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "The following form is not vulnerable to column name duplication:"
|
||||
msgstr "Reglas/limitaciones para usar procedimientos almacenados"
|
||||
|
||||
#: index.docbook:168
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT {cat.*}, {mother.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID\")\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .addEntity(\"mother\", Cat.class)\n"
|
||||
"]]>"
|
||||
msgstr "Para usar procedimientos almacenados con Hibernate los procedimientos tienen que seguir algunas reglas. Si no siguen esas reglas no son usables por Hibernate. Si aún quisieras usar estos procedimientos tendrías que ejecutarlos por medio de <literal>session.connection()</literal>. Las reglas son diferentes para cada base de datos, ya que los vendedores de base de datos tienen diferentes semánticas/sintáxis de procedimientos almacenados."
|
||||
|
||||
#: index.docbook:174
|
||||
msgid "the SQL query string, with placeholders for Hibernate to inject column aliases"
|
||||
msgstr "Para Oracle se aplican las siguientes reglas:"
|
||||
|
||||
#: index.docbook:179
|
||||
msgid "the entities returned by the query"
|
||||
msgstr "El procedimiento debe devolver un conjunto resultado. Esto se hace devolviendo un <literal>SYS_REFCURSOR</literal> en Oracle 9 o 10. En Oracle necesitas definir un tipo <literal>REF CURSOR</literal>."
|
||||
|
||||
#: index.docbook:183
|
||||
msgid "The {cat.*} and {mother.*} notation used above is a shorthand for \"all properties\". Alternatively, you may list the columns explicity, 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."
|
||||
msgstr "La forma recomendada es <literal>{ ? = call procName(<parameters>) }</literal> o <literal>{ ? = call procName }</literal> (esto es más una regla de Oracle que una regla de Hibernate)."
|
||||
|
||||
#: index.docbook:192
|
||||
msgid ""
|
||||
"<![CDATA[String sql = \"SELECT ID as {c.id}, NAME as {c.name}, \" + \n"
|
||||
" \"BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} \" +\n"
|
||||
" \"FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID\";\n"
|
||||
"\n"
|
||||
"List loggedCats = sess.createSQLQuery(sql)\n"
|
||||
" .addEntity(\"cat\", Cat.class)\n"
|
||||
" .addEntity(\"mother\", Cat.class).list()\n"
|
||||
"]]>"
|
||||
msgstr "Para Sybase o MS SQL server se aplican las siguientes reglas:"
|
||||
|
||||
#: index.docbook:195
|
||||
msgid "Alias and property references"
|
||||
msgstr "El procedimiento debe devolver un conjunto resultado. Nota que ya que estos servidores pueden y devolverán múltiples conjuntos resultados y cuentas de actualización, Hibernate iterará los resultados y tomará el primer resultado que sea un conjunto resultado como su valor a devolver. Todo lo demás será descartado."
|
||||
|
||||
#: index.docbook:197
|
||||
msgid "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."
|
||||
msgstr "Si habilitas <literal>SET NOCOUNT ON</literal> en tu procedimiento será probablemente más eficiente, pero esto no es un requerimiento."
|
||||
|
||||
#: index.docbook:202
|
||||
msgid "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."
|
||||
msgstr "SQL personalizado para crear, actualizar y borrar"
|
||||
|
||||
#: index.docbook:208
|
||||
msgid "Alias injection names"
|
||||
msgstr "Hibernate3 puede usar sentencias SQL personalizadas para las operaciones de crear, actualizar y borrar. Los persistidores de clases y colecciones en Hibernate ya contienen un conjunto de cadenas generadas en tiempo de configuración (insertsql, deletesql, updatesql, etc.). Las etiquetas de mapeo <literal><sql-insert></literal>, <literal><sql-delete></literal>, y <literal><sql-update></literal> sobrescriben estas cadenas:"
|
||||
|
||||
#: index.docbook:219
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\" not-null=\"true\"/>\n"
|
||||
" <sql-insert>INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )</sql-insert>\n"
|
||||
" <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?</sql-update>\n"
|
||||
" <sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:221
|
||||
msgid "Syntax"
|
||||
msgstr "El SQL se ejecuta directamente en tu base de datos, de modo que eres libre de usar cualquier dialecto que quieras. Esto reducirá, por supuesto, la portabilidad de tu mapeo si usas SQL específico de la base de datos."
|
||||
|
||||
#: index.docbook:223
|
||||
msgid "Example"
|
||||
msgstr "Los procedimientos almacenados son soportados si está establecido el atributo <literal>callable</literal>:"
|
||||
|
||||
#: index.docbook:229
|
||||
msgid "A simple property"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\" not-null=\"true\"/>\n"
|
||||
" <sql-insert callable=\"true\">{call createPerson (?, ?)}</sql-insert>\n"
|
||||
" <sql-delete callable=\"true\">{? = call deletePerson (?)}</sql-delete>\n"
|
||||
" <sql-update callable=\"true\">{? = call updatePerson (?, ?)}</sql-update>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:231
|
||||
msgid "{[aliasname].[propertyname]"
|
||||
msgstr "El orden de los parámetros posicionales son actualmente vitales, ya que deben estar en la misma secuencia en que las espera Hibernate."
|
||||
|
||||
#: index.docbook:233
|
||||
msgid "A_NAME as {item.name}"
|
||||
msgstr "Puedes ver el orden esperado habilitando el registro de depuración para el nivel <literal>org.hibernate.persister.entity</literal>. Con este nivel habilitado, Hibernate imprimirá el SQL estático que se usa para crear, actualizar, borrar, etc. las entidades. (Para ver la secuencia esperada, recuerda no incluir tu SQL personalizado en los ficheros de mapeo ya que sobrescribirán el sql estático generado por Hibernate.)"
|
||||
|
||||
#: index.docbook:237
|
||||
msgid "A composite property"
|
||||
msgstr "Los procedimientos almacenados son, en la mayoría de los casos (léase, mejor hacerlo que no hacerlo), obligados a devolver el número de filas insertadas/actualizadas/borradas, ya que Hibernate tiene algunas comprobaciones en tiempo de ejecución del éxito de la sentencia. Hibernate siempre registra el primer parámetro de la sentencia como un parámetro de salida numérico para las operaciones CUD:"
|
||||
|
||||
#: index.docbook:239
|
||||
msgid "{[aliasname].[componentname].[propertyname]}"
|
||||
msgstr ""
|
||||
"<![CDATA[CREATE OR REPLACE FUNCTION updatePerson (uid IN NUMBER, uname IN VARCHAR2)\n"
|
||||
" RETURN NUMBER IS\n"
|
||||
"BEGIN\n"
|
||||
"\n"
|
||||
" update PERSON\n"
|
||||
" set\n"
|
||||
" NAME = uname,\n"
|
||||
" where\n"
|
||||
" ID = uid;\n"
|
||||
"\n"
|
||||
" return SQL%ROWCOUNT;\n"
|
||||
"\n"
|
||||
"END updatePerson;]]>"
|
||||
|
||||
#: index.docbook:241
|
||||
msgid "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}"
|
||||
msgstr "SQL personalizado para carga"
|
||||
|
||||
#: index.docbook:246
|
||||
msgid "Discriminator of an entity"
|
||||
msgstr "Puedes también declarar tu propias consultas SQL (o HQL) para cargar entidades:"
|
||||
|
||||
#: index.docbook:248
|
||||
msgid "{[aliasname].class}"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"person\">\n"
|
||||
" <return alias=\"pers\" class=\"Person\" lock-mode=\"upgrade\"/>\n"
|
||||
" SELECT NAME AS {pers.name}, ID AS {pers.id} \n"
|
||||
" FROM PERSON \n"
|
||||
" WHERE ID=? \n"
|
||||
" FOR UPDATE\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:250
|
||||
msgid "DISC as {item.class}"
|
||||
msgstr "Esto es sólo una declaración de consulta con nombrem como se ha discutido anteriormente. Puedes hacer referencia a esta consulta con nombre en un mapeo de clase:"
|
||||
|
||||
#: index.docbook:254
|
||||
msgid "All properties of an entity"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\" not-null=\"true\"/>\n"
|
||||
" <loader query-ref=\"person\"/>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:256, index.docbook:304
|
||||
msgid "{[aliasname].*}"
|
||||
msgstr "Esto incluso funciona con procedimientos almacenados."
|
||||
|
||||
#: index.docbook:258
|
||||
msgid "{item.*}"
|
||||
msgstr "Puedes incluso definit una consulta para la carga de colecciones:"
|
||||
|
||||
#: index.docbook:262
|
||||
msgid "A collection key"
|
||||
msgstr ""
|
||||
"<![CDATA[<set name=\"employments\" inverse=\"true\">\n"
|
||||
" <key/>\n"
|
||||
" <one-to-many class=\"Employment\"/>\n"
|
||||
" <loader query-ref=\"employments\"/>\n"
|
||||
"</set>]]>"
|
||||
|
||||
#: index.docbook:264
|
||||
msgid "{[aliasname].key}"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"employments\">\n"
|
||||
" <load-collection alias=\"emp\" role=\"Person.employments\"/>\n"
|
||||
" SELECT {emp.*}\n"
|
||||
" FROM EMPLOYMENT emp\n"
|
||||
" WHERE EMPLOYER = :id\n"
|
||||
" ORDER BY STARTDATE ASC, EMPLOYEE ASC\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:266
|
||||
msgid "ORGID as {coll.key}"
|
||||
msgstr "Podrías incluso definir un cargador de entidades que cargue una colección por recuperación por unión (join fetching):"
|
||||
|
||||
#: index.docbook:270
|
||||
msgid "The id of an collection"
|
||||
msgstr ""
|
||||
"<![CDATA[<sql-query name=\"person\">\n"
|
||||
" <return alias=\"pers\" class=\"Person\"/>\n"
|
||||
" <return-join alias=\"emp\" property=\"pers.employments\"/> \n"
|
||||
" SELECT NAME AS {pers.*}, {emp.*}\n"
|
||||
" FROM PERSON pers\n"
|
||||
" LEFT OUTER JOIN EMPLOYMENT emp \n"
|
||||
" ON pers.ID = emp.PERSON_ID\n"
|
||||
" WHERE ID=?\n"
|
||||
"</sql-query>]]>"
|
||||
|
||||
#: index.docbook:272
|
||||
msgid "{[aliasname].id}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:274
|
||||
msgid "EMPID as {coll.id}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:278
|
||||
msgid "The element of an collection"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:280
|
||||
msgid "{[aliasname].element}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:282
|
||||
msgid "XID as {coll.element}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:286
|
||||
msgid "roperty of the element in the collection"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:288
|
||||
msgid "{[aliasname].element.[propertyname]}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:290
|
||||
msgid "NAME as {coll.element.name}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:294
|
||||
msgid "All properties of the element in the collection"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:296
|
||||
msgid "{[aliasname].element.*}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:298
|
||||
msgid "{coll.element.*}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:302
|
||||
msgid "All properties of the the collection"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:306
|
||||
msgid "{coll.*}"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:315
|
||||
msgid "Returning non-managed entities"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:317
|
||||
msgid "It is possible to apply a ResultTransformer to native sql queries. Allowing it to e.g. return non-managed entities."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:319
|
||||
msgid ""
|
||||
"<![CDATA[sess.createSQLQuery(\"SELECT NAME, BIRTHDATE FROM CATS\")\n"
|
||||
" .setResultTransformer(Transformers.aliasToBean(CatDTO.class))]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:329
|
||||
msgid "a result transformer"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:333
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:340
|
||||
msgid "Handling inheritance"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:342
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:348
|
||||
msgid "Parameters"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:350
|
||||
msgid "Native sql queries support positional as well as named parameters:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:353
|
||||
msgid ""
|
||||
"<![CDATA[Query query = sess.createSQLQuery(\"SELECT * FROM CATS WHERE NAME like ?\").addEntity(Cat.class);\n"
|
||||
"List pusList = query.setString(0, \"Pus%\").list();\n"
|
||||
" \n"
|
||||
"query = sess.createSQLQuery(\"SELECT * FROM CATS WHERE NAME like :name\").addEntity(Cat.class);\n"
|
||||
"List pusList = query.setString(\"name\", \"Pus%\").list(); ]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:361
|
||||
msgid "Named SQL queries"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:363
|
||||
msgid "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>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:368
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"persons\">\n"
|
||||
" <return alias=\"person\" class=\"eg.Person\"/>\n"
|
||||
" SELECT person.NAME AS {person.name},\n"
|
||||
" person.AGE AS {person.age},\n"
|
||||
" person.SEX AS {person.sex}\n"
|
||||
" FROM PERSON person\n"
|
||||
" WHERE person.NAME LIKE :namePattern\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:370
|
||||
msgid ""
|
||||
"<![CDATA[List people = sess.getNamedQuery(\"persons\")\n"
|
||||
" .setString(\"namePattern\", namePattern)\n"
|
||||
" .setMaxResults(50)\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:372
|
||||
msgid "The <literal><return-join></literal> and <literal><load-collection></literal> elements are used to join associations and define queries which initialize collections, respectively."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:377
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"personsWith\">\n"
|
||||
" <return alias=\"person\" class=\"eg.Person\"/>\n"
|
||||
" <return-join alias=\"address\" property=\"person.mailingAddress\"/>\n"
|
||||
" SELECT person.NAME AS {person.name},\n"
|
||||
" person.AGE AS {person.age},\n"
|
||||
" person.SEX AS {person.sex},\n"
|
||||
" address.STREET AS {address.street},\n"
|
||||
" address.CITY AS {address.city},\n"
|
||||
" address.STATE AS {address.state},\n"
|
||||
" address.ZIP AS {address.zip}\n"
|
||||
" FROM PERSON person\n"
|
||||
" JOIN ADDRESS address\n"
|
||||
" ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'\n"
|
||||
" WHERE person.NAME LIKE :namePattern\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:379
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:383
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"mySqlQuery\">\n"
|
||||
" <return-scalar column=\"name\" type=\"string\"/>\n"
|
||||
" <return-scalar column=\"age\" type=\"long\"/>\n"
|
||||
" SELECT p.NAME AS name,\n"
|
||||
" p.AGE AS age,\n"
|
||||
" FROM PERSON p WHERE p.NAME LIKE 'Hiber%'\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:385
|
||||
msgid "You can externalize the resultset mapping informations in a <literal><resultset></literal> element to either reuse them accross several named queries or through the <literal>setResultSetMapping()</literal> API."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:390
|
||||
msgid ""
|
||||
"<![CDATA[<resultset name=\"personAddress\">\n"
|
||||
" <return alias=\"person\" class=\"eg.Person\"/>\n"
|
||||
" <return-join alias=\"address\" property=\"person.mailingAddress\"/>\n"
|
||||
"</resultset>\n"
|
||||
"\n"
|
||||
"<sql-query name=\"personsWith\" resultset-ref=\"personAddress\">\n"
|
||||
" SELECT person.NAME AS {person.name},\n"
|
||||
" person.AGE AS {person.age},\n"
|
||||
" person.SEX AS {person.sex},\n"
|
||||
" address.STREET AS {address.street},\n"
|
||||
" address.CITY AS {address.city},\n"
|
||||
" address.STATE AS {address.state},\n"
|
||||
" address.ZIP AS {address.zip}\n"
|
||||
" FROM PERSON person\n"
|
||||
" JOIN ADDRESS address\n"
|
||||
" ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'\n"
|
||||
" WHERE person.NAME LIKE :namePattern\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:392
|
||||
msgid "You can alternatively use the resultset mapping information in your hbm files directly in java code."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:395
|
||||
msgid ""
|
||||
"<![CDATA[List cats = sess.createSQLQuery(\n"
|
||||
" \"select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id\"\n"
|
||||
" )\n"
|
||||
" .setResultSetMapping(\"catAndKitten\")\n"
|
||||
" .list();]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:398
|
||||
msgid "Using return-property to explicitly specify column/alias names"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:401
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:406
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"mySqlQuery\">\n"
|
||||
" <return alias=\"person\" class=\"eg.Person\">\n"
|
||||
" <return-property name=\"name\" column=\"myName\"/>\n"
|
||||
" <return-property name=\"age\" column=\"myAge\"/>\n"
|
||||
" <return-property name=\"sex\" column=\"mySex\"/>\n"
|
||||
" </return>\n"
|
||||
" SELECT person.NAME AS myName,\n"
|
||||
" person.AGE AS myAge,\n"
|
||||
" person.SEX AS mySex,\n"
|
||||
" FROM PERSON person WHERE person.NAME LIKE :name\n"
|
||||
"</sql-query>\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:408
|
||||
msgid "<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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:413
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"organizationCurrentEmployments\">\n"
|
||||
" <return alias=\"emp\" class=\"Employment\">\n"
|
||||
" <return-property name=\"salary\">\n"
|
||||
" <return-column name=\"VALUE\"/>\n"
|
||||
" <return-column name=\"CURRENCY\"/>\n"
|
||||
" </return-property>\n"
|
||||
" <return-property name=\"endDate\" column=\"myEndDate\"/>\n"
|
||||
" </return>\n"
|
||||
" SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},\n"
|
||||
" STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},\n"
|
||||
" REGIONCODE as {emp.regionCode}, EID AS {emp.id}, VALUE, CURRENCY\n"
|
||||
" FROM EMPLOYMENT\n"
|
||||
" WHERE EMPLOYER = :id AND ENDDATE IS NULL\n"
|
||||
" ORDER BY STARTDATE ASC\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:415
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:420
|
||||
msgid "If your mapping has a discriminator you must use <literal><return-discriminator></literal> to specify the discriminator column."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:426
|
||||
msgid "Using stored procedures for querying"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:428
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:434
|
||||
msgid ""
|
||||
"<![CDATA[CREATE OR REPLACE FUNCTION selectAllEmployments\n"
|
||||
" RETURN SYS_REFCURSOR\n"
|
||||
"AS\n"
|
||||
" st_cursor SYS_REFCURSOR;\n"
|
||||
"BEGIN\n"
|
||||
" OPEN st_cursor FOR\n"
|
||||
" SELECT EMPLOYEE, EMPLOYER,\n"
|
||||
" STARTDATE, ENDDATE,\n"
|
||||
" REGIONCODE, EID, VALUE, CURRENCY\n"
|
||||
" FROM EMPLOYMENT;\n"
|
||||
" RETURN st_cursor;\n"
|
||||
" END;]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:436
|
||||
msgid "To use this query in Hibernate you need to map it via a named query."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:439
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"selectAllEmployees_SP\" callable=\"true\">\n"
|
||||
" <return alias=\"emp\" class=\"Employment\">\n"
|
||||
" <return-property name=\"employee\" column=\"EMPLOYEE\"/>\n"
|
||||
" <return-property name=\"employer\" column=\"EMPLOYER\"/>\n"
|
||||
" <return-property name=\"startDate\" column=\"STARTDATE\"/>\n"
|
||||
" <return-property name=\"endDate\" column=\"ENDDATE\"/>\n"
|
||||
" <return-property name=\"regionCode\" column=\"REGIONCODE\"/>\n"
|
||||
" <return-property name=\"id\" column=\"EID\"/>\n"
|
||||
" <return-property name=\"salary\">\n"
|
||||
" <return-column name=\"VALUE\"/>\n"
|
||||
" <return-column name=\"CURRENCY\"/>\n"
|
||||
" </return-property>\n"
|
||||
" </return>\n"
|
||||
" { ? = call selectAllEmployments() }\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:441
|
||||
msgid "Notice stored procedures currently only return scalars and entities. <literal><return-join></literal> and <literal><load-collection></literal> are not supported."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:446
|
||||
msgid "Rules/limitations for using stored procedures"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:448
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:455
|
||||
msgid "Stored procedure queries can't be paged with <literal>setFirstResult()/setMaxResults()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:458
|
||||
msgid "Recommended call form is standard SQL92: <literal>{ ? = call functionName(<parameters>) }</literal> or <literal>{ ? = call procedureName(<parameters>}</literal>. Native call syntax is not supported."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:463
|
||||
msgid "For Oracle the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:467
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:476
|
||||
msgid "For Sybase or MS SQL server the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:480
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:488
|
||||
msgid "If you can enable <literal>SET NOCOUNT ON</literal> in your procedure it will probably be more efficient, but this is not a requirement."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:498
|
||||
msgid "Custom SQL for create, update and delete"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:500
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:508
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\" not-null=\"true\"/>\n"
|
||||
" <sql-insert>INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )</sql-insert>\n"
|
||||
" <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?</sql-update>\n"
|
||||
" <sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:510
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:514
|
||||
msgid "Stored procedures are supported if the <literal>callable</literal> attribute is set:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:517
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\" not-null=\"true\"/>\n"
|
||||
" <sql-insert callable=\"true\">{call createPerson (?, ?)}</sql-insert>\n"
|
||||
" <sql-delete callable=\"true\">{? = call deletePerson (?)}</sql-delete>\n"
|
||||
" <sql-update callable=\"true\">{? = call updatePerson (?, ?)}</sql-update>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:519
|
||||
msgid "The order of the positional parameters are currently vital, as they must be in the same sequence as Hibernate expects them."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:522
|
||||
msgid "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.)"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:529
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:535
|
||||
msgid ""
|
||||
"<![CDATA[CREATE OR REPLACE FUNCTION updatePerson (uid IN NUMBER, uname IN VARCHAR2)\n"
|
||||
" RETURN NUMBER IS\n"
|
||||
"BEGIN\n"
|
||||
"\n"
|
||||
" update PERSON\n"
|
||||
" set\n"
|
||||
" NAME = uname,\n"
|
||||
" where\n"
|
||||
" ID = uid;\n"
|
||||
"\n"
|
||||
" return SQL%ROWCOUNT;\n"
|
||||
"\n"
|
||||
"END updatePerson;]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:539
|
||||
msgid "Custom SQL for loading"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:541
|
||||
msgid "You may also declare your own SQL (or HQL) queries for entity loading:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:544
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"person\">\n"
|
||||
" <return alias=\"pers\" class=\"Person\" lock-mode=\"upgrade\"/>\n"
|
||||
" SELECT NAME AS {pers.name}, ID AS {pers.id}\n"
|
||||
" FROM PERSON\n"
|
||||
" WHERE ID=?\n"
|
||||
" FOR UPDATE\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:546
|
||||
msgid "This is just a named query declaration, as discussed earlier. You may reference this named query in a class mapping:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:549
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Person\">\n"
|
||||
" <id name=\"id\">\n"
|
||||
" <generator class=\"increment\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"name\" not-null=\"true\"/>\n"
|
||||
" <loader query-ref=\"person\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:551
|
||||
msgid "This even works with stored procedures."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:553
|
||||
msgid "You may even define a query for collection loading:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:555
|
||||
msgid ""
|
||||
"<![CDATA[<set name=\"employments\" inverse=\"true\">\n"
|
||||
" <key/>\n"
|
||||
" <one-to-many class=\"Employment\"/>\n"
|
||||
" <loader query-ref=\"employments\"/>\n"
|
||||
"</set>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:557
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"employments\">\n"
|
||||
" <load-collection alias=\"emp\" role=\"Person.employments\"/>\n"
|
||||
" SELECT {emp.*}\n"
|
||||
" FROM EMPLOYMENT emp\n"
|
||||
" WHERE EMPLOYER = :id\n"
|
||||
" ORDER BY STARTDATE ASC, EMPLOYEE ASC\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:559
|
||||
msgid "You could even define an entity loader that loads a collection by join fetching:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:562
|
||||
msgid ""
|
||||
"<![CDATA[<sql-query name=\"person\">\n"
|
||||
" <return alias=\"pers\" class=\"Person\"/>\n"
|
||||
" <return-join alias=\"emp\" property=\"pers.employments\"/>\n"
|
||||
" SELECT NAME AS {pers.*}, {emp.*}\n"
|
||||
" FROM PERSON pers\n"
|
||||
" LEFT OUTER JOIN EMPLOYMENT emp\n"
|
||||
" ON pers.ID = emp.PERSON_ID\n"
|
||||
" WHERE ID=?\n"
|
||||
"</sql-query>]]>"
|
||||
msgstr ""
|
||||
|
||||
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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,725 @@
|
|||
#, 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 "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:85
|
||||
msgid "<![CDATA[<property name=\"balance\" precision=\"12\" scale=\"2\"/>]]>"
|
||||
msgstr "Algunas etiquetas aceptan un atributo <literal>index</literal> para especificar el nombre de un índice para esa columna. Se puede usar un atributo <literal>unique-key</literal> para agrupar columnas en una restricción de clave de una sola unidad. Actualmente, el valor especificado del atributo <literal>unique-key</literal> <emphasis>no</emphasis> es usado para nombrar la restricción, sólo para agrupar las columnas en el fichero de mapeo."
|
||||
|
||||
#: 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 "Ejemplos:"
|
||||
|
||||
#: index.docbook:93
|
||||
msgid "<![CDATA[<many-to-one name=\"bar\" column=\"barId\" not-null=\"true\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"foo\" type=\"string\" length=\"64\" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
"<many-to-one name=\"bar\" foreign-key=\"fk_foo_bar\" not-null=\"true\"/>\n"
|
||||
"\n"
|
||||
"<element column=\"serial_number\" type=\"long\" not-null=\"true\" unique=\"true\"/>]]>"
|
||||
|
||||
#: index.docbook:95
|
||||
msgid "<![CDATA[<element column=\"serialNumber\" type=\"long\" not-null=\"true\" unique=\"true\"/>]]>"
|
||||
msgstr "Alternativamente, estos elementos aceptan tambíen un elemento hijo <literal><column></literal>. Esto es particularmente útil para tipos multicolumnas:"
|
||||
|
||||
#: 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 ""
|
||||
"<![CDATA[<property name=\"foo\" type=\"string\">\n"
|
||||
" <column name=\"foo\" length=\"64\" not-null=\"true\" sql-type=\"text\"/>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: index.docbook:105
|
||||
msgid ""
|
||||
"<![CDATA[<many-to-one name=\"org\" column=\"orgId\" unique-key=\"OrgEmployeeId\"/>\n"
|
||||
"<property name=\"employeeId\" unique-key=\"OrgEmployee\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"bar\" type=\"my.customtypes.MultiColumnType\"/>\n"
|
||||
" <column name=\"fee\" not-null=\"true\" index=\"bar_idx\"/>\n"
|
||||
" <column name=\"fi\" not-null=\"true\" index=\"bar_idx\"/>\n"
|
||||
" <column name=\"fo\" not-null=\"true\" index=\"bar_idx\"/>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: 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 "El atributo <literal>sql-type</literal> permite al usuario sobrescribir el mapeo por defecto de tipo Hibernate a tipo de datos SQL."
|
||||
|
||||
#: index.docbook:113
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"lastName\" index=\"CustName\"/>\n"
|
||||
"<property name=\"firstName\" index=\"CustName\"/>]]>"
|
||||
msgstr "El atributo <literal>check</literal> te permite especificar una comprobación de restricción."
|
||||
|
||||
#: index.docbook:115
|
||||
msgid "A <literal>foreign-key</literal> attribute may be used to override the name of any generated foreign key constraint."
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"foo\" type=\"integer\">\n"
|
||||
" <column name=\"foo\" check=\"foo > 10\"/>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: index.docbook:120
|
||||
msgid "<![CDATA[<many-to-one name=\"bar\" column=\"barId\" foreign-key=\"FKFooBar\"/>]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Foo\" table=\"foos\" check=\"bar < 100.0\">\n"
|
||||
" ...\n"
|
||||
" <property name=\"bar\" type=\"float\"/>\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: 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 "Resumen"
|
||||
|
||||
#: 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 "Atributo"
|
||||
|
||||
#: 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 "Valores"
|
||||
|
||||
#: index.docbook:135
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"credits\" type=\"integer\" insert=\"false\">\n"
|
||||
" <column name=\"credits\" default=\"10\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr "Interpretación"
|
||||
|
||||
#: index.docbook:137
|
||||
msgid ""
|
||||
"<![CDATA[<version name=\"version\" type=\"integer\" insert=\"false\">\n"
|
||||
" <column name=\"version\" default=\"0\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr "length"
|
||||
|
||||
#: 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 "number"
|
||||
|
||||
#: index.docbook:144
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"balance\" type=\"float\">\n"
|
||||
" <column name=\"balance\" sql-type=\"decimal(13,3)\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr "largo de columna/precisión decimal"
|
||||
|
||||
#: index.docbook:146
|
||||
msgid "The <literal>check</literal> attribute allows you to specify a check constraint."
|
||||
msgstr "not-null"
|
||||
|
||||
#: index.docbook:150
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"foo\" type=\"integer\">\n"
|
||||
" <column name=\"foo\" check=\"foo > 10\"/>\n"
|
||||
"</property>]]>"
|
||||
msgstr "true|false"
|
||||
|
||||
#: index.docbook:152
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Foo\" table=\"foos\" check=\"bar < 100.0\">\n"
|
||||
" ...\n"
|
||||
" <property name=\"bar\" type=\"float\"/>\n"
|
||||
"</class>]]>"
|
||||
msgstr "especifica que la columna debe ser no nulable"
|
||||
|
||||
#: index.docbook:156
|
||||
msgid "Summary"
|
||||
msgstr "unique"
|
||||
|
||||
#: index.docbook:163
|
||||
msgid "Attribute"
|
||||
msgstr "true|false"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "Values"
|
||||
msgstr "especifica que la columna debe tener una restricción de unicidad"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "Interpretation"
|
||||
msgstr "index"
|
||||
|
||||
#: index.docbook:170
|
||||
msgid "length"
|
||||
msgstr "index_name"
|
||||
|
||||
#: index.docbook:171, index.docbook:176, index.docbook:181
|
||||
msgid "number"
|
||||
msgstr "especifica el nombre de un índice (multicolumna)"
|
||||
|
||||
#: index.docbook:172
|
||||
msgid "column length"
|
||||
msgstr "unique-key"
|
||||
|
||||
#: index.docbook:175
|
||||
msgid "precision"
|
||||
msgstr "unique_key_name"
|
||||
|
||||
#: index.docbook:177
|
||||
msgid "column decimal precision"
|
||||
msgstr "foreign-key"
|
||||
|
||||
#: index.docbook:180
|
||||
msgid "scale"
|
||||
msgstr "foreign_key_name"
|
||||
|
||||
#: index.docbook:182
|
||||
msgid "column decimal scale"
|
||||
msgstr "sql-type"
|
||||
|
||||
#: index.docbook:185
|
||||
msgid "not-null"
|
||||
msgstr "column_type"
|
||||
|
||||
#: index.docbook:186, index.docbook:191
|
||||
msgid "true|false"
|
||||
msgstr "sobrescribe el tipo de columna por defecto (sólo atributo del elemento <literal><column></literal>)"
|
||||
|
||||
#: index.docbook:187
|
||||
msgid "specfies that the column should be non-nullable"
|
||||
msgstr "check"
|
||||
|
||||
#: index.docbook:190
|
||||
msgid "unique"
|
||||
msgstr "expresión SQL"
|
||||
|
||||
#: index.docbook:192
|
||||
msgid "specifies that the column should have a unique constraint"
|
||||
msgstr "El elemento <literal><comment></literal> te permite especificar un comentario para el esquema generado."
|
||||
|
||||
#: index.docbook:195
|
||||
msgid "index"
|
||||
msgstr ""
|
||||
"<![CDATA[<class name=\"Customer\" table=\"CurCust\">\n"
|
||||
" <comment>Current customers only</comment>\n"
|
||||
" ...\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:196
|
||||
msgid "index_name"
|
||||
msgstr ""
|
||||
"<![CDATA[<property name=\"balance\">\n"
|
||||
" <column name=\"bal\">\n"
|
||||
" <comment>Balance in USD</comment>\n"
|
||||
" </column>\n"
|
||||
"</property>]]>"
|
||||
|
||||
#: index.docbook:197
|
||||
msgid "specifies the name of a (multi-column) index"
|
||||
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:200
|
||||
msgid "unique-key"
|
||||
msgstr "Ejecutando la herramienta"
|
||||
|
||||
#: index.docbook:201
|
||||
msgid "unique_key_name"
|
||||
msgstr "La herramienta <literal>SchemaExport</literal> escribe un guión DDL a la salida estándar y/o ejecuta las sentencias DDL."
|
||||
|
||||
#: index.docbook:202
|
||||
msgid "specifies the name of a multi-column unique constraint"
|
||||
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:205
|
||||
msgid "foreign-key"
|
||||
msgstr "Opciones de Línea de Comandos de <literal>SchemaExport</literal>"
|
||||
|
||||
#: index.docbook:206
|
||||
msgid "foreign_key_name"
|
||||
msgstr "Opción"
|
||||
|
||||
#: 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 "Descripción"
|
||||
|
||||
#: index.docbook:217
|
||||
msgid "sql-type"
|
||||
msgstr "--quiet"
|
||||
|
||||
#: index.docbook:218
|
||||
msgid "SQL column type"
|
||||
msgstr "no enviar a salida estándar el guión"
|
||||
|
||||
#: index.docbook:219
|
||||
msgid "overrides the default column type (attribute of <literal><column></literal> element only)"
|
||||
msgstr "--drop"
|
||||
|
||||
#: index.docbook:225
|
||||
msgid "default"
|
||||
msgstr "sólo desechar las tablas"
|
||||
|
||||
#: index.docbook:226, index.docbook:233
|
||||
msgid "SQL expression"
|
||||
msgstr "--text"
|
||||
|
||||
#: index.docbook:227
|
||||
msgid "specify a default value for the column"
|
||||
msgstr "no exportar a la base de datos"
|
||||
|
||||
#: index.docbook:232
|
||||
msgid "check"
|
||||
msgstr "--output=my_schema.ddl"
|
||||
|
||||
#: index.docbook:234
|
||||
msgid "create an SQL check constraint on either column or table"
|
||||
msgstr "--config=hibernate.cfg.xml"
|
||||
|
||||
#: index.docbook:242
|
||||
msgid "The <literal><comment></literal> element allows you to specify comments for the generated schema."
|
||||
msgstr "lee la configuración de Hibernate de un fichero XML"
|
||||
|
||||
#: index.docbook:247
|
||||
msgid ""
|
||||
"<![CDATA[<class name=\"Customer\" table=\"CurCust\">\n"
|
||||
" <comment>Current customers only</comment>\n"
|
||||
" ...\n"
|
||||
"</class>]]>"
|
||||
msgstr "--properties=hibernate.properties"
|
||||
|
||||
#: index.docbook:249
|
||||
msgid ""
|
||||
"<![CDATA[<property name=\"balance\">\n"
|
||||
" <column name=\"bal\">\n"
|
||||
" <comment>Balance in USD</comment>\n"
|
||||
" </column>\n"
|
||||
"</property>]]>"
|
||||
msgstr "lee las propiedades de base de datos de un fichero"
|
||||
|
||||
#: 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 "--format"
|
||||
|
||||
#: index.docbook:260
|
||||
msgid "Running the tool"
|
||||
msgstr "formatea agradablemente el SQL generado en el guión"
|
||||
|
||||
#: index.docbook:262
|
||||
msgid "The <literal>SchemaExport</literal> tool writes a DDL script to standard out and/or executes the DDL statements."
|
||||
msgstr "--delimiter=x"
|
||||
|
||||
#: 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 "establece un delimitador de fin de línea para el guión"
|
||||
|
||||
#: index.docbook:273
|
||||
msgid "<literal>SchemaExport</literal> Command Line Options"
|
||||
msgstr "Puedes incluso encajar <literal>SchemaExport</literal> en tu aplicación:"
|
||||
|
||||
#: index.docbook:279, index.docbook:429, index.docbook:498
|
||||
msgid "Option"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaExport(cfg).create(false, true);]]>"
|
||||
|
||||
#: index.docbook:280, index.docbook:367, index.docbook:430, index.docbook:499
|
||||
msgid "Description"
|
||||
msgstr "Propiedades"
|
||||
|
||||
#: index.docbook:285, index.docbook:435
|
||||
msgid "--quiet"
|
||||
msgstr "Las propiedades de base de datos pueden especificarse"
|
||||
|
||||
#: index.docbook:286, index.docbook:436
|
||||
msgid "don't output the script to stdout"
|
||||
msgstr "como propiedades de sistema con <literal>-D</literal><emphasis><property></emphasis>"
|
||||
|
||||
#: index.docbook:289
|
||||
msgid "--drop"
|
||||
msgstr "en <literal>hibernate.properties</literal>"
|
||||
|
||||
#: index.docbook:290
|
||||
msgid "only drop the tables"
|
||||
msgstr "en un fichero de propiedades mencionado con <literal>--properties</literal>"
|
||||
|
||||
#: index.docbook:293
|
||||
msgid "--create"
|
||||
msgstr "Las propiedades necesarias son:"
|
||||
|
||||
#: index.docbook:294
|
||||
msgid "only create the tables"
|
||||
msgstr "Propiedades de Conexión de SchemaExport"
|
||||
|
||||
#: index.docbook:297, index.docbook:439
|
||||
msgid "--text"
|
||||
msgstr "Nombre de Propiedad"
|
||||
|
||||
#: index.docbook:298
|
||||
msgid "don't export to the database"
|
||||
msgstr "Descripción"
|
||||
|
||||
#: index.docbook:301
|
||||
msgid "--output=my_schema.ddl"
|
||||
msgstr "hibernate.connection.driver_class"
|
||||
|
||||
#: index.docbook:302
|
||||
msgid "output the ddl script to a file"
|
||||
msgstr "clase del driver jdbc"
|
||||
|
||||
#: index.docbook:305, index.docbook:443, index.docbook:504
|
||||
msgid "--naming=eg.MyNamingStrategy"
|
||||
msgstr "hibernate.connection.url"
|
||||
|
||||
#: index.docbook:306, index.docbook:444, index.docbook:505
|
||||
msgid "select a <literal>NamingStrategy</literal>"
|
||||
msgstr "url de jdbc"
|
||||
|
||||
#: index.docbook:309, index.docbook:451, index.docbook:512
|
||||
msgid "--config=hibernate.cfg.xml"
|
||||
msgstr "hibernate.connection.username"
|
||||
|
||||
#: index.docbook:310
|
||||
msgid "read Hibernate configuration from an XML file"
|
||||
msgstr "usuario de base de datos"
|
||||
|
||||
#: index.docbook:313, index.docbook:447, index.docbook:508
|
||||
msgid "--properties=hibernate.properties"
|
||||
msgstr "hibernate.connection.password"
|
||||
|
||||
#: index.docbook:314, index.docbook:448, index.docbook:509
|
||||
msgid "read database properties from a file"
|
||||
msgstr "contraseña de usuario"
|
||||
|
||||
#: index.docbook:317
|
||||
msgid "--format"
|
||||
msgstr "hibernate.dialect"
|
||||
|
||||
#: index.docbook:318
|
||||
msgid "format the generated SQL nicely in the script"
|
||||
msgstr "dialecto"
|
||||
|
||||
#: index.docbook:321
|
||||
msgid "--delimiter=;"
|
||||
msgstr "Usando Ant"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "set an end of line delimiter for the script"
|
||||
msgstr "Puedes llamar a <literal>SchemaExport</literal> desde tu guión de construcción de Ant:"
|
||||
|
||||
#: index.docbook:328
|
||||
msgid "You may even embed <literal>SchemaExport</literal> in your application:"
|
||||
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:332
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaExport(cfg).create(false, true);]]>"
|
||||
msgstr "Actualizaciones incrementales de esquema"
|
||||
|
||||
#: index.docbook:337
|
||||
msgid "Properties"
|
||||
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:339
|
||||
msgid "Database properties may be specified"
|
||||
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:345
|
||||
msgid "as system properties with <literal>-D</literal><emphasis><property></emphasis>"
|
||||
msgstr "Opciones de Línea de Comandos de <literal>SchemaUpdate</literal>"
|
||||
|
||||
#: index.docbook:348
|
||||
msgid "in <literal>hibernate.properties</literal>"
|
||||
msgstr "Opción"
|
||||
|
||||
#: index.docbook:351
|
||||
msgid "in a named properties file with <literal>--properties</literal>"
|
||||
msgstr "Descripción"
|
||||
|
||||
#: index.docbook:355
|
||||
msgid "The needed properties are:"
|
||||
msgstr "--quiet"
|
||||
|
||||
#: index.docbook:360
|
||||
msgid "SchemaExport Connection Properties"
|
||||
msgstr "no enviar a salida estándar el guión"
|
||||
|
||||
#: index.docbook:366
|
||||
msgid "Property Name"
|
||||
msgstr "--properties=hibernate.properties"
|
||||
|
||||
#: index.docbook:372
|
||||
msgid "hibernate.connection.driver_class"
|
||||
msgstr "Puedes encajar <literal>SchemaUpdate</literal> en tu aplicación:"
|
||||
|
||||
#: index.docbook:373
|
||||
msgid "jdbc driver class"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaUpdate(cfg).execute(false);]]>"
|
||||
|
||||
#: index.docbook:376
|
||||
msgid "hibernate.connection.url"
|
||||
msgstr "Usando Ant para actualizaciones incrementales de esquema"
|
||||
|
||||
#: index.docbook:377
|
||||
msgid "jdbc url"
|
||||
msgstr "Puedes llamar a <literal>SchemaUpdate</literal> desde el guión de Ant:"
|
||||
|
||||
#: index.docbook:380
|
||||
msgid "hibernate.connection.username"
|
||||
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:381
|
||||
msgid "database user"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:384
|
||||
msgid "hibernate.connection.password"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:385
|
||||
msgid "user password"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:388
|
||||
msgid "hibernate.dialect"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:389
|
||||
msgid "dialect"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:398
|
||||
msgid "Using Ant"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:400
|
||||
msgid "You can call <literal>SchemaExport</literal> from your Ant build script:"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:409
|
||||
msgid "Incremental schema updates"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:423
|
||||
msgid "<literal>SchemaUpdate</literal> Command Line Options"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:440
|
||||
msgid "don't export the script to the database"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:452, index.docbook:513
|
||||
msgid "specify a <literal>.cfg.xml</literal> file"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:458
|
||||
msgid "You may embed <literal>SchemaUpdate</literal> in your application:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:462
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaUpdate(cfg).execute(false);]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:467
|
||||
msgid "Using Ant for incremental schema updates"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:469
|
||||
msgid "You can call <literal>SchemaUpdate</literal> from the Ant script:"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:478
|
||||
msgid "Schema validation"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:492
|
||||
msgid "<literal>SchemaValidator</literal> Command Line Options"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:519
|
||||
msgid "You may embed <literal>SchemaValidator</literal> in your application:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:523
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaValidator(cfg).validate();]]>"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:528
|
||||
msgid "Using Ant for schema validation"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:530
|
||||
msgid "You can call <literal>SchemaValidator</literal> from the Ant script:"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,738 @@
|
|||
#, 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 "Transactions And Concurrency"
|
||||
msgstr "Transacciones y Concurrencia"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "The most important point about Hibernate and concurrency control is that it is very easy to understand. Hibernate directly uses JDBC connections and JTA resources without adding any additional locking behavior. We highly recommend you spend some time with the JDBC, ANSI, and transaction isolation specification of your database management system."
|
||||
msgstr "El punto más importante sobre Hibernate y el control de concurrencia es que muy fácil de comprender. Hibernate usa directamente conexiones JDBC y recursos JTA sin agregar ningún comportamiento de bloqueo adicional. Recomendamos altamente que gastes algo de tiempo con la especificación de JDBC, ANSI, y el aislamiento de transacciones de tu sistema de gestión de base de datos. Hibernate sólo añade versionado automático pero no bloquea objetos en memoria ni cambia el nivel de aislamiento de tus transacciones de base de datos. Básicamente, usa Hibernate como usarías JDBC directo (o JTA/CMT) con tus recursos de base de datos."
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Hibernate does not lock objects in memory. Your application can expect the behavior as defined by the isolation level of your database transactions. Note that thanks to the <literal>Session</literal>, which is also a transaction-scoped cache, Hibernate provides repeatable reads for lookup by identifier and entity queries (not reporting queries that return scalar values)."
|
||||
msgstr "Sin embargo, además del versionado automático, Hibernate ofrece una API (menor) para bloqueo pesimista de filas, usando la sintáxis <literal>SELECT FOR UPDATE</literal>. Esta API se discute más adelante en este capítulo:"
|
||||
|
||||
#: index.docbook:22
|
||||
msgid "In addition to versioning for automatic optimistic concurrency control, Hibernate also offers a (minor) API for pessimistic locking of rows, using the <literal>SELECT FOR UPDATE</literal> syntax. Optimistic concurrency control and this API are discussed later in this chapter."
|
||||
msgstr "Comenzamos la discusión del control de concurrencia en Hibernate con la granularidad de <literal>Configuration</literal>, <literal>SessionFactory</literal>, y <literal>Session</literal>, así como la base de datos y las transacciones de aplicación largas."
|
||||
|
||||
#: index.docbook:29
|
||||
msgid "We start the discussion of concurrency control in Hibernate with the granularity of <literal>Configuration</literal>, <literal>SessionFactory</literal>, and <literal>Session</literal>, as well as database transactions and long conversations."
|
||||
msgstr "Ámbitos de sesión y de transacción"
|
||||
|
||||
#: index.docbook:36
|
||||
msgid "Session and transaction scopes"
|
||||
msgstr "Una <literal>SessionFactory</literal> es un objeto seguro entre hebras caro-de-crear pensado para ser compartido por todas las hebras de la aplicación. Es creado una sola vez, usualmente en el arranque de la aplicación, a partir de una instancia de <literal>Configuration</literal>."
|
||||
|
||||
#: index.docbook:38
|
||||
msgid "A <literal>SessionFactory</literal> is an expensive-to-create, threadsafe object intended to be shared by all application threads. It is created once, usually on application startup, from a <literal>Configuration</literal> instance."
|
||||
msgstr "Una <literal>Session</literal> es un objeto barato, inseguro entre hebras que debe ser usado una sola vez, para un solo proceso de negocio, una sola unidad de trabajo, y luego descartado. Una <literal>Session</literal> no obtendrá una <literal>Connection</literal> JDBC (o un <literal>Datasource</literal>) a menos que sea necesario, de modo que puedas abrir y cerrar seguramente una <literal>Session</literal> incluso si no estás seguro que se necesitará acceso a los datos para servir una petición en particular. (Esto se vuelve importante en cuanto estés implementando alguno de los siguientes patrones usando intercepción de peticiones)."
|
||||
|
||||
#: index.docbook:44
|
||||
msgid "A <literal>Session</literal> is an inexpensive, non-threadsafe object that should be used once, for a single request, a conversation, single unit of work, and then discarded. A <literal>Session</literal> will not obtain a JDBC <literal>Connection</literal> (or a <literal>Datasource</literal>) unless it is needed, hence consume no resources until used."
|
||||
msgstr "Para completar este cuadro tienes que pensar también en las transacciones de base de datos. Una transacción de base de datos tiene que ser tan corta como sea posible, para reducir la contención de bloqueos en la base de datos. Las transacciones largas de base de datos prevendrán a tu aplicación de escalar a una carga altamente concurrente."
|
||||
|
||||
#: index.docbook:52
|
||||
msgid "To complete this picture you also have to think about database transactions. A database transaction has to be as short as possible, to reduce lock contention in the database. Long database transactions will prevent your application from scaling to highly concurrent load. Hence, it is almost never good design to hold a database transaction open during user think time, until the unit of work is complete."
|
||||
msgstr "¿Qué es el ámbito de una unidad de trabajo? ¿Puede una sola <literal>Session</literal> de Hibernate extenderse a través de varias transacciones de base de datos o es ésta una relación uno-a-uno de ámbitos? ¿Cuándo debes abrir y cerrar una <literal>Session</literal> y cómo demarcas los límites de la transacción de base de datos?"
|
||||
|
||||
#: index.docbook:61
|
||||
msgid "What is the scope of a unit of work? Can a single Hibernate <literal>Session</literal> span several database transactions or is this a one-to-one relationship of scopes? When should you open and close a <literal>Session</literal> and how do you demarcate the database transaction boundaries?"
|
||||
msgstr "Unidad de trabajo"
|
||||
|
||||
#: index.docbook:69
|
||||
msgid "Unit of work"
|
||||
msgstr "Primero, no uses el antipatrón <emphasis>sesión-por-operación</emphasis>, esto es, ¡no abras y cierres una <literal>Session</literal> para cada simple llamada a la base de datos en una sola hebra! Por supuesto, lo mismo es verdad para transacciones de base de datos. Las llamadas a base de datos en una aplicación se hacen usando una secuencia prevista, que están agrupadas dentro de unidades de trabajo atómicas. (Nota que esto también significa que el auto-commit después de cada una de las sentencias SQL es inútil en una aplicación, este modo está pensado para trabajo ad-hoc de consola SQL. Hibernate deshabilita, o espera que el servidor de aplicaciones lo haga, el modo auto-commit inmediatamente.)"
|
||||
|
||||
#: index.docbook:71
|
||||
msgid "First, don't use the <emphasis>session-per-operation</emphasis> antipattern, that is, don't open and close a <literal>Session</literal> for every simple database call in a single thread! Of course, the same is true for database transactions. Database calls in an application are made using a planned sequence, they are grouped into atomic units of work. (Note that this also means that auto-commit after every single SQL statement is useless in an application, this mode is intended for ad-hoc SQL console work. Hibernate disables, or expects the application server to do so, auto-commit mode immediately.) Database transactions are never optional, all communication with a database has to occur inside a transaction, no matter if you read or write data. As explained, auto-commit behavior for reading data should be avoided, as many small transactions are unlikely to perform better than one clearly defined unit of work. The latter is also much more maintainable and extensible."
|
||||
msgstr "El patrón más común en una aplicación mutiusuario cliente/servidor es <emphasis>sesión-por-petición</emphasis>. En este modelo, una petición del cliente es enviada al servidor (en donde se ejecuta la capa de persistencia de Hibernate), se abre una nueva <literal>Session</literal> de Hibernate, y todas las operaciones de base de datos se ejecutan en esta unidad de trabajo. Una vez completado el trabajo (y se ha preparado la respuesta para el cliente) la sesión es limpiada y cerrada. Podrías usar una sola transacción de base de datos para servir a petición del cliente, comenzándola y comprometiéndola cuando abres y cierras la <literal>Session</literal>. La relación entre las dos es uno-a-uno y este modelo es a la medida perfecta de muchas aplicaciones."
|
||||
|
||||
#: index.docbook:87
|
||||
msgid "The most common pattern in a multi-user client/server application is <emphasis>session-per-request</emphasis>. In this model, a request from the client is send to the server (where the Hibernate persistence layer runs), a new Hibernate <literal>Session</literal> is opened, and all database operations are executed in this unit of work. Once the work has been completed (and the response for the client has been prepared), the session is flushed and closed. You would also use a single database transaction to serve the clients request, starting and committing it when you open and close the <literal>Session</literal>. The relationship between the two is one-to-one and this model is a perfect fit for many applications."
|
||||
msgstr "El desafío yace en la implementación: no sólo tienen que comenzarse y terminarse correctamente la <literal>Session</literal> y la transacción, sino que además tienen que estar accesibles para las operaciones de acceso a datos. La demarcación de una unidad de trabajo se implementa idealmente usando un interceptor que se ejecuta cuando una petición llama al servidor y anter que la respuesta sea enviada (es decir, un <literal>ServletFilter</literal>). Recomendamos ligar la <literal>Session</literal> a la hebra que atiende la petición, usando una variable <literal>ThreadLocal</literal>. Esto permite un fácil acceso (como acceder a una variable static) en tódo el código que se ejecuta en esta hebra. Dependiendo del mecanismo de demarcación de transacciones de base de datos que elijas, podrías mantener también el contexto de la transacción en una variable <literal>ThreadLocal</literal>. Los patrones de implementación para esto son conocidos como <emphasis>Sesión Local de Hebra (ThreadLocal Session)</emphasis> y <emphasis>Sesión Abierta en Vista (Open Session in View)</emphasis>. Puedes extender fácilmente la clase de ayuda <literal>HibernateUtil</literal> mostrada anteriormente para encontrar una forma de implementar un interceptor e instalarlo en tu entorno. Ver el sitio web de Hibernate para consejos y ejemplos."
|
||||
|
||||
#: index.docbook:99
|
||||
msgid "The challenge lies in the implementation. Hibernate provides built-in management of the \"current session\" to simplify this pattern. All you have to do is start a transaction when a server request has to be processed, and end the transaction before the response is send to the client. You can do this in any way you like, common solutions are <literal>ServletFilter</literal>, AOP interceptor with a pointcut on the service methods, or a proxy/interception container. An EJB container is a standardized way to implement cross-cutting aspects such as transaction demarcation on EJB session beans, declaratively with CMT. If you decide to use programmatic transaction demarcation, prefer the Hibernate <literal>Transaction</literal> API shown later in this chapter, for ease of use and code portability."
|
||||
msgstr "Transacciones de aplicación"
|
||||
|
||||
#: index.docbook:112
|
||||
msgid "Your application code can access a \"current session\" to process the request by simply calling <literal>sessionFactory.getCurrentSession()</literal> anywhere and as often as needed. You will always get a <literal>Session</literal> scoped to the current database transaction. This has to be configured for either resource-local or JTA environments, see <xref linkend=\"architecture-current-session\"/>."
|
||||
msgstr "El patrón sesión-por-petición no es el único concepto útil que puedes usar para diseñar unidades de trabajo. Muchos procesos de negocio requiere una serie completa de interacciones con el usuario intercaladas con accesos a base de datos. En aplicaciones web y de empresa no es aceptable que una transacción de base de datos se extienda a través de la interacción de un usuario. Considera el siguiente ejemplo:"
|
||||
|
||||
#: index.docbook:120
|
||||
msgid "Sometimes it is convenient to extend the scope of a <literal>Session</literal> and database transaction until the \"view has been rendered\". This is especially useful in servlet applications that utilize a separate rendering phase after the request has been processed. Extending the database transaction until view rendering is complete is easy to do if you implement your own interceptor. However, it is not easily doable if you rely on EJBs with container-managed transactions, as a transaction will be completed when an EJB method returns, before rendering of any view can start. See the Hibernate website and forum for tips and examples around this <emphasis>Open Session in View</emphasis> pattern."
|
||||
msgstr "Se abre la primera pantalla de un diálogo, los datos vistos por el usuario han sido cargados en una <literal>Session</literal> y transacción de base de datos particular. El usuario es libre de modificar los objetos."
|
||||
|
||||
#: index.docbook:135
|
||||
msgid "Long conversations"
|
||||
msgstr "El usuario hace click en \"Salvar\" después de 5 minutos y espera que sus modificaciones sean hechas persistentes. También espera que él sea la única persona editando esta información y que no puede ocurrir ninguna modificación en conflicto."
|
||||
|
||||
#: index.docbook:137
|
||||
msgid "The session-per-request pattern is not the only useful concept you can use to design units of work. Many business processes require a whole series of interactions with the user interleaved with database accesses. In web and enterprise applications it is not acceptable for a database transaction to span a user interaction. Consider the following example:"
|
||||
msgstr "Llamamos a esto unidad de trabajo, desde el punto de vista del usuario, una larga <emphasis>transacción de aplicación</emphasis> ejecutándose. Hay muchas formas en que puedes implementar esto en tu aplicación."
|
||||
|
||||
#: index.docbook:147
|
||||
msgid "The first screen of a dialog opens, the data seen by the user has been loaded in a particular <literal>Session</literal> and database transaction. The user is free to modify the objects."
|
||||
msgstr "Una primera implementación ingenua podría mantener abierta la <literal>Session</literal> y la transacción de base de datos durante el tiempo de pensar del usuario, con bloqueos tomados en la base de datos para prevenir la modificación concurrente, y para garantizar aislamiento y atomicidad. Esto es, por supuesto, un antipatrón, ya que la contención de bloqueo no permitiría a la aplicación escalar con el número de usuarios concurrentes."
|
||||
|
||||
#: index.docbook:154
|
||||
msgid "The user clicks \"Save\" after 5 minutes and expects his modifications to be made persistent; he also expects that he was the only person editing this information and that no conflicting modification can occur."
|
||||
msgstr "Claramente, tenemos que usar muchas transacciones de base de datos para implementar la transacción de aplicación. En este caso, mantener el aislamiento de los procesos de negocio se vuelve una responsabilidad parcial de la capa de aplicación. Una sola transacción de aplicación usualmente abarca varias transacciones de base de datos. Será atómica si sólo una de estas transacciones de base de datos (la última) almacena los datos actualizados, todas las otras simplemente leen datos (por ejemplo, en un diálogo estilo-asistente abarcando muchos ciclos petición/respuesta). Esto es más fácil de implementar de lo que suena, especialmente si usas las funcionalidades de Hibernate:"
|
||||
|
||||
#: index.docbook:162
|
||||
msgid "We call this unit of work, from the point of view of the user, a long running <emphasis>conversation</emphasis> (or <emphasis>application transaction</emphasis>). There are many ways how you can implement this in your application."
|
||||
msgstr "<emphasis>Versionado Automático</emphasis> - Hibernate puede llevar un control automático de concurrencia optimista por ti, puede detectar automáticamente si una modificación concurrente ha ocurrido durante el tiempo de pensar del usuario."
|
||||
|
||||
#: index.docbook:168
|
||||
msgid "A first naive implementation might keep the <literal>Session</literal> and database transaction open during user think time, with locks held in the database to prevent concurrent modification, and to guarantee isolation and atomicity. This is of course an anti-pattern, since lock contention would not allow the application to scale with the number of concurrent users."
|
||||
msgstr "<emphasis>Objetos Separados</emphasis> - Si decides usar el ya discutido patrón de <emphasis>sesión-por-petición</emphasis>, todas las instancias cargadas estarán en estado separado durante el tiempo de pensar del usuario. Hibernate te permite volver a unir los objetos y hacer persistentes las modificaciones. El patrón se llama <emphasis>sesión-por-petición-con-objetos-separados</emphasis>. Se usa versionado automático para aislar las modificaciones concurrentes."
|
||||
|
||||
#: index.docbook:176
|
||||
msgid "Clearly, we have to use several database transactions to implement the converastion. In this case, maintaining isolation of business processes becomes the partial responsibility of the application tier. A single conversation usually spans several database transactions. It will be atomic if only one of these database transactions (the last one) stores the updated data, all others simply read data (e.g. in a wizard-style dialog spanning several request/response cycles). This is easier to implement than it might sound, especially if you use Hibernate's features:"
|
||||
msgstr "<emphasis>Sesión Larga</emphasis> - La <literal>Session</literal> de Hibernate puede ser desconectada de la conexión JDBC subyacente después que se haya sido comprometida la transacción de base de datos, y reconectada cuando ocurra una nueva petición del cliente. Este patrón es conocido como <emphasis>sesión-por-transacción-de-aplicación</emphasis> y hace la re-unión innecesaria. Para aislar las modificaciones concurrentes se usa el versionado automático."
|
||||
|
||||
#: index.docbook:189
|
||||
msgid "<emphasis>Automatic Versioning</emphasis> - Hibernate can do automatic optimistic concurrency control for you, it can automatically detect if a concurrent modification occured during user think time. Usually we only check at the end of the conversation."
|
||||
msgstr "Tanto <emphasis>sesión-por-petición-con-objetos-separados</emphasis> como <emphasis>sesión-por-transacción-de-aplicación</emphasis>, ambas tienen ventajas y desventajas, las discutimos más adelante en este capítulo en el contexto del control optimista de concurrencia."
|
||||
|
||||
#: index.docbook:197
|
||||
msgid "<emphasis>Detached Objects</emphasis> - If you decide to use the already discussed <emphasis>session-per-request</emphasis> pattern, all loaded instances will be in detached state during user think time. Hibernate allows you to reattach the objects and persist the modifications, the pattern is called <emphasis>session-per-request-with-detached-objects</emphasis>. Automatic versioning is used to isolate concurrent modifications."
|
||||
msgstr "Considerando la identidad del objeto"
|
||||
|
||||
#: index.docbook:207
|
||||
msgid "<emphasis>Extended (or Long) Session</emphasis> - The Hibernate <literal>Session</literal> may be disconnected from the underlying JDBC connection after the database transaction has been committed, and reconnected when a new client request occurs. This pattern is known as <emphasis>session-per-conversation</emphasis> and makes even reattachment unnecessary. Automatic versioning is used to isolate concurrent modifications and the <literal>Session</literal> is usually not allowed to be flushed automatically, but explicitely."
|
||||
msgstr "Una aplicación puede acceder concurrentemente a el mismo estado persistente en dos <literal>Session</literal>s diferentes. Sin embargo, una instancia de una clase persistente nunca se comparte entre dos instancias de <literal>Session</literal>. Por lo tanto existen dos nociones diferentes de identidad:"
|
||||
|
||||
#: index.docbook:220
|
||||
msgid "Both <emphasis>session-per-request-with-detached-objects</emphasis> and <emphasis>session-per-conversation</emphasis> have advantages and disadvantages, we discuss them later in this chapter in the context of optimistic concurrency control."
|
||||
msgstr "Identidad de Base de Datos"
|
||||
|
||||
#: index.docbook:229
|
||||
msgid "Considering object identity"
|
||||
msgstr "foo.getId().equals( bar.getId() )"
|
||||
|
||||
#: index.docbook:231
|
||||
msgid "An application may concurrently access the same persistent state in two different <literal>Session</literal>s. However, an instance of a persistent class is never shared between two <literal>Session</literal> instances. Hence there are two different notions of identity:"
|
||||
msgstr "Identidad JVM"
|
||||
|
||||
#: index.docbook:240
|
||||
msgid "Database Identity"
|
||||
msgstr "foo==bar"
|
||||
|
||||
#: index.docbook:243
|
||||
msgid "foo.getId().equals( bar.getId() )"
|
||||
msgstr "Entonces para objetos unidos a una <literal>Session</literal> <emphasis>en particular</emphasis> (es decir en el ámbito de una <literal>Session</literal>) las dos nociones son equivalentes, y la identidad JVM para la identidad de base de datos está garantizada por Hibernate. Sin embargo, mientras la aplicación acceda concurrentemente al \"mismo\" (identidad persistente) objeto de negocio en dos sesiones diferentes, las dos instancias serán realmente \"diferentes\" (identidad JVM). Los conflictos se resuelven (con versionado automático) en tiempo de limpieza (flush) usando un enfoque optimista."
|
||||
|
||||
#: index.docbook:248
|
||||
msgid "JVM Identity"
|
||||
msgstr "Este enfoque deja que Hibernate y la base de datos se preocupen sobre la concurrencia. Además provee la mejor escalabilidad, ya que garantizando la identidad un unidades de trabajo monohebra no se necesitan bloqueos caros u otros medios de sincronización. La aplicación nunca necesita sincronizar sobre ningún objeto de negocio, siempre que se apegue a una sola hebra por <literal>Session</literal>. Dentro de una <literal>Session</literal> la aplicación puede usar con seguridad <literal>==</literal> para comparar objetos."
|
||||
|
||||
#: index.docbook:251
|
||||
msgid "foo==bar"
|
||||
msgstr "Sin embargo, una aplicación que usa <literal>==</literal> fuera de una <literal>Session</literal>, podría ver resultados inesperados. Esto podría ocurrir incluso en sitios algo inesperados, por ejemplo, si pones dos instancias separadas dentro del mismo <literal>Set</literal>. Ambas podrían tener la misma identidad de base de datos (es decir, representar la misma fila), pero la identidad JVM, por definición, no está garantizada para las instancias en estado separado. El desarrollador tiene que sobrescribir los métodos <literal>equals()</literal> y <literal>hashCode()</literal> en las clases persistentes e implementar su propia noción de igualdad de objetos. Hay una advertencia: Nunca uses el identificador de base de datos para implementar la igualdad, usa una clave de negocio, una combinación de atributos únicos, usualmente inmutables. El identificador de base de datos cambiará si un objeto transitorio es hecho persistente. Si la instancia transitoria (usualmente junta a instancias separadas) es mantenida en un <literal>Set</literal>, cambiar el código hash rompe el contrato del <literal>Set</literal>. Los atributos para las claves de negocio no tienen que ser tan estables como las claves primarias de base de datos, sólo tienes que garantizar estabilidad en tanto los objetos estén en el mismo <literal>Set</literal>. Mira el sitio web de Hibernate para una discusión más cuidadosa de este tema. Nota también que éste no es un tema de Hibernate, sino simplemente cómo la identidad y la igualdad de los objetos Java tiene que ser implementada."
|
||||
|
||||
#: index.docbook:257
|
||||
msgid "Then for objects attached to a <emphasis>particular</emphasis> <literal>Session</literal> (i.e. in the scope of a <literal>Session</literal>) the two notions are equivalent, and JVM identity for database identity is guaranteed by Hibernate. However, while the application might concurrently access the \"same\" (persistent identity) business object in two different sessions, the two instances will actually be \"different\" (JVM identity). Conflicts are resolved using (automatic versioning) at flush/commit time, using an optimistic approach."
|
||||
msgstr "Temas comunes"
|
||||
|
||||
#: index.docbook:266
|
||||
msgid "This approach leaves Hibernate and the database to worry about concurrency; it also provides the best scalability, since guaranteeing identity in single-threaded units of work only doesn't need expensive locking or other means of synchronization. The application never needs to synchronize on any business object, as long as it sticks to a single thread per <literal>Session</literal>. Within a <literal>Session</literal> the application may safely use <literal>==</literal> to compare objects."
|
||||
msgstr "Nunca uses los antipatrones <emphasis>sesión-por-sesión-de-usuario</emphasis> o <emphasis>sesión-por-aplicación</emphasis> (por supuesto, hay raras excepciones a esta regla). Nota que algunis de los siguientes temas podrían también aparecer con los patrones recomendados. Asegúrate que entiendes las implicaciones antes de tomar una decisión de diseño:"
|
||||
|
||||
#: index.docbook:275
|
||||
msgid "However, an application that uses <literal>==</literal> outside of a <literal>Session</literal>, might see unexpected results. This might occur even in some unexpected places, for example, if you put two detached instances into the same <literal>Set</literal>. Both might have the same database identity (i.e. they represent the same row), but JVM identity is by definition not guaranteed for instances in detached state. The developer has to override the <literal>equals()</literal> and <literal>hashCode()</literal> methods in persistent classes and implement his own notion of object equality. There is one caveat: Never use the database identifier to implement equality, use a business key, a combination of unique, usually immutable, attributes. The database identifier will change if a transient object is made persistent. If the transient instance (usually together with detached instances) is held in a <literal>Set</literal>, changing the hashcode breaks the contract of the <literal>Set</literal>. Attributes for business keys don't have to be as stable as database primary keys, you only have to guarantee stability as long as the objects are in the same <literal>Set</literal>. See the Hibernate website for a more thorough discussion of this issue. Also note that this is not a Hibernate issue, but simply how Java object identity and equality has to be implemented."
|
||||
msgstr "Una <literal>Session</literal> no es segura entre hebras. Las cosas que se suponen que funcionan concurrentemente, como peticiones HTTP, beans de sesión, o workers de Swing, provocarán condiciones de competencia si una instancia de <literal>Session</literal> fuese compartida. Si guardas tu <literal>Session</literal> de Hibernate en tu <literal>HttpSession</literal> (discutido más adelante), debes considerar sincronizar el acceso a tu sesión HTTP. De otro modo, un usuario que hace click lo suficientemente rápido puede llegar a usar la misma <literal>Session</literal> en dos hebras ejecutándose concurrentemente."
|
||||
|
||||
#: index.docbook:296
|
||||
msgid "Common issues"
|
||||
msgstr "Una excepción lanzada por Hibernate significa que tienes que deshacer (rollback) tu transacción de base de datos y cerrar la <literal>Session</literal> inmediatamente (discutido en más detalle luego). Si tu <literal>Session</literal> está ligada a la aplicación, tienes que parar la aplicación. Deshacer (rollback) la transacción de base de datos no pone a tus objetos de vuelta al estado en que estaban al comienzo de la transacción. Esto significa que el estado de la base de datos y los objetos de negocio quedan fuera de sincronía. Usualmente esto no es un problema, pues las excepciones no son recuperables y tienes que volver a comenzar después del rollback de todos modos."
|
||||
|
||||
#: index.docbook:298
|
||||
msgid "Never use the anti-patterns <emphasis>session-per-user-session</emphasis> or <emphasis>session-per-application</emphasis> (of course, there are rare exceptions to this rule). Note that some of the following issues might also appear with the recommended patterns, make sure you understand the implications before making a design decision:"
|
||||
msgstr "La <literal>Session</literal> pone en caché todo objeto que esté en estado persistente (vigilado y chequeado por estado sucio por Hibernate). Esto significa que crece sin fin hasta que obtienes una OutOfMemoryException, si la mantienes abierta por un largo tiempo o simplemente cargas demasiados datos. Una solución para esto es llamar a <literal>clear()</literal> y <literal>evict()</literal> para gestionar el caché de la <literal>Session</literal>, pero probalemente debas considerar un procedimiento almacenado si necesitas operaciones de datos masivas. Se muestran algunas soluciones en <xref linkend=\"batch\"/>. Mantener una <literal>Session</literal> abierta por la duración de una sesión de usuario significa también una alta probabilidad de datos añejos."
|
||||
|
||||
#: index.docbook:307
|
||||
msgid "A <literal>Session</literal> is not thread-safe. Things which are supposed to work concurrently, like HTTP requests, session beans, or Swing workers, will cause race conditions if a <literal>Session</literal> instance would be shared. If you keep your Hibernate <literal>Session</literal> in your <literal>HttpSession</literal> (discussed later), you should consider synchronizing access to your Http session. Otherwise, a user that clicks reload fast enough may use the same <literal>Session</literal> in two concurrently running threads."
|
||||
msgstr "Demarcación de la transacción de base de datos"
|
||||
|
||||
#: index.docbook:318
|
||||
msgid "An exception thrown by Hibernate means you have to rollback your database transaction and close the <literal>Session</literal> immediately (discussed later in more detail). If your <literal>Session</literal> is bound to the application, you have to stop the application. Rolling back the database transaction doesn't put your business objects back into the state they were at the start of the transaction. This means the database state and the business objects do get out of sync. Usually this is not a problem, because exceptions are not recoverable and you have to start over after rollback anyway."
|
||||
msgstr "Los límites de las transacciones de base de datos (o sistema) son siempre necesarios. Ninguna comunicación con la base de datos puede darse fuera de una transacción de base de datos (esto parece confundir muchos desarrolladores acostumbrados al modo auto-commit). Siempre usa límites de transacción claros, incluso para las operaciones de sólo lectura. Dependiendo del nivel de aislamiento y las capacidades de base de datos, esto podría o no ser requerido, pero no hay un merma si siempre demarcas explícitamente las transacciones."
|
||||
|
||||
#: index.docbook:330
|
||||
msgid "The <literal>Session</literal> caches every object that is in persistent state (watched and checked for dirty state by Hibernate). This means it grows endlessly until you get an OutOfMemoryException, if you keep it open for a long time or simply load too much data. One solution for this is to call <literal>clear()</literal> and <literal>evict()</literal> to manage the <literal>Session</literal> cache, but you most likely should consider a Stored Procedure if you need mass data operations. Some solutions are shown in <xref linkend=\"batch\"/>. Keeping a <literal>Session</literal> open for the duration of a user session also means a high probability of stale data."
|
||||
msgstr "Una aplicación Hibernate puede ejecutarse en entornos no manejados (es decir, como independiente, Web simple, o aplicaciones Swing) y entornos manejados J2EE. En un entorno no manejado, Hibernate es usualmente responsable de su propio pool de conexiones de base de datos. El desarrollador de aplicaciones tiene que establecer manualmente los límites de transacción, en otras palabras, hacer begin, commit, o rollback las transacciones de base de datos por sí mismo. Un entorno manejado usualmente provee transacciones gestionadas por contenedor, con el ensamble de transacción definido declarativamente en descriptores de despliegue de beans de sesión EJB, por ejemplo. La demarcación programática de transacciones no es más necesario, incluso limpiar (flush) la <literal>Session</literal> es hecho automáticamente."
|
||||
|
||||
#: index.docbook:348
|
||||
msgid "Database transaction demarcation"
|
||||
msgstr "Sin embargo, frecuentemente es deseable mantener portable tu capa de persistencia. Hibernate ofrece una API de envoltura llamada <literal>Transaction</literal> que se traduce al sistema de transacciones nativo de tu entorno de despliegue. Esta API es realmente opcional, pero recomendamos fuertemente su uso salvo que estés en un bean de sesión CMT."
|
||||
|
||||
#: index.docbook:350
|
||||
msgid "Datatabase (or system) transaction boundaries are always necessary. No communication with the database can occur outside of a database transaction (this seems to confuse many developers who are used to the auto-commit mode). Always use clear transaction boundaries, even for read-only operations. Depending on your isolation level and database capabilities this might not be required but there is no downside if you always demarcate transactions explicitly. Certainly, a single database transaction is going to perform better than many small transactions, even for reading data."
|
||||
msgstr "Usualmente, finalizar una <literal>Session</literal> implica cuatro fases distintas:"
|
||||
|
||||
#: index.docbook:360
|
||||
msgid "A Hibernate application can run in non-managed (i.e. standalone, simple Web- or Swing applications) and managed J2EE environments. In a non-managed environment, Hibernate is usually responsible for its own database connection pool. The application developer has to manually set transaction boundaries, in other words, begin, commit, or rollback database transactions himself. A managed environment usually provides container-managed transactions (CMT), with the transaction assembly defined declaratively in deployment descriptors of EJB session beans, for example. Programmatic transaction demarcation is then no longer necessary."
|
||||
msgstr "limpiar (flush) la sesión"
|
||||
|
||||
#: index.docbook:370
|
||||
msgid "However, it is often desirable to keep your persistence layer portable between non-managed resource-local environments, and systems that can rely on JTA but use BMT instead of CMT. In both cases you'd use programmatic transaction demaracation. Hibernate offers a wrapper API called <literal>Transaction</literal> that translates into the native transaction system of your deployment environment. This API is actually optional, but we strongly encourage its use unless you are in a CMT session bean."
|
||||
msgstr "comprometer la transacción"
|
||||
|
||||
#: index.docbook:379
|
||||
msgid "Usually, ending a <literal>Session</literal> involves four distinct phases:"
|
||||
msgstr "cerrar la sesión"
|
||||
|
||||
#: index.docbook:385
|
||||
msgid "flush the session"
|
||||
msgstr "manejar excepciones"
|
||||
|
||||
#: index.docbook:390
|
||||
msgid "commit the transaction"
|
||||
msgstr "Limpiar la sesión ha sido discutido anteriormente, tendremos ahora una mirada más de cerca a la demarcación de transacciones y manejo de excepciones en sendos entornos manejado y no manejados."
|
||||
|
||||
#: index.docbook:395
|
||||
msgid "close the session"
|
||||
msgstr "Entorno no manejado"
|
||||
|
||||
#: index.docbook:400
|
||||
msgid "handle exceptions"
|
||||
msgstr "Si una capa de persistencia Hibernate se ejecuta en un entorno no manejado, las conexiones de base de datos son manejadas usualmente por el mecanismo de pooling de Hibernate. El idioma manejo de sesión/transacción se ve así:"
|
||||
|
||||
#: index.docbook:406
|
||||
msgid "Flushing the session has been discussed earlier, we'll now have a closer look at transaction demarcation and exception handling in both managed- and non-managed environments."
|
||||
msgstr ""
|
||||
"<![CDATA[//Non-managed environment idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:413
|
||||
msgid "Non-managed environment"
|
||||
msgstr "No tienes que limpiar con <literal>flush()</literal> la <literal>Session</literal> explícitamente - la llamada a <literal>commit()</literal> automáticamente dispara la sincronización."
|
||||
|
||||
#: index.docbook:415
|
||||
msgid "If a Hibernate persistence layer runs in a non-managed environment, database connections are usually handled by simple (i.e. non-DataSource) connection pools from which Hibernate obtains connections as needed. The session/transaction handling idiom looks like this:"
|
||||
msgstr "Una llamada a <literal>close()</literal> marca el fin de una sesión. La principal implicación de <literal>close()</literal> es que la conexión JDBC será abandonada por la sesión."
|
||||
|
||||
#: index.docbook:422
|
||||
msgid ""
|
||||
"<![CDATA[// Non-managed environment idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
msgstr "Este código Java es portable y se ejecuta tanto en entornos no manejados como en entornos JTA."
|
||||
|
||||
#: index.docbook:424
|
||||
msgid "You don't have to <literal>flush()</literal> the <literal>Session</literal> explicitly - the call to <literal>commit()</literal> automatically triggers the synchronization (depending upon the <xref linkend=\"objectstate-flushing\"/>FlushMode for the session. A call to <literal>close()</literal> marks the end of a session. The main implication of <literal>close()</literal> is that the JDBC connection will be relinquished by the session. This Java code is portable and runs in both non-managed and JTA environments."
|
||||
msgstr "Muy probablemente nunca veas este idioma en código de negocio en una aplicación normal; las excepciones fatales (sistema) deben siempre ser capturadas en la \"cima\". En otras palabras, el código que ejecuta las llamadas de Hibernate (en la capa de persistencia) y el código que maneja <literal>RuntimeException</literal> (y usualmente sólo puede limpiar y salir) están en capas diferentes. Esto puede ser un desafío de diseñarlo tú mismo y debes usar los servicios de contenedor J2EE/EJB en cuanto estuviesen disponibles. El manejo de excepciones se dicute más adelante en este capítulo."
|
||||
|
||||
#: index.docbook:433
|
||||
msgid "A much more flexible solution is Hibernate's built-in \"current session\" context management, as described earlier:"
|
||||
msgstr "Nota que debes seleccionar <literal>org.hibernate.transaction.JDBCTransactionFactory</literal> (que es el por defecto)."
|
||||
|
||||
#: index.docbook:438
|
||||
msgid ""
|
||||
"<![CDATA[// Non-managed environment idiom with getCurrentSession()\n"
|
||||
"try {\n"
|
||||
" factory.getCurrentSession().beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" factory.getCurrentSession().getTransaction().commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" factory.getCurrentSession().getTransaction().rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}]]>"
|
||||
msgstr "Usando JTA"
|
||||
|
||||
#: index.docbook:440
|
||||
msgid "You will very likely never see these code snippets in a regular application; fatal (system) exceptions should always be caught at the \"top\". In other words, the code that executes Hibernate calls (in the persistence layer) and the code that handles <literal>RuntimeException</literal> (and usually can only clean up and exit) are in different layers. The current context management by Hibernate can significantly simplify this design, as all you need is access to a <literal>SessionFactory</literal>. Exception handling is discussed later in this chapter."
|
||||
msgstr "Si tu capa de persistencia se ejecuta en un servidor de aplicaciones (por ejemplo, detrás de beans de sesión EJB), cada conexión de datasource obtenida por Hibernate será parte automáticamente de la transacción JTA global. Hibernate ofrece dos estrategias para esta integración."
|
||||
|
||||
#: index.docbook:450
|
||||
msgid "Note that you should select <literal>org.hibernate.transaction.JDBCTransactionFactory</literal> (which is the default), and for the second example <literal>\"thread\"</literal> as your <literal>hibernate.current_session_context_class</literal>."
|
||||
msgstr "Si usas transacciones gestionadas-por-bean (BMT) Hibernate le dirá al servidor de aplicaciones que comience y finalice una transacción BMT si usas la API de <literal>Transaction</literal>. De modo que, el código de gestión de la transacción es idéntico al de un entorno no manejado."
|
||||
|
||||
#: index.docbook:459
|
||||
msgid "Using JTA"
|
||||
msgstr ""
|
||||
"<![CDATA[// BMT idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:461
|
||||
msgid "If your persistence layer runs in an application server (e.g. behind EJB session beans), every datasource connection obtained by Hibernate will automatically be part of the global JTA transaction. You can also install a standalone JTA implementation and use it without EJB. Hibernate offers two strategies for JTA integration."
|
||||
msgstr "Con CMT, la demarcación de la transacción se hace en descriptores de despliegue de beans de sesión, no programáticamente. Si no quieres limpiar (flush) y cerrar manualmente la <literal>Session</literal> por ti mismo, solamente establece <literal>hibernate.transaction.flush_before_completion</literal> a <literal>true</literal>, <literal>hibernate.connection.release_mode</literal> a <literal>after_statement</literal> o <literal>auto</literal> y <literal>hibernate.transaction.auto_close_session</literal> a <literal>true</literal>. Hibernate limpiará y cerrará entonces automáticamente la <literal>Session</literal> para ti. Lo único que resta es deshacer (rollback) la transacción cuando ocurra una excepción. Afortunadamente, en un bean CMT, incluso esto ocurre automáticamente, ya que una <literal>RuntimeException</literal> no manejada disparada por un método de un bean de sesión le dice al contenedor que ponga a deshacer la transacción global. <emphasis>Esto significa que, en CMT, no necesitas usar en absoluto la API de <literal>Transaction</literal> de Hibernate.</emphasis>"
|
||||
|
||||
#: index.docbook:468
|
||||
msgid "If you use bean-managed transactions (BMT) Hibernate will tell the application server to start and end a BMT transaction if you use the <literal>Transaction</literal> API. So, the transaction management code is identical to the non-managed environment."
|
||||
msgstr "Nota que debes elegir <literal>org.hibernate.transaction.JTATransactionFactory</literal> en un bean de sesión BMT, y <literal>org.hibernate.transaction.CMTTransactionFactory</literal> en un bean de sesión CMT, cuando configures la fábrica de transacciones de Hibernate. Recuerda además establecer <literal>org.hibernate.transaction.manager_lookup_class</literal>."
|
||||
|
||||
#: index.docbook:474
|
||||
msgid ""
|
||||
"<![CDATA[// BMT idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
msgstr "Si trabajas en un entorno CMT, y usas limpieza (flushing) y cierre automáticos de la sesión, podrías querer también usar la misma sesión en diferentes partes de tu código. Típicamente, en un entorno no manejado, usarías una variable <literal>ThreadLocal</literal> para tener la sesión, pero una sola petición de EJB puede ejecutarse en diferentes hebras (por ejemplo, un bean de sesión llamando a otro bean de sesión). Si no quieres molestarte en pasar tu <literal>Session</literal> por alrededor, la <literal>SessionFactory</literal> provee el método <literal>getCurrentSession()</literal>, que devuelve una sesión que está pegada al contexto de transacción JTA. ¡Esta es la forma más fácil de integrar Hibernate en una aplicación! La sesión \"actual\" siempre tiene habilitados limpieza, cierre y liberación de conexión automáticos (sin importar la configuración de las propiedades anteriores). Nuestra idioma de gestión de sesión/transacción se reduce a:"
|
||||
|
||||
#: index.docbook:476
|
||||
msgid "If you want to use a transaction-bound <literal>Session</literal>, that is, the <literal>getCurrentSession()</literal> functionality for easy context propagation, you will have to use the JTA <literal>UserTransaction</literal> API directly:"
|
||||
msgstr ""
|
||||
"<![CDATA[// CMT idiom\n"
|
||||
"Session sess = factory.getCurrentSession();\n"
|
||||
"\n"
|
||||
"// do some work\n"
|
||||
"...\n"
|
||||
"\n"
|
||||
"]]>"
|
||||
|
||||
#: index.docbook:482
|
||||
msgid ""
|
||||
"<![CDATA[// BMT idiom with getCurrentSession()\n"
|
||||
"try {\n"
|
||||
" UserTransaction tx = (UserTransaction)new InitialContext()\n"
|
||||
" .lookup(\"java:comp/UserTransaction\");\n"
|
||||
"\n"
|
||||
" tx.begin();\n"
|
||||
"\n"
|
||||
" // Do some work on Session bound to transaction\n"
|
||||
" factory.getCurrentSession().load(...);\n"
|
||||
" factory.getCurrentSession().persist(...);\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}]]>"
|
||||
msgstr "En otras palabras, todo lo que tienes que hacer en un entorno manejado, es llamar a <literal>SessionFactory.getCurrentSession()</literal>, hacer tu trabajo de acceso a datos, y dejar el resto al contenedor. Los límites de transacción se establecen declarativamente en los descriptores de despliegue de tu bean de sesión. El ciclo de vida de la sesión es manejado completamente por Hibernate."
|
||||
|
||||
#: index.docbook:484
|
||||
msgid "With CMT, transaction demarcation is done in session bean deployment descriptors, not programatically, hence, the code is reduced to:"
|
||||
msgstr "Existe una advertencia al uso del modo de liberación de conexión <literal>after_statement</literal>. Debido a una limitación tonta de la especificación de JTA, no es posible para Hibernate limpiar automáticamente ningún <literal>ScrollableResults</literal> no cerrado ni instancias de <literal>Iterator</literal> devueltas por <literal>scroll()</literal> o <literal>iterate()</literal>. <emphasis>Debes</emphasis> liberar el cursor de base de datos subyacente llamando a <literal>ScrollableResults.close()</literal> o <literal>Hibernate.close(Iterator)</literal> explícitamente desde un bloque <literal>finally</literal>. (Por supuesto, la mayoría de las aplicaciones pueden evitarlo fácilmente no usando en absoluto ningún <literal>scroll()</literal> o <literal>iterate()</literal> desde el código CMT.)"
|
||||
|
||||
#: index.docbook:489
|
||||
msgid ""
|
||||
"<![CDATA[// CMT idiom\n"
|
||||
" Session sess = factory.getCurrentSession();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"]]>"
|
||||
msgstr "Manejo de excepciones"
|
||||
|
||||
#: index.docbook:491
|
||||
msgid "In a CMT/EJB even rollback happens automatically, since an unhandled <literal>RuntimeException</literal> thrown by a session bean method tells the container to set the global transaction to rollback. <emphasis>This means you do not need to use the Hibernate <literal>Transaction</literal> API at all with BMT or CMT, and you get automatic propagation of the \"current\" Session bound to the transaction.</emphasis>"
|
||||
msgstr "Si la <literal>Session</literal> lanza una excepción (incluyendo cualquier <literal>SQLException</literal>), debes inmediatamente deshacer (rollback) la transacción de base de datos, llamar a <literal>Session.close()</literal> y descartar la instancia de <literal>Session</literal>. Ciertos métodos de <literal>Session</literal> <emphasis>no</emphasis> dejarán la sesión en un estado consistente. Ninguna excepción lanzada por Hibernate puede ser tratada como recuperable. Asegúrate que la <literal>Session</literal> sea cerrada llamando a <literal>close()</literal> en un bloque <literal>finally</literal>."
|
||||
|
||||
#: index.docbook:499
|
||||
msgid "Note that you should choose <literal>org.hibernate.transaction.JTATransactionFactory</literal> if you use JTA directly (BMT), and <literal>org.hibernate.transaction.CMTTransactionFactory</literal> in a CMT session bean, when you configure Hibernate's transaction factory. Remember to also set <literal>hibernate.transaction.manager_lookup_class</literal>. Furthermore, make sure that your <literal>hibernate.current_session_context_class</literal> is either unset (backwards compatiblity), or set to <literal>\"jta\"</literal>."
|
||||
msgstr "La <literal>HibernateException</literal>, que envuelve la mayoría de los errores que pueden ocurrir en la capa de persistencia de Hibernate, en una excepción no chequeada (no lo era en versiones anteriores de Hibernate). En nuestra opinión, no debemos forzar al desarrollador de aplicaciones a capturar una excepción irrecuperable en una capa baja. En la mayoría de los sistemas, las excepciones no chequeadas y fatales son manejadas en uno de los primeros cuadros de la pila de llamadas a métodos (es decir, en las capas más altas) y se presenta un mensaje de error al usuario de la aplicación (o se toma alguna otra acción apropiada). Nota que Hibernate podría también lanzar otras excepciones no chequeadas que no sean una <literal>HibernateException</literal>. Una vez más, no son recuperables y debe tomarse una acción apropiada."
|
||||
|
||||
#: index.docbook:508
|
||||
msgid "The <literal>getCurrentSession()</literal> operation has one downside in a JTA environment. There is one caveat to the use of <literal>after_statement</literal> connection release mode, which is then used by default. Due to a silly limitation of the JTA spec, it is not possible for Hibernate to automatically clean up any unclosed <literal>ScrollableResults</literal> or <literal>Iterator</literal> instances returned by <literal>scroll()</literal> or <literal>iterate()</literal>. You <emphasis>must</emphasis> release the underlying database cursor by calling <literal>ScrollableResults.close()</literal> or <literal>Hibernate.close(Iterator)</literal> explicity from a <literal>finally</literal> block. (Of course, most applications can easily avoid using <literal>scroll()</literal> or <literal>iterate()</literal> at all from the JTA or CMT code.)"
|
||||
msgstr "Hibernate envuelve <literal>SQLException</literal>s lanzadas mientras se interactúa con la base de datos en una <literal>JDBCException</literal>. De hecho, Hibernate intentará convertir la excepción en una subclase de <literal>JDBCException</literal> más significativa. La <literal>SQLException</literal> está siempre disponible vía <literal>JDBCException.getCause()</literal>. Hibernate convierte la <literal>SQLException</literal> en una subclase de <literal>JDBCException</literal> apropiada usando el <literal>SQLExceptionConverter</literal> adjunto a la <literal>SessionFactory</literal>. Por defecto, el <literal>SQLExceptionConverter</literal> está definido para el dialecto configurado; sin embargo, es también posible enchufar una implementación personalizada (ver los javadocs de la clase <literal>SQLExceptionConverterFactory</literal> para los detalles). Los subtipos estándar de <literal>JDBCException</literal> son:"
|
||||
|
||||
#: index.docbook:524
|
||||
msgid "Exception handling"
|
||||
msgstr "<literal>JDBCConnectionException</literal> - indica un error con la comunicación JDBC subyacente."
|
||||
|
||||
#: index.docbook:526
|
||||
msgid "If the <literal>Session</literal> throws an exception (including any <literal>SQLException</literal>), you should immediately rollback the database transaction, call <literal>Session.close()</literal> and discard the <literal>Session</literal> instance. Certain methods of <literal>Session</literal> will <emphasis>not</emphasis> leave the session in a consistent state. No exception thrown by Hibernate can be treated as recoverable. Ensure that the <literal>Session</literal> will be closed by calling <literal>close()</literal> in a <literal>finally</literal> block."
|
||||
msgstr "<literal>SQLGrammarException</literal> - indica un problema de gramática o sintáxis con el SQL publicado."
|
||||
|
||||
#: index.docbook:537
|
||||
msgid "The <literal>HibernateException</literal>, which wraps most of the errors that can occur in a Hibernate persistence layer, is an unchecked exception (it wasn't in older versions of Hibernate). In our opinion, we shouldn't force the application developer to catch an unrecoverable exception at a low layer. In most systems, unchecked and fatal exceptions are handled in one of the first frames of the method call stack (i.e. in higher layers) and an error message is presented to the application user (or some other appropriate action is taken). Note that Hibernate might also throw other unchecked exceptions which are not a <literal>HibernateException</literal>. These are, again, not recoverable and appropriate action should be taken."
|
||||
msgstr "<literal>ConstraintViolationException</literal> - indica alguna forma de violación de restricción de integridad."
|
||||
|
||||
#: index.docbook:549
|
||||
msgid "Hibernate wraps <literal>SQLException</literal>s thrown while interacting with the database in a <literal>JDBCException</literal>. In fact, Hibernate will attempt to convert the eexception into a more meningful subclass of <literal>JDBCException</literal>. The underlying <literal>SQLException</literal> is always available via <literal>JDBCException.getCause()</literal>. Hibernate converts the <literal>SQLException</literal> into an appropriate <literal>JDBCException</literal> subclass using the <literal>SQLExceptionConverter</literal> attached to the <literal>SessionFactory</literal>. By default, the <literal>SQLExceptionConverter</literal> is defined by the configured dialect; however, it is also possible to plug in a custom implementation (see the javadocs for the <literal>SQLExceptionConverterFactory</literal> class for details). The standard <literal>JDBCException</literal> subtypes are:"
|
||||
msgstr "<literal>LockAcquisitionException</literal> - indica un error adquiriendo un nivel de bloqueo necesario para realizar una operación solicitada."
|
||||
|
||||
#: index.docbook:565
|
||||
msgid "<literal>JDBCConnectionException</literal> - indicates an error with the underlying JDBC communication."
|
||||
msgstr "<literal>GenericJDBCException</literal> - una excepción genérica que no cayó en ninguna de las otras categorías."
|
||||
|
||||
#: index.docbook:571
|
||||
msgid "<literal>SQLGrammarException</literal> - indicates a grammar or syntax problem with the issued SQL."
|
||||
msgstr "Control optimista de concurrencia"
|
||||
|
||||
#: index.docbook:577
|
||||
msgid "<literal>ConstraintViolationException</literal> - indicates some form of integrity constraint violation."
|
||||
msgstr "El único enfoque que es consistente con alta concurrencia y alta escalabilidad es el control optimista de concurrencia con versionamiento. El chuequeo de versión usa números de versión, o timestamps, para detectar actualizaciones en conflicto (y para prevenir actualizaciones perdidas). Hibernate provee para tres enfoques posibles de escribir código de aplicación que use concurrencia optimista. Los casos de uso que hemos mostrado están en el contexto de transacciones de aplicación largas pero el chequeo de versiones tiene además el beneficio de prevenir actualizaciones perdidas en transacciones de base de datos solas."
|
||||
|
||||
#: index.docbook:583
|
||||
msgid "<literal>LockAcquisitionException</literal> - indicates an error acquiring a lock level necessary to perform the requested operation."
|
||||
msgstr "Chequeo de versiones de aplicación"
|
||||
|
||||
#: index.docbook:589
|
||||
msgid "<literal>GenericJDBCException</literal> - a generic exception which did not fall into any of the other categories."
|
||||
msgstr "En una implementación sin mucha ayuda de Hibernate, cada interacción con la base de datos ocurre en una nueva <literal>Session</literal> y el desarrollador es responsable de recargar todas las intancias persistentes desde la base de datos antes de manipularlas. Este enfoque fuerza a la aplicación a realizar su propio chequeo de versiones para asegurar el aislamiento de transacciones de base de datos. Es el enfoque más similar a los EJBs de entidad."
|
||||
|
||||
#: index.docbook:599
|
||||
msgid "Transaction timeout"
|
||||
msgstr ""
|
||||
"<![CDATA[// foo is an instance loaded by a previous Session\n"
|
||||
"session = factory.openSession();\n"
|
||||
"Transaction t = session.beginTransaction();\n"
|
||||
"int oldVersion = foo.getVersion();\n"
|
||||
"session.load( foo, foo.getKey() ); // load the current state\n"
|
||||
"if ( oldVersion != foo.getVersion() ) throw new StaleObjectStateException();\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"t.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:601
|
||||
msgid "One extremely important feature provided by a managed environment like EJB that is never provided for non-managed code is transaction timeout. Transaction timeouts ensure that no misbehaving transaction can indefinitely tie up resources while returning no response to the user. Outside a managed (JTA) environment, Hibernate cannot fully provide this functionality. However, Hibernate can at least control data access operations, ensuring that database level deadlocks and queries with huge result sets are limited by a defined timeout. In a managed environment, Hibernate can delegate transaction timeout to JTA. This functioanlity is abstracted by the Hibernate <literal>Transaction</literal> object."
|
||||
msgstr "La propiedad <literal>version</literal> se mapea usando <literal><version></literal>, e Hibernate la incrementará automáticamente durante la limpieza si la entidad está sucia."
|
||||
|
||||
#: index.docbook:614
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"try {\n"
|
||||
" //set transaction timeout to 3 seconds\n"
|
||||
" sess.getTransaction().setTimeout(3);\n"
|
||||
" sess.getTransaction().begin();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" sess.getTransaction().commit()\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" sess.getTransaction().rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
msgstr "Por supuesto, si estás operando un entorno de baja-concurrencia-de-datos y no requieres chequeo de versiones, puedes usar este enfoque y simplemente saltar el chequeo de versiones. En ese caso, <emphasis>el último compromiso (commit) gana</emphasis> será la estrategia por defecto para tus transacciones de aplicación largas. Ten en mente que esto podría confundir a los usuarios de la aplicación, pues podrían experimentar actualizaciones perdidas sin mensajes de error ni chance de fusionar los cambios conflictivos."
|
||||
|
||||
#: index.docbook:616
|
||||
msgid "Note that <literal>setTimeout()</literal> may not be called in a CMT bean, where transaction timeouts must be defined declaratively."
|
||||
msgstr "Claramente, el chequeo manual de versiones es factible solamente en circunstancias muy triviales, y no es práctico para la mayoría de aplicaciones. Frecuentemente, no sólo intancias solas, sino grafos completos de objetos modificados tienen que ser chequeados. Hibernate ofrece chequeo de versiones automático con el paradigma de diseño de <literal>Session</literal> larga o de instancias separadas."
|
||||
|
||||
#: index.docbook:626
|
||||
msgid "Optimistic concurrency control"
|
||||
msgstr "Sesión larga y versionado automático"
|
||||
|
||||
#: index.docbook:628
|
||||
msgid "The only approach that is consistent with high concurrency and high scalability is optimistic concurrency control with versioning. Version checking uses version numbers, or timestamps, to detect conflicting updates (and to prevent lost updates). Hibernate provides for three possible approaches to writing application code that uses optimistic concurrency. The use cases we show are in the context of long conversations, but version checking also has the benefit of preventing lost updates in single database transactions."
|
||||
msgstr "Una sola instancia de <literal>Session</literal> y sus instancias persistentes son usadas para toda la transacción de aplicación. Hibernate chequea las versiones de instancia en el momento de limpieza (flush), lanzando una excepción si se detecta una modificación concurrente. Concierne al desarrollador capturar y manejar esta excepción (las opciones comunes son la oportunidad del usuario de fusionar los cambios, o recomenzar el proceso de negocio sin datos añejos)."
|
||||
|
||||
#: index.docbook:639
|
||||
msgid "Application version checking"
|
||||
msgstr "La <literal>Session</literal> se desconecta de cualquier conexión JDBC subyacente al esperar por una interacción del usuario. Este enfoque es el más eficiente en términos de acceso a base de datos. La aplicación no necesita tratar por sí misma con el chequeo de versiones, ni re-uniendo instancias separadas, ni tiene que recargar instancias en cada transacción de base de datos."
|
||||
|
||||
#: index.docbook:641
|
||||
msgid "In an implementation without much help from Hibernate, each interaction with the database occurs in a new <literal>Session</literal> and the developer is responsible for reloading all persistent instances from the database before manipulating them. This approach forces the application to carry out its own version checking to ensure conversation transaction isolation. This approach is the least efficient in terms of database access. It is the approach most similar to entity EJBs."
|
||||
msgstr ""
|
||||
"<![CDATA[// foo is an instance loaded earlier by the Session\n"
|
||||
"session.reconnect(); // Obtain a new JDBC connection\n"
|
||||
"Transaction t = session.beginTransaction();\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"t.commit(); // End database transaction, flushing the change and checking the version\n"
|
||||
"session.disconnect(); // Return JDBC connection ]]>"
|
||||
|
||||
#: index.docbook:650
|
||||
msgid ""
|
||||
"<![CDATA[// foo is an instance loaded by a previous Session\n"
|
||||
"session = factory.openSession();\n"
|
||||
"Transaction t = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"int oldVersion = foo.getVersion();\n"
|
||||
"session.load( foo, foo.getKey() ); // load the current state\n"
|
||||
"if ( oldVersion != foo.getVersion() ) throw new StaleObjectStateException();\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"\n"
|
||||
"t.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr "El objeto <literal>foo</literal> todavía conoce en qué <literal>Session</literal> fue cargado. <literal>Session.reconnect()</literal> obtiene una nueva conexión (o puedes proveer una) y reasume la sesión. El método <literal>Session.disconnect()</literal> desconectará la sesión de la conexión JDBC y la devolverá la conexión al pool (a menos que hayas provisto la conexión). Después de la reconexión, para forzar un chequeo de versión en datos que no estés actualizando, puedes llamar a <literal>Session.lock()</literal> con <literal>LockMode.READ</literal> sobre cualquier objeto que pudiese haber sido actualizado por otra transacción. No necesitas bloquear ningún dato que <emphasis>sí estés</emphasis> actualizando."
|
||||
|
||||
#: index.docbook:652
|
||||
msgid "The <literal>version</literal> property is mapped using <literal><version></literal>, and Hibernate will automatically increment it during flush if the entity is dirty."
|
||||
msgstr "Si las llamadas explícitas a <literal>disconnect()</literal> y <literal>reconnect()</literal> son muy onerosas, puedes usar en cambio <literal>hibernate.connection.release_mode</literal>."
|
||||
|
||||
#: index.docbook:658
|
||||
msgid "Of course, if you are operating in a low-data-concurrency environment and don't require version checking, you may use this approach and just skip the version check. In that case, <emphasis>last commit wins</emphasis> will be the default strategy for your long conversations. Keep in mind that this might confuse the users of the application, as they might experience lost updates without error messages or a chance to merge conflicting changes."
|
||||
msgstr "Este patrón es problemático si la <literal>Session</literal> es demasiado grande para ser almacenada durante el tiempo de pensar del usuario, por ejemplo, una <literal>HttpSession</literal> debe mantenerse tan pequeña como sea posible. Ya que la <literal>Session</literal> es también el caché (obligatorio) de primer nivel y contiene todos los objetos cargados, podemos probablemente cargar esta estrategia sólo para unos pocos ciclos petición/respuesta. Esto está de hecho recomendado, ya que la <literal>Session</literal> tendrá pronto también datos añejos."
|
||||
|
||||
#: index.docbook:667
|
||||
msgid "Clearly, manual version checking is only feasible in very trivial circumstances and not practical for most applications. Often not only single instances, but complete graphs of modified ojects have to be checked. Hibernate offers automatic version checking with either an extended <literal>Session</literal> or detached instances as the design paradigm."
|
||||
msgstr "Nota también que debes mantener la <literal>Session</literal> desconectada próxima a la capa de persistencia. En otras palabras, usa una sesión de EJB con estado para tener la <literal>Session</literal> y no transferirla a la capa web para almacenarla en la <literal>HttpSession</literal> (ni incluso serializarla a una capa separada)."
|
||||
|
||||
#: index.docbook:678
|
||||
msgid "Extended session and automatic versioning"
|
||||
msgstr "Objetos separados y versionado automático"
|
||||
|
||||
#: index.docbook:680
|
||||
msgid "A single <literal>Session</literal> instance and its persistent instances are used for the whole conversation, known as <emphasis>session-per-conversation</emphasis>. Hibernate checks instance versions at flush time, throwing an exception if concurrent modification is detected. It's up to the developer to catch and handle this exception (common options are the opportunity for the user to merge changes or to restart the business conversation with non-stale data)."
|
||||
msgstr "Cada interacción con el almacén persistente ocurre en una nueva <literal>Session</literal>. Sin embargo, las mismas instancias persistentes son reusadas para cada interacción con la base de datos. La aplicación manipula el estado de las instancias separadas originalmente cargadas en otra <literal>Session</literal> y luego las readjunta usando <literal>Session.update()</literal>, <literal>Session.saveOrUpdate()</literal>, o <literal>Session.merge()</literal>."
|
||||
|
||||
#: index.docbook:689
|
||||
msgid "The <literal>Session</literal> is disconnected from any underlying JDBC connection when waiting for user interaction. This approach is the most efficient in terms of database access. The application need not concern itself with version checking or with reattaching detached instances, nor does it have to reload instances in every database transaction."
|
||||
msgstr ""
|
||||
"<![CDATA[// foo is an instance loaded by a previous Session\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"session = factory.openSession();\n"
|
||||
"Transaction t = session.beginTransaction();\n"
|
||||
"session.saveOrUpdate(foo); // Use merge() if \"foo\" might have been loaded already\n"
|
||||
"t.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: index.docbook:697
|
||||
msgid ""
|
||||
"<![CDATA[// foo is an instance loaded earlier by the old session\n"
|
||||
"Transaction t = session.beginTransaction(); // Obtain a new JDBC connection, start transaction\n"
|
||||
"\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"\n"
|
||||
"session.flush(); // Only for last transaction in conversation\n"
|
||||
"t.commit(); // Also return JDBC connection\n"
|
||||
"session.close(); // Only for last transaction in conversation]]>"
|
||||
msgstr "De nuevo, Hibernate chequeará las versiones de instancia durante la limpieza (flush), lanzando una excepción si ocurrieron actualizaciones en conflicto."
|
||||
|
||||
#: index.docbook:698
|
||||
msgid "The <literal>foo</literal> object still knows which <literal>Session</literal> it was loaded in. Beginning a new database transaction on an old session obtains a new connection and resumes the session. Committing a database transaction disconnects a session from the JDBC connection and returns the connection to the pool. After reconnection, to force a version check on data you aren't updating, you may call <literal>Session.lock()</literal> with <literal>LockMode.READ</literal> on any objects that might have been updated by another transaction. You don't need to lock any data that you <emphasis>are</emphasis> updating. Usually you would set <literal>FlushMode.MANUAL</literal> on an extended <literal>Session</literal>, so that only the last database transaction cycle is allowed to actually persist all modifications made in this conversation. Hence, only this last database transaction would include the <literal>flush()</literal> operation, and then also <literal>close()</literal> the session to end the conversation."
|
||||
msgstr "Puedes también llamar a <literal>lock()</literal> en vez de <literal>update()</literal> y usar <literal>LockMode.READ</literal> (realizando un chequeo de versión, puenteando todos los cachés) si estás seguro que el objeto no ha sido modificado."
|
||||
|
||||
#: index.docbook:713
|
||||
msgid "This pattern is problematic if the <literal>Session</literal> is too big to be stored during user think time, e.g. an <literal>HttpSession</literal> should be kept as small as possible. As the <literal>Session</literal> is also the (mandatory) first-level cache and contains all loaded objects, we can probably use this strategy only for a few request/response cycles. You should use a <literal>Session</literal> only for a single conversation, as it will soon also have stale data."
|
||||
msgstr "Personalizando el versionado automático"
|
||||
|
||||
#: index.docbook:723
|
||||
msgid "(Note that earlier Hibernate versions required explicit disconnection and reconnection of a <literal>Session</literal>. These methods are deprecated, as beginning and ending a transaction has the same effect.)"
|
||||
msgstr "Puedes deshabilitar el incremento de versión automático de Hibernate para propiedades en particular y colecciones estableciendo el atributo de mapeo <literal>optimistic-lock</literal> a <literal>false</literal>. Hibernate entonces no incrementará ya más las versiones si la propiedad está sucia."
|
||||
|
||||
#: index.docbook:729
|
||||
msgid "Also note that you should keep the disconnected <literal>Session</literal> close to the persistence layer. In other words, use an EJB stateful session bean to hold the <literal>Session</literal> in a three-tier environment, and don't transfer it to the web layer (or even serialize it to a separate tier) to store it in the <literal>HttpSession</literal>."
|
||||
msgstr "Los esquemas de base de datos heredados son frecuentemente estáticos y no pueden ser modificados. U otras aplicaciones podrían también acceder la misma base de datos y no saber cómo manejar los números de versión ni incluso timestamps. En ambos casos, el versionado no puede confiarse a una columna en particular en una tabla. Para forzar un chequeo de versiones sin un mapeo de propiedad de versión o timestamp, con una comparación del estado de todos los campos en una fila, activa <literal>optimistic-lock=\"all\"</literal> en el mapeo de <literal><class></literal>. Nota que esto conceptualmente funciona solamente si Hibernate puede comparar el estado viejo y nuevo, es decir, si usas una sola <literal>Session</literal> larga y no sesión-por-petición-con-instancias-separadas."
|
||||
|
||||
#: index.docbook:737
|
||||
msgid "The extended session pattern, or <emphasis>session-per-conversation</emphasis>, is more difficult to implement with automatic current session context management. You need to supply your own implementation of the <literal>CurrentSessionContext</literal> for this, see the Hibernate Wiki for examples."
|
||||
msgstr "A veces las modificaciones concurrentes pueden permitirse, en cuanto los cambios que hayan sido hechos no se traslapen. Si estableces <literal>optimistic-lock=\"dirty\"</literal> al mapear la <literal><class></literal>, Hibernate sólo comparará los campos sucios durante la limpieza."
|
||||
|
||||
#: index.docbook:747
|
||||
msgid "Detached objects and automatic versioning"
|
||||
msgstr "En ambos casos, con columnas de versión/timestamp dedicadas o con comparación de campos completa/sucios, Hibernate usa una sola sentencia <literal>UPDATE</literal> (con una cláusula <literal>WHERE</literal> apropiada) por entidad para ejecutar el chequeo de versiones y actualizar la información. Si usas persistencia transitiva para la re-unión en cascada de entidades asociadas, Hibernate podría ejecutar actualizaciones innecesarias. Esto usualmente no es un problema, pero podrían ejecutarse disparadores (triggers) <emphasis>on update</emphasis> en la base de datos incluso cuando no se haya hecho ningún cambio a las instancias separadas. Puedes personalizar este comportamiento estableciendo <literal>select-before-update=\"true\"</literal> en el mapeo de <literal><class></literal>, forzando a Hibernate a <literal>SELECT</literal> la instancia para asegurar que las actualizaciones realmente ocurran, antes de actualizar la fila."
|
||||
|
||||
#: index.docbook:749
|
||||
msgid "Each interaction with the persistent store occurs in a new <literal>Session</literal>. However, the same persistent instances are reused for each interaction with the database. The application manipulates the state of detached instances originally loaded in another <literal>Session</literal> and then reattaches them using <literal>Session.update()</literal>, <literal>Session.saveOrUpdate()</literal>, or <literal>Session.merge()</literal>."
|
||||
msgstr "Bloqueo pesimista"
|
||||
|
||||
#: index.docbook:757
|
||||
msgid ""
|
||||
"<![CDATA[// foo is an instance loaded by a previous Session\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"session = factory.openSession();\n"
|
||||
"Transaction t = session.beginTransaction();\n"
|
||||
"session.saveOrUpdate(foo); // Use merge() if \"foo\" might have been loaded already\n"
|
||||
"t.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr "No se pretende que los usuarios gasten mucho tiempo preocupándose de las estrategias de bloqueo. Usualmente es suficiente con especificar un nivel de aislamiento para las conexiones JDBC y entonces simplemente dejar que la base de datos haga todo el trabajo. Sin embargo, los usuarios avanzados pueden a veces obtener bloqueos exclusivos pesimistas, o reobtener bloqueos al comienzo de una nueva transacción."
|
||||
|
||||
#: index.docbook:759
|
||||
msgid "Again, Hibernate will check instance versions during flush, throwing an exception if conflicting updates occured."
|
||||
msgstr "¡Hibernate siempre usará el mecanismo de bloqueo de la base de datos, nunca bloqueo de objetos en memoria!"
|
||||
|
||||
#: index.docbook:764
|
||||
msgid "You may also call <literal>lock()</literal> instead of <literal>update()</literal> and use <literal>LockMode.READ</literal> (performing a version check, bypassing all caches) if you are sure that the object has not been modified."
|
||||
msgstr "La clase <literal>LockMode</literal> define los diferentes niveles de bloqueo que pueden ser adquiridos por Hibernate. Un bloqueo se obtiene por los siguientes mecanismos:"
|
||||
|
||||
#: index.docbook:773
|
||||
msgid "Customizing automatic versioning"
|
||||
msgstr "<literal>LockMode.WRITE</literal> se adquiere automáticamente cuando Hibernate actualiza o inserta una fila."
|
||||
|
||||
#: index.docbook:775
|
||||
msgid "You may disable Hibernate's automatic version increment for particular properties and collections by setting the <literal>optimistic-lock</literal> mapping attribute to <literal>false</literal>. Hibernate will then no longer increment versions if the property is dirty."
|
||||
msgstr "<literal>LockMode.UPGRADE</literal> puede ser adquirido bajo petición explícita del usuario usando <literal>SELECT ... FOR UPDATE</literal> en base de datos que soporten esa sintáxis."
|
||||
|
||||
#: index.docbook:782
|
||||
msgid "Legacy database schemas are often static and can't be modified. Or, other applications might also access the same database and don't know how to handle version numbers or even timestamps. In both cases, versioning can't rely on a particular column in a table. To force a version check without a version or timestamp property mapping, with a comparison of the state of all fields in a row, turn on <literal>optimistic-lock=\"all\"</literal> in the <literal><class></literal> mapping. Note that this concepetually only works if Hibernate can compare the old and new state, i.e. if you use a single long <literal>Session</literal> and not session-per-request-with-detached-objects."
|
||||
msgstr "<literal>LockMode.UPGRADE_NOWAIT</literal> puede ser adquirido bajo petición explícita del usuario usando un <literal>SELECT ... FOR UPDATE NOWAIT</literal> bajo Oracle."
|
||||
|
||||
#: index.docbook:793
|
||||
msgid "Sometimes concurrent modification can be permitted as long as the changes that have been made don't overlap. If you set <literal>optimistic-lock=\"dirty\"</literal> when mapping the <literal><class></literal>, Hibernate will only compare dirty fields during flush."
|
||||
msgstr "<literal>LockMode.READ</literal> es adquirido automáticamente cuando Hibernate lee datos bajo los niveles de aislamiento Repeatable Read o Serializable. Puede ser readquirido por pedido explícito del usuario."
|
||||
|
||||
#: index.docbook:799
|
||||
msgid "In both cases, with dedicated version/timestamp columns or with full/dirty field comparison, Hibernate uses a single <literal>UPDATE</literal> statement (with an appropriate <literal>WHERE</literal> clause) per entity to execute the version check and update the information. If you use transitive persistence to cascade reattachment to associated entities, Hibernate might execute uneccessary updates. This is usually not a problem, but <emphasis>on update</emphasis> triggers in the database might be executed even when no changes have been made to detached instances. You can customize this behavior by setting <literal>select-before-update=\"true\"</literal> in the <literal><class></literal> mapping, forcing Hibernate to <literal>SELECT</literal> the instance to ensure that changes did actually occur, before updating the row."
|
||||
msgstr "<literal>LockMode.NONE</literal> representa la ausencia de un bloqueo. Todos los objetos se pasan a este modo de bloqueo al final de una <literal>Transaction</literal>. Los objetos asociados con una sesión vía una llamada a <literal>update()</literal> o <literal>saveOrUpdate()</literal> también comienzan en este modo de bloqueo."
|
||||
|
||||
#: index.docbook:817
|
||||
msgid "Pessimistic Locking"
|
||||
msgstr "La \"petición explícita del usuario\" se expresa en una de las siguientes formas:"
|
||||
|
||||
#: index.docbook:819
|
||||
msgid "It is not intended that users spend much time worring about locking strategies. Its usually enough to specify an isolation level for the JDBC connections and then simply let the database do all the work. However, advanced users may sometimes wish to obtain exclusive pessimistic locks, or re-obtain locks at the start of a new transaction."
|
||||
msgstr "Una llamada a <literal>Session.load()</literal>, especificando un <literal>LockMode</literal>."
|
||||
|
||||
#: index.docbook:826
|
||||
msgid "Hibernate will always use the locking mechanism of the database, never lock objects in memory!"
|
||||
msgstr "Una llamada a <literal>Session.lock()</literal>."
|
||||
|
||||
#: index.docbook:831
|
||||
msgid "The <literal>LockMode</literal> class defines the different lock levels that may be acquired by Hibernate. A lock is obtained by the following mechanisms:"
|
||||
msgstr "Una llamada a <literal>Query.setLockMode()</literal>."
|
||||
|
||||
#: index.docbook:838
|
||||
msgid "<literal>LockMode.WRITE</literal> is acquired automatically when Hibernate updates or inserts a row."
|
||||
msgstr "Si se llama a <literal>Session.load()</literal> con <literal>UPGRADE</literal> o <literal>UPGRADE_NOWAIT</literal>, y el objeto pedido no ha sido aún cargado por la sesión, el objeto es cargado usando <literal>SELECT ... FOR UPDATE</literal>. Si se llama a <literal>load()</literal> para un objeto que ya esté cargado con un bloqueo menos restrictivo que el pedido, Hibernate llama a <literal>lock()</literal> para ese objeto."
|
||||
|
||||
#: index.docbook:844
|
||||
msgid "<literal>LockMode.UPGRADE</literal> may be acquired upon explicit user request using <literal>SELECT ... FOR UPDATE</literal> on databases which support that syntax."
|
||||
msgstr "<literal>Session.lock()</literal> realiza un chequeo de número de versión si el modo de bloqueo especificado es <literal>READ</literal>, <literal>UPGRADE</literal> o <literal>UPGRADE_NOWAIT</literal>. (En el caso de <literal>UPGRADE</literal> o <literal>UPGRADE_NOWAIT</literal>, se usa <literal>SELECT ... FOR UPDATE</literal>.)"
|
||||
|
||||
#: index.docbook:850
|
||||
msgid "<literal>LockMode.UPGRADE_NOWAIT</literal> may be acquired upon explicit user request using a <literal>SELECT ... FOR UPDATE NOWAIT</literal> under Oracle."
|
||||
msgstr "Si la base de datos no soporta el modo de bloqueo solicitado, Hibernate usará un modo alternativo apropiado (en vez de lanzar una excepción). Esto asegura que las aplicaciones serán portables."
|
||||
|
||||
#: index.docbook:856
|
||||
msgid "<literal>LockMode.READ</literal> is acquired automatically when Hibernate reads data under Repeatable Read or Serializable isolation level. May be re-acquired by explicit user request."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:863
|
||||
msgid "<literal>LockMode.NONE</literal> represents the absence of a lock. All objects switch to this lock mode at the end of a <literal>Transaction</literal>. Objects associated with the session via a call to <literal>update()</literal> or <literal>saveOrUpdate()</literal> also start out in this lock mode."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:872
|
||||
msgid "The \"explicit user request\" is expressed in one of the following ways:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:878
|
||||
msgid "A call to <literal>Session.load()</literal>, specifying a <literal>LockMode</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:883
|
||||
msgid "A call to <literal>Session.lock()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:888
|
||||
msgid "A call to <literal>Query.setLockMode()</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:894
|
||||
msgid "If <literal>Session.load()</literal> is called with <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>, and the requested object was not yet loaded by the session, the object is loaded using <literal>SELECT ... FOR UPDATE</literal>. If <literal>load()</literal> is called for an object that is already loaded with a less restrictive lock than the one requested, Hibernate calls <literal>lock()</literal> for that object."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:903
|
||||
msgid "<literal>Session.lock()</literal> performs a version number check if the specified lock mode is <literal>READ</literal>, <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>. (In the case of <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>, <literal>SELECT ... FOR UPDATE</literal> is used.)"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:910
|
||||
msgid "If the database does not support the requested lock mode, Hibernate will use an appropriate alternate mode (instead of throwing an exception). This ensures that applications will be portable."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:919
|
||||
msgid "Connection Release Modes"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:921
|
||||
msgid "The legacy (2.x) behavior of Hibernate in regards to JDBC connection management was that a <literal>Session</literal> would obtain a connection when it was first needed and then hold unto that connection until the session was closed. Hibernate 3.x introduced the notion of connection release modes to tell a session how to handle its JDBC connections. Note that the following discussion is pertinent only to connections provided through a configured <literal>ConnectionProvider</literal>; user-supplied connections are outside the breadth of this discussion. The different release modes are identified by the enumerated values of <literal>org.hibernate.ConnectionReleaseMode</literal>:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:935
|
||||
msgid "<literal>ON_CLOSE</literal> - is essentially the legacy behavior described above. The Hibernate session obatins a connection when it first needs to perform some JDBC access and holds unto that connection until the session is closed."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:942
|
||||
msgid "<literal>AFTER_TRANSACTION</literal> - says to release connections after a <literal>org.hibernate.Transaction</literal> has completed."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:948
|
||||
msgid "<literal>AFTER_STATEMENT</literal> (also referred to as aggressive release) - says to release connections after each and every statement execution. This aggressive releasing is skipped if that statement leaves open resources associated with the given session; currently the only situation where this occurs is through the use of <literal>org.hibernate.ScrollableResults</literal>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:958
|
||||
msgid "The configuration parameter <literal>hibernate.connection.release_mode</literal> is used to specify which release mode to use. The possible values:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:965
|
||||
msgid "<literal>auto</literal> (the default) - this choice delegates to the release mode returned by the <literal>org.hibernate.transaction.TransactionFactory.getDefaultReleaseMode()</literal> method. For JTATransactionFactory, this returns ConnectionReleaseMode.AFTER_STATEMENT; for JDBCTransactionFactory, this returns ConnectionReleaseMode.AFTER_TRANSACTION. It is rarely a good idea to change this default behavior as failures due to the value of this setting tend to indicate bugs and/or invalid assumptions in user code."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:975
|
||||
msgid "<literal>on_close</literal> - says to use ConnectionReleaseMode.ON_CLOSE. This setting is left for backwards compatibility, but its use is highly discouraged."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:981
|
||||
msgid "<literal>after_transaction</literal> - says to use ConnectionReleaseMode.AFTER_TRANSACTION. This setting should not be used in JTA environments. Also note that with ConnectionReleaseMode.AFTER_TRANSACTION, if a session is considered to be in auto-commit mode connections will be released as if the release mode were AFTER_STATEMENT."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:989
|
||||
msgid "<literal>after_statement</literal> - says to use ConnectionReleaseMode.AFTER_STATEMENT. Additionally, the configured <literal>ConnectionProvider</literal> is consulted to see if it supports this setting (<literal>supportsAggressiveRelease()</literal>). If not, the release mode is reset to ConnectionReleaseMode.AFTER_TRANSACTION. This setting is only safe in environments where we can either re-acquire the same underlying JDBC connection each time we make a call into <literal>ConnectionProvider.getConnection()</literal> or in auto-commit environments where it does not matter whether we get back the same connection."
|
||||
msgstr ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,420 @@
|
|||
#, 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,48 @@
|
|||
#, 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 material may be distributed only subject to the terms and conditions set forth in the Open Publication License, V1.0 or later (the latest version is presently available at <ulink url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/openpub/</ulink>)."
|
||||
msgstr "Copyright <trademark class=\"copyright\"></trademark> 2007 by Red Hat, Inc. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, V1.0 or later (the latest version is presently available at <ulink url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/openpub/</ulink>)."
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder."
|
||||
msgstr "Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder."
|
||||
|
||||
#: index.docbook:37
|
||||
msgid "Distribution of the work or derivative of the work in any standard (paper) book form for commercial purposes is prohibited unless prior permission is obtained from the copyright holder."
|
||||
msgstr "Distribution of the work or derivative of the work in any standard (paper) book form for commercial purposes is prohibited unless prior permission is obtained from the copyright holder."
|
||||
|
||||
#: 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,216 @@
|
|||
#, 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 "Architecture"
|
||||
|
||||
#: index.docbook:24
|
||||
msgid "Overview"
|
||||
msgstr "Généralités"
|
||||
|
||||
#: index.docbook:26
|
||||
msgid "A (very) high-level view of the Hibernate architecture:"
|
||||
msgstr "Voici une vue (très) haut niveau de l'architecture d'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 "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."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "L'architecture la plus complète abstrait l'application des APIs JDBC/JTA sous-jacentes et laisse Hibernate s'occuper des détails."
|
||||
|
||||
#: index.docbook:75
|
||||
msgid "Heres some definitions of the objects in the diagrams:"
|
||||
msgstr "Voici quelques définitions des objets des diagrammes :"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:104
|
||||
msgid "Persistent objects and collections"
|
||||
msgstr "Objets et Collections persistants"
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: index.docbook:117
|
||||
msgid "Transient and detached objects and collections"
|
||||
msgstr "Objets et collections transients"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "(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!"
|
||||
|
||||
#: 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 "(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."
|
||||
|
||||
#: 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 "(Optionnel) Une fabrique d'instances de <literal>Transaction</literal>. Non exposé à l'application, mais peut être étendu/implémenté par le développeur."
|
||||
|
||||
#: index.docbook:160
|
||||
msgid "Extension Interfaces"
|
||||
msgstr "Interfaces d'extension"
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:179
|
||||
msgid "Instance states"
|
||||
msgstr "Etats des instances"
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: index.docbook:188
|
||||
msgid "transient"
|
||||
msgstr "passager (transient)"
|
||||
|
||||
#: 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 "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)"
|
||||
|
||||
#: index.docbook:198
|
||||
msgid "persistent"
|
||||
msgstr "persistant"
|
||||
|
||||
#: 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 "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)"
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "detached"
|
||||
msgstr "détaché"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:229
|
||||
msgid "JMX Integration"
|
||||
msgstr "Intégration 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 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>."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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>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>."
|
||||
|
||||
#: 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>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."
|
||||
|
||||
#: index.docbook:268
|
||||
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."
|
||||
|
||||
#: index.docbook:272
|
||||
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\"/>."
|
||||
|
||||
#: index.docbook:279
|
||||
msgid "JCA Support"
|
||||
msgstr "Support 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 "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."
|
||||
|
||||
#: index.docbook:287
|
||||
msgid "Contextual Sessions"
|
||||
msgstr "Sessions Contextuelles"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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> - 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."
|
||||
|
||||
#: 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> - les sessions courantes sont associées au thread d'exécution. Voir les javadocs pour les détails."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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\"."
|
||||
|
||||
#: 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 ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,970 @@
|
|||
#, 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:6
|
||||
msgid "Association Mappings"
|
||||
msgstr "Mapper les associations"
|
||||
|
||||
#: index.docbook:9
|
||||
msgid "Introduction"
|
||||
msgstr "Introduction"
|
||||
|
||||
#: index.docbook:11
|
||||
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>."
|
||||
|
||||
#: index.docbook:19
|
||||
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."
|
||||
|
||||
#: index.docbook:24
|
||||
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."
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Unidirectional associations"
|
||||
msgstr "Association unidirectionnelle"
|
||||
|
||||
#: index.docbook:37, index.docbook:108
|
||||
msgid "many to one"
|
||||
msgstr "plusieurs à un"
|
||||
|
||||
#: index.docbook:39
|
||||
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."
|
||||
|
||||
#: index.docbook:44
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:45, index.docbook:161
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:50, index.docbook:121, index.docbook:185, index.docbook:225
|
||||
msgid "one to one"
|
||||
msgstr "un à un"
|
||||
|
||||
#: index.docbook:52
|
||||
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."
|
||||
|
||||
#: index.docbook:57
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:58, index.docbook:193
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:60
|
||||
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.)"
|
||||
|
||||
#: index.docbook:66
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:67, index.docbook:201
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( personId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( personId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:72, index.docbook:94
|
||||
msgid "one to many"
|
||||
msgstr "un à plusieurs"
|
||||
|
||||
#: index.docbook:74
|
||||
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."
|
||||
|
||||
#: index.docbook:79
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:80
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:82
|
||||
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."
|
||||
|
||||
#: index.docbook:91
|
||||
msgid "Unidirectional associations with join tables"
|
||||
msgstr "Associations unidirectionnelles avec tables de jointure"
|
||||
|
||||
#: index.docbook:96
|
||||
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)."
|
||||
|
||||
#: index.docbook:102
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:103
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:110
|
||||
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."
|
||||
|
||||
#: index.docbook:115
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:116
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:123
|
||||
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."
|
||||
|
||||
#: index.docbook:128
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:129, index.docbook:233
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:134, index.docbook:238
|
||||
msgid "many to many"
|
||||
msgstr "plusieurs à plusieurs"
|
||||
|
||||
#: index.docbook:136
|
||||
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>."
|
||||
|
||||
#: index.docbook:140
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:141, index.docbook:246
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:148
|
||||
msgid "Bidirectional associations"
|
||||
msgstr "Associations bidirectionnelles"
|
||||
|
||||
#: index.docbook:151, index.docbook:211
|
||||
msgid "one to many / many to one"
|
||||
msgstr "un à plusieurs / plusieurs à un"
|
||||
|
||||
#: index.docbook:153
|
||||
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.)"
|
||||
|
||||
#: index.docbook:159
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:163
|
||||
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>):"
|
||||
|
||||
#: index.docbook:171
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:173
|
||||
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 "Un à un"
|
||||
|
||||
#: index.docbook:187
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> is quite common."
|
||||
msgstr ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:192
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:195
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a primary key</emphasis> uses the special id generator."
|
||||
msgstr ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:200
|
||||
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 ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( personId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:208
|
||||
msgid "Bidirectional associations with join tables"
|
||||
msgstr "un à plusieurs / plusieurs à un"
|
||||
|
||||
#: index.docbook:213
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:219
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:220
|
||||
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 "Un à un"
|
||||
|
||||
#: index.docbook:227
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."
|
||||
msgstr ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:232
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:240
|
||||
msgid "Finally, we have a <emphasis>bidirectional many-to-many association</emphasis>."
|
||||
msgstr ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:244
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:253
|
||||
msgid "More complex association mappings"
|
||||
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:"
|
||||
|
||||
#: index.docbook:255
|
||||
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 ""
|
||||
"<![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\"/>]]>"
|
||||
|
||||
#: index.docbook:264
|
||||
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 "alors nous pouvons mapper une association à l'instance <emphasis>courante</emphasis> (celle avec une <literal>effectiveEndDate</literal>) nulle en utilisant:"
|
||||
|
||||
#: index.docbook:266
|
||||
msgid "Then we can map an association to the <emphasis>current</emphasis> instance (the one with null <literal>effectiveEndDate</literal>) using:"
|
||||
msgstr ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:271
|
||||
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 "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:"
|
||||
|
||||
#: index.docbook:273
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:281
|
||||
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 "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."
|
||||
|
||||
#: index.docbook:283
|
||||
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 ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,365 @@
|
|||
#, 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 "Traitement par paquet"
|
||||
|
||||
#: index.docbook:7
|
||||
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 :"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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) :"
|
||||
|
||||
#: 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 "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é :"
|
||||
|
||||
#: 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 "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
msgstr "Insertions en paquet"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:47
|
||||
msgid "Batch inserts"
|
||||
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, même taille que la taille du paquet JDBC\n"
|
||||
" //flush un paquet d'insertions et libère la mémoire :\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: 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 "Paquet de mises à jour"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:60
|
||||
msgid "Batch updates"
|
||||
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 un paquet de mises à jour et libère la mémoire :\n"
|
||||
" session.flush();\n"
|
||||
" session.clear();\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"tx.commit();\n"
|
||||
"session.close();]]>"
|
||||
|
||||
#: 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 "L'interface StatelessSession"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:73
|
||||
msgid "The StatelessSession interface"
|
||||
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: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 "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."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "Opérations de style DML"
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: index.docbook:110
|
||||
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 :"
|
||||
|
||||
#: 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 (<xref linkend=\"queryhql\"/>HQL)."
|
||||
msgstr "Dans la clause from, le mot-clef FROM est optionnel"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:130
|
||||
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."
|
||||
|
||||
#: 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 "La clause where est aussi optionnelle."
|
||||
|
||||
#: index.docbook:143
|
||||
msgid "No <xref linkend=\"queryhql-joins-forms\"/>joins (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) :"
|
||||
|
||||
#: index.docbook:150
|
||||
msgid "The where-clause is also optional."
|
||||
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"
|
||||
"// ou 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: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 "Pour exécuter un <literal>DELETE</literal> HQL, utilisez la même méthode <literal>Query.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 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();]]>"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "HQL <literal>UPDATE</literal> statements, by default do not effect the <xref linkend=\"mapping-declaration-version\"/>version or the <xref linkend=\"mapping-declaration-timestamp\"/>timestamp 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 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."
|
||||
|
||||
#: 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 "La pseudo-syntaxe pour l'expression <literal>INSERT</literal> est : <literal>INSERT INTO EntityName properties_list select_statement</literal>. Quelques points sont à noter :"
|
||||
|
||||
#: 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 "Seule la forme INSERT INTO ... SELECT ... est supportée ; pas la forme INSERT INTO ... VALUES ... ."
|
||||
|
||||
#: index.docbook:181
|
||||
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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: index.docbook:207
|
||||
msgid "Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form."
|
||||
msgstr "Un exemple d'exécution d'une expression <literal>INSERT</literal> HQL :"
|
||||
|
||||
#: 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 ""
|
||||
"<![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();]]>"
|
||||
|
||||
#: 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,168 @@
|
|||
#, 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 "Meilleures pratiques"
|
||||
|
||||
#: index.docbook:9
|
||||
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>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:19
|
||||
msgid "Declare identifier properties on persistent classes."
|
||||
msgstr "Déclarez des propriétés d'identifiants dans les classes persistantes."
|
||||
|
||||
#: 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 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)."
|
||||
|
||||
#: index.docbook:29
|
||||
msgid "Identify natural keys."
|
||||
msgstr "Identifiez les clefs naturelles."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "Place each class mapping in its own file."
|
||||
msgstr "Placez chaque mapping de classe dans son propre fichier."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:49
|
||||
msgid "Load mappings as resources."
|
||||
msgstr "Chargez les mappings comme des ressources."
|
||||
|
||||
#: index.docbook:51
|
||||
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."
|
||||
|
||||
#: index.docbook:57
|
||||
msgid "Consider externalising query strings."
|
||||
msgstr "Pensez à externaliser les chaînes de caractères."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:67
|
||||
msgid "Use bind variables."
|
||||
msgstr "Utilisez les variables \"bindées\"."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:77
|
||||
msgid "Don't manage your own JDBC connections."
|
||||
msgstr "Ne gérez pas vous même les connexions 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 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>."
|
||||
|
||||
#: index.docbook:87
|
||||
msgid "Consider using a custom type."
|
||||
msgstr "Pensez à utiliser les types utilisateurs."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:98
|
||||
msgid "Use hand-coded JDBC in bottlenecks."
|
||||
msgstr "Utilisez du JDBC pur dans les goulets d'étranglement."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "Understand <literal>Session</literal> flushing."
|
||||
msgstr "Comprendre le flush 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 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."
|
||||
|
||||
#: index.docbook:121
|
||||
msgid "In a three tiered architecture, consider using detached objects."
|
||||
msgstr "Dans une architecture à trois couches, pensez à utiliser <literal>saveOrUpdate()</literal>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:132
|
||||
msgid "In a two tiered architecture, consider using long persistence contexts."
|
||||
msgstr "Dans une architecture à deux couches, pensez à utiliser la déconnexion de session."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:148
|
||||
msgid "Don't treat exceptions as recoverable."
|
||||
msgstr "Considérez que les exceptions ne sont pas rattrapables."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:160
|
||||
msgid "Prefer lazy fetching for associations."
|
||||
msgstr "Préférez le chargement tardif des associations."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: index.docbook:191
|
||||
msgid "Consider abstracting your business logic from Hibernate."
|
||||
msgstr "Pensez à abstraite votre logique métier d'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 "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)."
|
||||
|
||||
#: index.docbook:203
|
||||
msgid "Don't use exotic association mappings."
|
||||
msgstr "N'utilisez pas d'associations de mapping exotiques."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:215
|
||||
msgid "Prefer bidirectional associations."
|
||||
msgstr "Préférez les associations bidirectionnelles."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,532 @@
|
|||
#, 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 "Mapping de composants"
|
||||
|
||||
#: 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 notion de <emphasis>composants</emphasis> est réutilisé dans différents contextes, avec différents objectifs, à travers Hibernate."
|
||||
|
||||
#: index.docbook:13
|
||||
msgid "Dependent objects"
|
||||
msgstr "Objects dépendants"
|
||||
|
||||
#: 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 "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:"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:32
|
||||
msgid "Our Hibernate mapping would look like:"
|
||||
msgstr "Nous serions alors amené à mapper ce composant de cette façon:"
|
||||
|
||||
#: 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\"/>\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 table person aurai les colonnes <literal>pid</literal>, <literal>birthday</literal>, <literal>initial</literal>, <literal>first</literal> and <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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "Le <literal><component></literal> peut inclure dans la liste de ses propriétés une référence au <literal><parent></literal> conteneur."
|
||||
|
||||
#: 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\"/>\n"
|
||||
" </id>\n"
|
||||
" <property name=\"birthday\" type=\"date\"/>\n"
|
||||
" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"
|
||||
" <parent name=\"namedPerson\"/> <!-- référence arrière à 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 "Collection d'objets dépendants"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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)"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:133
|
||||
msgid "Even ternary (or quaternary, etc) associations are possible:"
|
||||
msgstr "Même les associations ternaires ou quaternaires sont possibles:"
|
||||
|
||||
#: 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 "Les éléments composites peuvent apparaître dans les requêtes en utilisant la même syntaxe que associations"
|
||||
|
||||
#: index.docbook:145
|
||||
msgid "Components as Map indices"
|
||||
msgstr "Utiliser les composants comme index 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 "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."
|
||||
|
||||
#: index.docbook:156
|
||||
msgid "Components as composite identifiers"
|
||||
msgstr "Utiliser un composant comme identifiant"
|
||||
|
||||
#: index.docbook:158
|
||||
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."
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "It must implement <literal>java.io.Serializable</literal>."
|
||||
msgstr "Elle doit implémenter <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 "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."
|
||||
|
||||
#: index.docbook:179
|
||||
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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "(Remarque: l'élément <literal><column></literal> est une alternative à l'attribut <literal>column</literal> que l'on utilise partout.)"
|
||||
|
||||
#: index.docbook:211
|
||||
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:"
|
||||
|
||||
#: 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 collection des <literal>OrderLine</literal>s dans <literal>Order</literal> utilisera:"
|
||||
|
||||
#: 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 "(L'élément <literal><one-to-many></literal>, comme d'habitude, ne déclare pas de colonne.)"
|
||||
|
||||
#: index.docbook:229
|
||||
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."
|
||||
|
||||
#: 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 "Composant Dynamique"
|
||||
|
||||
#: index.docbook:241
|
||||
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>:"
|
||||
|
||||
#: 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\"/>\n"
|
||||
" <property name=\"bar\" column=\"BAR\"/>\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 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>"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,358 @@
|
|||
#, 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 "Les intercepteurs et les événements"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Interceptors"
|
||||
msgstr "Intercepteurs"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:27
|
||||
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>."
|
||||
|
||||
#: 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.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"
|
||||
" // ne fait rien\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 postFlush(Iterator entities) {\n"
|
||||
" System.out.println(\"Creations: \" + creates + \", Updates: \" + updates);\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"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Interceptors come in two flavors: <literal>Session</literal>-scoped and <literal>SessionFactory</literal>-scoped."
|
||||
msgstr "L'intercepteur doit être spécifié quand une session est créée."
|
||||
|
||||
#: 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 "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
|
||||
|
||||
#: index.docbook:45
|
||||
msgid "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
|
||||
msgstr "Vous pouvez aussi mettre un intercepteur au niveau global, en utilisant l'objet <literal>Configuration</literal>. Dans ce cas, l'intercepteur doit être \"threadsafe\"."
|
||||
|
||||
#: 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 "<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
|
||||
#: index.docbook:56
|
||||
msgid "<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
msgstr "Système d'événements"
|
||||
|
||||
#: index.docbook:61
|
||||
msgid "Event system"
|
||||
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."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 ""
|
||||
"<![CDATA[public class MyLoadListener implements LoadEventListener {\n"
|
||||
" // C'est une simple méthode définie par l'interface LoadEventListener\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"
|
||||
"}]]>"
|
||||
|
||||
#: 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 "Vous avez aussi besoin d'une entrée de configuration disant à Hibernate d'utiliser ce listener en plus du listener par défaut :"
|
||||
|
||||
#: index.docbook:101
|
||||
msgid "You also need a configuration entry telling Hibernate to use the listener in addition to the default listener:"
|
||||
msgstr ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: 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 "Vous pouvez aussi l'inscrire par programmation :"
|
||||
|
||||
#: index.docbook:108
|
||||
msgid "Instead, you may register it programmatically:"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = new Configuration();\n"
|
||||
"LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };\n"
|
||||
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
|
||||
|
||||
#: index.docbook:112
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = new Configuration();\n"
|
||||
"LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };\n"
|
||||
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
|
||||
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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "Sécurité déclarative d'Hibernate"
|
||||
|
||||
#: index.docbook:132
|
||||
msgid "Hibernate declarative security"
|
||||
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."
|
||||
|
||||
#: 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 "D'abord, vous devez configurer les listeners d'événements appropriés pour permettre l'utilisation d'autorisations JAAS."
|
||||
|
||||
#: index.docbook:139
|
||||
msgid "First, you must configure the appropriate event listeners, to enable the use of JAAS authorization."
|
||||
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: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 "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."
|
||||
|
||||
#: 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 "Ensuite, toujours dans <literal>hibernate.cfg.xml</literal>, lier les permissions aux rôles :"
|
||||
|
||||
#: index.docbook:152
|
||||
msgid "Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:"
|
||||
msgstr ""
|
||||
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,read\"/>\n"
|
||||
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
|
||||
|
||||
#: index.docbook:156
|
||||
msgid ""
|
||||
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,read\"/>\n"
|
||||
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
|
||||
msgstr "Les noms de rôle sont les rôles compris par votre fournisseur JAAC."
|
||||
|
||||
#: index.docbook:158
|
||||
msgid "The role names are the roles understood by your JACC provider."
|
||||
msgstr ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,350 @@
|
|||
#, 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 "Exemple : Père/Fils"
|
||||
|
||||
#: 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 "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 !"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "A note about collections"
|
||||
msgstr "Une note à propos des collections"
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: index.docbook:30
|
||||
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é."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 "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é."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:64
|
||||
msgid "Bidirectional one-to-many"
|
||||
msgstr "un-vers-plusieurs bidirectionnel"
|
||||
|
||||
#: 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 "Supposons que nous ayons une simple association <literal><one-to-many></literal> de <literal>Parent</literal> vers <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 nous executions le code suivant"
|
||||
|
||||
#: 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 exécuterait deux ordres SQL:"
|
||||
|
||||
#: index.docbook:85
|
||||
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>"
|
||||
|
||||
#: 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> pour créer le lien de <literal>p</literal> vers <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 "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 :"
|
||||
|
||||
#: 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 "Cependant ce n'est pas la solution recommandée."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "(Nous avons aussi besoin d'ajouter la propriété <literal>parent</literal> dans la classe <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 "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>."
|
||||
|
||||
#: 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 "Le code suivant serait utilisé pour ajouter un nouveau <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 "Maintenant, seul un <literal>INSERT</literal> SQL est nécessaire !"
|
||||
|
||||
#: index.docbook:136
|
||||
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>."
|
||||
|
||||
#: 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 "Le code d'ajout d'un <literal>Child</literal> serait alors"
|
||||
|
||||
#: 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 "Cycle de vie en cascade"
|
||||
|
||||
#: index.docbook:154
|
||||
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."
|
||||
|
||||
#: 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 "Simplifie le code précédent en"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "Par contre, ce code"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: index.docbook:206
|
||||
msgid "Cascades and <literal>unsaved-value</literal>"
|
||||
msgstr "Cascades et <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 "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>"
|
||||
|
||||
#: index.docbook:220
|
||||
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>."
|
||||
|
||||
#: 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 et child ont été chargés dans une session précédente\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 "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."
|
||||
|
||||
#: index.docbook:260
|
||||
msgid "Conclusion"
|
||||
msgstr "Conclusion"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
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 "Example: Weblog Application"
|
||||
msgstr "Exemple : application Weblog"
|
||||
|
||||
#: index.docbook:8
|
||||
msgid "Persistent Classes"
|
||||
msgstr "Classes persistantes"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "Mappings Hibernate"
|
||||
|
||||
#: index.docbook:25
|
||||
msgid "The XML mappings should now be quite straightforward."
|
||||
msgstr "Le mapping XML doit maintenant être relativement simple à vos yeux."
|
||||
|
||||
#: 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 "Code 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 classe suivante montre quelques utilisations que nous pouvons faire de ces classes."
|
||||
|
||||
#: 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,192 @@
|
|||
#, 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 "Filtrer les données"
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Hibernate filters"
|
||||
msgstr "Filtres 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 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."
|
||||
|
||||
#: 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 "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> :"
|
||||
|
||||
#: 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 "Puis, ce filtre peut être attaché à une classe :"
|
||||
|
||||
#: 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 "ou à une collection :"
|
||||
|
||||
#: 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 "ou même aux deux (ou à plusieurs de chaque) en même temps."
|
||||
|
||||
#: 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 "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.enabledFilter()</literal>, laquelle retourne une instance de l'interface <literal>Filter</literal>. Utiliser le simple filtre défini au-dessus ressemblerait à :"
|
||||
|
||||
#: 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 "Notez que des méthodes sur l'interface org.hibernate.Filter autorisent le chaînage de beaucoup de méthodes communes d'Hibernate."
|
||||
|
||||
#: index.docbook:65
|
||||
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 :"
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: index.docbook:76
|
||||
msgid ""
|
||||
"<![CDATA[Session session = ...;\n"
|
||||
"session.enabledFilter(\"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.enabledFilter(\"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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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,642 @@
|
|||
#, 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 "Mapping d'héritage de classe"
|
||||
|
||||
#: index.docbook:8
|
||||
msgid "The Three Strategies"
|
||||
msgstr "Les trois stratégies"
|
||||
|
||||
#: index.docbook:10
|
||||
msgid "Hibernate supports the three basic inheritance mapping strategies:"
|
||||
msgstr "Hibernate supporte les trois stratégies d'héritage de base :"
|
||||
|
||||
#: index.docbook:16
|
||||
msgid "table per class hierarchy"
|
||||
msgstr "une table par hiérarchie de classe (table per class hierarchy)"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "<para>table per subclass</para>"
|
||||
msgstr "une table par classe fille (table per subclass)"
|
||||
|
||||
#: index.docbook:26
|
||||
msgid "table per concrete class"
|
||||
msgstr "une table par classe concrète (table per concrete class)"
|
||||
|
||||
#: index.docbook:32
|
||||
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 :"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "implicit polymorphism"
|
||||
msgstr "le polymorphisme implicite"
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 ""
|
||||
"<![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:74
|
||||
msgid "Table per class hierarchy"
|
||||
msgstr "Une table par hiérarchie de classe"
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: index.docbook:94
|
||||
msgid "Table per subclass"
|
||||
msgstr "Une table par classe fille"
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "A table per subclass mapping would look like:"
|
||||
msgstr "La stratégie une table par classe fille serait :"
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: index.docbook:111
|
||||
msgid "Table per subclass, using a discriminator"
|
||||
msgstr "Une table par classe fille, en utilisant un discriminant"
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: index.docbook:136
|
||||
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"
|
||||
|
||||
#: index.docbook:138
|
||||
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 :"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "Une table par classe concrète"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:189
|
||||
msgid "Table per concrete class, using implicit polymorphism"
|
||||
msgstr "Une table par classe concrète, en utilisant le polymorphisme implicite"
|
||||
|
||||
#: index.docbook:191
|
||||
msgid "An alternative approach is to make use of implicit polymorphism:"
|
||||
msgstr "Une approche alternative est l'emploi du polymorphisme implicite :"
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:212
|
||||
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>."
|
||||
|
||||
#: 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 "Mélange du polymorphisme implicite avec d'autres mappings d'héritage"
|
||||
|
||||
#: 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 "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>)."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: index.docbook:249
|
||||
msgid "Limitations"
|
||||
msgstr "Limitations"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: index.docbook:258
|
||||
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."
|
||||
|
||||
#: index.docbook:264
|
||||
msgid "Features of inheritance mappings"
|
||||
msgstr "Caractéristiques du mapping d'héritage"
|
||||
|
||||
#: index.docbook:276
|
||||
msgid "Inheritance strategy"
|
||||
msgstr "Stratégie d'héritage"
|
||||
|
||||
#: index.docbook:277
|
||||
msgid "Polymorphic many-to-one"
|
||||
msgstr "many-to-one polymorphique"
|
||||
|
||||
#: index.docbook:278
|
||||
msgid "Polymorphic one-to-one"
|
||||
msgstr "one-to-one polymorphique"
|
||||
|
||||
#: index.docbook:279
|
||||
msgid "Polymorphic one-to-many"
|
||||
msgstr "one-to-many polymorphique"
|
||||
|
||||
#: index.docbook:280
|
||||
msgid "Polymorphic many-to-many"
|
||||
msgstr "many-to-many polymorphique"
|
||||
|
||||
#: index.docbook:281
|
||||
msgid "Polymorphic <literal>load()/get()</literal>"
|
||||
msgstr "<literal>load()/get()</literal> polymorphique"
|
||||
|
||||
#: index.docbook:282
|
||||
msgid "Polymorphic queries"
|
||||
msgstr "Requêtes polymorphiques"
|
||||
|
||||
#: index.docbook:283
|
||||
msgid "Polymorphic joins"
|
||||
msgstr "Jointures polymorphiques"
|
||||
|
||||
#: index.docbook:284
|
||||
msgid "Outer join fetching"
|
||||
msgstr "Récupération par jointure externe"
|
||||
|
||||
#: index.docbook:289
|
||||
msgid "table per class-hierarchy"
|
||||
msgstr "une table par hiérarchie de classe"
|
||||
|
||||
#: 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 "supportée"
|
||||
|
||||
#: index.docbook:300
|
||||
msgid "<entry>table per subclass</entry>"
|
||||
msgstr "une table par classe fille"
|
||||
|
||||
#: index.docbook:311
|
||||
msgid "table per concrete-class (union-subclass)"
|
||||
msgstr "une table par classe concrète (union-subclass)"
|
||||
|
||||
#: index.docbook:314
|
||||
msgid "<literal><one-to-many></literal> (for <literal>inverse=\"true\"</literal> only)"
|
||||
msgstr "<literal><one-to-many></literal> (pour <literal>inverse=\"true\"</literal> seulement)"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "table per concrete class (implicit polymorphism)"
|
||||
msgstr "une table par classe concrète (polymorphisme implicite)"
|
||||
|
||||
#: index.docbook:323
|
||||
msgid "<any>"
|
||||
msgstr "<any>"
|
||||
|
||||
#: index.docbook:324, index.docbook:325, index.docbook:329, index.docbook:330
|
||||
msgid "not supported"
|
||||
msgstr "non supporté"
|
||||
|
||||
#: 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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,660 @@
|
|||
#, 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 "Classes persistantes"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: index.docbook:23
|
||||
msgid "A simple POJO example"
|
||||
msgstr "Un exemple simple de POJO"
|
||||
|
||||
#: index.docbook:25
|
||||
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."
|
||||
|
||||
#: 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 "Il y a quatre règles à suivre ici :"
|
||||
|
||||
#: index.docbook:37
|
||||
msgid "Implement a no-argument constructor"
|
||||
msgstr "Implémenter un constructeur sans argument"
|
||||
|
||||
#: 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> 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."
|
||||
|
||||
#: index.docbook:49
|
||||
msgid "Provide an identifier property (optional)"
|
||||
msgstr "Fournir une propriété d'indentifiant (optionnel)"
|
||||
|
||||
#: 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> 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)."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: index.docbook:65
|
||||
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é :"
|
||||
|
||||
#: index.docbook:72
|
||||
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"
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "Prefer non-final classes (optional)"
|
||||
msgstr "Favoriser les classes non finales (optionnel)"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: index.docbook:115
|
||||
msgid "Declare accessors and mutators for persistent fields (optional)"
|
||||
msgstr "Déclarer les accesseurs et mutateurs des attributs persistants (optionnel)"
|
||||
|
||||
#: 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> 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."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: index.docbook:138
|
||||
msgid "Implementing inheritance"
|
||||
msgstr "Implémenter l'héritage"
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "Implémenter <literal>equals()</literal> et <literal>hashCode()</literal>"
|
||||
|
||||
#: index.docbook:151
|
||||
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"
|
||||
|
||||
#: 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 "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>"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "intend to use reattachment of detached instances"
|
||||
msgstr "avez l'intention d'utiliser le réattachement d'instances détachées"
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 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é."
|
||||
|
||||
#: 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 "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>) :"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "Dynamic models"
|
||||
msgstr "Modèles dynamiques"
|
||||
|
||||
#: index.docbook:215
|
||||
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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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\"/>)."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:265
|
||||
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> :"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:283
|
||||
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\"/>."
|
||||
|
||||
#: index.docbook:291
|
||||
msgid "Tuplizers"
|
||||
msgstr "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>, 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."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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.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 "TODO: Document user-extension framework in the property and proxy packages"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
#, 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 "Préface"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:48
|
||||
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 :"
|
||||
|
||||
#: 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 "Lisez <xref linkend=\"tutorial\"/> pour un didacticiel plus long avec plus d'instructions étape par étape."
|
||||
|
||||
#: index.docbook:63
|
||||
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é."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:90
|
||||
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."
|
||||
|
||||
#: index.docbook:95
|
||||
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."
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 "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)."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,672 @@
|
|||
#, 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 "Requêtes par critères"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "Hibernate features an intuitive, extensible criteria query API."
|
||||
msgstr "Hibernate offre une API d'interrogation par critères intuitive et extensible."
|
||||
|
||||
#: index.docbook:12
|
||||
msgid "Creating a <literal>Criteria</literal> instance"
|
||||
msgstr "Créer une instance 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 "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>."
|
||||
|
||||
#: 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 "Restriction du résultat"
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 "Les restrictions peuvent être goupées de manière logique."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "La zone <literal>{alias}</literal> sera remplacée par l'alias de colonne de l'entité que l'on souhaite intérroger."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "Trier les résultats"
|
||||
|
||||
#: index.docbook:70
|
||||
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>."
|
||||
|
||||
#: 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 "Associations"
|
||||
|
||||
#: index.docbook:83
|
||||
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>."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "The following, alternate form is useful in certain circumstances."
|
||||
msgstr "La forme alternative suivante est utile dans certains cas."
|
||||
|
||||
#: 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> ne crée pas de nouvelle instance 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 "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>."
|
||||
|
||||
#: 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"
|
||||
" .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"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:119
|
||||
msgid "Dynamic association fetching"
|
||||
msgstr "Peuplement d'associations de manière dynamique"
|
||||
|
||||
#: index.docbook:121
|
||||
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."
|
||||
|
||||
#: 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 "Cette requête recherchera <literal>mate</literal> et <literal>kittens</literal> via les jointures externes. Voir <xref linkend=\"performance-fetching\"/> pour plus d'informations."
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "Example queries"
|
||||
msgstr "Requêtes par l'exemple"
|
||||
|
||||
#: 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 classe <literal>org.hibernate.criterion.Example</literal> vous permet de construire un critère suivant une instance d'objet donnée."
|
||||
|
||||
#: 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 "Les propriétés de type version, identifiant et association sont ignorées. Par défaut, les valeurs null sont exclues."
|
||||
|
||||
#: index.docbook:150
|
||||
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>."
|
||||
|
||||
#: 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 "Vous pouvez utiliser les \"exemples\" pour des critères sur les objets associés."
|
||||
|
||||
#: 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 "Projections, agrégation et regroupement"
|
||||
|
||||
#: 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 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>."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "Vous pouvez aussi utiliser <literal>Property.forName()</literal> pour formuler des projections :"
|
||||
|
||||
#: 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 "Requêtes et sous-requêtes détachées"
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: 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 "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>."
|
||||
|
||||
#: 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 "Même des requêtes corrélées sont possibles :"
|
||||
|
||||
#: 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 "Requêtes par identifiant naturel"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "Notez que cette fonctionnalité n'est pas prévue pour l'utilisation avec des entités avec des clefs naturelles <emphasis>mutables</emphasis>."
|
||||
|
||||
#: index.docbook:267
|
||||
msgid "Next, enable the Hibernate query cache."
|
||||
msgstr "Ensuite, activez le cache de requête d'Hibernate."
|
||||
|
||||
#: index.docbook:271
|
||||
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."
|
||||
|
||||
#: 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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,742 @@
|
|||
#, 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 "Guide des outils"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "Roundtrip engineering with Hibernate is possible using a set of Eclipse plugins, commandline tools, as well as Ant tasks."
|
||||
msgstr "Des outils en ligne de commande, des plugins Eclipse ainsu que des tâches Ant permettent de gérer de cycles de développement complet de projets utilisant Hibernate."
|
||||
|
||||
#: 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 "Les <emphasis>outils Hibernate</emphasis> actuels incluent des plugins pour l'IDE Eclipse ainsi que des tâches Ant pour l'ingénierie inverse de bases de données existantes :"
|
||||
|
||||
#: 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>Mapping Editor :</emphasis> un éditeur pour les fichiers de mapping XML Hibernate, supportant l'auto-complétion et la mise en valeur de la syntaxe. Il supporte aussi l'auto-complétion automatique pour les noms de classes et les noms de propriété/champ, le rendant beaucoup plus polyvalent qu'un éditeurXML 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>Console :</emphasis> la console est une nouvelle vue d'Eclipse. En plus de la vue d'ensemble arborescente de vos configurations de console, vous obtenez aussi une vue interactive de vos classes persistantes et de leurs relations. La console vous permet d'exécuter des requête HQL dans votre base de données et de parcourir les résultats directement dans 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>Development Wizards :</emphasis> plusieurs assistants sont fournis avec les outils d'Hibernate pour Eclipse ; vous pouvez utiliser un assistant pour générer rapidement les fichiers de configuration d'Hibernate (cfg.xml), ou vous pouvez même complètement générer les fichiers de mapping Hibernate et les sources des POJOs à partir d'un schéma de base de données existant. L'assistant d'ingénierie inverse supporte les modèles utilisateur."
|
||||
|
||||
#: index.docbook:38
|
||||
msgid "Ant Tasks:"
|
||||
msgstr "Tâches Ant :"
|
||||
|
||||
#: index.docbook:43
|
||||
msgid "Please refer to the <emphasis>Hibernate Tools</emphasis> package and it's documentation for more information."
|
||||
msgstr "Veuillez-vous référer au paquet <emphasis>outils Hibernate</emphasis> et sa documentation pour plus d'informations."
|
||||
|
||||
#: 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 "Pourtant, le paquet principal d'Hibernate arrive avec un lot d'outils intégrés (il peut même être utilisé de \"l'intérieur\" d'Hibernate à la volée) : <emphasis>SchemaExport</emphasis> aussi connu comme <literal>hbm2ddl</literal>."
|
||||
|
||||
#: index.docbook:55
|
||||
msgid "Automatic schema generation"
|
||||
msgstr "Génération automatique du schéma"
|
||||
|
||||
#: 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 "La DDL peut être générée à partir de vos fichiers de mapping par un utilitaire d'Hibernate. Le schéma généré inclut les contraintes d'intégrité référentielle (clefs primaires et étrangères) pour les tables d'entités et de collections. Les tables et les séquences sont aussi créées pour les générateurs d'identifiant mappés."
|
||||
|
||||
#: 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 "Vous <emphasis>devez</emphasis> spécifier un <literal>Dialect</literal> SQL via la propriété <literal>hibernate.dialect</literal> lors de l'utilisation de cet outils, puisque la DDL est fortement dépendante de la base de données."
|
||||
|
||||
#: index.docbook:70
|
||||
msgid "First, customize your mapping files to improve the generated schema."
|
||||
msgstr "D'abord, personnalisez vos fichiers de mapping pour améliorer le schéma généré."
|
||||
|
||||
#: index.docbook:75
|
||||
msgid "Customizing the schema"
|
||||
msgstr "Personnaliser le schéma"
|
||||
|
||||
#: 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 "Plusieurs éléments du mapping hibernate définissent des attributs optionnels nommés <literal>length</literal>, <literal>precision</literal> et <literal>scale</literal>. Vous pouvez paramétrer la longueur, la précision,... d'une colonne avec ces attributs."
|
||||
|
||||
#: 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 "Certains éléments acceptent aussi un attribut <literal>not-null</literal> (utilisé pour générer les contraintes de colonnes <literal>NOT NULL</literal>) et un attribut <literal>unique</literal> (pour générer une contrainte de colonne <literal>UNIQUE</literal>)."
|
||||
|
||||
#: 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 "Un attribut <literal>unique-key</literal> peut être utilisé pour grouper les colonnes en une seule contrainte d'unicité. Actuellement, la valeur spécifiée par l'attribut <literal>unique-key</literal> n'est <emphasis>pas</emphasis> utilisée pour nommer la contrainte dans le DDL généré, elle sert juste à grouper les colonnes dans le fichier de mapping."
|
||||
|
||||
#: 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=\"OrgEmployeeId\"/>]]>"
|
||||
|
||||
#: 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 "Un attribut <literal>index</literal> indique le nom d'un index qui sera créé en utilisant la ou les colonnes mappées. Plusieurs colonnes peuvent être groupées dans un même index, en spécifiant le même nom d'index."
|
||||
|
||||
#: 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 "Un attribut <literal>foreign-key</literal> peut être utilisé pour surcharger le nom des clés étrangères générées."
|
||||
|
||||
#: 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 "Plusieurs éléments de mapping acceptent aussi un élément fils <literal><column></literal>. Ceci est utile pour les type multi-colonnes:"
|
||||
|
||||
#: 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 "L'attribut <literal>default</literal> vous laisse spécifier une valeur par défaut pour une colonnes (vous devriez assigner la même valeur à la propriété mappée avant de sauvegarder une nouvelle instance de la classe mappée)."
|
||||
|
||||
#: 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 "L'attribut <literal>sql-type</literal> laisse l'utilisateur surcharger le mapping par défaut du type Hibernate vers un type 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 "L'attribut <literal>check</literal> permet de spécifier une contrainte de vérification."
|
||||
|
||||
#: 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 "Summary"
|
||||
|
||||
#: index.docbook:163
|
||||
msgid "Attribute"
|
||||
msgstr "Attribut"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "Values"
|
||||
msgstr "Valeur"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "Interpretation"
|
||||
msgstr "Interprétation"
|
||||
|
||||
#: index.docbook:170
|
||||
msgid "length"
|
||||
msgstr "length"
|
||||
|
||||
#: index.docbook:171, index.docbook:176, index.docbook:181
|
||||
msgid "number"
|
||||
msgstr "numérique"
|
||||
|
||||
#: index.docbook:172
|
||||
msgid "column length"
|
||||
msgstr "taille d'une colonne"
|
||||
|
||||
#: index.docbook:175
|
||||
msgid "precision"
|
||||
msgstr "precision"
|
||||
|
||||
#: index.docbook:177
|
||||
msgid "column decimal precision"
|
||||
msgstr "précision décimale de la colonne"
|
||||
|
||||
#: index.docbook:180
|
||||
msgid "scale"
|
||||
msgstr "scale"
|
||||
|
||||
#: index.docbook:182
|
||||
msgid "column decimal scale"
|
||||
msgstr "scale décimale de la colonne"
|
||||
|
||||
#: 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 "spécifie que la colonne doit être non-nulle"
|
||||
|
||||
#: index.docbook:190
|
||||
msgid "unique"
|
||||
msgstr "unique"
|
||||
|
||||
#: index.docbook:192
|
||||
msgid "specifies that the column should have a unique constraint"
|
||||
msgstr "spécifie que la colonne doit avoir une contrainte d'unicité"
|
||||
|
||||
#: 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 "spécifie le nom d'un index (multi-colonnes)"
|
||||
|
||||
#: 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 "spécifie le nom d'une contrainte d'unicité multi-colonnes"
|
||||
|
||||
#: 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 "spécifie le nom d'une contrainte de clé étrangère générée pour une association, utilisez-la avec les éléments de mapping <one-to-one>, <many-to-one>, <key>, et <many-to-many> Notez que les extrêmités <literal>inverse=\"true\"</literal> se seront pas prises en compte par <literal>SchemaExport</literal>."
|
||||
|
||||
#: index.docbook:217
|
||||
msgid "sql-type"
|
||||
msgstr "sql-type"
|
||||
|
||||
#: index.docbook:218
|
||||
msgid "SQL column type"
|
||||
msgstr "SQL column_type"
|
||||
|
||||
#: index.docbook:219
|
||||
msgid "overrides the default column type (attribute of <literal><column></literal> element only)"
|
||||
msgstr "surcharge le type par défaut (attribut de l'élément <literal><column></literal> uniquement)"
|
||||
|
||||
#: index.docbook:225
|
||||
msgid "default"
|
||||
msgstr "default"
|
||||
|
||||
#: index.docbook:226, index.docbook:233
|
||||
msgid "SQL expression"
|
||||
msgstr "expression SQL"
|
||||
|
||||
#: index.docbook:227
|
||||
msgid "specify a default value for the column"
|
||||
msgstr "spécifie une valeur par défaut pour la colonne"
|
||||
|
||||
#: index.docbook:232
|
||||
msgid "check"
|
||||
msgstr "check"
|
||||
|
||||
#: index.docbook:234
|
||||
msgid "create an SQL check constraint on either column or table"
|
||||
msgstr "crée une contrainte de vérification sur la table ou la colonne"
|
||||
|
||||
#: index.docbook:242
|
||||
msgid "The <literal><comment></literal> element allows you to specify comments for the generated schema."
|
||||
msgstr "L'élément <literal><comment></literal> vous permet de spécifier un commentaire pour le schéma généré."
|
||||
|
||||
#: 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 "Ceci a pour résultat une expression <literal>comment on table</literal> ou <literal>comment on column</literal> dans la DDL générée (où supportée)."
|
||||
|
||||
#: index.docbook:260
|
||||
msgid "Running the tool"
|
||||
msgstr "Exécuter l'outil"
|
||||
|
||||
#: index.docbook:262
|
||||
msgid "The <literal>SchemaExport</literal> tool writes a DDL script to standard out and/or executes the DDL statements."
|
||||
msgstr "L'outil <literal>SchemaExport</literal> génère un script DDL vers la sortie standard et/ou exécute les ordres 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>classpath_hibernate</emphasis> <literal>net.sf.hibernate.tool.hbm2ddl.SchemaExport</literal> <emphasis>options fichiers_de_mapping</emphasis>"
|
||||
|
||||
#: index.docbook:273
|
||||
msgid "<literal>SchemaExport</literal> Command Line Options"
|
||||
msgstr "<literal>SchemaExport</literal> Options de la ligne de commande"
|
||||
|
||||
#: index.docbook:279, index.docbook:429, index.docbook:498
|
||||
msgid "Option"
|
||||
msgstr "Option"
|
||||
|
||||
#: index.docbook:280, index.docbook:367, index.docbook:430, index.docbook:499
|
||||
msgid "Description"
|
||||
msgstr "Description"
|
||||
|
||||
#: 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 "ne pas écrire le script vers la sortie standard"
|
||||
|
||||
#: index.docbook:289
|
||||
msgid "--drop"
|
||||
msgstr "--drop"
|
||||
|
||||
#: index.docbook:290
|
||||
msgid "only drop the tables"
|
||||
msgstr "supprime seuleument les tables"
|
||||
|
||||
#: index.docbook:293
|
||||
msgid "--create"
|
||||
msgstr "--create"
|
||||
|
||||
#: index.docbook:294
|
||||
msgid "only create the tables"
|
||||
msgstr "ne créé que les tables"
|
||||
|
||||
#: index.docbook:297, index.docbook:439
|
||||
msgid "--text"
|
||||
msgstr "--text"
|
||||
|
||||
#: index.docbook:298
|
||||
msgid "don't export to the database"
|
||||
msgstr "ne pas exécuter sur la base de données"
|
||||
|
||||
#: 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 "écrit le script ddl vers un fichier"
|
||||
|
||||
#: 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 "sélectionne une <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 "lit la configuration Hibernate à partir d'un fichier 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 "lit les propriétés de la base de données à partir d'un fichier"
|
||||
|
||||
#: index.docbook:317
|
||||
msgid "--format"
|
||||
msgstr "--format"
|
||||
|
||||
#: index.docbook:318
|
||||
msgid "format the generated SQL nicely in the script"
|
||||
msgstr "formatte proprement le SQL généré dans le script"
|
||||
|
||||
#: index.docbook:321
|
||||
msgid "--delimiter=;"
|
||||
msgstr "--delimiter=x"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "set an end of line delimiter for the script"
|
||||
msgstr "paramètre un délimiteur de fin de ligne pour le script"
|
||||
|
||||
#: index.docbook:328
|
||||
msgid "You may even embed <literal>SchemaExport</literal> in your application:"
|
||||
msgstr "Vous pouvez même intégrer <literal>SchemaExport</literal> dans votre application :"
|
||||
|
||||
#: 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 "Propriétés"
|
||||
|
||||
#: index.docbook:339
|
||||
msgid "Database properties may be specified"
|
||||
msgstr "Les propriétés de la base de données peuvent être spécifiées"
|
||||
|
||||
#: index.docbook:345
|
||||
msgid "as system properties with <literal>-D</literal><emphasis><property></emphasis>"
|
||||
msgstr "comme propriétés système avec <literal>-D</literal><emphasis><property></emphasis>"
|
||||
|
||||
#: index.docbook:348
|
||||
msgid "in <literal>hibernate.properties</literal>"
|
||||
msgstr "dans <literal>hibernate.properties</literal>"
|
||||
|
||||
#: index.docbook:351
|
||||
msgid "in a named properties file with <literal>--properties</literal>"
|
||||
msgstr "dans un fichier de propriétés déclaré avec <literal>--properties</literal>"
|
||||
|
||||
#: index.docbook:355
|
||||
msgid "The needed properties are:"
|
||||
msgstr "Les propriétés nécessaires sont :"
|
||||
|
||||
#: index.docbook:360
|
||||
msgid "SchemaExport Connection Properties"
|
||||
msgstr "SchemaExport Connection Properties"
|
||||
|
||||
#: index.docbook:366
|
||||
msgid "Property Name"
|
||||
msgstr "Nom de la propriété"
|
||||
|
||||
#: index.docbook:372
|
||||
msgid "hibernate.connection.driver_class"
|
||||
msgstr "hibernate.connection.driver_class"
|
||||
|
||||
#: index.docbook:373
|
||||
msgid "jdbc driver class"
|
||||
msgstr "classe du driver JDBC"
|
||||
|
||||
#: index.docbook:376
|
||||
msgid "hibernate.connection.url"
|
||||
msgstr "hibernate.connection.url"
|
||||
|
||||
#: index.docbook:377
|
||||
msgid "jdbc url"
|
||||
msgstr "URL JDBC"
|
||||
|
||||
#: index.docbook:380
|
||||
msgid "hibernate.connection.username"
|
||||
msgstr "hibernate.connection.username"
|
||||
|
||||
#: index.docbook:381
|
||||
msgid "database user"
|
||||
msgstr "utilisateur de la base de données"
|
||||
|
||||
#: index.docbook:384
|
||||
msgid "hibernate.connection.password"
|
||||
msgstr "hibernate.connection.password"
|
||||
|
||||
#: index.docbook:385
|
||||
msgid "user password"
|
||||
msgstr "mot de passe de l'utilisateur"
|
||||
|
||||
#: index.docbook:388
|
||||
msgid "hibernate.dialect"
|
||||
msgstr "hibernate.dialect"
|
||||
|
||||
#: index.docbook:389
|
||||
msgid "dialect"
|
||||
msgstr "dialecte"
|
||||
|
||||
#: index.docbook:398
|
||||
msgid "Using Ant"
|
||||
msgstr "Utiliser Ant"
|
||||
|
||||
#: index.docbook:400
|
||||
msgid "You can call <literal>SchemaExport</literal> from your Ant build script:"
|
||||
msgstr "Vous pouvez appeler <literal>SchemaExport</literal> depuis votre script de construction 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 "Mises à jour incrémentales du schéma"
|
||||
|
||||
#: 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 "L'outil <literal>SchemaUpdate</literal> mettra à jour un schéma existant en effectuant les changement par \"incrément\". Notez que <literal>SchemaUpdate</literal> dépends beaucoup de l'API JDBC metadata, il ne fonctionnera donc pas avec tous les 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>classpath_hibernate</emphasis> <literal>net.sf.hibernate.tool.hbm2ddl.SchemaUpdate</literal> <emphasis>options fichiers_de_mapping</emphasis>"
|
||||
|
||||
#: index.docbook:423
|
||||
msgid "<literal>SchemaUpdate</literal> Command Line Options"
|
||||
msgstr "<literal>SchemaUpdate</literal> Options de ligne de commande"
|
||||
|
||||
#: index.docbook:440
|
||||
msgid "don't export the script to the database"
|
||||
msgstr "ne pas exporter vers la base de données"
|
||||
|
||||
#: index.docbook:452, index.docbook:513
|
||||
msgid "specify a <literal>.cfg.xml</literal> file"
|
||||
msgstr ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaUpdate(cfg).execute(false);]]>"
|
||||
|
||||
#: index.docbook:458
|
||||
msgid "You may embed <literal>SchemaUpdate</literal> in your application:"
|
||||
msgstr "Utiliser Ant pour des mises à jour de schéma par incrément"
|
||||
|
||||
#: index.docbook:462
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaUpdate(cfg).execute(false);]]>"
|
||||
msgstr "Vous pouvez appeler <literal>SchemaUpdate</literal> depuis le script Ant :"
|
||||
|
||||
#: index.docbook:467
|
||||
msgid "Using Ant for incremental schema updates"
|
||||
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:469
|
||||
msgid "You can call <literal>SchemaUpdate</literal> from the Ant script:"
|
||||
msgstr "Validation du schéma"
|
||||
|
||||
#: 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 "L'outil <literal>SchemaValidator</literal> validera que le schéma existant correspond à vos documents de mapping. Notez que le <literal>SchemaValidator</literal> dépends de l'API metadata de JDBC, il ne fonctionnera donc pas avec tous les drivers JDBC. Cet outil est extrêmement utile pour tester."
|
||||
|
||||
#: index.docbook:478
|
||||
msgid "Schema validation"
|
||||
msgstr "<literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis> <literal>org.hibernate.tool.hbm2ddl.SchemaValidator</literal> <emphasis>options mapping_files</emphasis>"
|
||||
|
||||
#: 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 "<literal>SchemaValidator</literal> Options de ligne de commande"
|
||||
|
||||
#: 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 "Option"
|
||||
|
||||
#: index.docbook:492
|
||||
msgid "<literal>SchemaValidator</literal> Command Line Options"
|
||||
msgstr "Description"
|
||||
|
||||
#: index.docbook:519
|
||||
msgid "You may embed <literal>SchemaValidator</literal> in your application:"
|
||||
msgstr "Utiliser Ant pour la validation du Schéma"
|
||||
|
||||
#: index.docbook:523
|
||||
msgid ""
|
||||
"<![CDATA[Configuration cfg = ....;\n"
|
||||
"new SchemaValidator(cfg).validate();]]>"
|
||||
msgstr "Vous pouvez appeler <literal>SchemaValidator</literal> depuis le script Ant:"
|
||||
|
||||
#: index.docbook:528
|
||||
msgid "Using Ant for schema validation"
|
||||
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>]]>"
|
||||
|
||||
#: index.docbook:530
|
||||
msgid "You can call <literal>SchemaValidator</literal> from the Ant script:"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,791 @@
|
|||
#, 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 "Transactions And Concurrency"
|
||||
msgstr "Transactions et accès concurrents"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "The most important point about Hibernate and concurrency control is that it is very easy to understand. Hibernate directly uses JDBC connections and JTA resources without adding any additional locking behavior. We highly recommend you spend some time with the JDBC, ANSI, and transaction isolation specification of your database management system."
|
||||
msgstr "L'un des principaux avantages du mécanisme de contrôle des accès concurrents d'Hibernate est qu'il est très facile à comprendre. Hibernate utilise directement les connexions JDBC ainsi que les ressources JTA sans y ajouter davantage de mécanisme de blocage. Nous vous recommandons de vous familiariser avec les spécifications JDBC, ANSI et d'isolement de transaction de la base de données que vous utilisez."
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Hibernate does not lock objects in memory. Your application can expect the behavior as defined by the isolation level of your database transactions. Note that thanks to the <literal>Session</literal>, which is also a transaction-scoped cache, Hibernate provides repeatable reads for lookup by identifier and entity queries (not reporting queries that return scalar values)."
|
||||
msgstr "Hibernate ne vérouille pas vos objets en mémoire. Votre application peut suivre le comportement défini par le niveau d'isolation de vos transactions de base de données. Notez que grâce à la <literal>Session</literal>, qui est aussi un cache de scope transaction, Hibernate fournit des lectures répétées pour les récupération par identifiants et les requêtes d'entités (pas celle de valeurs scalaires)."
|
||||
|
||||
#: index.docbook:22
|
||||
msgid "In addition to versioning for automatic optimistic concurrency control, Hibernate also offers a (minor) API for pessimistic locking of rows, using the <literal>SELECT FOR UPDATE</literal> syntax. Optimistic concurrency control and this API are discussed later in this chapter."
|
||||
msgstr "En addition au versionning pour le controle automatique de concurrence, Hibernate fournit une API (mineure) pour le verrouillage perssimiste des enregistrements, en générant une syntaxe <literal>SELECT FOR UPDATE</literal>. Le controle de concurrence optimiste et cette API seront détaillés plus tard dans ce chapitre."
|
||||
|
||||
#: index.docbook:29
|
||||
msgid "We start the discussion of concurrency control in Hibernate with the granularity of <literal>Configuration</literal>, <literal>SessionFactory</literal>, and <literal>Session</literal>, as well as database transactions and long conversations."
|
||||
msgstr "Nous aborderons la gestion des accès concurrents en discutant de la granularité des objets <literal>Configuration</literal>, <literal>SessionFactory</literal>, et <literal>Session</literal>, ainsi que de certains concepts relatifs à la base de données et aux longues transactions applicatives."
|
||||
|
||||
#: index.docbook:36
|
||||
msgid "Session and transaction scopes"
|
||||
msgstr "Gestion de session et délimitation de transactions"
|
||||
|
||||
#: index.docbook:38
|
||||
msgid "A <literal>SessionFactory</literal> is an expensive-to-create, threadsafe object intended to be shared by all application threads. It is created once, usually on application startup, from a <literal>Configuration</literal> instance."
|
||||
msgstr "Il est important de savoir qu'un objet <literal>SessionFactory</literal> est un objet complexe et optimisé pour fonctionner avec les threads(thread- safe). Il est coûteux à créer et est ainsi prévu pour n'être instancié qu?une seule fois via un objet <literal>Configuration</literal> au démarrage de l'application, et être partagé par tous les threads d'une application."
|
||||
|
||||
#: index.docbook:44
|
||||
msgid "A <literal>Session</literal> is an inexpensive, non-threadsafe object that should be used once, for a single request, a conversation, single unit of work, and then discarded. A <literal>Session</literal> will not obtain a JDBC <literal>Connection</literal> (or a <literal>Datasource</literal>) unless it is needed, hence consume no resources until used."
|
||||
msgstr "Un objet <literal>Session</literal> est relativement simple et n'est threadsafe. Il est également peu coûteux à créer. Il devrait n'être utilisé qu'une seule fois, pour un processus d'affaire ou une unité de travail ou une conversation et ensuite être relâché. Un objet <literal>Session</literal> ne tentera pas d'obtenir de connexion ( <literal>Connection</literal> ) JDBC (ou de <literal>Datasource</literal> ) si ce n'est pas nécessaire."
|
||||
|
||||
#: index.docbook:52
|
||||
msgid "To complete this picture you also have to think about database transactions. A database transaction has to be as short as possible, to reduce lock contention in the database. Long database transactions will prevent your application from scaling to highly concurrent load. Hence, it is almost never good design to hold a database transaction open during user think time, until the unit of work is complete."
|
||||
msgstr "Afin de compléter ce tableau, vous devez également penser aux transactions de base de données. Une transaction de base de données se doit d'être la plus courte possible afin de réduire les risques de collision sur des enregistrements verrouillés. De longues transactions à la base de données nuiront à l'extensibilité de vos applications lorsque confrontées à de hauts niveaux de charge. Par conséquent, il n'est jamais bon de maintenir une transaction ouverte pendant la durée de reflexion de l'utilisateur, jusqu'a ce que l'unité de travail soit achevée."
|
||||
|
||||
#: index.docbook:61
|
||||
msgid "What is the scope of a unit of work? Can a single Hibernate <literal>Session</literal> span several database transactions or is this a one-to-one relationship of scopes? When should you open and close a <literal>Session</literal> and how do you demarcate the database transaction boundaries?"
|
||||
msgstr "Maintenant, comment délimiter une unité de travail? Est-ce qu'une instance de <literal>Session</literal> peut avoir une durée de vie dépassant plusieurs transactions à la base de données, ou bien est-ce que celles-ci doivent être liées une à une? Quand faut-il ouvrir et fermer une <literal>Session</literal> ? Comment définir la démarcation de vos transactions à la base de données?"
|
||||
|
||||
#: index.docbook:69
|
||||
msgid "Unit of work"
|
||||
msgstr "Unité de travail"
|
||||
|
||||
#: index.docbook:71
|
||||
msgid "First, don't use the <emphasis>session-per-operation</emphasis> antipattern, that is, don't open and close a <literal>Session</literal> for every simple database call in a single thread! Of course, the same is true for database transactions. Database calls in an application are made using a planned sequence, they are grouped into atomic units of work. (Note that this also means that auto-commit after every single SQL statement is useless in an application, this mode is intended for ad-hoc SQL console work. Hibernate disables, or expects the application server to do so, auto-commit mode immediately.) Database transactions are never optional, all communication with a database has to occur inside a transaction, no matter if you read or write data. As explained, auto-commit behavior for reading data should be avoided, as many small transactions are unlikely to perform better than one clearly defined unit of work. The latter is also much more maintainable and extensible."
|
||||
msgstr "Il est important de mentionner que d'utiliser un paradigme <emphasis>session-par-operation</emphasis> est un anti-pattern. Autrement dit: n'ouvrez et ne fermez pas la <literal>Session</literal> à chacun de vos accès simples à la base de données dans un même thread! Bien sûr, le même raisonnement s'applique sur la gestion des transactions à la base de données. Les appels à la base de données devraient être faits en ordre et selon une séquence définie. Ils devraient également être regroupés en des unités de travail atomiques. (Notez que l?utilisation d?une connexion auto-commit constitue le même anti-pattern. Ce mode de fonctionnement existe pour les applications émettant des commandes SQL à partir d?une console. Hibernate désengage le mode auto-commit et s'attend à ce qu'un serveur d'applications le fasse également.) Les transactions avec la base de données ne sont jamais optionnelles, toute communication avec une base de données doit se dérouler dans une transaction, peu importe si vous lisez ou écrivez des données. Comme évoqué, le comportement auto-commit pour lire les données devrait être évité, puisque plusieurs petites transactions ne seront jamais aussi efficaces qu'une seule plus grosse clairement définie comme unité de travail. Ce dernier choix et en plus beaucoup plus facile a maintenir et à faire évoluer."
|
||||
|
||||
#: index.docbook:87
|
||||
msgid "The most common pattern in a multi-user client/server application is <emphasis>session-per-request</emphasis>. In this model, a request from the client is send to the server (where the Hibernate persistence layer runs), a new Hibernate <literal>Session</literal> is opened, and all database operations are executed in this unit of work. Once the work has been completed (and the response for the client has been prepared), the session is flushed and closed. You would also use a single database transaction to serve the clients request, starting and committing it when you open and close the <literal>Session</literal>. The relationship between the two is one-to-one and this model is a perfect fit for many applications."
|
||||
msgstr "Le pattern d'utilisation le plus fréquemment rencontré dans des applications clients serveur multi-usagers est le <emphasis>session-per-request</emphasis> (littéralement : Session par requête). Dans ce modèle, la requête d'un client est envoyée à un serveur (Où la couche de persistance est implémentée via Hibernate), une nouvelle <literal>Session</literal> est ouverte et toutes les opérations d'accès à la base de données sont exécutées à l'intérieur de celle-ci. Lorsque le travail est terminé (et que les réponses à envoyer au client ont été préparées), la session est flushée et fermée. Une seule transaction à la base de données peut être utilisée pour répondre à la requête du client. La transaction est démarrée et validée au même moment où la Session est ouverte et fermée. La relation entre la <literal>Session</literal> et la <literal>Transaction</literal> est donc one-to-one. Ce modèle permet de répondre parfaitement aux attentes de la grande majorité des applications."
|
||||
|
||||
#: index.docbook:99
|
||||
msgid "The challenge lies in the implementation. Hibernate provides built-in management of the \"current session\" to simplify this pattern. All you have to do is start a transaction when a server request has to be processed, and end the transaction before the response is send to the client. You can do this in any way you like, common solutions are <literal>ServletFilter</literal>, AOP interceptor with a pointcut on the service methods, or a proxy/interception container. An EJB container is a standardized way to implement cross-cutting aspects such as transaction demarcation on EJB session beans, declaratively with CMT. If you decide to use programmatic transaction demarcation, prefer the Hibernate <literal>Transaction</literal> API shown later in this chapter, for ease of use and code portability."
|
||||
msgstr "Le défi réside dans l'implémentation. Hibernate fournit une fonction de gestion de la \"session courante\" pour simplifier ce pattern. Tout ce que vous devez faire est démarrer une transaction lorsqu'une requête est traitée par le serveur, et la terminer avant que la réponse ne soit envoyée au client. Vous pouvez le faire de la manière que vous voulez, les solutions communes sont un <literal>ServletFilter</literal>, l'interception via AOP avec une pointcut sur les méthodes de type \"service\", ou un conteneur avec interception/proxy. Un conteneur EJB est un moyen standard d'implémenter ce genre d'acpect tranverse comme la démarcation des transactions sur les EJBs session, de manière déclarative avec CMT. Si vous décidez d'utiliser la démarcation programmatique des transactions, préferrez l'API Hibernate <literal>Transaction</literal> détaillée plus tard dans ce chapitre, afin de facilité l'utilisation et la portabilité du code."
|
||||
|
||||
#: index.docbook:112
|
||||
msgid "Your application code can access a \"current session\" to process the request by simply calling <literal>sessionFactory.getCurrentSession()</literal> anywhere and as often as needed. You will always get a <literal>Session</literal> scoped to the current database transaction. This has to be configured for either resource-local or JTA environments, see <xref linkend=\"architecture-current-session\"/>."
|
||||
msgstr "Votre application peut accéder la \"session courante\" pour exécuter une requête en invoquant simplement <literal>sessionFactory.getCurrentSession()</literal> n'importe où et autant de fois que souhaité. Vous obtiendrez toujours une <literal>Session</literal> dont le scope est la transaction courante avec la base de données. Ceci doit être configuré soit dans les ressources local ou dans l'environnement JTA, voir <xref linkend=\"architecture-current-session\"/>."
|
||||
|
||||
#: index.docbook:120
|
||||
msgid "Sometimes it is convenient to extend the scope of a <literal>Session</literal> and database transaction until the \"view has been rendered\". This is especially useful in servlet applications that utilize a separate rendering phase after the request has been processed. Extending the database transaction until view rendering is complete is easy to do if you implement your own interceptor. However, it is not easily doable if you rely on EJBs with container-managed transactions, as a transaction will be completed when an EJB method returns, before rendering of any view can start. See the Hibernate website and forum for tips and examples around this <emphasis>Open Session in View</emphasis> pattern."
|
||||
msgstr "Il est parfois utile d'étendre le scope d'une <literal>Session</literal> et d'une transaction à la base de données jusqu'à ce que \"la vue soit rendue\". Ceci est particulièrement utile dans des applications à base de servlet qui utilisent une phase de rendue séparée une fois que la réponse a été préparée. Etendre la transaction avec la base de données jusqu'à la fin du rendering de la vue est aisé si vous implémentez votre propre intercepteur. Cependant, ce n'est pas facile si vous vous appuyez sur les EJBs avec CMT, puisqu'une transaction sera achevée au retour de la méthode EJB, avant le rendu de la vue. Rendez vous sur le site Hibernate et sur le forum pour des astuces et des exemples sur le pattern <emphasis>Open Session in View</emphasis> pattern.."
|
||||
|
||||
#: index.docbook:135
|
||||
msgid "Long conversations"
|
||||
msgstr "Longue conversation"
|
||||
|
||||
#: index.docbook:137
|
||||
msgid "The session-per-request pattern is not the only useful concept you can use to design units of work. Many business processes require a whole series of interactions with the user interleaved with database accesses. In web and enterprise applications it is not acceptable for a database transaction to span a user interaction. Consider the following example:"
|
||||
msgstr "Le paradigme <emphasis>session-per-request</emphasis> n'est pas le seul élément à utiliser dans le design de vos unités de travail. Plusieurs processus d'affaire requièrent toute une série d'interactions avec l'utilisateur, entrelacées d'accès à la base de donnée. Dans une application Web ou une application d'entreprise, il serait inacceptable que la durée de vie d'une transaction s'étale sur plusieurs interactions avec l'usager. Considérez l'exemple suivant:"
|
||||
|
||||
#: index.docbook:147
|
||||
msgid "The first screen of a dialog opens, the data seen by the user has been loaded in a particular <literal>Session</literal> and database transaction. The user is free to modify the objects."
|
||||
msgstr "Un écran s'affiche. Les données vues par l'usager ont été chargées dans l'instance d'un objet <literal>Session</literal> , dans le cadre d'une transaction de base de données. L'usager est libre de modifier ces objets."
|
||||
|
||||
#: index.docbook:154
|
||||
msgid "The user clicks \"Save\" after 5 minutes and expects his modifications to be made persistent; he also expects that he was the only person editing this information and that no conflicting modification can occur."
|
||||
msgstr "L'usager clique \"Sauvegarder\" après 5 minutes et souhaite persister les modifications qu'il a apportées. Il s'attend à être la seule personne a avoir modifié ces données et qu'aucune modification conflictuelle ne se soit produite durant ce laps de temps."
|
||||
|
||||
#: index.docbook:162
|
||||
msgid "We call this unit of work, from the point of view of the user, a long running <emphasis>conversation</emphasis> (or <emphasis>application transaction</emphasis>). There are many ways how you can implement this in your application."
|
||||
msgstr "Ceci s'appelle une unité de travail. Du point de vue de l'utilisateur: une <emphasis>conversation</emphasis> (ou <emphasis>transaction d'application</emphasis>). Il y a plusieurs façon de mettre ceci en place dans votre application."
|
||||
|
||||
#: index.docbook:168
|
||||
msgid "A first naive implementation might keep the <literal>Session</literal> and database transaction open during user think time, with locks held in the database to prevent concurrent modification, and to guarantee isolation and atomicity. This is of course an anti-pattern, since lock contention would not allow the application to scale with the number of concurrent users."
|
||||
msgstr "Une première implémentation naïve pourrait consister à garder la <literal>Session</literal> et la transaction à la base de données ouvertes durant le temps de travail de l'usager, à maintenir les enregistrements verrouillés dans la base de données afin d'éviter des modifications concurrentes et de maintenir l'isolation et l'atomicité de la transaction de l'usager. Ceci est un anti-pattern à éviter, puisque le verrouillage des enregistrements dans la base de données ne permettrait pas à l'application de gérer un grand nombre d'usagers concurrents."
|
||||
|
||||
#: index.docbook:176
|
||||
msgid "Clearly, we have to use several database transactions to implement the converastion. In this case, maintaining isolation of business processes becomes the partial responsibility of the application tier. A single conversation usually spans several database transactions. It will be atomic if only one of these database transactions (the last one) stores the updated data, all others simply read data (e.g. in a wizard-style dialog spanning several request/response cycles). This is easier to implement than it might sound, especially if you use Hibernate's features:"
|
||||
msgstr "Il apparaît donc évident qu'il faille utiliser plusieurs transactions BDD afin d'implémenter la conversation. Dans ce cas, maintenir l'isolation des processus d'affaire devient partiellement la responsabilité de la couche applicative. Ainsi, la durée de vie d'une conversation devrait englober celle d'une ou de plusieurs transactions de base de données. Celle-ci sera atomique seulement si l'écriture des données mises à jour est faite exclusivement par la dernière transaction BDD la composant. Toutes les autres sous transactions BD ne doivent faire que la lecture de données. Ceci est relativement facile à mettre en place, surtout avec l'utilisation de certaines fonctionnalités d'Hibernate:"
|
||||
|
||||
#: index.docbook:189
|
||||
msgid "<emphasis>Automatic Versioning</emphasis> - Hibernate can do automatic optimistic concurrency control for you, it can automatically detect if a concurrent modification occured during user think time. Usually we only check at the end of the conversation."
|
||||
msgstr "<emphasis>Versionnage Automatique</emphasis> - Hibernate peut gérer automatiquement les accès concurrents de manière optimiste et détecter si une modification concurrente s'est produite durant le temps de réflexion d'un usager."
|
||||
|
||||
#: index.docbook:197
|
||||
msgid "<emphasis>Detached Objects</emphasis> - If you decide to use the already discussed <emphasis>session-per-request</emphasis> pattern, all loaded instances will be in detached state during user think time. Hibernate allows you to reattach the objects and persist the modifications, the pattern is called <emphasis>session-per-request-with-detached-objects</emphasis>. Automatic versioning is used to isolate concurrent modifications."
|
||||
msgstr "<emphasis>Objets Détachés</emphasis> - Si vous décidez d'utiliser le paradigme <emphasis>session-par-requête</emphasis> discuté plus haut, toutes les entités chargées en mémoire deviendront des objets détachés durant le temps de réflexion de l'usager. Hibernate vous permet de rattacher ces objets et de persister les modifications y ayant été apportées. Ce pattern est appelé: <emphasis>session-per- request-with-detached-objects</emphasis> (littéralement: session- par-requête-avec-objets-détachés). Le versionnage automatique est utilisé afin d'isoler les modifications concurrentes."
|
||||
|
||||
#: index.docbook:207
|
||||
msgid "<emphasis>Extended (or Long) Session</emphasis> - The Hibernate <literal>Session</literal> may be disconnected from the underlying JDBC connection after the database transaction has been committed, and reconnected when a new client request occurs. This pattern is known as <emphasis>session-per-conversation</emphasis> and makes even reattachment unnecessary. Automatic versioning is used to isolate concurrent modifications and the <literal>Session</literal> is usually not allowed to be flushed automatically, but explicitely."
|
||||
msgstr "<emphasis>Session Longues (conversation)</emphasis> - Une <literal>Session</literal> Hibernate peut être déconnectée de la couche JDBC sous-jacente après que commit() ait été appelé sur une transaction à la base de données et reconnectée lors d'une nouvelle requête-client. Ce pattern s'appelle: <emphasis>session-per-conversation</emphasis> (Littéralement: session-par- conversation) et rend superflu le rattachement des objets. Le versionnage automatique est utilisé afin d'isoler les modifications concurrentes."
|
||||
|
||||
#: index.docbook:220
|
||||
msgid "Both <emphasis>session-per-request-with-detached-objects</emphasis> and <emphasis>session-per-conversation</emphasis> have advantages and disadvantages, we discuss them later in this chapter in the context of optimistic concurrency control."
|
||||
msgstr "Les deux patterns <emphasis>session-per-request-with- detached- objects</emphasis> (session-par-requête-avec-objets- détachés) et <emphasis>session-per-conversation</emphasis> (session-par-conversation) ont chacun leurs avantages et désavantages qui seront exposés dans ce même chapitre, dans la section au sujet du contrôle optimiste de concurrence."
|
||||
|
||||
#: index.docbook:229
|
||||
msgid "Considering object identity"
|
||||
msgstr "L'identité des objets"
|
||||
|
||||
#: index.docbook:231
|
||||
msgid "An application may concurrently access the same persistent state in two different <literal>Session</literal>s. However, an instance of a persistent class is never shared between two <literal>Session</literal> instances. Hence there are two different notions of identity:"
|
||||
msgstr "Une application peut accéder à la même entité persistante de manière concurrente dans deux <literal>Session</literal> s différentes. Toutefois, une instance d'une classe persistante n'est jamais partagée par deux instances distinctes de la classe <literal>Session</literal> . Il existe donc deux notions de l'identité d'un objet:"
|
||||
|
||||
#: index.docbook:240
|
||||
msgid "Database Identity"
|
||||
msgstr "Identité BD"
|
||||
|
||||
#: index.docbook:243
|
||||
msgid "foo.getId().equals( bar.getId() )"
|
||||
msgstr "foo.getId().equals( bar.getId() )"
|
||||
|
||||
#: index.docbook:248
|
||||
msgid "JVM Identity"
|
||||
msgstr "Identité JVM"
|
||||
|
||||
#: index.docbook:251
|
||||
msgid "foo==bar"
|
||||
msgstr "foo==bar"
|
||||
|
||||
#: index.docbook:257
|
||||
msgid "Then for objects attached to a <emphasis>particular</emphasis> <literal>Session</literal> (i.e. in the scope of a <literal>Session</literal>) the two notions are equivalent, and JVM identity for database identity is guaranteed by Hibernate. However, while the application might concurrently access the \"same\" (persistent identity) business object in two different sessions, the two instances will actually be \"different\" (JVM identity). Conflicts are resolved using (automatic versioning) at flush/commit time, using an optimistic approach."
|
||||
msgstr "Ainsi, pour des objets attachés à une <literal>Session</literal> <emphasis>précise</emphasis> (dans la cadre d'exécution (scope) d'une instance de <literal>Session</literal> ), ces deux notions d'identité sont équivalentes et garanties par Hibernate. Par contre, si une application peut accéder de manière concurrente à la même entité persistante dans deux sessions différentes, les deux instances seront en fait différentes (en ce qui a trait à l'identité JVM). Les conflits sont résolus automatiquement par approche optimiste grâce au système de versionnage automatique lorsque <literal>Session.flush()</literal> ou <literal>Transaction.commit()</literal> est appelé."
|
||||
|
||||
#: index.docbook:266
|
||||
msgid "This approach leaves Hibernate and the database to worry about concurrency; it also provides the best scalability, since guaranteeing identity in single-threaded units of work only doesn't need expensive locking or other means of synchronization. The application never needs to synchronize on any business object, as long as it sticks to a single thread per <literal>Session</literal>. Within a <literal>Session</literal> the application may safely use <literal>==</literal> to compare objects."
|
||||
msgstr "Cette approche permet de reléguer à Hibernate et à la base de données sous-jacente le soin de gérer les problèmes d'accès concurrents. Cette manière de faire assure également une meilleure extensibilité de l'application puisque assurer l'identité JVM dans un thread ne nécessite pas de mécanismes de verrouillage coûteux ou d'autres dispositifs de synchronisation. Une application n'aura jamais le besoin de synchroniser des objets d'affaire tant qu'elle peut garantir qu'un seul thread aura accès à une instance de <literal>Session</literal> . Dans le cadre d'exécution d'un objet <literal>Session</literal> , l'application peut utiliser en toute sécurité <literal>== </literal> pour comparer des objets."
|
||||
|
||||
#: index.docbook:275
|
||||
msgid "However, an application that uses <literal>==</literal> outside of a <literal>Session</literal>, might see unexpected results. This might occur even in some unexpected places, for example, if you put two detached instances into the same <literal>Set</literal>. Both might have the same database identity (i.e. they represent the same row), but JVM identity is by definition not guaranteed for instances in detached state. The developer has to override the <literal>equals()</literal> and <literal>hashCode()</literal> methods in persistent classes and implement his own notion of object equality. There is one caveat: Never use the database identifier to implement equality, use a business key, a combination of unique, usually immutable, attributes. The database identifier will change if a transient object is made persistent. If the transient instance (usually together with detached instances) is held in a <literal>Set</literal>, changing the hashcode breaks the contract of the <literal>Set</literal>. Attributes for business keys don't have to be as stable as database primary keys, you only have to guarantee stability as long as the objects are in the same <literal>Set</literal>. See the Hibernate website for a more thorough discussion of this issue. Also note that this is not a Hibernate issue, but simply how Java object identity and equality has to be implemented."
|
||||
msgstr "Une application qui utiliserait <literal>==</literal> à l'extérieur du cadre d'exécution d'une <literal>Session</literal> pourrait obtenir des résultats inattendus et causer certains effets de bords. Par exemple, si vous mettez 2 objets dans le même <literal>Set</literal> , ceux-ci pourraient avoir la même identité BD (i.e. ils représentent le même enregistrement), mais leur identité JVM pourrait être différente (elle ne peut, par définition, pas être garantie sur deux objets détachés). Le développeur doit donc redéfinir l'implémentation des méthodes <literal>equals()</literal> et <literal>hashcode()</literal> dans les classes persistantes et y adjoindre sa propre notion d'identité. Il existe toutefois une restriction: Il ne faut jamais utiliser uniquement l'identifiant de la base de données dans l'implémentation de l'égalité; Il faut utiliser une clé d'affaire, généralement une combinaison de plusieurs attributs uniques, si possible immuables. Les identifiants de base de données vont changer si un objet transitoire (transient) devient persistant. Si une instance transitoire est contenue dans un <literal>Set</literal> , changer le hashcode brisera le contrat du <literal>Set</literal> . Les attributs pour les clés d'affaire n'ont pas à être aussi stables que des clés primaires de bases de données. Il suffit simplement qu'elles soient stables tant et aussi longtemps que les objets sont dans le même <literal>Set</literal> . Veuillez consulter le site web Hibernate pour des discussions plus pointues à ce sujet. Notez que ce concept n'est pas propre à Hibernate mais bien général à l'implémentation de l'identité et de l'égalité en Java."
|
||||
|
||||
#: index.docbook:296
|
||||
msgid "Common issues"
|
||||
msgstr "Problèmes communs"
|
||||
|
||||
#: index.docbook:298
|
||||
msgid "Never use the anti-patterns <emphasis>session-per-user-session</emphasis> or <emphasis>session-per-application</emphasis> (of course, there are rare exceptions to this rule). Note that some of the following issues might also appear with the recommended patterns, make sure you understand the implications before making a design decision:"
|
||||
msgstr "Bien qu'il puisse y avoir quelques rares exceptions à cette règle, il est recommandé de ne jamais utiliser les anti-patterns <emphasis>session-per- user-session</emphasis> et <emphasis>session-per-application</emphasis> . Vous trouverez ici- bas quelques problèmes que vous risquez de rencontrer si vous en faite l?utilisation. (Ces problèmes pourraient quand même survenir avec des patterns recommandés) Assurez-vous de bien comprendre les implications de chacun des patterns avant de prendre votre décision."
|
||||
|
||||
#: index.docbook:307
|
||||
msgid "A <literal>Session</literal> is not thread-safe. Things which are supposed to work concurrently, like HTTP requests, session beans, or Swing workers, will cause race conditions if a <literal>Session</literal> instance would be shared. If you keep your Hibernate <literal>Session</literal> in your <literal>HttpSession</literal> (discussed later), you should consider synchronizing access to your Http session. Otherwise, a user that clicks reload fast enough may use the same <literal>Session</literal> in two concurrently running threads."
|
||||
msgstr "L'objet <literal>Session</literal> n?est pas conçu pour être utilisé par de multiples threads. En conséquence, les objets potentiellement multi-thread comme les requêtes HTTP, les EJB Session et Swing Worker, risquent de provoquer des conditions de course dans la <literal>Session</literal> si celle-ci est partagée. Dans un environnement web classique, il serait préférable de synchroniser les accès à la session http afin d?éviter qu?un usager ne recharge une page assez rapidement pour que deux requêtes s?exécutant dans des threads concurrents n?utilisent la même <literal>Session</literal> ."
|
||||
|
||||
#: index.docbook:318
|
||||
msgid "An exception thrown by Hibernate means you have to rollback your database transaction and close the <literal>Session</literal> immediately (discussed later in more detail). If your <literal>Session</literal> is bound to the application, you have to stop the application. Rolling back the database transaction doesn't put your business objects back into the state they were at the start of the transaction. This means the database state and the business objects do get out of sync. Usually this is not a problem, because exceptions are not recoverable and you have to start over after rollback anyway."
|
||||
msgstr "Lorsque Hibernate lance une exception, le roll back de la transaction en cours doit être effectué et la <literal>Session</literal> doit être immédiatement fermée. (Ceci sera exploré plus tard dans le chapitre.) Si la <literal>Session</literal> est directement associée à une application, il faut arrêter l?application. Le roll back de la transaction ne remettra pas les objets dans leur état du début de la transaction. Ainsi, ceux-ci pourraient être désynchronisés d?avec les enregistrements. (Généralement, cela ne cause pas de réels problèmes puisque la plupart des exceptions sont non traitables et requièrent la reprise du processus d?affaire ayant échoué.)"
|
||||
|
||||
#: index.docbook:330
|
||||
msgid "The <literal>Session</literal> caches every object that is in persistent state (watched and checked for dirty state by Hibernate). This means it grows endlessly until you get an OutOfMemoryException, if you keep it open for a long time or simply load too much data. One solution for this is to call <literal>clear()</literal> and <literal>evict()</literal> to manage the <literal>Session</literal> cache, but you most likely should consider a Stored Procedure if you need mass data operations. Some solutions are shown in <xref linkend=\"batch\"/>. Keeping a <literal>Session</literal> open for the duration of a user session also means a high probability of stale data."
|
||||
msgstr "La <literal>Session</literal> met en mémoire cache tous les objets persistants (les objets surveillés et dont l'état est géré par Hibernate.) Si la <literal>Session</literal> est ouverte indéfiniment ou si une trop grande quantité d'objets y est chargée, l?utilisation de la mémoire peut potentiellement croître jusqu?à atteindre le maximum allouable à l?application (java.lang.OutOfMemoryError.) Une solution à ce problème est d?appeler les méthodes <literal>Session.clear()</literal> et <literal>Session.evict()</literal> pour gérer la mémoire cache de la <literal>Session</literal> . Vous pouvez également utiliser des stored procedures si vous devez lancer des traitements sur de grandes quantités d?informations. Certaines solutions sont décrites ici : <xref linkend=\"batch\"/> . Garder une <literal>Session</literal> ouverte pour toute la durée d?une session usager augmente également considérablement le risque de travailler avec de l?information périmée."
|
||||
|
||||
#: index.docbook:348
|
||||
msgid "Database transaction demarcation"
|
||||
msgstr "Démarcation des transactions"
|
||||
|
||||
#: index.docbook:350
|
||||
msgid "Datatabase (or system) transaction boundaries are always necessary. No communication with the database can occur outside of a database transaction (this seems to confuse many developers who are used to the auto-commit mode). Always use clear transaction boundaries, even for read-only operations. Depending on your isolation level and database capabilities this might not be required but there is no downside if you always demarcate transactions explicitly. Certainly, a single database transaction is going to perform better than many small transactions, even for reading data."
|
||||
msgstr "La démarcation des transactions est importante dans le design d?une application. Aucune communication avec la base de données ne peut être effectuée à l?extérieur du cadre d?une transaction. (Il semble que ce concept soit mal compris par plusieurs développeurs trop habitués à utiliser le mode auto-commit.) Même si certains niveaux d'isolation et certaines possibilités offertes par les bases de données permettent de l?éviter, il n'est jamais désavantageux de toujours explicitement indiquer les bornes de transaction pour les opérations complexes comme pour les opérations simples de lecture."
|
||||
|
||||
#: index.docbook:360
|
||||
msgid "A Hibernate application can run in non-managed (i.e. standalone, simple Web- or Swing applications) and managed J2EE environments. In a non-managed environment, Hibernate is usually responsible for its own database connection pool. The application developer has to manually set transaction boundaries, in other words, begin, commit, or rollback database transactions himself. A managed environment usually provides container-managed transactions (CMT), with the transaction assembly defined declaratively in deployment descriptors of EJB session beans, for example. Programmatic transaction demarcation is then no longer necessary."
|
||||
msgstr "Une application utilisant Hibernate peut s'exécuter dans un environnement léger n?offrant pas la gestion automatique des transactions (application autonome, application web simple ou applications Swing) ou dans un environnement J2EE offrant des services de gestion automatique des transactions JTA. Dans un environnement simple, Hibernate a généralement la responsabilité de la gestion de son propre pool de connexions à la base de données. Le développeur de l'application doit manuellement délimiter les transactions. En d'autres mots, il appartient au développeur de gérer les appels à <literal>Transaction.begin()</literal> , <literal>Transaction.commit()</literal> et <literal>Transaction.rollback()</literal> . Un environnement transactionnel J2EE (serveur d'application J2EE) doit offrir la gestion des transactions au niveau du container J2EE. Les bornes de transaction peuvent normalement être définies de manière déclarative dans les descripteurs de déploiement d'EJB Session, par exemple. La gestion programmatique des transactions n'y est donc pas nécessaire. Même les appels à <literal>Session.flush()</literal> sont faits automatiquement."
|
||||
|
||||
#: index.docbook:370
|
||||
msgid "However, it is often desirable to keep your persistence layer portable between non-managed resource-local environments, and systems that can rely on JTA but use BMT instead of CMT. In both cases you'd use programmatic transaction demaracation. Hibernate offers a wrapper API called <literal>Transaction</literal> that translates into the native transaction system of your deployment environment. This API is actually optional, but we strongly encourage its use unless you are in a CMT session bean."
|
||||
msgstr "Il peut être requis d'avoir une couche de persistance portable. Hibernate offre donc une API appelée <literal>Transaction</literal> qui sert d'enveloppe pour le système de transaction natif de l'environnement de déploiement. Il n'est pas obligatoire d'utiliser cette API mais il est fortement conseillé de le faire, sauf lors de l'utilisation de CMT Session Bean (EJB avec transactions gérées automatiquement par le container EJB)."
|
||||
|
||||
#: index.docbook:379
|
||||
msgid "Usually, ending a <literal>Session</literal> involves four distinct phases:"
|
||||
msgstr "Il existe quatre étapes disctinctes lors de la fermeture d'une <literal>Session</literal>"
|
||||
|
||||
#: index.docbook:385
|
||||
msgid "flush the session"
|
||||
msgstr "flush de la session"
|
||||
|
||||
#: index.docbook:390
|
||||
msgid "commit the transaction"
|
||||
msgstr "commit de la transaction"
|
||||
|
||||
#: index.docbook:395
|
||||
msgid "close the session"
|
||||
msgstr "Fermeture de la session (Close)"
|
||||
|
||||
#: index.docbook:400
|
||||
msgid "handle exceptions"
|
||||
msgstr "<para>Gestion des exceptions</para>"
|
||||
|
||||
#: index.docbook:406
|
||||
msgid "Flushing the session has been discussed earlier, we'll now have a closer look at transaction demarcation and exception handling in both managed- and non-managed environments."
|
||||
msgstr "La synchronisation de bdd depuis la session (flush) a déjà été expliqué, nous nous attarderons maintenant à la démarcation des transactions et à la gestion des exceptions dans les environnements légers et les environnements J2EE."
|
||||
|
||||
#: index.docbook:413
|
||||
msgid "Non-managed environment"
|
||||
msgstr "Environnement non managé"
|
||||
|
||||
#: index.docbook:415
|
||||
msgid "If a Hibernate persistence layer runs in a non-managed environment, database connections are usually handled by simple (i.e. non-DataSource) connection pools from which Hibernate obtains connections as needed. The session/transaction handling idiom looks like this:"
|
||||
msgstr "Si la couche de persistance Hibernate s'exécute dans un environnement non managé, les connexions à la base de données seront généralement prises en charge par le mécanisme de pool d'Hibernate. La gestion de la session et de la transaction se fera donc de la manière suivante:"
|
||||
|
||||
#: index.docbook:422
|
||||
msgid ""
|
||||
"<![CDATA[// Non-managed environment idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[// Non-managed environment idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:424
|
||||
msgid "You don't have to <literal>flush()</literal> the <literal>Session</literal> explicitly - the call to <literal>commit()</literal> automatically triggers the synchronization (depending upon the <xref linkend=\"objectstate-flushing\"/>FlushMode for the session. A call to <literal>close()</literal> marks the end of a session. The main implication of <literal>close()</literal> is that the JDBC connection will be relinquished by the session. This Java code is portable and runs in both non-managed and JTA environments."
|
||||
msgstr "Vous n'avez pas à invoquer <literal>flush()</literal> explicitement sur la <literal>Session</literal> - l'appel de <literal>commit()</literal> déclenchera automatiquement la synchronisation (selon le <xref linkend=\"objectstate-flushing\"/>FlushMode de la session. Un appel à <literal>close()</literal> marque la fin de la session. La conséquence directe est que la connexion à la base de données sera relachée par la session. Ce code est portable est fonctionne dans les environnements non managé ET les environnements JTA."
|
||||
|
||||
#: index.docbook:433
|
||||
msgid "A much more flexible solution is Hibernate's built-in \"current session\" context management, as described earlier:"
|
||||
msgstr "Une solution plus flexible est la gestion par contexte fourni par Hibernate que nous avons déjà rencontré:"
|
||||
|
||||
#: index.docbook:438
|
||||
msgid ""
|
||||
"<![CDATA[// Non-managed environment idiom with getCurrentSession()\n"
|
||||
"try {\n"
|
||||
" factory.getCurrentSession().beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" factory.getCurrentSession().getTransaction().commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" factory.getCurrentSession().getTransaction().rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[// Non-managed environment idiom with getCurrentSession()\n"
|
||||
"try {\n"
|
||||
" factory.getCurrentSession().beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" factory.getCurrentSession().getTransaction().commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" factory.getCurrentSession().getTransaction().rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:440
|
||||
msgid "You will very likely never see these code snippets in a regular application; fatal (system) exceptions should always be caught at the \"top\". In other words, the code that executes Hibernate calls (in the persistence layer) and the code that handles <literal>RuntimeException</literal> (and usually can only clean up and exit) are in different layers. The current context management by Hibernate can significantly simplify this design, as all you need is access to a <literal>SessionFactory</literal>. Exception handling is discussed later in this chapter."
|
||||
msgstr "Vous ne verrez probablement jamais ces exemples de code dans les applications; les exceptions fatales (exceptions du système) ne devraient être traitées que dans la couche la plus \"haute\". En d'autres termes, le code qui exécute les appels à Hibernate (à la couche de persistance) et le code qui gère les <literal>RuntimeException</literal> (qui ne peut généralement effectuer qu'un nettoyage et une sortie) sont dans des couches différentes. La gestion du contexte courant par Hibernate peut simplifier notablement ce design, puisque vous devez accéder à la gestion des exceptions de la <literal>SessionFactory</literal>, ce qui est décrit plus tard dans ce chapitre."
|
||||
|
||||
#: index.docbook:450
|
||||
msgid "Note that you should select <literal>org.hibernate.transaction.JDBCTransactionFactory</literal> (which is the default), and for the second example <literal>\"thread\"</literal> as your <literal>hibernate.current_session_context_class</literal>."
|
||||
msgstr "Notez que vous devriez sélectionner <literal>org.hibernate.transaction.JDBCTransactionFactory</literal> (le défaut), pour le second exemple <literal>\"thread\"</literal> comme <literal>hibernate.current_session_context_class</literal>."
|
||||
|
||||
#: index.docbook:459
|
||||
msgid "Using JTA"
|
||||
msgstr "Utilisation de JTA"
|
||||
|
||||
#: index.docbook:461
|
||||
msgid "If your persistence layer runs in an application server (e.g. behind EJB session beans), every datasource connection obtained by Hibernate will automatically be part of the global JTA transaction. You can also install a standalone JTA implementation and use it without EJB. Hibernate offers two strategies for JTA integration."
|
||||
msgstr "Si votre couche de persistance s'exécute dans un serveur d'application (par exemple, derrière un EJB Session Bean), toutes les datasource utilisées par Hibernate feront automatiquement partie de transactions JTA globales. Hibernate propose deux stratégies pour réussir cette intégration."
|
||||
|
||||
#: index.docbook:468
|
||||
msgid "If you use bean-managed transactions (BMT) Hibernate will tell the application server to start and end a BMT transaction if you use the <literal>Transaction</literal> API. So, the transaction management code is identical to the non-managed environment."
|
||||
msgstr "Si vous utilisez des transactions gérées par un EJB (bean managed transactions - BMT), Hibernate informera le serveur d'application du début et de la fin des transactions si vous utilisez l'API <literal>Transaction</literal> . Ainsi, le code de gestion des transactions sera identique dans les deux types d'environnements."
|
||||
|
||||
#: index.docbook:474
|
||||
msgid ""
|
||||
"<![CDATA[// BMT idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[// BMT idiom\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"Transaction tx = null;\n"
|
||||
"try {\n"
|
||||
" tx = sess.beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" if (tx != null) tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:476
|
||||
msgid "If you want to use a transaction-bound <literal>Session</literal>, that is, the <literal>getCurrentSession()</literal> functionality for easy context propagation, you will have to use the JTA <literal>UserTransaction</literal> API directly:"
|
||||
msgstr "Ou encore, avec la gestion automatique de contexte:"
|
||||
|
||||
#: index.docbook:482
|
||||
msgid ""
|
||||
"<![CDATA[// BMT idiom with getCurrentSession()\n"
|
||||
"try {\n"
|
||||
" UserTransaction tx = (UserTransaction)new InitialContext()\n"
|
||||
" .lookup(\"java:comp/UserTransaction\");\n"
|
||||
"\n"
|
||||
" tx.begin();\n"
|
||||
"\n"
|
||||
" // Do some work on Session bound to transaction\n"
|
||||
" factory.getCurrentSession().load(...);\n"
|
||||
" factory.getCurrentSession().persist(...);\n"
|
||||
"\n"
|
||||
" tx.commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" tx.rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[// BMT idiom with getCurrentSession()\n"
|
||||
"try {\n"
|
||||
" factory.getCurrentSession().beginTransaction();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" factory.getCurrentSession().getTransaction().commit();\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" factory.getCurrentSession().getTransaction().rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:484
|
||||
msgid "With CMT, transaction demarcation is done in session bean deployment descriptors, not programatically, hence, the code is reduced to:"
|
||||
msgstr "Avec CMT, la démarcation des transactions est faite dans les descripteurs de déploiement des Beans Sessions et non de manière programmmatique, ceci réduit le code:"
|
||||
|
||||
#: index.docbook:489
|
||||
msgid ""
|
||||
"<![CDATA[// CMT idiom\n"
|
||||
" Session sess = factory.getCurrentSession();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[// CMT idiom\n"
|
||||
" Session sess = factory.getCurrentSession();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"]]>"
|
||||
|
||||
#: index.docbook:491
|
||||
msgid "In a CMT/EJB even rollback happens automatically, since an unhandled <literal>RuntimeException</literal> thrown by a session bean method tells the container to set the global transaction to rollback. <emphasis>This means you do not need to use the Hibernate <literal>Transaction</literal> API at all with BMT or CMT, and you get automatic propagation of the \"current\" Session bound to the transaction.</emphasis>"
|
||||
msgstr "Dans un EJB CMT même le rollback intervient automatiquement, puisqu'une <literal>RuntimeException</literal> non traitée et soulevée par une méthode d'un bean session indique au conteneur d'annuler la transaction globale. <emphasis>Ceci veut donc dire que vous n'avez pas à utiliser l'API <literal>Transaction</literal> d'Hibernate dans CMT.</emphasis>"
|
||||
|
||||
#: index.docbook:499
|
||||
msgid "Note that you should choose <literal>org.hibernate.transaction.JTATransactionFactory</literal> if you use JTA directly (BMT), and <literal>org.hibernate.transaction.CMTTransactionFactory</literal> in a CMT session bean, when you configure Hibernate's transaction factory. Remember to also set <literal>hibernate.transaction.manager_lookup_class</literal>. Furthermore, make sure that your <literal>hibernate.current_session_context_class</literal> is either unset (backwards compatiblity), or set to <literal>\"jta\"</literal>."
|
||||
msgstr "Notez que le fichier de configuration Hibernate devrait contenir les valeurs <literal>org.hibernate.transaction.JTATransactionFactory</literal> dans un environnement BMT ou <literal>org.hibernate.transaction.CMTTransactionFactory</literal> dans un environnement CMT là où vous configurez votre transaction factory Hibernate. N'oubliez pas non plus de spécifier le paramètre <literal>org.hibernate.transaction.manager_lookup_class</literal> . De plus, assurez vous de fixez votre <literal>hibernate.current_session_context_class</literal> soit à <literal>\"jta\"</literal> ou de ne pas le configurer (compatibilité avec les versions précédentes)."
|
||||
|
||||
#: index.docbook:508
|
||||
msgid "The <literal>getCurrentSession()</literal> operation has one downside in a JTA environment. There is one caveat to the use of <literal>after_statement</literal> connection release mode, which is then used by default. Due to a silly limitation of the JTA spec, it is not possible for Hibernate to automatically clean up any unclosed <literal>ScrollableResults</literal> or <literal>Iterator</literal> instances returned by <literal>scroll()</literal> or <literal>iterate()</literal>. You <emphasis>must</emphasis> release the underlying database cursor by calling <literal>ScrollableResults.close()</literal> or <literal>Hibernate.close(Iterator)</literal> explicity from a <literal>finally</literal> block. (Of course, most applications can easily avoid using <literal>scroll()</literal> or <literal>iterate()</literal> at all from the JTA or CMT code.)"
|
||||
msgstr "La méthode <literal>getCurrentSession()</literal> a un inconvénient dans les environnement JTA. Il y a une astuce qui est d'utiliser un mode de libération de connexion <literal>after_statement</literal> , qui est alors utilisé par défaut. Du à une étrange limitation de la spec JTA, il n'est pas possible pour Hibernate de nettoyer et ferme automatiquement un <literal>ScrollableResults</literal> ouvert ou une instance d'<literal>Iterator</literal> retournés <literal>scroll()</literal> ou <literal>iterate()</literal>. Vous <emphasis>devez</emphasis> libérer le curseur base de données sous jacent ou invoquer <literal>Hibernate.close(Iterator)</literal> explicitement depuis un bloc <literal>finally</literal>. (Bien sur, la plupart des applications peuvent éviter d'uiliser <literal>scroll()</literal> ou <literal>iterate()</literal> dans un code CMT.)"
|
||||
|
||||
#: index.docbook:524
|
||||
msgid "Exception handling"
|
||||
msgstr "<title>Gestion des exceptions</title>"
|
||||
|
||||
#: index.docbook:526
|
||||
msgid "If the <literal>Session</literal> throws an exception (including any <literal>SQLException</literal>), you should immediately rollback the database transaction, call <literal>Session.close()</literal> and discard the <literal>Session</literal> instance. Certain methods of <literal>Session</literal> will <emphasis>not</emphasis> leave the session in a consistent state. No exception thrown by Hibernate can be treated as recoverable. Ensure that the <literal>Session</literal> will be closed by calling <literal>close()</literal> in a <literal>finally</literal> block."
|
||||
msgstr "Si une <literal>Session</literal> lance une exception (incluant les exceptions du type <literal>SQLException</literal> ou d'un sous-type), vous devez immédiatement faire le rollback de la transaction, appeler <literal>Session.close()</literal> et relâcher les références sur l'objet <literal>Session</literal> . La <literal>Session</literal> contient des méthodes pouvant la mettre dans un état inutilisable. Vous devez considérer qu'<emphasis>aucune</emphasis> exception lancée par Hibernate n'est traitable. Assurez-vous de fermer la session en faisant l'appel à <literal>close()</literal> dans un bloc <literal>finally</literal> ."
|
||||
|
||||
#: index.docbook:537
|
||||
msgid "The <literal>HibernateException</literal>, which wraps most of the errors that can occur in a Hibernate persistence layer, is an unchecked exception (it wasn't in older versions of Hibernate). In our opinion, we shouldn't force the application developer to catch an unrecoverable exception at a low layer. In most systems, unchecked and fatal exceptions are handled in one of the first frames of the method call stack (i.e. in higher layers) and an error message is presented to the application user (or some other appropriate action is taken). Note that Hibernate might also throw other unchecked exceptions which are not a <literal>HibernateException</literal>. These are, again, not recoverable and appropriate action should be taken."
|
||||
msgstr "L'exception <literal>HibernateException</literal> , qui englobe la plupart des exceptions pouvant survenir dans la couche de persistance Hibernate, est une exception non vérifiée (Ceci n'était pas le cas dans certaines versions antérieures de Hibernate.) Il est de notre avis que nous ne devrions pas forcer un développeur à gérer une exception qu'il ne peut de toute façon pas traiter dans une couche technique. Dans la plupart des applications, les exceptions non vérifiées et les exceptions fatales sont gérées en amont du processus (dans les couches hautes) et un message d'erreur est alors affiché à l'usager (ou un traitement alternatif est invoqué.) Veuillez noter qu'Hibernate peut également lancer des exceptions non vérifiées d'un autre type que <literal>HibernateException</literal> . Celles-ci sont également non traitables et vous devez les traiter comme telles."
|
||||
|
||||
#: index.docbook:549
|
||||
msgid "Hibernate wraps <literal>SQLException</literal>s thrown while interacting with the database in a <literal>JDBCException</literal>. In fact, Hibernate will attempt to convert the eexception into a more meningful subclass of <literal>JDBCException</literal>. The underlying <literal>SQLException</literal> is always available via <literal>JDBCException.getCause()</literal>. Hibernate converts the <literal>SQLException</literal> into an appropriate <literal>JDBCException</literal> subclass using the <literal>SQLExceptionConverter</literal> attached to the <literal>SessionFactory</literal>. By default, the <literal>SQLExceptionConverter</literal> is defined by the configured dialect; however, it is also possible to plug in a custom implementation (see the javadocs for the <literal>SQLExceptionConverterFactory</literal> class for details). The standard <literal>JDBCException</literal> subtypes are:"
|
||||
msgstr "Hibernate englobe les <literal>SQLException</literal> s lancées lors des interactions directes avec la base de données dans des exceptions de type: <literal>JDBCException</literal> . En fait, Hibernate essaiera de convertir l'exception dans un sous-type plus significatif de <literal>JDBCException</literal> . L'exception <literal>SQLException</literal> sous-jacente est toujours disponible via la méthode <literal>JDBCException.getCause()</literal> . Cette conversion est faite par un objet de type <literal>SQLExceptionConverter</literal> , qui est rattaché à l'objet <literal>SessionFactory</literal> . Par défaut, le <literal>SQLExceptionConverter</literal> est associé au dialecte de BD configuré dans Hibernate. Toutefois, il est possible de fournir sa propre implémentation de l'interface. (Veuillez vous référer à la javadoc sur la classe <literal>SQLExceptionConverterFactory</literal> pour plus de détails. Les sous-types standard de <literal>JDBCException</literal> sont:"
|
||||
|
||||
#: index.docbook:565
|
||||
msgid "<literal>JDBCConnectionException</literal> - indicates an error with the underlying JDBC communication."
|
||||
msgstr "<literal>JDBCConnectionException</literal> - Indique une erreur de communication avec la couche JDBC sous-jacente."
|
||||
|
||||
#: index.docbook:571
|
||||
msgid "<literal>SQLGrammarException</literal> - indicates a grammar or syntax problem with the issued SQL."
|
||||
msgstr "<literal>SQLGrammarException</literal> - Indique un problème de grammaire ou de syntaxe avec la requête SQL envoyée."
|
||||
|
||||
#: index.docbook:577
|
||||
msgid "<literal>ConstraintViolationException</literal> - indicates some form of integrity constraint violation."
|
||||
msgstr "<literal>ConstraintViolationException</literal> - Indique une violation de contrainte d'intégrité."
|
||||
|
||||
#: index.docbook:583
|
||||
msgid "<literal>LockAcquisitionException</literal> - indicates an error acquiring a lock level necessary to perform the requested operation."
|
||||
msgstr "<literal>LockAcquisitionException</literal> - Indique une erreur de verrouillage lors de l'éxécution de la requête."
|
||||
|
||||
#: index.docbook:589
|
||||
msgid "<literal>GenericJDBCException</literal> - a generic exception which did not fall into any of the other categories."
|
||||
msgstr "<literal>GenericJDBCException</literal> - Indique une erreur générique JDBC d'une autre catégorie."
|
||||
|
||||
#: index.docbook:599
|
||||
msgid "Transaction timeout"
|
||||
msgstr "Timeout de transaction"
|
||||
|
||||
#: index.docbook:601
|
||||
msgid "One extremely important feature provided by a managed environment like EJB that is never provided for non-managed code is transaction timeout. Transaction timeouts ensure that no misbehaving transaction can indefinitely tie up resources while returning no response to the user. Outside a managed (JTA) environment, Hibernate cannot fully provide this functionality. However, Hibernate can at least control data access operations, ensuring that database level deadlocks and queries with huge result sets are limited by a defined timeout. In a managed environment, Hibernate can delegate transaction timeout to JTA. This functioanlity is abstracted by the Hibernate <literal>Transaction</literal> object."
|
||||
msgstr "L'un des avantages fournis par les environnements transactionnels JTA (tels les containers EJB) est la gestion du timeout de transaction. La gestion des dépassements de temps de transaction vise à s'assurer qu'une transaction agissant incorrectement ne viendra pas bloquer indéfiniment les ressources de l'application. Hibernate ne peut fournir cette fonctionnalité dans un environnement transactionnel non-JTA. Par contre, Hibernate gère les opérations d'accès aux données en allouant un temps maximal aux requêtes pour s'exécuter. Ainsi, une requête créant de l'inter blocage ou retournant de très grandes quantités d'information pourrait être interrompue. Dans un environnement transactionnel JTA, Hibernate peut déléguer au gestionnaire de transaction le soin de gérer les dépassements de temps. Cette fonctionnalité est abstraite par l'objet <literal>Transaction</literal> ."
|
||||
|
||||
#: index.docbook:614
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"Session sess = factory.openSession();\n"
|
||||
"try {\n"
|
||||
" //set transaction timeout to 3 seconds\n"
|
||||
" sess.getTransaction().setTimeout(3);\n"
|
||||
" sess.getTransaction().begin();\n"
|
||||
"\n"
|
||||
" // do some work\n"
|
||||
" ...\n"
|
||||
"\n"
|
||||
" sess.getTransaction().commit()\n"
|
||||
"}\n"
|
||||
"catch (RuntimeException e) {\n"
|
||||
" sess.getTransaction().rollback();\n"
|
||||
" throw e; // or display error message\n"
|
||||
"}\n"
|
||||
"finally {\n"
|
||||
" sess.close();\n"
|
||||
"}]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[\n"
|
||||
" Session sess = factory.openSession();\n"
|
||||
" try {\n"
|
||||
" //mettre le timeout à 3 secondes.\n"
|
||||
" sess.getTransaction().setTimeout(3);\n"
|
||||
" sess.getTransaction().begin();\n"
|
||||
"\n"
|
||||
" // Effectuer le travail ...\n"
|
||||
"\n"
|
||||
" sess.getTransaction().commit()\n"
|
||||
" }\n"
|
||||
" catch (RuntimeException e) {\n"
|
||||
" if ( sess.getTransaction().isActive() ) {\n"
|
||||
" sess.getTransaction().rollback();\n"
|
||||
" }\n"
|
||||
" throw e;\n"
|
||||
" // ou afficher le message d'erreur.\n"
|
||||
" }\n"
|
||||
" finally {\n"
|
||||
" sess.close();\n"
|
||||
" }]]>"
|
||||
|
||||
#: index.docbook:616
|
||||
msgid "Note that <literal>setTimeout()</literal> may not be called in a CMT bean, where transaction timeouts must be defined declaratively."
|
||||
msgstr "Notez que <literal>setTimeout()</literal> ne peut pas être appelé d'un EJB CMT, puisque le timeout des transaction doit être spécifié de manière déclarative."
|
||||
|
||||
#: index.docbook:626
|
||||
msgid "Optimistic concurrency control"
|
||||
msgstr "Contrôle de consurrence optimiste"
|
||||
|
||||
#: index.docbook:628
|
||||
msgid "The only approach that is consistent with high concurrency and high scalability is optimistic concurrency control with versioning. Version checking uses version numbers, or timestamps, to detect conflicting updates (and to prevent lost updates). Hibernate provides for three possible approaches to writing application code that uses optimistic concurrency. The use cases we show are in the context of long conversations, but version checking also has the benefit of preventing lost updates in single database transactions."
|
||||
msgstr "La gestion optimiste des accès concurrents avec versionnage est la seule approche pouvant garantir l'extensibilité des applications à haut niveau de charge. Le système de versionnage utilise des numéros de version ou l'horodatage pour détecter les mises à jour causant des conflits avec d'autres actualisations antérieures. Hibernate propose trois approches pour l'écriture de code applicatif utilisant la gestion optimiste d'accès concurrents. Le cas d'utilisation décrit plus bas fait mention de conversation, mais le versionnage peut également améliorer la qualité d'une application en prévenant la perte de mises à jour."
|
||||
|
||||
#: index.docbook:639
|
||||
msgid "Application version checking"
|
||||
msgstr "Gestion du versionnage au niveau applicatif"
|
||||
|
||||
#: index.docbook:641
|
||||
msgid "In an implementation without much help from Hibernate, each interaction with the database occurs in a new <literal>Session</literal> and the developer is responsible for reloading all persistent instances from the database before manipulating them. This approach forces the application to carry out its own version checking to ensure conversation transaction isolation. This approach is the least efficient in terms of database access. It is the approach most similar to entity EJBs."
|
||||
msgstr "Dans cet exemple d'implémentation utilisant peu les fonctionnalités d'Hibernate, chaque interaction avec la base de données se fait en utilisant une nouvelle <literal>Session</literal> et le développeur doit recharger les données persistantes à partir de la BD avant de les manipuler. Cette implémentation force l'application à vérifier la version des objets afin de maintenir l'isolation transactionnelle. Cette approche, semblable à celle retrouvée pour les EJB, est la moins efficace de celles présentées dans ce chapitre."
|
||||
|
||||
#: index.docbook:650
|
||||
msgid ""
|
||||
"<![CDATA[// foo is an instance loaded by a previous Session\n"
|
||||
"session = factory.openSession();\n"
|
||||
"Transaction t = session.beginTransaction();\n"
|
||||
"\n"
|
||||
"int oldVersion = foo.getVersion();\n"
|
||||
"session.load( foo, foo.getKey() ); // load the current state\n"
|
||||
"if ( oldVersion != foo.getVersion() ) throw new StaleObjectStateException();\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"\n"
|
||||
"t.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[// foo est une instance chargée antérieurement par une autre\n"
|
||||
" Session session = factory.openSession();\n"
|
||||
" Transaction t = session.beginTransaction();\n"
|
||||
"\n"
|
||||
" int oldVersion = foo.getVersion();\n"
|
||||
" session.load( foo, foo.getKey() ); // Charger l'état courant\n"
|
||||
"\n"
|
||||
" if ( oldVersion != foo.getVersion() )\n"
|
||||
" throw new StaleObjectStateException();\n"
|
||||
"\n"
|
||||
" foo.setProperty(\"bar\");\n"
|
||||
" t.commit();\n"
|
||||
" session.close();]]>"
|
||||
|
||||
#: index.docbook:652
|
||||
msgid "The <literal>version</literal> property is mapped using <literal><version></literal>, and Hibernate will automatically increment it during flush if the entity is dirty."
|
||||
msgstr "Le mapping de la propriété <literal>version</literal> est fait via <literal><version></literal> et Hibernate l'incrémentera automatiquement à chaque flush() si l'entité doit être mise à jour."
|
||||
|
||||
#: index.docbook:658
|
||||
msgid "Of course, if you are operating in a low-data-concurrency environment and don't require version checking, you may use this approach and just skip the version check. In that case, <emphasis>last commit wins</emphasis> will be the default strategy for your long conversations. Keep in mind that this might confuse the users of the application, as they might experience lost updates without error messages or a chance to merge conflicting changes."
|
||||
msgstr "Bien sûr, si votre application ne fait pas face à beaucoup d'accès concurrents et ne nécessite pas l'utilisation du versionnage, cette approche peut également être utilisée, il n'y a qu'à ignorer le code relié au versionnage. Dans ce cas, la stratégie du <emphasis>last commit wins</emphasis> (littéralement: le dernier commit l'emporte) sera utilisée pour les conversations (longues transactions applicatives). Gardez à l'esprit que cette approche pourrait rendre perplexe les utilisateurs de l'application car ils pourraient perdre des données mises à jour sans qu'aucun message d'erreur ne leur soit présenté et sans avoir la possibilité de fusionner les données."
|
||||
|
||||
#: index.docbook:667
|
||||
msgid "Clearly, manual version checking is only feasible in very trivial circumstances and not practical for most applications. Often not only single instances, but complete graphs of modified ojects have to be checked. Hibernate offers automatic version checking with either an extended <literal>Session</literal> or detached instances as the design paradigm."
|
||||
msgstr "Il est clair que la gestion manuelle de la vérification du versionnage des objets ne peut être effectuée que dans certains cas triviaux et que cette approche n'est pas valable pour la plupart des applications. De manière générale, les applications ne cherchent pas à actualiser de simples objets sans relations, elles le font généralement pour de larges graphes d'objets. Pour toute application utilisant le paradigme des conversations ou des objets détachés, Hibernate peut gérer automatiquement la vérification des versions d'objets."
|
||||
|
||||
#: index.docbook:678
|
||||
msgid "Extended session and automatic versioning"
|
||||
msgstr "Les sessions longues et le versionnage automatique."
|
||||
|
||||
#: index.docbook:680
|
||||
msgid "A single <literal>Session</literal> instance and its persistent instances are used for the whole conversation, known as <emphasis>session-per-conversation</emphasis>. Hibernate checks instance versions at flush time, throwing an exception if concurrent modification is detected. It's up to the developer to catch and handle this exception (common options are the opportunity for the user to merge changes or to restart the business conversation with non-stale data)."
|
||||
msgstr "Dans ce scénario, une seule instance de <literal>Session</literal> et des objets persistants est utilisée pour toute l'application. Hibernate vérifie la version des objets persistants avant d'effectuer le flush() et lance une exception si une modification concurrente est détectée. Il appartient alors au développeur de gérer l'exception. Les traitements alternatifs généralement proposés sont alors de permettre à l'usager de faire la fusion des données ou de lui offrir de recommencer son travail à partie des données les plus récentes dans la BD."
|
||||
|
||||
#: index.docbook:689
|
||||
msgid "The <literal>Session</literal> is disconnected from any underlying JDBC connection when waiting for user interaction. This approach is the most efficient in terms of database access. The application need not concern itself with version checking or with reattaching detached instances, nor does it have to reload instances in every database transaction."
|
||||
msgstr "Il est à noter que lorsqu'une application est en attente d'une action de la part de l?usager, La <literal>Session</literal> n'est pas connectée à la couche JDBC sous-jacente. C'est la manière la plus efficace de gérer les accès à la base de données. L'application ne devrait pas se préoccuper du versionnage des objets, de la réassociation des objets détachés, ni du rechargement de tous les objets à chaque transaction."
|
||||
|
||||
#: index.docbook:697
|
||||
msgid ""
|
||||
"<![CDATA[// foo is an instance loaded earlier by the old session\n"
|
||||
"Transaction t = session.beginTransaction(); // Obtain a new JDBC connection, start transaction\n"
|
||||
"\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"\n"
|
||||
"session.flush(); // Only for last transaction in conversation\n"
|
||||
"t.commit(); // Also return JDBC connection\n"
|
||||
"session.close(); // Only for last transaction in conversation]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[// foo est une instance chargée antérieurement par une autre session\n"
|
||||
"\n"
|
||||
" session.reconnect();// Obtention d'une nouvelle connexion JDBC\n"
|
||||
" Transaction t = session.beginTransaction();\n"
|
||||
" foo.setProperty(\"bar\");\n"
|
||||
" t.commit(); //Terminer la transaction, propager les changements et vérifier les versions.\n"
|
||||
" session.disconnect(); // Retourner la connexion JDBC\n"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:698
|
||||
msgid "The <literal>foo</literal> object still knows which <literal>Session</literal> it was loaded in. Beginning a new database transaction on an old session obtains a new connection and resumes the session. Committing a database transaction disconnects a session from the JDBC connection and returns the connection to the pool. After reconnection, to force a version check on data you aren't updating, you may call <literal>Session.lock()</literal> with <literal>LockMode.READ</literal> on any objects that might have been updated by another transaction. You don't need to lock any data that you <emphasis>are</emphasis> updating. Usually you would set <literal>FlushMode.MANUAL</literal> on an extended <literal>Session</literal>, so that only the last database transaction cycle is allowed to actually persist all modifications made in this conversation. Hence, only this last database transaction would include the <literal>flush()</literal> operation, and then also <literal>close()</literal> the session to end the conversation."
|
||||
msgstr "L'objet <literal>foo</literal> sait quel objet <literal>Session</literal> l'a chargé. <literal>Session.reconnect()</literal> obtient une nouvelle connexion (celle-ci peut être également fournie) et permet à la session de continuer son travail. La méthode <literal>Session.disconnect()</literal> déconnecte la session de la connexion JDBC et retourne celle-ci au pool de connexion (à moins que vous ne lui ayez fourni vous même la connexion.) Après la reconnexion, afin de forcer la vérification du versionnage de certaines entités que vous ne cherchez pas à actualiser, vous pouvez faire un appel à <literal>Session.lock()</literal> en mode <literal>LockMode.READ</literal> pour tout objet ayant pu être modifié par une autre transaction. Il n'est pas nécessaire de verrouiller les données que vous désirez mettre à jour."
|
||||
|
||||
#: index.docbook:713
|
||||
msgid "This pattern is problematic if the <literal>Session</literal> is too big to be stored during user think time, e.g. an <literal>HttpSession</literal> should be kept as small as possible. As the <literal>Session</literal> is also the (mandatory) first-level cache and contains all loaded objects, we can probably use this strategy only for a few request/response cycles. You should use a <literal>Session</literal> only for a single conversation, as it will soon also have stale data."
|
||||
msgstr "Si des appels implicites aux méthodes <literal>disconnect()</literal> et <literal>reconnect()</literal> sont trop coûteux, vous pouvez les éviter en utilisant <literal>hibernate.connection.release_mode</literal> ."
|
||||
|
||||
#: index.docbook:723
|
||||
msgid "(Note that earlier Hibernate versions required explicit disconnection and reconnection of a <literal>Session</literal>. These methods are deprecated, as beginning and ending a transaction has the same effect.)"
|
||||
msgstr "Ce pattern peut présenter des problèmes si la <literal>Session</literal> est trop volumineuse pour être stockée entre les actions de l'usager. Plus spécifiquement, une session <literal>HttpSession</literal> se doit d'être la plus petite possible. Puisque la <literal>Session</literal> joue obligatoirement le rôle de mémoire cache de premier niveau et contient à ce titre tous les objets chargés, il est préférable de n'utiliser cette stratégie que pour quelques cycles de requêtes car les objets risquent d'y être rapidement périmés."
|
||||
|
||||
#: index.docbook:729
|
||||
msgid "Also note that you should keep the disconnected <literal>Session</literal> close to the persistence layer. In other words, use an EJB stateful session bean to hold the <literal>Session</literal> in a three-tier environment, and don't transfer it to the web layer (or even serialize it to a separate tier) to store it in the <literal>HttpSession</literal>."
|
||||
msgstr "Notez que la <literal>Session</literal> déconnectée devrait être conservée près de la couche de persistance. Autrement dit, utilisez un EJB stateful pour conserver la <literal>Session</literal> et évitez de la sérialiser et de la transférer à la couche de présentation (i.e. Il est préférable de ne pas la conserver dans la session <literal>HttpSession</literal> .)"
|
||||
|
||||
#: index.docbook:737
|
||||
msgid "The extended session pattern, or <emphasis>session-per-conversation</emphasis>, is more difficult to implement with automatic current session context management. You need to supply your own implementation of the <literal>CurrentSessionContext</literal> for this, see the Hibernate Wiki for examples."
|
||||
msgstr "Les objets détachés et le versionnage automatique"
|
||||
|
||||
#: index.docbook:747
|
||||
msgid "Detached objects and automatic versioning"
|
||||
msgstr "Chaque interaction avec le système de persistance se fait via une nouvelle <literal>Session</literal> . Toutefois, les mêmes instances d'objets persistants sont réutilisées pour chacune de ces interactions. L'application doit pouvoir manipuler l'état des instances détachées ayant été chargées antérieurement via une autre session. Pour ce faire, ces objets persistants doivent être rattachés à la <literal>Session</literal> courante en utilisant <literal>Session.update()</literal> , <literal>Session.saveOrUpdate()</literal> , ou <literal>Session.merge()</literal> ."
|
||||
|
||||
#: index.docbook:749
|
||||
msgid "Each interaction with the persistent store occurs in a new <literal>Session</literal>. However, the same persistent instances are reused for each interaction with the database. The application manipulates the state of detached instances originally loaded in another <literal>Session</literal> and then reattaches them using <literal>Session.update()</literal>, <literal>Session.saveOrUpdate()</literal>, or <literal>Session.merge()</literal>."
|
||||
msgstr ""
|
||||
"<![CDATA[// foo est une instance chargée antérieurement par une autre session\n"
|
||||
"\n"
|
||||
" foo.setProperty(\"bar\");\n"
|
||||
" session = factory.openSession();\n"
|
||||
" Transaction t = session.beginTransaction();\n"
|
||||
" session.saveOrUpdate(foo); //Utiliser merge() si \"foo\" pourrait avoir été chargé précédement\n"
|
||||
" t.commit();\n"
|
||||
" session.close();]]>"
|
||||
|
||||
#: index.docbook:757
|
||||
msgid ""
|
||||
"<![CDATA[// foo is an instance loaded by a previous Session\n"
|
||||
"foo.setProperty(\"bar\");\n"
|
||||
"session = factory.openSession();\n"
|
||||
"Transaction t = session.beginTransaction();\n"
|
||||
"session.saveOrUpdate(foo); // Use merge() if \"foo\" might have been loaded already\n"
|
||||
"t.commit();\n"
|
||||
"session.close();]]>"
|
||||
msgstr "Encore une fois, Hibernate vérifiera la version des instances devant être actualisées durant le flush(). Une exception sera lancée si des conflits sont détectés."
|
||||
|
||||
#: index.docbook:759
|
||||
msgid "Again, Hibernate will check instance versions during flush, throwing an exception if conflicting updates occured."
|
||||
msgstr "Vous pouvez également utiliser <literal>lock()</literal> au lieu de <literal>update()</literal> et utiliser le mode <literal>LockMode.READ</literal> (qui lancera une vérification de version, en ignorant tous les niveaux de mémoire cache) si vous êtes certain que l'objet n'a pas été modifié."
|
||||
|
||||
#: index.docbook:764
|
||||
msgid "You may also call <literal>lock()</literal> instead of <literal>update()</literal> and use <literal>LockMode.READ</literal> (performing a version check, bypassing all caches) if you are sure that the object has not been modified."
|
||||
msgstr "Personnaliser le versionnage automatique"
|
||||
|
||||
#: index.docbook:773
|
||||
msgid "Customizing automatic versioning"
|
||||
msgstr "Vous pouvez désactiver l'incrémentation automatique du numéro de version de certains attributs et collections en mettant la valeur du paramètre de mapping <literal>optimistic-lock</literal> à false. Hibernate cessera ainsi d'incrémenter leur numéro de version s'ils sont mis à jour."
|
||||
|
||||
#: index.docbook:775
|
||||
msgid "You may disable Hibernate's automatic version increment for particular properties and collections by setting the <literal>optimistic-lock</literal> mapping attribute to <literal>false</literal>. Hibernate will then no longer increment versions if the property is dirty."
|
||||
msgstr "Certaines entreprises possèdent de vieux systèmes dont les schémas de bases de données sont statiques et ne peuvent être modifiés. Il existe aussi des cas où plusieurs applications doivent accéder à la même base de données, mais certaines d'entre elles ne peuvent gérer les numéros de version ou les champs horodatés. Dans les deux cas, le versionnage ne peut être implanté par le rajout d'une colonne dans la base de données. Afin de forcer la vérification de version dans un système sans en faire le mapping, mais en forçant une comparaison des états de tous les attributs d'une entité, vous pouvez utiliser l'attribut <literal>optimistic- lock=\"all\"</literal> sous l'élément <literal><class></literal> . Veuillez noter que cette manière de gérer le versionnage ne peut être utilisée que si l'application utilises de longues sessions, lui permettant de comparer l'ancien état et le nouvel état d'une entité. L'utilisation d'un pattern <literal>session-per-request-with-detached- objects</literal> devient alors impossible."
|
||||
|
||||
#: index.docbook:782
|
||||
msgid "Legacy database schemas are often static and can't be modified. Or, other applications might also access the same database and don't know how to handle version numbers or even timestamps. In both cases, versioning can't rely on a particular column in a table. To force a version check without a version or timestamp property mapping, with a comparison of the state of all fields in a row, turn on <literal>optimistic-lock=\"all\"</literal> in the <literal><class></literal> mapping. Note that this concepetually only works if Hibernate can compare the old and new state, i.e. if you use a single long <literal>Session</literal> and not session-per-request-with-detached-objects."
|
||||
msgstr "Il peut être souhaitable de permettre les modifications concurrentes lorsque des champs distincts sont modifiés. En mettant la propriété <literal>optimistic-lock=\"dirty\"</literal> dans l'élément <literal><class></literal> , Hibernate ne fera la comparaison que des champs devant être actualisés lors du flush()."
|
||||
|
||||
#: index.docbook:793
|
||||
msgid "Sometimes concurrent modification can be permitted as long as the changes that have been made don't overlap. If you set <literal>optimistic-lock=\"dirty\"</literal> when mapping the <literal><class></literal>, Hibernate will only compare dirty fields during flush."
|
||||
msgstr "Dans les deux cas: en utilisant une colonne de version/horodatée ou via la comparaison de l'état complet de l'objet ou de ses champs modifiés, Hibernate ne créera qu'une seule commande d'UPDATE par entité avec la clause WHERE appropriée pour mettre à jour l'entité <emphasis>ET</emphasis> en vérifier la version. Si vous utilisez la persistance transitive pour propager l'évènement de rattachement à des entités associées, il est possible qu'Hibernate génère des commandes d'UPDATE inutiles. Ceci n'est généralement pas un problème, mais certains déclencheurs <emphasis>on update</emphasis> dans la base de données pourraient être activés même si aucun changement n'était réellement persisté sur des objets associés. Vous pouvez personnaliser ce comportement en indiquant <literal>select-before- update=\"true\"</literal> dans l'élément de mapping <literal><class></literal> . Ceci forcera Hibernate à faire le SELECT de l'instance afin de s'assurer que l'entité doit réellement être actualisée avant de lancer la commande d'UPDATE."
|
||||
|
||||
#: index.docbook:799
|
||||
msgid "In both cases, with dedicated version/timestamp columns or with full/dirty field comparison, Hibernate uses a single <literal>UPDATE</literal> statement (with an appropriate <literal>WHERE</literal> clause) per entity to execute the version check and update the information. If you use transitive persistence to cascade reattachment to associated entities, Hibernate might execute uneccessary updates. This is usually not a problem, but <emphasis>on update</emphasis> triggers in the database might be executed even when no changes have been made to detached instances. You can customize this behavior by setting <literal>select-before-update=\"true\"</literal> in the <literal><class></literal> mapping, forcing Hibernate to <literal>SELECT</literal> the instance to ensure that changes did actually occur, before updating the row."
|
||||
msgstr "Verouillage pessimiste"
|
||||
|
||||
#: index.docbook:817
|
||||
msgid "Pessimistic Locking"
|
||||
msgstr "Il n'est nécessaire de s'attarder à la stratégie de verrouillage des entités dans une application utilisant Hibernate. Il est généralement suffisant de définir le niveau d'isolation pour les connexions JDBC et de laisser ensuite la base de donnée effectuer son travail. Toutefois, certains utilisateurs avancés peuvent vouloir obtenir un verrouillage pessimiste exclusif sur un enregistrement et le réobtenir au lancement d'une nouvelle transaction."
|
||||
|
||||
#: index.docbook:819
|
||||
msgid "It is not intended that users spend much time worring about locking strategies. Its usually enough to specify an isolation level for the JDBC connections and then simply let the database do all the work. However, advanced users may sometimes wish to obtain exclusive pessimistic locks, or re-obtain locks at the start of a new transaction."
|
||||
msgstr "Hibernate utilisera toujours le mécanisme de verrouillage de la base de données et ne verrouillera jamais les objets en mémoire!"
|
||||
|
||||
#: index.docbook:826
|
||||
msgid "Hibernate will always use the locking mechanism of the database, never lock objects in memory!"
|
||||
msgstr "La classe <literal>LockMode</literal> définit les différents niveaux de verrouillage pouvant être obtenus par Hibernate. Le verrouillage est obtenu par les mécanismes suivants:"
|
||||
|
||||
#: index.docbook:831
|
||||
msgid "The <literal>LockMode</literal> class defines the different lock levels that may be acquired by Hibernate. A lock is obtained by the following mechanisms:"
|
||||
msgstr "<literal>LockMode.WRITE</literal> est obtenu automatiquement quand Hibernate actualise ou insert un enregistrement."
|
||||
|
||||
#: index.docbook:838
|
||||
msgid "<literal>LockMode.WRITE</literal> is acquired automatically when Hibernate updates or inserts a row."
|
||||
msgstr "<literal>LockMode.UPGRADE</literal> peut être obtenu de manière explicite via la requête en utilisant <literal>SELECT ... FOR UPDATE</literal> sur une base de données supportant cette syntaxe."
|
||||
|
||||
#: index.docbook:844
|
||||
msgid "<literal>LockMode.UPGRADE</literal> may be acquired upon explicit user request using <literal>SELECT ... FOR UPDATE</literal> on databases which support that syntax."
|
||||
msgstr "<literal>LockMode.UPGRADE_NOWAIT</literal> peut être obtenu de manière explicite en utilisant <literal>SELECT ... FOR UPDATE NOWAIT</literal> sur Oracle."
|
||||
|
||||
#: index.docbook:850
|
||||
msgid "<literal>LockMode.UPGRADE_NOWAIT</literal> may be acquired upon explicit user request using a <literal>SELECT ... FOR UPDATE NOWAIT</literal> under Oracle."
|
||||
msgstr "<literal>LockMode.READ</literal> est obtenu automatiquement quand Hibernate lit des données dans un contexte d'isolation <literal>Repeatable Read</literal> ou <literal>Serializable</literal> . Peut être réobtenu explicitement via une requête."
|
||||
|
||||
#: index.docbook:856
|
||||
msgid "<literal>LockMode.READ</literal> is acquired automatically when Hibernate reads data under Repeatable Read or Serializable isolation level. May be re-acquired by explicit user request."
|
||||
msgstr "<literal>LockMode.NONE</literal> représente l'absence de verouillage. Tous les objets migrent vers ce mode a la fin d'une <literal>Transaction</literal> . Les objets associés à une session via un appel à <literal>saveOrUpdate()</literal> commencent également leur cycle de vie dans cet état."
|
||||
|
||||
#: index.docbook:863
|
||||
msgid "<literal>LockMode.NONE</literal> represents the absence of a lock. All objects switch to this lock mode at the end of a <literal>Transaction</literal>. Objects associated with the session via a call to <literal>update()</literal> or <literal>saveOrUpdate()</literal> also start out in this lock mode."
|
||||
msgstr "Les niveaux de verrouillage peuvent être explicitement obtenus de l'une des manières suivantes:"
|
||||
|
||||
#: index.docbook:872
|
||||
msgid "The \"explicit user request\" is expressed in one of the following ways:"
|
||||
msgstr "Un appel à <literal>Session.load()</literal> , en spécifiant un niveau verrouillage <literal>LockMode</literal> ."
|
||||
|
||||
#: index.docbook:878
|
||||
msgid "A call to <literal>Session.load()</literal>, specifying a <literal>LockMode</literal>."
|
||||
msgstr "Un appel à <literal>Session.lock()</literal> ."
|
||||
|
||||
#: index.docbook:883
|
||||
msgid "A call to <literal>Session.lock()</literal>."
|
||||
msgstr "Une appel à <literal>Query.setLockMode()</literal> ."
|
||||
|
||||
#: index.docbook:888
|
||||
msgid "A call to <literal>Query.setLockMode()</literal>."
|
||||
msgstr "Si <literal>Session.load()</literal> est appelé avec le paramètre de niveau de verouillage <literal>UPGRADE</literal> ou <literal>UPGRADE_NOWAIT</literal> et que l'objet demandé n'est pas présent dans la session, celui-ci sera chargé à l'aide d'une requête <literal>SELECT ... FOR UPDATE</literal> . Si la méthode <literal>load()</literal> est appelée pour un objet déjà en session avec un verrouillage moindre que celui demandé, Hibernate appellera la méthode <literal>lock()</literal> pour cet objet."
|
||||
|
||||
#: index.docbook:894
|
||||
msgid "If <literal>Session.load()</literal> is called with <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>, and the requested object was not yet loaded by the session, the object is loaded using <literal>SELECT ... FOR UPDATE</literal>. If <literal>load()</literal> is called for an object that is already loaded with a less restrictive lock than the one requested, Hibernate calls <literal>lock()</literal> for that object."
|
||||
msgstr "<literal>Session.lock()</literal> effectue une vérification de version si le niveau de verrouillage est <literal>READ</literal> , <literal>UPGRADE</literal> ou <literal>UPGRADE_NOWAIT</literal> . (Dans le cas des niveaux <literal>UPGRADE</literal> ou <literal>UPGRADE_NOWAIT</literal> , une requête <literal>SELECT ... FOR UPDATE</literal> sera utilisée.)"
|
||||
|
||||
#: index.docbook:903
|
||||
msgid "<literal>Session.lock()</literal> performs a version number check if the specified lock mode is <literal>READ</literal>, <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>. (In the case of <literal>UPGRADE</literal> or <literal>UPGRADE_NOWAIT</literal>, <literal>SELECT ... FOR UPDATE</literal> is used.)"
|
||||
msgstr "Si une base de données ne supporte pas le niveau de verrouillage demandé, Hibernate utilisera un niveau alternatif convenable au lieux de lancer une exception. Ceci assurera la portabilité de votre application."
|
||||
|
||||
#: index.docbook:910
|
||||
msgid "If the database does not support the requested lock mode, Hibernate will use an appropriate alternate mode (instead of throwing an exception). This ensures that applications will be portable."
|
||||
msgstr "Mode de libération de Connection"
|
||||
|
||||
#: index.docbook:919
|
||||
msgid "Connection Release Modes"
|
||||
msgstr "Le comportement original (2.x) d'Hibernate pour la gestion des connexions JDBC était que la <literal>Session</literal> obtenait une connexion dès qu'elle en avait besoin et la libérait une fois la session fermée. Hibernate 3 a introduit les modes de libération de connexion pour indiquer à la session comment gérer les transactions JDBC. Notez que la discussion suivante n'est pertinente que pour des connexions fournies par un <literal>ConnectionProvider</literal>, celles gérées par l'utilisateur sont en dehors du scope de cette discussion. Les différents modes sont définies par <literal>org.hibernate.ConnectionReleaseMode</literal>:"
|
||||
|
||||
#: index.docbook:921
|
||||
msgid "The legacy (2.x) behavior of Hibernate in regards to JDBC connection management was that a <literal>Session</literal> would obtain a connection when it was first needed and then hold unto that connection until the session was closed. Hibernate 3.x introduced the notion of connection release modes to tell a session how to handle its JDBC connections. Note that the following discussion is pertinent only to connections provided through a configured <literal>ConnectionProvider</literal>; user-supplied connections are outside the breadth of this discussion. The different release modes are identified by the enumerated values of <literal>org.hibernate.ConnectionReleaseMode</literal>:"
|
||||
msgstr "<literal>ON_CLOSE</literal> - est essentiellement le comportement passé. La session Hibernate obtient une connexion lorsqu'elle en a besoin et la garde jusqu'à ce que la session se ferme."
|
||||
|
||||
#: index.docbook:935
|
||||
msgid "<literal>ON_CLOSE</literal> - is essentially the legacy behavior described above. The Hibernate session obatins a connection when it first needs to perform some JDBC access and holds unto that connection until the session is closed."
|
||||
msgstr "<literal>AFTER_TRANSACTION</literal> - indique de relacher la connexion après qu'une <literal>org.hibernate.Transaction</literal> se soit achevée."
|
||||
|
||||
#: index.docbook:942
|
||||
msgid "<literal>AFTER_TRANSACTION</literal> - says to release connections after a <literal>org.hibernate.Transaction</literal> has completed."
|
||||
msgstr "<literal>AFTER_STATEMENT</literal> (aussi appelé libération brutale) - indique de relacher les connexions après chaque exécution d'un statement. Ce relachement aggressif est annulé si ce statement laisse des ressources associées à une session donnée ouvertes, actuellement ceci n'arrive que lors de l'utilisation de <literal>org.hibernate.ScrollableResults</literal>."
|
||||
|
||||
#: index.docbook:948
|
||||
msgid "<literal>AFTER_STATEMENT</literal> (also referred to as aggressive release) - says to release connections after each and every statement execution. This aggressive releasing is skipped if that statement leaves open resources associated with the given session; currently the only situation where this occurs is through the use of <literal>org.hibernate.ScrollableResults</literal>."
|
||||
msgstr "Le paramètre de configuration <literal>hibernate.connection.release_mode</literal> est utilisé pour spécifier quel mode de libération doit être utiliser. Les valeurs possibles sont:"
|
||||
|
||||
#: index.docbook:958
|
||||
msgid "The configuration parameter <literal>hibernate.connection.release_mode</literal> is used to specify which release mode to use. The possible values:"
|
||||
msgstr "<literal>auto</literal> (valeur par défaut) - ce choix délègue le choix de libération à la méthode <literal>org.hibernate.transaction.TransactionFactory.getDefaultReleaseMode()</literal> Pour la JTATransactionFactory, elle retourne ConnectionReleaseMode.AFTER_STATEMENT; pour JDBCTransactionFactory, elle retourne ConnectionReleaseMode.AFTER_TRANSACTION. C'est rarement une bonne idée de changer ce comportement par défaut puisque les erreurs soulevées par ce paramétrage tend à prouver une erreur dans le code de l'utilisateur."
|
||||
|
||||
#: index.docbook:965
|
||||
msgid "<literal>auto</literal> (the default) - this choice delegates to the release mode returned by the <literal>org.hibernate.transaction.TransactionFactory.getDefaultReleaseMode()</literal> method. For JTATransactionFactory, this returns ConnectionReleaseMode.AFTER_STATEMENT; for JDBCTransactionFactory, this returns ConnectionReleaseMode.AFTER_TRANSACTION. It is rarely a good idea to change this default behavior as failures due to the value of this setting tend to indicate bugs and/or invalid assumptions in user code."
|
||||
msgstr "<literal>on_close</literal> - indique d'utiliser ConnectionReleaseMode.ON_CLOSE. Ce paramétrage existe pour garantir la compatibilité avec les versions précédentes, mais ne devrait plus être utilisé."
|
||||
|
||||
#: index.docbook:975
|
||||
msgid "<literal>on_close</literal> - says to use ConnectionReleaseMode.ON_CLOSE. This setting is left for backwards compatibility, but its use is highly discouraged."
|
||||
msgstr "<literal>after_transaction</literal> - indique d'utiliser ConnectionReleaseMode.AFTER_TRANSACTION. Ne devrait pas être utilisé dans les environnements JTA. Notez aussi qu'avec ConnectionReleaseMode.AFTER_TRANSACTION, si une session est considérée comme étant en mode auto-commit les connexions seront relachées comme si le mode était AFTER_STATEMENT."
|
||||
|
||||
#: index.docbook:981
|
||||
msgid "<literal>after_transaction</literal> - says to use ConnectionReleaseMode.AFTER_TRANSACTION. This setting should not be used in JTA environments. Also note that with ConnectionReleaseMode.AFTER_TRANSACTION, if a session is considered to be in auto-commit mode connections will be released as if the release mode were AFTER_STATEMENT."
|
||||
msgstr "<literal>after_statement</literal> - indique d'utiliser ConnectionReleaseMode.AFTER_STATEMENT. Additonnellement, le <literal>ConnectionProvider</literal> utilisé est consulté pour savoir s'il supporte ce paramétrage (<literal>supportsAggressiveRelease()</literal>). Si ce n'est pas le cas, le mode de libération est ré initialisé à ConnectionReleaseMode.AFTER_TRANSACTION. Ce paramétrage n'est sûr que dans les environnements où il est possible d'obtenir à nouveau la même connexion JDBC à chaque fois que l'on fait un appel de <literal>ConnectionProvider.getConnection()</literal> ou dans les envrionnements auto-commit où il n'est pas important d'obtenir plusieurs fois la même connexion."
|
||||
|
||||
#: index.docbook:989
|
||||
msgid "<literal>after_statement</literal> - says to use ConnectionReleaseMode.AFTER_STATEMENT. Additionally, the configured <literal>ConnectionProvider</literal> is consulted to see if it supports this setting (<literal>supportsAggressiveRelease()</literal>). If not, the release mode is reset to ConnectionReleaseMode.AFTER_TRANSACTION. This setting is only safe in environments where we can either re-acquire the same underlying JDBC connection each time we make a call into <literal>ConnectionProvider.getConnection()</literal> or in auto-commit environments where it does not matter whether we get back the same connection."
|
||||
msgstr ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,420 @@
|
|||
#, 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 "Mapping XML"
|
||||
|
||||
#: index.docbook:7
|
||||
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."
|
||||
|
||||
#: index.docbook:13
|
||||
msgid "Working with XML data"
|
||||
msgstr "Travailler avec des données 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 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."
|
||||
|
||||
#: 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 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é)."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 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."
|
||||
|
||||
#: index.docbook:44
|
||||
msgid "Specifying XML and class mapping together"
|
||||
msgstr "Spécifier le mapping XML et le mapping d'une classe ensemble"
|
||||
|
||||
#: index.docbook:46
|
||||
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 :"
|
||||
|
||||
#: 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 "Spécifier seulement un mapping XML"
|
||||
|
||||
#: index.docbook:56
|
||||
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 :"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: index.docbook:73
|
||||
msgid "XML mapping metadata"
|
||||
msgstr "Métadonnées du mapping 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 "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 :"
|
||||
|
||||
#: index.docbook:84
|
||||
msgid "<literal>\"element-name\"</literal> - map to the named XML element"
|
||||
msgstr "<literal>\"element-name\"</literal> - mappe vers l'élément XML nommé"
|
||||
|
||||
#: index.docbook:87
|
||||
msgid "<literal>\"@attribute-name\"</literal> - map to the named XML attribute"
|
||||
msgstr "<literal>\"@attribute-name\"</literal> - mappe vers l'attribut XML nommé"
|
||||
|
||||
#: index.docbook:90
|
||||
msgid "<literal>\".\"</literal> - map to the parent element"
|
||||
msgstr "<literal>\".\"</literal> - mappe vers le parent de l'élément"
|
||||
|
||||
#: 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> - mappe vers l'élément nommé de l'attribut nommé"
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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."
|
||||
|
||||
#: 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 "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 :"
|
||||
|
||||
#: 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 "devrait retourner l'ensemble de données suivant :"
|
||||
|
||||
#: 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 vous positionnez <literal>embed-xml=\"true\"</literal> sur le mapping <literal><one-to-many></literal>, les données pourraient ressembler plus à ça :"
|
||||
|
||||
#: 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 "Manipuler des données XML"
|
||||
|
||||
#: index.docbook:143
|
||||
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 :"
|
||||
|
||||
#: 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.getRootElement().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 "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."
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
#, 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 material may be distributed only subject to the terms and conditions set forth in the Open Publication License, V1.0 or later (the latest version is presently available at <ulink url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/openpub/</ulink>)."
|
||||
msgstr "Copyright <trademark class=\"copyright\"></trademark> 2007 by Red Hat, Inc. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, V1.0 or later (the latest version is presently available at <ulink url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/openpub/</ulink>)."
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder."
|
||||
msgstr "Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder."
|
||||
|
||||
#: index.docbook:37
|
||||
msgid "Distribution of the work or derivative of the work in any standard (paper) book form for commercial purposes is prohibited unless prior permission is obtained from the copyright holder."
|
||||
msgstr "Distribution of the work or derivative of the work in any standard (paper) book form for commercial purposes is prohibited unless prior permission is obtained from the copyright holder."
|
||||
|
||||
#: 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 - Relational Persistence for Idiomatic Java"
|
||||
|
||||
#: index.docbook:27
|
||||
msgid "Hibernate Reference Documentation"
|
||||
msgstr "Hibernate Reference Documentation"
|
||||
|
||||
#: 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,216 @@
|
|||
#, 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 ""
|
||||
|
||||
#: index.docbook:24
|
||||
msgid "Overview"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:26
|
||||
msgid "A (very) high-level view of the Hibernate architecture:"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:75
|
||||
msgid "Heres some definitions of the objects in the diagrams:"
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:80
|
||||
msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:92
|
||||
msgid "Session (<literal>org.hibernate.Session</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:104
|
||||
msgid "Persistent objects and collections"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:117
|
||||
msgid "Transient and detached objects and collections"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:128
|
||||
msgid "Transaction (<literal>org.hibernate.Transaction</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:141
|
||||
msgid "ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:151
|
||||
msgid "TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:160
|
||||
msgid "Extension Interfaces"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:179
|
||||
msgid "Instance states"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:188
|
||||
msgid "transient"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:198
|
||||
msgid "persistent"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "detached"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:229
|
||||
msgid "JMX Integration"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:268
|
||||
msgid "Consult the JBoss AS user guide for more information about these options."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:272
|
||||
msgid "Another feature available as a JMX service are runtime Hibernate statistics. See <xref linkend=\"configuration-optional-statistics\"/>."
|
||||
msgstr ""
|
||||
|
||||
#: index.docbook:279
|
||||
msgid "JCA Support"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: index.docbook:287
|
||||
msgid "Contextual Sessions"
|
||||
msgstr ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
#: 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 ""
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
|
@ -0,0 +1,952 @@
|
|||
#, 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:6
|
||||
msgid "Association Mappings"
|
||||
msgstr "関連マッピング"
|
||||
|
||||
#: index.docbook:9
|
||||
msgid "Introduction"
|
||||
msgstr "イントロダクション"
|
||||
|
||||
#: index.docbook:11
|
||||
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 "関連マッピングはしばしば理解が最も難しいものになります。 この章では、基本的な一つ一つのケースについて述べます。 単方向のマッピングから始め、それから双方向のケースについて考えていきます。 例として、<literal>Person</literal> と <literal>Address</literal> を用います。"
|
||||
|
||||
#: index.docbook:19
|
||||
msgid "We'll classify associations by whether or not they map to an intervening join table, and by multiplicity."
|
||||
msgstr "関連は、結合テーブルを入れるかかどうかと、 多重度によって分類することにします。"
|
||||
|
||||
#: index.docbook:24
|
||||
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 "すべての例でnot nullの外部キーを使用します。 これはHibernateの要件ではありません。 not null制約を外したとしても、マッピングは問題なく動作します。"
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Unidirectional associations"
|
||||
msgstr "単方向関連"
|
||||
|
||||
#: index.docbook:37, index.docbook:108
|
||||
msgid "many to one"
|
||||
msgstr "<title>多対一</title>"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "A <emphasis>unidirectional many-to-one association</emphasis> is the most common kind of unidirectional association."
|
||||
msgstr "<emphasis>単方向多対一関連</emphasis> は単方向関連の中で最も一般的なものです。"
|
||||
|
||||
#: index.docbook:44
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:45, index.docbook:161
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:50, index.docbook:121, index.docbook:185, index.docbook:225
|
||||
msgid "one to one"
|
||||
msgstr "<title>一対一</title>"
|
||||
|
||||
#: index.docbook:52
|
||||
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 "<emphasis>外部キーの単方向一対一関連</emphasis> はほとんど同じものです。 唯一違うのは、カラムのユニークな制約です。"
|
||||
|
||||
#: index.docbook:57
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:58, index.docbook:193
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:60
|
||||
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 "<emphasis>主キーの単方向一対一関連</emphasis> は通常、特別なIDジェネレータを使います。 (この例では関連の方向が逆になっていることに注意してください)"
|
||||
|
||||
#: index.docbook:66
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:67, index.docbook:201
|
||||
msgid ""
|
||||
"<![CDATA[\n"
|
||||
"create table Person ( personId bigint not null primary key )\n"
|
||||
"create table Address ( personId bigint not null primary key )\n"
|
||||
" ]]>"
|
||||
msgstr ""
|
||||
"<![CDATA[
\n"
|
||||
"create table Person ( personId bigint not null primary key )
\n"
|
||||
"create table Address ( personId bigint not null primary key )
\n"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:72, index.docbook:94
|
||||
msgid "one to many"
|
||||
msgstr "<title>一対多</title>"
|
||||
|
||||
#: index.docbook:74
|
||||
msgid "A <emphasis>unidirectional one-to-many association on a foreign key</emphasis> is a very unusual case, and is not really recommended."
|
||||
msgstr "<emphasis>外部キーの単方向一対多関連</emphasis> はとても特殊なケースで、 あまり推奨されていません。"
|
||||
|
||||
#: index.docbook:79
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:80
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:82
|
||||
msgid "We think it's better to use a join table for this kind of association."
|
||||
msgstr "このような関連のために結合テーブルを使うことをお薦めします。"
|
||||
|
||||
#: index.docbook:91
|
||||
msgid "Unidirectional associations with join tables"
|
||||
msgstr "結合テーブルを使った単方向関連"
|
||||
|
||||
#: index.docbook:96
|
||||
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 "<emphasis>結合テーブルを使った単方向一対多関連</emphasis> はより好ましいです。 <literal>unique=\"true\"</literal> の指定により、多重度が多対多から一対多 に変わったことに注意して下さい。"
|
||||
|
||||
#: index.docbook:102
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:103
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "A <emphasis>unidirectional many-to-one association on a join table</emphasis> is quite common when the association is optional."
|
||||
msgstr "<emphasis>結合テーブルの単方向多対一関連</emphasis> は 関連が任意であるときに非常に一般的なものです。"
|
||||
|
||||
#: index.docbook:115
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:116
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:123
|
||||
msgid "A <emphasis>unidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."
|
||||
msgstr "<emphasis>結合テーブルの単方向一対一関連</emphasis> は、本当に特殊ですが 不可能ではありません。"
|
||||
|
||||
#: index.docbook:128
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:129, index.docbook:233
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:134, index.docbook:238
|
||||
msgid "many to many"
|
||||
msgstr "<title>多対多</title>"
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "Finally, we have a <emphasis>unidirectional many-to-many association</emphasis>."
|
||||
msgstr "最後に、<emphasis>単方向多対多関連</emphasis> を示します。"
|
||||
|
||||
#: index.docbook:140
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:141, index.docbook:246
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:148
|
||||
msgid "Bidirectional associations"
|
||||
msgstr "双方向関連"
|
||||
|
||||
#: index.docbook:151, index.docbook:211
|
||||
msgid "one to many / many to one"
|
||||
msgstr "一対多/多対一"
|
||||
|
||||
#: index.docbook:153
|
||||
msgid "A <emphasis>bidirectional many-to-one association</emphasis> is the most common kind of association. (This is the standard parent/child relationship.)"
|
||||
msgstr "<emphasis>双方向多対一関連</emphasis> は最も一般的な関連です。 (標準的な親子関係です)"
|
||||
|
||||
#: index.docbook:159
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:163
|
||||
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 "<literal>List</literal> (または他のインデックス付きのコレクション)を使うなら、 外部キーの <literal>key</literal> カラムを <literal>not null</literal> に設定し、 コレクション側が各要素のインデックスをメンテナンスするように、 関連を扱う必要があります (<literal>update=\"false\"</literal> かつ <literal>insert=\"false\"</literal> と設定して、反対側を仮想的にinverseにします):"
|
||||
|
||||
#: index.docbook:171
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:173
|
||||
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 "もし外部キーカラムが <literal>NOT NULL</literal> であるならば、 コレクションマッピングの <literal><key></literal> 要素を <literal>not-null=\"true\"</literal> にすることは重要です。 入れ子になった <literal><column></literal> 要素だけではなく、 <literal><key></literal> 要素も <literal>not-null=\"true\"</literal> と定義しないようにしてください。"
|
||||
|
||||
#: index.docbook:187
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> is quite common."
|
||||
msgstr "<emphasis>外部キーの双方向一対一関連</emphasis> は非常に一般的です。"
|
||||
|
||||
#: index.docbook:192
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:195
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a primary key</emphasis> uses the special id generator."
|
||||
msgstr "<emphasis>主キーの双方向一対一関連</emphasis> は特殊なIDジェネレータを使います。"
|
||||
|
||||
#: index.docbook:200
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:208
|
||||
msgid "Bidirectional associations with join tables"
|
||||
msgstr "結合テーブルを使った双方向関連"
|
||||
|
||||
#: index.docbook:213
|
||||
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 "<emphasis>結合テーブルの双方向一対多関連</emphasis> です。 <literal>inverse=\"true\"</literal> が関連端、コレクション、結合のいずれかに 設定できることに注意してください。"
|
||||
|
||||
#: index.docbook:219
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:220
|
||||
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 ""
|
||||
"<![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"
|
||||
" ]]>"
|
||||
|
||||
#: index.docbook:227
|
||||
msgid "A <emphasis>bidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."
|
||||
msgstr "<emphasis>結合テーブルの双方向一対一関連</emphasis> は非常に特殊ですが、可能です。"
|
||||
|
||||
#: index.docbook:232
|
||||
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 ""
|
||||
"<![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=\"address\"
\n"
|
||||
" column=\"personId\"
\n"
|
||||
" not-null=\"true\"
\n"
|
||||
" unique=\"true\"/>
\n"
|
||||
" </join>
\n"
|
||||
"</class>]]>"
|
||||
|
||||
#: index.docbook:240
|
||||
msgid "Finally, we have a <emphasis>bidirectional many-to-many association</emphasis>."
|
||||
msgstr "最後に、<emphasis>双方向多対多関連</emphasis> を示します。"
|
||||
|
||||
#: index.docbook:244
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:253
|
||||
msgid "More complex association mappings"
|
||||
msgstr "より複雑な関連マッピング"
|
||||
|
||||
#: index.docbook:255
|
||||
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 "より複雑な関連結合は <emphasis>極めて</emphasis> 稀です。 マッピングドキュメントにSQL文を埋め込むことで、 さらに複雑な状況を扱うことができます。 例えば、<literal>accountNumber</literal>, <literal>effectiveEndDate</literal>, <literal>effectiveStartDate</literal> カラムを持つaccount(口座)情報の履歴を扱うテーブルは、 以下のようにマッピングします。"
|
||||
|
||||
#: index.docbook:264
|
||||
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 ""
|
||||
"<![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\"/>]]>"
|
||||
|
||||
#: index.docbook:266
|
||||
msgid "Then we can map an association to the <emphasis>current</emphasis> instance (the one with null <literal>effectiveEndDate</literal>) using:"
|
||||
msgstr "そして、関連を <emphasis>現時点の</emphasis> インスタンス (<literal>effectiveEndDate</literal> がnullであるもの)にマッピングします。 以下のようになります:"
|
||||
|
||||
#: index.docbook:271
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:273
|
||||
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 "さらに複雑な例では、<literal>Employee(従業員)</literal> と <literal>Organization(組織)</literal> 間の関連が <literal>Employment(雇用)</literal> テーブルで保持される場合を想像してください。 このテーブルには雇用データの履歴がすべて含まれます。 すると従業員の <emphasis>最も最近の</emphasis> 雇用者を表す関連 (最も最近の <literal>startDate</literal> を持つもの)は、このようにマッピングできます:"
|
||||
|
||||
#: index.docbook:281
|
||||
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 ""
|
||||
"<![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>]]>"
|
||||
|
||||
#: index.docbook:283
|
||||
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 "この機能は非常に強力です。 しかしこのような場合、普通はHQLやcriteriaクエリを使う方がより実践的です。"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,374 @@
|
|||
#, 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 "バッチ処理"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "A naive approach to inserting 100 000 rows in the database using Hibernate might look like this:"
|
||||
msgstr "Hibernateを使ってデータベースに100,000行を挿入する愚直な方法は、このようなものです:"
|
||||
|
||||
#: 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 "これは50,000番目の行のあたりで <literal>OutOfMemoryException</literal> で失敗するでしょう。 Hibernateがセッションレベルキャッシュで、 新しく挿入されたすべての <literal>Customer</literal> インスタンスをキャッシュするからです。"
|
||||
|
||||
#: 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 "この章では、この問題を回避する方法を紹介します。 しかしバッチ処理をするなら、JDBCバッチが使用可能であることが非常に重要です。 そうでなければ手頃なパフォーマンスが得られません。 JDBCバッチサイズを手頃な数値(例えば、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 "また二次キャッシュが全く効かないプロセスで、 このような作業をしたいと思うかもしれません:"
|
||||
|
||||
#: 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 "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
|
||||
msgstr "しかし、これは絶対に必要というわけではありません。 なぜなら明示的に <literal>CacheMode</literal> を設定して、 二次キャッシュとの相互作用を無効にすることができるからです。"
|
||||
|
||||
#: 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 "バッチ挿入"
|
||||
|
||||
#: index.docbook:47
|
||||
msgid "Batch inserts"
|
||||
msgstr "新しいオブジェクトを永続化するとき、一次キャッシュのサイズを制限するため、 セッションを <literal>flush()</literal> して <literal>clear()</literal> しなければなりません。"
|
||||
|
||||
#: 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 ""
|
||||
"<![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: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 "バッチ更新"
|
||||
|
||||
#: index.docbook:60
|
||||
msgid "Batch updates"
|
||||
msgstr "データを復元したり更新したりするには同じアイディアを適用します。 それに加えて、データの行を多く返すクエリに対して有効な サーバーサイドのカーソルの利点を生かしたければ <literal>scroll()</literal> を使う必要があります。"
|
||||
|
||||
#: 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 ""
|
||||
"<![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: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 "StatelessSessionインターフェイス"
|
||||
|
||||
#: index.docbook:73
|
||||
msgid "The StatelessSession interface"
|
||||
msgstr "また別の方法として、Hibernateはコマンド指向のAPIを用意しています。 これは分離オブジェクトの形で、 データベースとのデータストリームのやり取りに使うことができます。 <literal>StatelessSession</literal> は関連する永続コンテキストを持たず、 高レベルのライフサイクルセマンティクスの多くを提供しません。 特にステートレスセッションは、一時キャッシュを実装せず、 またどのような二次キャッシュやクエリキャッシュとも相互作用しません。 トランザクショナルなwrite-behindや自動ダーティチェックも実装しません。 ステートレスセッションを使って行われる操作が、 関連するインスタンスへカスケードされることは決してありません。 コレクションは、ステートレスセッションからは無視されます。 ステートレスセッションを通して行われる操作は、 Hibernateのイベントモデルやインターセプタの影響を受けません。 一時キャッシュを持たないため、 ステートレスセッションは別名を持つデータに上手く対処できません。 ステートレスセッションは低レベルの抽象化であり、JDBCに非常によく似ています。"
|
||||
|
||||
#: 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 ""
|
||||
"<![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: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 "このコード例では、クエリが返す <literal>Customer</literal> インスタンスは即座に(セッションから)分離されることに注意してください。 これは、どのような永続コンテキストとも決して関連しません。"
|
||||
|
||||
#: 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 "<literal>StatelessSession</literal> インターフェイスで定義されている <literal>insert(), update(), delete()</literal> は、 低レベルの直接的なデータベース操作と考えられます。 結果として、SQLの <literal>INSERT, UPDATE, DELETE</literal> がそれぞれ即座に実行されます。 このように、これらは <literal>Session</literal> インターフェイスで定義されている <literal>save(), saveOrUpdate(), delete()</literal> とは非常に異なる意味を持ちます。"
|
||||
|
||||
#: 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 "DMLスタイルの操作"
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "DML-style operations"
|
||||
msgstr "すでに議論したように、自動的かつ透過的なオブジェクト/リレーショナルマッピングは、 オブジェクトの状態の管理であると考えられます。 これはメモリ内のオブジェクトの状態を利用できるということです。 そのため(SQLの <literal>データ操作言語</literal> (DML) 文: <literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</literal> を使って)データベース内のデータを直接操作しても、 メモリ内の状態には影響を与えません。 しかしHibernateは、バルクSQLスタイルのDML文実行に対応するメソッドを用意しています。 これはHibernateクエリ言語(<xref linkend=\"queryhql\"/>HQL) を通して実行されます。"
|
||||
|
||||
#: 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 (<xref linkend=\"queryhql\"/>HQL)."
|
||||
msgstr "<literal>UPDATE</literal> と <literal>DELETE</literal> 文の疑似構文は: <literal>( UPDATE | DELETE ) FROM? エンティティ名 (WHERE 条件節)?</literal> です。 注意すべき点がいくつかあります:"
|
||||
|
||||
#: 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 "from節において、FROMキーワードはオプションです。"
|
||||
|
||||
#: index.docbook:130
|
||||
msgid "In the from-clause, the FROM keyword is optional"
|
||||
msgstr "from節では単一のエンティティ名だけが可能で、 任意で別名を付けることができます。 エンティティ名に別名が与えられると、どのようなプロパティ参照も、 その別名を使って修飾しなければなりません。 もしエンティティ名に別名が与えられなければ、 どのようなプロパティ参照も修飾してはなりません。"
|
||||
|
||||
#: 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 "(暗黙的であれ明示的であれ)<xref linkend=\"queryhql-joins-forms\"/>結合 をバルクHQLクエリ内で指定することはできません。 サブクエリはwhere節で使うことができます サブクエリそのものは、結合を含められます。"
|
||||
|
||||
#: index.docbook:143
|
||||
msgid "No <xref linkend=\"queryhql-joins-forms\"/>joins (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 "where節はオプションです。"
|
||||
|
||||
#: index.docbook:150
|
||||
msgid "The where-clause is also optional."
|
||||
msgstr "例として、HQLの <literal>UPDATE</literal> を実行するには、 <literal>Query.executeUpdate()</literal> メソッドを使ってください。 (このメソッドはおなじみのJDBC <literal>PreparedStatement.executeUpdate()</literal> から名付けられました): d"
|
||||
|
||||
#: 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 ""
|
||||
"<![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: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 "HQLの <literal>UPDATE</literal> 文は、デフォルトでは、作用するエンティティの <xref linkend=\"mapping-declaration-version\"/>version や <xref linkend=\"mapping-declaration-timestamp\"/>timestamp プロパティの値には影響しません。 これはEJB3の仕様にも受け継がれています。 しかし <literal>versioned update</literal> を使って、 <literal>version</literal> や <literal>timestamp</literal> プロパティの値を強制的にリセットさせることができます。 これは <literal>UPDATE</literal> キーワードの後に <literal>VERSIONED</literal> キーワードを追加することで行えます。"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "HQL <literal>UPDATE</literal> statements, by default do not effect the <xref linkend=\"mapping-declaration-version\"/>version or the <xref linkend=\"mapping-declaration-timestamp\"/>timestamp 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 ""
|
||||
"<![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: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 "カスタムバージョン型(<literal>org.hibernate.usertype.UserVersionType</literal>) は <literal>update versioned</literal> 文と一緒に使えないことに注意してください。"
|
||||
|
||||
#: 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 "HQLの <literal>DELETE</literal> を実行するには、 同じ <literal>Query.executeUpdate()</literal> メソッドを使ってください:"
|
||||
|
||||
#: index.docbook:181
|
||||
msgid "To execute an HQL <literal>DELETE</literal>, use the same <literal>Query.executeUpdate()</literal> method:"
|
||||
msgstr ""
|
||||
"<![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();]]>"
|
||||
|
||||
#: 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 "<literal>Query.executeUpdate()</literal> メソッドが返す <literal>int</literal> の値は、この操作が影響を及ぼしたエンティティの数です。 これが影響するデータベース内の行数と、相互に関係するかどうかを考えてみてください。 HQLバルク操作は、結果として、実際のSQL文が複数実行されることになります。 例えばjoined-subclassです。 返される数は、その文によって影響された実際のエンティティの数を示します。 joined-subclassの例に戻ると、サブクラスの一つに対する削除は、 そのサブクラスがマッピングされたテーブルだけではなく、 「ルート」テーブルと継承階層をさらに下ったjoined-subclassのテーブルの削除になります。"
|
||||
|
||||
#: 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 "<literal>INSERT</literal> 文の疑似構文は: <literal>INSERT INTO エンティティ名 プロパティリスト select文</literal> です。 注意すべき点がいくつかあります:"
|
||||
|
||||
#: 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 "INSERT INTO ... SELECT ... の形式だけがサポートされています。 INSERT INTO ... VALUES ... の形式はサポートされていません。"
|
||||
|
||||
#: index.docbook:207
|
||||
msgid "Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form."
|
||||
msgstr "プロパティリストは、SQLの <literal>INSERT</literal> 文における <literal>カラムの仕様</literal> に類似しています。 継承のマッピングに含まれるエンティティに対して、 クラスレベルで直接定義されたプロパティだけが、プロパティリストに使えます。 スーパークラスのプロパティは認められず、サブクラスのプロパティは効果がありません。 言い換えると <literal>INSERT</literal> 文は、本質的にポリモーフィックではありません。"
|
||||
|
||||
#: 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 "select文の返り値の型がinsert文が期待する型とマッチしていれば、 そのselect文は妥当なHQL selectクエリとなりえます。 現在このチェックをデータベースへ任せるのではなく、クエリのコンパイル時にチェックします。 このことは、<emphasis>equal</emphasis>とは違い、 Hibernateの <literal>Type</literal> 間の <emphasis>equivalent</emphasis> に関する 問題を引き起こすことに注意してください。 これは <literal>org.hibernate.type.DataType</literal> として定義されたプロパティと、 <literal>org.hibernate.type.TimestampType</literal> として定義されたプロパティの間のミスマッチの問題を引き起こします。 データベースがそれらを区別できなくても、変換することができても、この問題は発生します。"
|
||||
|
||||
#: 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 "idプロパティに対して、insert文には二つの選択肢があります。 プロパティリストで明示的にidプロパティを指定するか (この場合、対応するselect式から値が取られます)、 プロパティリストから除外するか (この場合、生成される値が使われます)のいずれかです。 後者の選択肢は、データベース内を操作するidジェネレータを使うときのみ、利用可能です。 この選択肢を採る場合、「インメモリ」型のジェネレータを使うと、構文解析時に例外が発生します。 この議論では、インデータベース型ジェネレータは <literal>org.hibernate.id.SequenceGenerator</literal> (とそのサブクラス)と、<literal>org.hibernate.id.PostInsertIdentifierGenerator</literal> の実装であると考えています。 ここで最も注意すべき例外は、<literal>org.hibernate.id.TableHiLoGenerator</literal> です。 値を取得する選択可能な方法がないため、このジェネレータを使うことはできません。"
|
||||
|
||||
#: 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 "<literal>version</literal> や <literal>timestamp</literal> としてマッピングされるプロパティに対して、 insert文には二つの選択肢があります。 プロパティリストで明示的にプロパティを指定するか (この場合、対応するselect式から値が取られます)、 プロパティリストから除外するか (この場合、<literal>org.hibernate.type.VersionType</literal> で定義された <literal>シード値</literal> が使われます)のいずれかです。"
|
||||
|
||||
#: 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 "HQLの <literal>INSERT</literal> 文の実行例です:"
|
||||
|
||||
#: index.docbook:257
|
||||
msgid "An example HQL <literal>INSERT</literal> statement execution:"
|
||||
msgstr ""
|
||||
"<![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();]]>"
|
||||
|
||||
#: 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,168 @@
|
|||
#, 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 "ベストプラクティス"
|
||||
|
||||
#: index.docbook:9
|
||||
msgid "Write fine-grained classes and map them using <literal><component></literal>."
|
||||
msgstr "クラスは細かい粒度で書き <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 "<literal>street</literal>(通り), <literal>suburb</literal> (都市), <literal>state</literal>(州), <literal>postcode</literal> (郵便番号)をカプセル化する <literal>Address</literal>(住所)クラスを使いましょう。 そうすればコードが再利用しやすくなり、リファクタリングも簡単になります。"
|
||||
|
||||
#: index.docbook:19
|
||||
msgid "Declare identifier properties on persistent classes."
|
||||
msgstr "永続クラスには識別子プロパティを定義しましょう。"
|
||||
|
||||
#: 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では識別子プロパティはオプションですが、 使用すべき理由がたくさんあります。 識別子は「人工的」(生成された、業務的な意味を持たない) なものにすることをおすすめします。"
|
||||
|
||||
#: index.docbook:29
|
||||
msgid "Identify natural keys."
|
||||
msgstr "自然キーを見つけましょう。"
|
||||
|
||||
#: 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 "すべてのエンティティに対して自然キーを見つけて、 <literal><natural-id></literal> でマッピングしましょう。 自然キーを構成するプロパティを比較するために、 <literal>equals()</literal> と <literal>hashCode()</literal> を実装しましょう。"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "Place each class mapping in its own file."
|
||||
msgstr "クラスのマッピングはそれぞれのクラス専用のファイルに書きましょう。"
|
||||
|
||||
#: 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 "単一の巨大なマッピングドキュメントを使用しないでください。 <literal>com.eg.Foo</literal> クラスなら <literal>com/eg/Foo.hbm.xml</literal> ファイルにマッピングしましょう。 このことは、特にチームでの開発に意味があります。"
|
||||
|
||||
#: index.docbook:49
|
||||
msgid "Load mappings as resources."
|
||||
msgstr "リソースとしてマッピングをロードしましょう。"
|
||||
|
||||
#: index.docbook:51
|
||||
msgid "Deploy the mappings along with the classes they map."
|
||||
msgstr "マッピングを、それらがマッピングするするクラスと一緒に配置しましょう。"
|
||||
|
||||
#: index.docbook:57
|
||||
msgid "Consider externalising query strings."
|
||||
msgstr "クエリ文字列を外部に置くことを考えましょう"
|
||||
|
||||
#: 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 "クエリがANSI標準でないSQL関数を呼んでいるなら、これはよいプラクティスです。 クエリ文字列をマッピングファイルへ外出しすればアプリケーションがポータブルになります。"
|
||||
|
||||
#: index.docbook:67
|
||||
msgid "Use bind variables."
|
||||
msgstr "バインド変数を使いましょう。"
|
||||
|
||||
#: 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 "JDBCの場合と同じように、定数でない値は必ず\"?\"で置き換えましょう。 定数でない値をバインドするために、クエリで文字列操作を使ってはいけません。 名前付きのパラメータを使うようにするとさらに良いです。"
|
||||
|
||||
#: index.docbook:77
|
||||
msgid "Don't manage your own JDBC connections."
|
||||
msgstr "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ではアプリケーションがJDBCコネクションを管理することが許されています。 しかしこれは最終手段だと思ってください。 組み込みのコネクションプロバイダを使うことができなければ、 <literal>org.hibernate.connection.ConnectionProvider</literal> を実装することを考えてください。"
|
||||
|
||||
#: index.docbook:87
|
||||
msgid "Consider using a custom type."
|
||||
msgstr "カスタム型の使用を考えましょう。"
|
||||
|
||||
#: 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 "あるライブラリから持ってきたJava型を永続化する必要があるとしましょう。 しかしその型には、コンポーネントとしてマッピングするために必要なアクセサがないとします。 このような場合は <literal>org.hibernate.UserType</literal> の実装を考えるべきです。 そうすればHibernate型との実装変換を心配せずにアプリケーションのコードを扱えます。"
|
||||
|
||||
#: index.docbook:98
|
||||
msgid "Use hand-coded JDBC in bottlenecks."
|
||||
msgstr "ボトルネックを解消するにはJDBCをハンドコードしましょう。"
|
||||
|
||||
#: 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 "システムのパフォーマンスクリティカルな領域では、 ある種の操作にJDBCを直接使うと良いかもしれません。 しかし何がボトルネックになっているか <emphasis>はっきりする</emphasis> までは待ってください。 またJDBCを直接使うからといって、必ずしも速くなるとは限らないことも理解してください。 JDBCを直接使う必要があれば、Hibernateの <literal>Session</literal> をオープンして、 JDBCコネクションを使うと良いかもしれません。 依然として同じトランザクション戦略とコネクションプロバイダが使えるからです。"
|
||||
|
||||
#: index.docbook:110
|
||||
msgid "Understand <literal>Session</literal> flushing."
|
||||
msgstr "<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 "Sessionが永続状態をデータベースと同期させることがときどきあります。 しかしこれがあまりに頻繁に起こるようだと、パフォーマンスに影響が出てきます。 自動フラッシュを無効にしたり、特定のトランザクションのクエリや操作の順番を変更することで、 不必要なフラッシュを最小限にできます。"
|
||||
|
||||
#: index.docbook:121
|
||||
msgid "In a three tiered architecture, consider using detached objects."
|
||||
msgstr "3層アーキテクチャでは分離オブジェクトの使用を考えましょう。"
|
||||
|
||||
#: 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 "サーブレット / セッションビーンアーキテクチャを使うとき、 サーブレット層 / JSP層間でセッションビーンでロードした永続オブジェクトをやり取りできます。 その際リクエストごとに新しいSessionを使ってください。 また <literal>Session.merge()</literal> や <literal>Session.saveOrUpdate()</literal> を使って、オブジェクトとデータベースを同期させてください。"
|
||||
|
||||
#: index.docbook:132
|
||||
msgid "In a two tiered architecture, consider using long persistence contexts."
|
||||
msgstr "2層アーキテクチャでは長い永続コンテキストの使用を考えましょう。"
|
||||
|
||||
#: 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 "最高のスケーラビリティを得るには、 データベーストランザクションをできるだけ短くしなければなりません。 しかし長い間実行する <emphasis>アプリケーショントランザクション</emphasis> の実装が必要なことはしばしばです。 これはユーザの視点からは1個の作業単位(unit of work)になります。 アプリケーショントランザクションはいくつかのクライアントのリクエスト/レスポンスサイクルにまたがります。 アプリケーショントランザクションの実装に分離オブジェクトを使うのは一般的です。 そうでなければ、2層アーキテクチャの場合は特に適切なことですが、 アプリケーショントランザクションのライフサイクル全体に対して 単一のオープンな永続化コンテキスト(セッション)を維持してください。 そして単純にリクエストの最後にJDBCコネクションから切断し、 次のリクエストの最初に再接続します。 決して複数のアプリケーショントランザクションユースケースに渡って 1個のSessionを使い回さないでください。 そうでなければ、古いデータで作業することになります。"
|
||||
|
||||
#: index.docbook:148
|
||||
msgid "Don't treat exceptions as recoverable."
|
||||
msgstr "例外を復帰可能なものとして扱ってはいけません。"
|
||||
|
||||
#: 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 "これは「ベスト」プラクティス以上の、必須のプラクティスです。 例外が発生したときは <literal>Transaction</literal> をロールバックして、 <literal>Session</literal> をクローズしてください。 そうしないとHibernateはメモリの状態が永続状態を正確に表現していることを保証できません。 この特別な場合として、与えられた識別子を持つインスタンスがデータベースに存在するかどうかを判定するために、 <literal>Session.load()</literal> を使うことはやめてください。 その代わりに <literal>Session.get()</literal> かクエリを使ってください。"
|
||||
|
||||
#: index.docbook:160
|
||||
msgid "Prefer lazy fetching for associations."
|
||||
msgstr "関連にはなるべく遅延フェッチを使いましょう。"
|
||||
|
||||
#: 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 "即時フェッチは控えめにしましょう。 二次キャッシュには完全に保持されないようなクラスの関連には、 プロキシと遅延コレクションを使ってください。 キャッシュされるクラスの関連、つまりキャッシュがヒットする可能性が非常に高い関連は、 <literal>lazy=\"false\"</literal> で積極的なフェッチを明示的に無効にしてください。 結合フェッチが適切な特定のユースケースには、 クエリで <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 "フェッチされていないデータに関わる問題を避けるために、 <emphasis>ビューの中でオープンセッションを使う(open session in view)</emphasis> パターンか、統制された <emphasis>組み立てフェーズ(assembly phase)</emphasis> を使いましょう。"
|
||||
|
||||
#: 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は <emphasis>Data Transfer Objects</emphasis> (DTO)を書く退屈な作業から開発者を解放します。 伝統的なEJBアーキテクチャではDTOは二つ目的があります: 1つ目は、エンティティビーンがシリアライズされない問題への対策です。 2つ目は、プレゼンテーション層に制御が戻る前に、 ビューに使われるすべてのデータがフェッチされて、DTOに復元されるような組み立てフェーズを暗黙的に定義します。 Hibernateでは1つ目の目的が不要になります。 しかしビューのレンダリング処理の間、永続コンテキスト(セッション)をオープンにしたままにしなければ、 組み立てフェーズはまだ必要です(分離オブジェクトの中のどのデータが利用可能かについて、 プレゼンテーション層と厳密な取り決めをしているビジネスメソッドを考えてみてください)。 これはHibernate側の問題ではありません。 トランザクション内で安全にデータアクセスするための基本的な要件です。"
|
||||
|
||||
#: index.docbook:191
|
||||
msgid "Consider abstracting your business logic from Hibernate."
|
||||
msgstr "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 "インターフェイスで(Hibernateの)データアクセスコードを隠蔽しましょう。 <emphasis>DAO</emphasis> と <emphasis>Thread Local Session</emphasis> パターンを組み合わせましょう。 <literal>UserType</literal> でHibernateに関連付けると、 ハンドコードしたJDBCで永続化するクラスを持つこともできます。 (このアドバイスは「十分大きな」アプリケーションに対してのものです。 テーブルが5個しかないようなアプリケーションには当てはまりません。)"
|
||||
|
||||
#: index.docbook:203
|
||||
msgid "Don't use exotic association mappings."
|
||||
msgstr "珍しい関連マッピングは使わないようにしましょう。"
|
||||
|
||||
#: 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 "よいユースケースに本当の多対多関連があることは稀(まれ)です。 ほとんどの場合「リンクテーブル」の付加的な情報が必要になります。 この場合、リンククラスに2つの1対多関連を使う方がずっと良いです。 実際ほとんどの場合関連は1対多と多対1なので、 他のスタイルの関連を使うときは本当に必要かどうかを考えてみてください。"
|
||||
|
||||
#: index.docbook:215
|
||||
msgid "Prefer bidirectional associations."
|
||||
msgstr "なるべく双方向関連にしましょう。"
|
||||
|
||||
#: 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 "単方向関連は双方向に比べて検索が難しくなります。 大きなアプリケーションでは、 ほとんどすべての関連が双方向にナビゲーションできなければなりません。"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,532 @@
|
|||
#, 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 "コンポーネントのマッピング"
|
||||
|
||||
#: index.docbook:7
|
||||
msgid "The notion of a <emphasis>component</emphasis> is re-used in several different contexts, for different purposes, throughout Hibernate."
|
||||
msgstr "<emphasis>コンポーネント</emphasis> の概念は、Hibernateを通して様々な状況の中で 異なる目的のために再利用されます。"
|
||||
|
||||
#: index.docbook:13
|
||||
msgid "Dependent objects"
|
||||
msgstr "依存オブジェクト"
|
||||
|
||||
#: 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 "コンポーネントは、エンティティの参照ではなく値型として永続化された、 包含されたオブジェクトです。コンポーネントという言葉については、コンポジションという オブジェクト指向の概念を参照してください(アーキテクチャレベルのコンポーネントではありません)。 例えば、以下のPersonモデルのようなものです。"
|
||||
|
||||
#: 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 "いま、<literal>Name</literal> は <literal>Person</literal> のコンポーネントとして 永続化することが出来ます。ここで <literal>Name</literal> は永続化属性に対してgetter、 setterメソッドを定義しますが、インターフェイスや識別子プロパティを定義する必要が ないことに注意して下さい。"
|
||||
|
||||
#: index.docbook:32
|
||||
msgid "Our Hibernate mapping would look like:"
|
||||
msgstr "マッピング定義は以下のようになります。"
|
||||
|
||||
#: 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\"/>
\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 "Personテーブルは <literal>pid</literal>、 <literal>birthday</literal>、 <literal>initial</literal>、 <literal>first</literal>、 <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 "全ての値型のように、コンポーネントは参照の共有をすることができません。 言い換えると、二人のPersonは同じ名前を持つことができますが、二つのPersonオブジェクトは \"値が同じだけ\"の別々のnameオブジェクトを含んでいるということです。 コンポーネントのnull値のセマンティクスは <emphasis>アドホック</emphasis> です。 コンポーネントのオブジェクトを再読み込みする際、Hibernateはコンポーネントのすべてのカラムが nullであるならコンポーネント自体がnullであると考えます。 これは大抵の場合問題ありません。"
|
||||
|
||||
#: 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 "コンポーネントの属性はどんなHibernateの型でも構いません(コレクション、many-to-one関連、 他のコンポーネントなど)。ネストされたコンポーネントは滅多に使わないと考えるべきでは <emphasis>ありません</emphasis> 。Hibernateは非常にきめの細かいオブジェクトモデルをサポートするように意図されています。"
|
||||
|
||||
#: 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 "<literal><component></literal> 要素は親エンティティへの逆参照として、コンポーネントクラスの 属性をマッピングする <literal><parent></literal> サブ要素を使用できます。"
|
||||
|
||||
#: 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\"/>
\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 "従属するオブジェクトのコレクション"
|
||||
|
||||
#: 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 "Hibernateはコンポーネントのコレクションをサポートしています(例えば <literal>Name</literal> 型の配列)。 <literal><element></literal> タグを <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 "注意: コンポジットエレメントの <literal>Set</literal> を定義したなら、 <literal>equals()</literal> と <literal>hashCode()</literal> を正しく実装することが重要です。"
|
||||
|
||||
#: 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 "コンポジットエレメントはコレクションを含まず、コンポーネントを含むこともあります。 コンポジットエレメント自身がコンポーネントを含んでいる場合は <literal><nested-composite-element></literal> を 使用してください。コンポーネントのコレクション自身がコンポーネントを持つというケースはめったにありません。 この段階までに、one-to-many関連の方がより適切でないかと熟考してください。 コンポジットエレメントをエンティティとして再度モデリングしてみてください。 しかしこれはJavaのモデルとしては同じですが、リレーショナルモデルと永続動作はまだ若干異なることに注意してください。"
|
||||
|
||||
#: 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 "もし <literal><set></literal> を使用するのであれば、コンポジットエレメントのマッピングがnull値が可能な 属性をサポートしていないことに注意してください。Hibernateはオブジェクトを削除するとき、 レコードを識別するためにそれぞれのカラムの値を使用する必要があるため、null値を持つことが出来ません (コンポジットエレメントテーブルには別の主キーカラムはありません)。 コンポジットエレメントにnot-nullの属性のみを使用するか、または <literal><list></literal>、<literal><map></literal>、 <literal><bag></literal>、<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 "コンポジットエレメントの特別なケースとして、ネストされた <literal><many-to-one></literal> 属性を持つ コンポジットエレメントがあります。 このマッピングは、コンポジットエレメントクラスを多対多関連テーブルの 余分なカラムへマッピングします。 次の例は <literal>Order</literal> から、<literal>Item</literal> への多対多関連です。 <literal>purchaseDate</literal>、<literal>price</literal>、<literal>quantity</literal> は関連の属性となります。"
|
||||
|
||||
#: 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 "もちろん、双方向関連のナビゲーションのために反対側からpurchaseへの参照を作ることは出来ません。 コンポーネントは値型であり、参照を共有できないことを覚えておいてください。 一つの <literal>Purchase</literal> は一つの <literal>Order</literal> のsetに存在できますが、 同時に <literal>Item</literal> から参照することは出来ません。"
|
||||
|
||||
#: index.docbook:133
|
||||
msgid "Even ternary (or quaternary, etc) associations are possible:"
|
||||
msgstr "3項関連(あるいは4項など)も可能です。"
|
||||
|
||||
#: 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 "コンポジットエレメントは他のエンティティへの関連として、 同じシンタックスを使っているクエリ内で使用できます。"
|
||||
|
||||
#: index.docbook:145
|
||||
msgid "Components as Map indices"
|
||||
msgstr "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 "<literal><composite-map-key></literal> 要素は <literal>Map</literal> のキーとしてコンポーネントクラスを マッピングします。コンポーネントクラス上で <literal>hashCode()</literal> と <literal>equals()</literal> を正確にオーバーライドしてください。"
|
||||
|
||||
#: index.docbook:156
|
||||
msgid "Components as composite identifiers"
|
||||
msgstr "複合識別子としてのコンポーネント"
|
||||
|
||||
#: index.docbook:158
|
||||
msgid "You may use a component as an identifier of an entity class. Your component class must satisfy certain requirements:"
|
||||
msgstr "コンポーネントをエンティティクラスの識別子として使うことができます。 コンポーネントクラスは以下の条件を満たす必要があります。"
|
||||
|
||||
#: index.docbook:165
|
||||
msgid "It must implement <literal>java.io.Serializable</literal>."
|
||||
msgstr "<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 "データベース上の複合キーの等価性と矛盾のないように、<literal>equals()</literal> と <literal>hashCode()</literal> を再実装しなければなりません。"
|
||||
|
||||
#: index.docbook:179
|
||||
msgid "Note: in Hibernate3, the second requirement is not an absolutely hard requirement of Hibernate. But do it anyway."
|
||||
msgstr "注意: Hibernate3において、2番目の条件は絶対的な条件ではありません。 しかしとにかく条件を満たしてください。"
|
||||
|
||||
#: 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 "複合キーを生成するために <literal>IdentifierGenerator</literal> を使用することはできません。 代わりにアプリケーションが識別子を割り当てなくてはなりません。"
|
||||
|
||||
#: 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 "通常の <literal><id></literal> 宣言の代わりに <literal><composite-id></literal> タグを (ネストされた <literal><key-property></literal> 属性と共に)使います。 以下の例では、<literal>OrderLine</literal> クラスは <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 "このとき、<literal>OrderLine</literal> テーブルへ関連する外部キーもまた複合です。 他のクラスのマッピングでこれを宣言しなければなりません。 <literal>OrderLine</literal> への関連は次のようにマッピングされます。"
|
||||
|
||||
#: 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 "(<literal><column></literal> タグはどこであっても <literal>column</literal> 属性の 代わりになります。)"
|
||||
|
||||
#: index.docbook:211
|
||||
msgid "A <literal>many-to-many</literal> association to <literal>OrderLine</literal> also uses the composite foreign key:"
|
||||
msgstr "<literal>OrderLine</literal> への <literal>many-to-many</literal> 関連も 複合外部キーを使います。"
|
||||
|
||||
#: 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 "<literal>Order</literal> にある <literal>OrderLine</literal> のコレクションは 次のものを使用します。"
|
||||
|
||||
#: 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 "(<literal><one-to-many></literal> 属性は、例によってカラムを宣言しません)"
|
||||
|
||||
#: index.docbook:229
|
||||
msgid "If <literal>OrderLine</literal> itself owns a collection, it also has a composite foreign key."
|
||||
msgstr "<literal>OrderLine</literal> 自身がコレクションを持っている場合、 同時に複合外部キーも持っています。"
|
||||
|
||||
#: 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 "動的コンポーネント"
|
||||
|
||||
#: index.docbook:241
|
||||
msgid "You may even map a property of type <literal>Map</literal>:"
|
||||
msgstr "<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 "<literal><dynamic-component></literal> マッピングのセマンティクスは <literal><component></literal> と同一のものです。この種のマッピングの利点は、マッピングドキュメントの編集により、配置時にbeanの属性を 決定できる点です。また、DOMパーサを利用して、マッピングドキュメントのランタイム操作が可能です。 さらに、<literal>Configuration</literal> オブジェクト経由でHibernateのコンフィグレーション時のメタモデルに アクセス(または変更)が可能です。"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,354 @@
|
|||
#, 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 "インターセプタとイベント"
|
||||
|
||||
#: 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 "アプリケーションがHibernateの内部で発生するイベントに対応できると役に立つことがあります。 ある種の一般的な機能を実装できるようになり、 またHibernateの機能を拡張することもできるようになります。"
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Interceptors"
|
||||
msgstr "インターセプタ"
|
||||
|
||||
#: 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 "<literal>Interceptor</literal> インターフェイスを使って、 セッションからアプリケーションへコールバックをすることができます。 これにより永続オブジェクトの保存、更新、削除、読み込みの前に、 アプリケーションがプロパティを検査したり操作したりできるようになります。 これは監査情報の追跡に利用できます。 下の例で <literal>Interceptor</literal> は <literal>Auditable</literal> が作成されると自動的に <literal>createTimestamp</literal> を設定し、 <literal>Auditable</literal> が更新されると自動的に <literal>lastUpdateTimestamp</literal> プロパティを更新します。"
|
||||
|
||||
#: index.docbook:27
|
||||
msgid "You may either implement <literal>Interceptor</literal> directly or (better) extend <literal>EmptyInterceptor</literal>."
|
||||
msgstr "<literal>Interceptor</literal> を直接実装したり、 (さらによいのは)<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.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"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:34
|
||||
msgid "Interceptors come in two flavors: <literal>Session</literal>-scoped and <literal>SessionFactory</literal>-scoped."
|
||||
msgstr "インターセプタには二種類あります: <literal>Session</literal> スコープのものと <literal>SessionFactory</literal> スコープのものです。"
|
||||
|
||||
#: 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 "<literal>Session</literal> スコープのインターセプタは、 セッションをオープンするときに指定します。 <literal>Interceptor</literal> を引数に取るSessionFactory.openSession() のオーバーロードメソッドの一つを使います。"
|
||||
|
||||
#: 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 "<literal>SessionFactory</literal> スコープのインターセプタは <literal>Configuration</literal> オブジェクトを使って登録します。 これは <literal>SessionFactory</literal> の構築よりも優先されます。 この場合、提供されるインターセプタは <literal>SessionFactory</literal> からオープンされたすべてのセッションに適用されます。 これは使用するインターセプタを明示的に指定してセッションをオープンしない限り、そうなります。 <literal>SessionFactory</literal> スコープのインターセプタはスレッドセーフでなければなりません。 複数のセッションが(潜在的に)このインターセプタを同時並行で使用することになるため、 セッション固有の状態を格納しないように気をつけてください。"
|
||||
|
||||
#: index.docbook:56
|
||||
msgid "<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
msgstr "<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
|
||||
|
||||
#: index.docbook:61
|
||||
msgid "Event system"
|
||||
msgstr "イベントシステム"
|
||||
|
||||
#: 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 "永続化層で特定のイベントに対応しなければならない場合、 Hibernate3の <emphasis>イベント</emphasis> アーキテクチャを使うこともできます。 イベントシステムはインターセプタと一緒に使うか、またはインターセプタの代わりとして使うことができます。"
|
||||
|
||||
#: 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 "本質的に <literal>Session</literal> インターフェイスのすべてのメソッドは、 1個のイベントと相互に関連します。 例えば <literal>LoadEvent</literal>、<literal>FlushEvent</literal> などがあります (定義済みのイベント型の一覧については、XML設定ファイルのDTDや <literal>org.hibernate.event</literal> パッケージを調べてください)。 リクエストがこれらのメソッドの1つから作られるとき、 Hibernateの <literal>Session</literal> は適切なイベントを生成し、 そのイベント型に設定されたイベントリスナに渡します。 すばらしいことに、これらのリスナはそのメソッドと同じ処理を実装します。 とはいえ、リスナインターフェイスの一つを自由にカスタム実装できます (つまり、<literal>LoadEvent</literal> は登録された <literal>LoadEventListener</literal> インターフェイスの実装により処理されます)。 その場合、その実装には <literal>Session</literal> から作られたどのような <literal>load()</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 "リスナは事実上シングルトンであると見なせます。 つまりリスナはリクエスト間で共有されるため、 インスタンス変数として状態を保持するべきではないということです。"
|
||||
|
||||
#: 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 "カスタムリスナは処理したいイベントについて適切なインターフェイスを実装するべきです。 便利な基底クラスのうちの一つを継承してもよいです (またはHibernateがデフォルトで使用するイベントリスナを継承してもよいです。 すばらしいことに、この目的のために非finalとして宣言されています)。 カスタムリスナは <literal>Configuration</literal> オブジェクトを使ってプログラムから登録するか、 HibernateのXML設定ファイルで指定できます (プロパティファイルで宣言的に設定する方法はサポートされていません)。 カスタムロードイベントリスナの例を示します。"
|
||||
|
||||
#: 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 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"
|
||||
"}]]>"
|
||||
|
||||
#: index.docbook:101
|
||||
msgid "You also need a configuration entry telling Hibernate to use the listener in addition to the default listener:"
|
||||
msgstr "デフォルトリスナ以外のリスナを使うには、Hibernateへの設定も必要です:"
|
||||
|
||||
#: 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"
|
||||
" <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>]]>"
|
||||
|
||||
#: index.docbook:108
|
||||
msgid "Instead, you may register it programmatically:"
|
||||
msgstr "またその他に、プログラムで登録する方法もあります:"
|
||||
|
||||
#: 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"
|
||||
"LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };
\n"
|
||||
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
|
||||
|
||||
#: 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 "リスナを宣言的に登録すると、そのリスナのインスタンスを共有できません。 複数の <literal><listener/></literal> 要素で同じクラス名が使われると、 それぞれの参照はそのクラスの別々のインスタンスを指すことになります。 リスナ型の間でリスナインスタンスを共有する必要があれば、 プログラムで登録する方法を採らなければなりません。"
|
||||
|
||||
#: 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 "なぜインターフェイスを実装して、特化した型を設定時に指定するのでしょうか? リスナの実装クラスに、複数のイベントリスナインターフェイスを実装できるからです。 登録時に追加で型を指定することで、カスタムリスナのon/offを設定時に簡単に切り替えられます。"
|
||||
|
||||
#: index.docbook:132
|
||||
msgid "Hibernate declarative security"
|
||||
msgstr "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 "一般的にHibernateアプリケーションの宣言的なセキュリティは、セッションファサード層で管理します。 現在、Hiberenate3はJACCで許可しかつ、JAASで認証したアクションを許しています。 これはイベントアーキテクチャの最上位に組み込まれているオプションの機能です。"
|
||||
|
||||
#: index.docbook:139
|
||||
msgid "First, you must configure the appropriate event listeners, to enable the use of JAAS authorization."
|
||||
msgstr "まず最初に、適切なイベントリスナを設定して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 "特定のイベント型に対してちょうど一つのリスナがあるとき、 <literal><listener type=\"...\" class=\"...\"/></literal> は <literal><event type=\"...\"><listener class=\"...\"/></event></literal> の簡略形に過ぎないことに注意してください。"
|
||||
|
||||
#: index.docbook:152
|
||||
msgid "Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:"
|
||||
msgstr "次に、同じく <literal>hibernate.cfg.xml</literal> でロールにパーミッションを与えてください:"
|
||||
|
||||
#: 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 "このロール名は使用するJACCプロバイダに理解されるロールです。"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,351 @@
|
|||
#, 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 "例:親/子供"
|
||||
|
||||
#: 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 "新規ユーザがHibernateを使ってまず最初に扱うモデルの一つに、親子型のモデル化があります。 このモデル化には二つのアプローチが存在します。とりわけ新規ユーザにとって、 さまざまな理由から最も便利だと思われるアプローチは、<literal>親</literal> から <literal>子供</literal> への <literal><one-to-many></literal> 関連により <literal>親</literal> と <literal>子供</literal> の両方をエンティティクラスとしてモデリングする方法です (もう一つの方法は、<literal>子供</literal> を <literal><composite-element></literal> として定義するものです)。 これで(Hibernateにおける)一対多関連のデフォルトのセマンティクスが、通常の複合要素のマッピングよりも、 親子関係のセマンティクスから遠いことがわかります。 それでは親子関係を効率的かつエレガントにモデリングするために、 <emphasis>カスケード操作を使った双方向一対多関連</emphasis> の扱い方を説明します。これはまったく難しいものではありません。"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "A note about collections"
|
||||
msgstr "コレクションに関する注意"
|
||||
|
||||
#: 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 "Hibernateのコレクションは自身のエンティティの論理的な部分と考えられ、 決して包含するエンティティのものではありません。これは致命的な違いです! これは以下のような結果になります:"
|
||||
|
||||
#: index.docbook:30
|
||||
msgid "When we remove / add an object from / to a collection, the version number of the collection owner is incremented."
|
||||
msgstr "オブジェクトをコレクションから削除、またはコレクションに追加するとき、 コレクションのオーナーのバージョン番号はインクリメントされます。"
|
||||
|
||||
#: 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 "もしコレクションから削除されたオブジェクトが値型のインスタンス (例えばコンポジットエレメント)だったならば、そのオブジェクトは永続的ではなくなり、 その状態はデータベースから完全に削除されます。 同じように、値型のインスタンスをコレクションに追加すると、その状態はすぐに永続的になります。"
|
||||
|
||||
#: 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 "一方、もしエンティティがコレクション(一対多または多対多関連)から削除されても、 デフォルトではそれは削除されません。この動作は完全に一貫しています。 すなわち、他のエンティティの内部状態を変更しても、関連するエンティティが消滅すべきではないということです。 同様に、エンティティがコレクションに追加されても、デフォルトではそのエンティティは永続的にはなりません。"
|
||||
|
||||
#: 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 "その代わりに、デフォルトの動作では、エンティティをコレクションに追加すると単に二つのエンティティ間のリンクを作成し、 一方エンティティを削除するとリンクも削除します。これはすべてのケースにおいて非常に適切です。 これが適切でないのは親/子関係の場合です。この場合子供の生存は親のライフサイクルに制限されるからです。"
|
||||
|
||||
#: index.docbook:64
|
||||
msgid "Bidirectional one-to-many"
|
||||
msgstr "双方向一対多"
|
||||
|
||||
#: 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 "<literal>Parent</literal> から <literal>Child</literal> への単純な <literal><one-to-many></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 "以下のコードを実行すると、"
|
||||
|
||||
#: 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は二つのSQL文を発行します:"
|
||||
|
||||
#: index.docbook:85
|
||||
msgid "an <literal>INSERT</literal> to create the record for <literal>c</literal>"
|
||||
msgstr "<literal>c</literal>に対するレコードを生成する<literal>INSERT</literal>"
|
||||
|
||||
#: index.docbook:88
|
||||
msgid "an <literal>UPDATE</literal> to create the link from <literal>p</literal> to <literal>c</literal>"
|
||||
msgstr "<literal>p</literal>から<literal>c</literal>へのリンクを作成する<literal>UPDATE</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 "これは非効率的なだけではなく、<literal>parent_id</literal> カラムにおいて <literal>NOT NULL</literal> 制約に違反します。 コレクションのマッピングで <literal>not-null=\"true\"</literal> と指定することで、null制約違反を解決することができます:"
|
||||
|
||||
#: 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 "しかしこの解決策は推奨できません。"
|
||||
|
||||
#: 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 "この動作の根本的な原因は、<literal>p</literal> から <literal>c</literal> へのリンク (外部キー <literal>parent_id</literal>)は <literal>Child</literal> オブジェクトの状態の一部とは考えられず、 そのため <literal>INSERT</literal> によってリンクが生成されないことです。 ですから、解決策はリンクをChildマッピングの一部にすることです。"
|
||||
|
||||
#: 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 "(また <literal>Child</literal> クラスに <literal>parent</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 "それでは <literal>Child</literal> エンティティがリンクの状態を制御するようになったので、 コレクションがリンクを更新しないようにしましょう。それには <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 "以下のコードを使えば、新しい <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 "これにより、SQLの <literal>INSERT</literal> 文が一つだけが発行されるようになりました!"
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "To tighten things up a bit, we could create an <literal>addChild()</literal> method of <literal>Parent</literal>."
|
||||
msgstr "もう少し強化するには、<literal>Parent</literal> の <literal>addChild()</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 "<literal>Child</literal> を追加するコードはこのようになります。"
|
||||
|
||||
#: 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 "ライフサイクルのカスケード"
|
||||
|
||||
#: index.docbook:154
|
||||
msgid "The explicit call to <literal>save()</literal> is still annoying. We will address this by using cascades."
|
||||
msgstr "明示的に <literal>save()</literal> をコールするのはまだ煩わしいものです。これをカスケードを使って対処します。"
|
||||
|
||||
#: 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 "これにより先ほどのコードをこのように単純化します"
|
||||
|
||||
#: 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 "同様に <literal>Parent</literal> を保存または削除するときに、子供を一つ一つ取り出して扱う必要はありません。 以下のコードは <literal>p</literal> を削除し、そしてデータベースからその子供をすべて削除します。"
|
||||
|
||||
#: 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 "しかしこのコードは"
|
||||
|
||||
#: 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 "データベースから <literal>c</literal> を削除しません。<literal>p</literal> へのリンクを削除する (そしてこのケースでは <literal>NOT NULL</literal> 制約違反を引き起こす)だけです。 <literal>Child</literal> の <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 "今このケースでは実際に <literal>Child</literal> が親なしでは存在できないようになりました。 そのため、もしコレクションから <literal>Child</literal> を取り除く場合、これも削除したいです。 そのためには <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 "注意:コレクションのマッピングで <literal>inverse=\"true\"</literal> と指定しても、 コレクションの要素のイテレーションによって、依然カスケードが実行されます。 そのためもしカスケードでオブジェクトをセーブ、削除、更新する必要があるなら、 それをコレクションに追加しなければなりません。単に <literal>setParent()</literal> を呼ぶだけでは不十分です。"
|
||||
|
||||
#: index.docbook:206
|
||||
msgid "Cascades and <literal>unsaved-value</literal>"
|
||||
msgstr "カスケードと <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 "<literal>Parent</literal> が、ある <literal>Session</literal> でロードされ、UIのアクションで変更が加えられ、 <literal>update()</literal> を呼んでこの変更を新しいセッションで永続化したいとします。 <literal>Parent</literal> が子供のコレクションを持ち、カスケード更新が有効になっているため、 Hibernateはどの子供が新しくインスタンス化されたか、どれがデータベースの既存の行に相当するのかを知る必要があります。 <literal>Parent</literal> と <literal>Child</literal> の両方が <literal>java.lang.Long</literal> 型の識別プロパティを生成したとしましょう。 Hibernateはどの子供が新しいものかを決定するために識別プロパティの値を使います(versionやtimestampプロパティも使えます。 <xref linkend=\"manipulatingdata-updating-detached\"/> 参照)。Hibernate3になって、 明示的に <literal>unsaved-value</literal> を指定する必要はなくなりました。"
|
||||
|
||||
#: index.docbook:220
|
||||
msgid "The following code will update <literal>parent</literal> and <literal>child</literal> and insert <literal>newChild</literal>."
|
||||
msgstr "以下のコードは <literal>parent</literal> と <literal>child</literal> を更新し、<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とchildは両方とも、以前の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 "これらは生成された識別子の場合には非常に良いのですが、割り当てられた識別子と複合識別子の場合はどうでしょうか? これはHibernateが、(ユーザにより割り当てられた識別子を持つ)新しくインスタンス化されたオブジェクトと、 以前のSessionでロードされたオブジェクトを区別できないため、より難しいです。 この場合、Hibernateはタイムスタンプかバージョンのプロパティのどちらかを使うか、二次キャッシュに問い合わせます。 最悪の場合、行が存在するかどうかデータベースを見ます。"
|
||||
|
||||
#: index.docbook:260
|
||||
msgid "Conclusion"
|
||||
msgstr "<title>結論</title>"
|
||||
|
||||
#: 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 "ここではかなりの量を要約したので、最初の頃は混乱しているように思われるかもしれません。 しかし実際は、すべて非常に良く動作します。ほとんどのHibernateアプリケーションでは、多くの場面で親子パターンを使用します。"
|
||||
|
||||
#: 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 "最初の段落で代替方法について触れました。上記のような問題は <literal><composite-element></literal> マッピングの場合は存在せず、 にもかかわらずそれは確かに親子関係のセマンティクスを持ちます。 しかし残念ながら、複合要素クラスには二つの大きな制限があります: 1つは複合要素はコレクションを持つことができないことです。もうひとつは、 ユニークな親ではないエンティティの子供となるべきではないということです"
|
||||
|
||||
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 "Example: Weblog Application"
|
||||
msgstr "例: Weblogアプリケーション"
|
||||
|
||||
#: index.docbook:8
|
||||
msgid "Persistent Classes"
|
||||
msgstr "永続クラス"
|
||||
|
||||
#: 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 "永続クラスがウェブログと、ウェブログに掲示された項目を表しています。 それらは通常の親子関係としてモデリングされますが、 setではなく順序を持ったbagを使用することにします。"
|
||||
|
||||
#: 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 "Hibernateのマッピング"
|
||||
|
||||
#: index.docbook:25
|
||||
msgid "The XML mappings should now be quite straightforward."
|
||||
msgstr "XMLマッピングは、今ではとても簡単なはずです。"
|
||||
|
||||
#: 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 "Hibernateのコード"
|
||||
|
||||
#: index.docbook:38
|
||||
msgid "The following class demonstrates some of the kinds of things we can do with these classes, using Hibernate."
|
||||
msgstr "以下のクラスは、 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,194 @@
|
|||
#, 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 "データのフィルタリング"
|
||||
|
||||
#: 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では「可視性」ルールに基づいてデータを扱うための画期的な方法を用意しています。 <emphasis>Hibernate filter</emphasis> はグローバルで、名前付きで、パラメータ化されたフィルタです。 これはHibernateセッションごとに有効無効を切り替えられます。"
|
||||
|
||||
#: index.docbook:14
|
||||
msgid "Hibernate filters"
|
||||
msgstr "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はフィルタクライテリアをあらかじめ定義し、 これらのフィルタをクラスやコレクションレベルに加える機能を加えました。 フィルタクライテリアは制約節を定義する機能です。 これらのフィルタ条件はパラメータ化できるということを除き、 クラスやさまざまなコレクション要素で利用可能な「where」句に非常によく似ています。 アプリケーションは、与えられたフィルタを可能にすべきか、 そしてそのパラメータ値を何にすべきかを実行時に決定することができます。 フィルタはデータベースビューのように使用されますが、アプリケーション内ではパラメータ化されます。"
|
||||
|
||||
#: 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 "フィルタを使うためにはまず、適切なマッピング要素に定義、追加しなくてはなりません。 フィルタを定義するためには、 <literal><hibernate-mapping/></literal> 要素内で <literal><filter-def/></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 "そうしてフィルタはクラスへと結び付けられます。:"
|
||||
|
||||
#: 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 "また、コレクションに対しては次のようになります。:"
|
||||
|
||||
#: 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 "どちらに対しても(また、それぞれを複数)同時に設定することもできます。"
|
||||
|
||||
#: 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 "<literal>Session</literal> 上のメソッドは <literal>enableFilter(String filterName)</literal>, <literal>getEnabledFilter(String filterName)</literal>, <literal>disableFilter(String filterName)</literal> です。 デフォルトでは、フィルタは与えられたセッションに対して使用 <emphasis>できません</emphasis> 。 <literal>Filter</literal> インスタンスを返り値とする <literal>Session.enabledFilter()</literal> メソッドを使うことで、 フィルタは明示的に使用可能となります。 上で定義した単純なフィルタの使用は、このようになります。:"
|
||||
|
||||
#: 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 "org.hibernate.Filterインターフェイスのメソッドは、 Hibernateの多くに共通しているメソッド連鎖を許していることに注意してください。"
|
||||
|
||||
#: index.docbook:65
|
||||
msgid "A full example, using temporal data with an effective record date pattern:"
|
||||
msgstr "有効なレコードデータパターンを持つ一時データを使った完全な例です:"
|
||||
|
||||
#: 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"
|
||||
"
\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 "常に現在の有効レコードを返却することを保証するために、 単純に、社員データの検索より前にセッション上のフィルタを有効にします。"
|
||||
|
||||
#: index.docbook:76
|
||||
msgid ""
|
||||
"<![CDATA[Session session = ...;\n"
|
||||
"session.enabledFilter(\"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.enabledFilter(\"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 "上記のHQLでは、結果の給料の制約について明示的に触れただけですが、 有効になっているフィルタのおかげで、このクエリは給料が100万ドル以上の現役の社員だけを返します。"
|
||||
|
||||
#: 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 "(HQLかロードフェッチで)外部結合を持つフィルタを使うつもりなら、 条件式の方向に注意してください。 これは左外部結合のために設定するのが最も安全です。 一般的に、演算子の後カラム名に続けて最初のパラメータを配置してください。"
|
||||
|
||||
#: 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,642 @@
|
|||
#, 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 "継承マッピング"
|
||||
|
||||
#: index.docbook:8
|
||||
msgid "The Three Strategies"
|
||||
msgstr "3つの戦略"
|
||||
|
||||
#: index.docbook:10
|
||||
msgid "Hibernate supports the three basic inheritance mapping strategies:"
|
||||
msgstr "Hibernateは3つの基本的な継承のマッピング戦略をサポートします。"
|
||||
|
||||
#: index.docbook:16
|
||||
msgid "table per class hierarchy"
|
||||
msgstr "<para>クラス階層ごとのテーブル(table-per-class-hierarchy)</para>"
|
||||
|
||||
#: index.docbook:21
|
||||
msgid "<para>table per subclass</para>"
|
||||
msgstr "<para>サブクラスごとのテーブル(table-per-subclass)</para>"
|
||||
|
||||
#: index.docbook:26
|
||||
msgid "table per concrete class"
|
||||
msgstr "<para>具象クラスごとのテーブル(table-per-concrete-class)</para>"
|
||||
|
||||
#: index.docbook:32
|
||||
msgid "In addition, Hibernate supports a fourth, slightly different kind of polymorphism:"
|
||||
msgstr "加えて4つ目に、Hibernateはわずかに異なる性質を持ったポリモーフィズムをサポートします。"
|
||||
|
||||
#: index.docbook:39
|
||||
msgid "implicit polymorphism"
|
||||
msgstr "暗黙的ポリモーフィズム"
|
||||
|
||||
#: 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 "同一の継承階層の異なるブランチに対して異なるマッピング戦略を使うことができます。 その場合には全体の階層に渡るポリモーフィズムを実現するために暗黙的ポリモーフィズムを使用します。 しかし、Hibernateは同じルート <literal><class></literal> 要素内で <literal><subclass></literal> マッピング、<literal><joined-subclass></literal> マッピング、 <literal><union-subclass></literal> マッピングの同時使用をサポートしていません。 <literal><subclass></literal> 要素と <literal><join></literal> 要素を組み合わせることで、 同一 <literal><class></literal> 要素内での table-per-hierarchy 戦略と table-per-subclass 戦略の同時使用は可能です。次の例を見てください。"
|
||||
|
||||
#: 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 "<literal>subclass</literal>, <literal>union-subclass</literal> と <literal>joined-subclass</literal> マッピングを複数のマッピングドキュメントに定義することが出来、 <literal>hibernate-mapping</literal> の直下に配置します。 これは新しいマッピングファイルを追加するだけで、クラス階層を拡張できるということです。 あらかじめマップしたスーパークラスを指定して、サブクラスマッピングに <literal>extends</literal> 属性を記述しなければなりません。 注意:この特徴により、以前はマッピング・ドキュメントの順番が重要でした。 Hibernate3からは、extendsキーワードを使う場合、マッピングドキュメントの順番は問題になりません。 1つのマッピングファイル内で順番付けを行うときは、 依然として、サブクラスを定義する前にスーパークラスを定義する必要があります。)"
|
||||
|
||||
#: 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 ""
|
||||
"<![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:74
|
||||
msgid "Table per class hierarchy"
|
||||
msgstr "<title>クラス階層ごとのテーブル(table-per-class-hierarchy)</title>"
|
||||
|
||||
#: 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 "例えば、インターフェイス <literal>Payment</literal> と、それを実装した <literal>CreditCardPayment</literal>、<literal>CashPayment</literal>、 <literal>ChequePayment</literal> があるとします。階層ごとのテーブルマッピングは 以下のようになります。"
|
||||
|
||||
#: 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 "ちょうど一つのテーブルが必要です。 このマッピング戦略には一つ大きな制限があります。 <literal>CCTYPE</literal> のような、サブクラスで宣言されたカラムは <literal>NOT NULL</literal> 制約を持てません。"
|
||||
|
||||
#: index.docbook:94
|
||||
msgid "Table per subclass"
|
||||
msgstr "<title>サブクラスごとのテーブル(table-per-subclass)</title>"
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "A table per subclass mapping would look like:"
|
||||
msgstr "table-per-subclass マッピングは以下のようになります。"
|
||||
|
||||
#: 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 "このマッピングには4つのテーブルが必要です。3つのサブクラステーブルは スーパークラステーブルとの関連を示す主キーを持っています (実際、関係モデル上は一対一関連です)。"
|
||||
|
||||
#: index.docbook:111
|
||||
msgid "Table per subclass, using a discriminator"
|
||||
msgstr "弁別子を用いた table-per-subclass"
|
||||
|
||||
#: 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 "Hibernateの table-per-subclass 実装は、discriminatorカラムを必要としないことを覚えておいてください。 Hibernate以外のO/Rマッパーは、table-per-subclass に異なる実装を用います。 それは、スーパークラスのテーブルにタイプdiscriminatorカラムを必要とします。 このアプローチは実装が困難になりますが、関係の視点から見ると、より正確なものです。 table-per-subclass 戦略でdiscriminatorカラムを使いたければ、 <literal><subclass></literal> と <literal><join></literal> を以下のように組み合わせて使ってください。"
|
||||
|
||||
#: 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 "オプションの <literal>fetch=\"select\"</literal> 宣言は、 スーパークラスのクエリ実行時に外部結合を使って、 サブクラスの <literal>ChequePayment</literal> データを取得しないように指定するためのものです。"
|
||||
|
||||
#: index.docbook:136
|
||||
msgid "Mixing table per class hierarchy with table per subclass"
|
||||
msgstr "table-per-subclass と table-per-class-hierarchy の混合"
|
||||
|
||||
#: index.docbook:138
|
||||
msgid "You may even mix the table per hierarchy and table per subclass strategies using this approach:"
|
||||
msgstr "このアプローチを使用すると、table-per-hierarchy と table-per-subclass 戦略を 組み合わせる事も可能です。"
|
||||
|
||||
#: 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 "いずれのマッピング戦略であっても、ルートである <literal>Payment</literal> クラスへの ポリモーフィックな関連は <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 "<title>具象クラスごとのテーブル(table-per-concrete-class)</title>"
|
||||
|
||||
#: 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 "table-per-concrete-class 戦略のマッピングに対するアプローチは、2つあります。 1つ目は <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 "サブクラスごとに3つのテーブルが必要です。それぞれのテーブルは、継承プロパティを含んだ、 クラスの全てのプロパティに対するカラムを定義します。"
|
||||
|
||||
#: 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 "このアプローチには制限があります。 それは、プロパティがスーパークラスにマッピングされていた場合、 全てのサブクラスにおいてカラム名が同じでなければならないというものです。 (Hibernateの今後のリリースで緩和されるかもしれません)。 <union-subclass> を使った table-per-concrete-class 戦略では識別子生成戦略を使用できません。 主キーを生成するためのシードは、全ての union subclass の階層内で共有する必要があるからです。"
|
||||
|
||||
#: 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 "もしスーパークラスが抽象クラスなら、<literal>abstract=\"true\"</literal>とマッピングします。 もちろん、スーパークラスが抽象クラスでないなら、スーパークラスのインスタンスを 保持するためのテーブルの追加が必要となります(上の例でのデフォルトは <literal>PAYMENT</literal> )。"
|
||||
|
||||
#: index.docbook:189
|
||||
msgid "Table per concrete class, using implicit polymorphism"
|
||||
msgstr "暗黙的ポリモーフィズムを用いた table-per-concrete-class"
|
||||
|
||||
#: index.docbook:191
|
||||
msgid "An alternative approach is to make use of implicit polymorphism:"
|
||||
msgstr "もう一つのアプローチは暗黙的ポリモーフィズムの使用です。"
|
||||
|
||||
#: 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 "<literal>Payment</literal> インターフェイスがどこにも明示的に示されていないことに注意してください。 そして、<literal>Payment</literal> プロパティがそれぞれのサブクラスにマッピングされていることにも注意してください。 もし重複を避けたいのであれば、XMLエンティティの利用を考えてください。 (例: <literal>DOCTYPE</literal> 宣言における <literal>[ <!ENTITY allproperties SYSTEM \"allproperties.xml\"> ]</literal> と、マッピングにおける <literal>&allproperties;</literal>)"
|
||||
|
||||
#: 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 "このアプローチの欠点は、Hibernateがポリモーフィックなクエリの実行時にSQL <literal>UNION</literal> を生成しない点です。"
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "For this mapping strategy, a polymorphic association to <literal>Payment</literal> is usually mapped using <literal><any></literal>."
|
||||
msgstr "このマッピング戦略に対しては、<literal>Payment</literal> へのポリモーフィックな関連は 通常、<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 "他の継承マッピングと暗黙的ポリモーフィズムの組み合わせ"
|
||||
|
||||
#: 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 "このマッピングについての更なる注意点があります。 サブクラスが自身を <literal><class></literal> 要素としてマッピングしているので、 (かつ <literal>Payment</literal> は単なるインターフェイスなので)、 それぞれのサブクラスは簡単にその他の継承階層の一部となります。 (しかも、今までどおり <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 "もう一度述べますが、<literal>Payment</literal> は明示的に定義されません。 もし、<literal>Payment</literal> インターフェイスに対してクエリを実行するなら (例えば <literal>from Payment</literal> 節を使って)、 Hibernateは自動的に <literal>CreditCardPayment</literal> (とCreditCardPaymentのサブクラス、<literal>Payment</literal> の実装であるため)、 および、<literal>CashPayment</literal> 、<literal>ChequePayment</literal> のインスタンスを返します。 <literal>NonelectronicTransaction</literal> インスタンスは返しません。"
|
||||
|
||||
#: index.docbook:249
|
||||
msgid "Limitations"
|
||||
msgstr "<title>制限</title>"
|
||||
|
||||
#: 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 "table-per-concrete-class マッピング戦略への「暗黙的ポリモーフィズム」アプローチには いくつかの制限があります。<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 "次のテーブルに、Hibernateにおけるtable-per-concrete-classマッピングの 制限や暗黙的ポリモーフィズムの制限を示します。"
|
||||
|
||||
#: index.docbook:264
|
||||
msgid "Features of inheritance mappings"
|
||||
msgstr "継承マッピングの機能"
|
||||
|
||||
#: index.docbook:276
|
||||
msgid "Inheritance strategy"
|
||||
msgstr "継承戦略"
|
||||
|
||||
#: index.docbook:277
|
||||
msgid "Polymorphic many-to-one"
|
||||
msgstr "多対一のポリモーフィズム"
|
||||
|
||||
#: index.docbook:278
|
||||
msgid "Polymorphic one-to-one"
|
||||
msgstr "一対一のポリモーフィズム"
|
||||
|
||||
#: index.docbook:279
|
||||
msgid "Polymorphic one-to-many"
|
||||
msgstr "一対多のポリモーフィズム"
|
||||
|
||||
#: index.docbook:280
|
||||
msgid "Polymorphic many-to-many"
|
||||
msgstr "多対多のポリモーフィズム"
|
||||
|
||||
#: index.docbook:281
|
||||
msgid "Polymorphic <literal>load()/get()</literal>"
|
||||
msgstr "ポリモーフィズムを使った<literal>load()/get()</literal>"
|
||||
|
||||
#: index.docbook:282
|
||||
msgid "Polymorphic queries"
|
||||
msgstr "ポリモーフィズムを使ったクエリ"
|
||||
|
||||
#: index.docbook:283
|
||||
msgid "Polymorphic joins"
|
||||
msgstr "ポリモーフィズムを使った結合"
|
||||
|
||||
#: index.docbook:284
|
||||
msgid "Outer join fetching"
|
||||
msgstr "外部結合によるフェッチ"
|
||||
|
||||
#: index.docbook:289
|
||||
msgid "table per class-hierarchy"
|
||||
msgstr "table per class-hierarchy"
|
||||
|
||||
#: 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 "サポート"
|
||||
|
||||
#: index.docbook:300
|
||||
msgid "<entry>table per subclass</entry>"
|
||||
msgstr "table per subclass"
|
||||
|
||||
#: index.docbook:311
|
||||
msgid "table per concrete-class (union-subclass)"
|
||||
msgstr "table per concrete-class (union-subclass)"
|
||||
|
||||
#: index.docbook:314
|
||||
msgid "<literal><one-to-many></literal> (for <literal>inverse=\"true\"</literal> only)"
|
||||
msgstr "<literal><one-to-many></literal> (for <literal>inverse=\"true\"</literal> only)"
|
||||
|
||||
#: index.docbook:322
|
||||
msgid "table per concrete class (implicit polymorphism)"
|
||||
msgstr "table per concrete class (implicit polymorphism)"
|
||||
|
||||
#: index.docbook:323
|
||||
msgid "<any>"
|
||||
msgstr "<any>"
|
||||
|
||||
#: index.docbook:324, index.docbook:325, index.docbook:329, index.docbook:330
|
||||
msgid "not supported"
|
||||
msgstr "サポートしていません"
|
||||
|
||||
#: 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-->"
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,660 @@
|
|||
#, 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 "永続クラス"
|
||||
|
||||
#: 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 "永続クラスはビジネス上の問題のエンティティ(例えば、Eコマースアプリケーションの顧客や注文) を実装するアプリケーションのクラスです。 永続クラスのすべてのインスタンスが永続状態であると見なされるわけではありません。 インスタンスは逆に一時的(transient)であったり、分離状態(detached)であったりするかもしれません。"
|
||||
|
||||
#: 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 "Plain Old Java Object (POJO)プログラミングモデルとしても知られる いくつかの単純なルールに従うなら、Hibernateは最もよく働きます。 しかしこれらのルールは難しいものではありません。 実際Hibernate3は永続オブジェクトの性質にほとんど何の前提も置いていません。 ドメインモデルは他の方法で表現することもできます。 例えば <literal>Map</literal> インスタンスのツリーを使う方法があります。"
|
||||
|
||||
#: index.docbook:23
|
||||
msgid "A simple POJO example"
|
||||
msgstr "単純なPOJOの例"
|
||||
|
||||
#: index.docbook:25
|
||||
msgid "Most Java applications require a persistent class representing felines."
|
||||
msgstr "ほとんどのJavaアプリケーションにはネコ科の動物を表現する永続クラスが必要です。"
|
||||
|
||||
#: 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 "従うべき4つのルールがあります:"
|
||||
|
||||
#: index.docbook:37
|
||||
msgid "Implement a no-argument constructor"
|
||||
msgstr "引数のないコンストラクタを実装する"
|
||||
|
||||
#: 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> には引数のないコンストラクタがあります。 Hibernateが <literal>Constructor.newInstance()</literal> を使って永続クラスの インスタンス化を行えるように、すべての永続クラスにはデフォルトコンストラクタ (publicでなくても構いません)がなければなりません。 Hibernateの実行時プロキシ生成のために、少なくとも <emphasis>package</emphasis> の可視性を持つデフォルトコンストラクタを強くお勧めします。"
|
||||
|
||||
#: index.docbook:49
|
||||
msgid "Provide an identifier property (optional)"
|
||||
msgstr "識別子プロパティを用意する(オプション)"
|
||||
|
||||
#: 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> には <literal>id</literal> というプロパティがあります。 このプロパティはデータベーステーブルの主キーカラムへマッピングされます。 このプロパティの名前は何でも構いませんし、型はどのようなプリミティブ型でも、 プリミティブの「ラッパー」型でも、<literal>java.lang.String</literal> や <literal>java.util.Date</literal> でも構いません。 (もしレガシーデータベーステーブルが複合キーを持つならば、 今述べたような型のプロパティを持つユーザ定義のクラスを使うことさえ可能です。 後で複合識別子の節を見てください。)"
|
||||
|
||||
#: 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 "識別子プロパティは厳密にはオプションです。 これを省略して、Hibernateに内部的にオブジェクトの識別子を追跡させることは可能です。 しかしおすすめはしません。"
|
||||
|
||||
#: index.docbook:65
|
||||
msgid "In fact, some functionality is available only to classes which declare an identifier property:"
|
||||
msgstr "実際に、識別子プロパティを宣言するクラスだけが利用可能な機能がいくつかあります:"
|
||||
|
||||
#: index.docbook:72
|
||||
msgid "Transitive reattachment for detached objects (cascade update or cascade merge) - see"
|
||||
msgstr "分離オブジェクトの連鎖的な再追加(カスケード更新やカスケードマージ)。 <xref linkend=\"objectstate-transitive\"/> を参照してください。"
|
||||
|
||||
#: 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 "永続クラスには、一貫した名前の識別子プロパティを定義することをお勧めします。 さらにnull値を取れる(つまりプリミティブではない)型を使った方がよいでしょう。"
|
||||
|
||||
#: index.docbook:96
|
||||
msgid "Prefer non-final classes (optional)"
|
||||
msgstr "finalクラスにしない(オプション)"
|
||||
|
||||
#: 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 "Hibernateの中心的な特徴である <emphasis>プロキシ</emphasis> は、 永続クラスがfinalでないこと、またはメソッドを全部publicで宣言している インターフェイスが実装されているかに依存しています。"
|
||||
|
||||
#: 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 "Hibernateでインターフェイスを実装していない <literal>final</literal> クラスを永続化することはできますが、 遅延関連フェッチに対してプロキシを使うことはできなくなります。 これはパフォーマンスチューニングへの選択肢を狭めることになります。"
|
||||
|
||||
#: 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 "finalではないクラスで <literal>public final</literal> メソッドを定義することも避けるべきです。 <literal>public final</literal> メソッドを持つクラスを使いたければ、 <literal>lazy=\"false\"</literal> と設定して明示的にプロキシを無効にしなければなりません。"
|
||||
|
||||
#: index.docbook:115
|
||||
msgid "Declare accessors and mutators for persistent fields (optional)"
|
||||
msgstr "永続フィールドに対するアクセサとミューテータを定義する(オプション)"
|
||||
|
||||
#: 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> ではすべての永続フィールドに対してアクセサメソッドを定義しています。 他の多くのORMツールは、永続インスタンス変数を直接永続化します。 私たちはリレーショナルスキーマとクラスの内部構造を分離する方が良いと信じています。 デフォルトでは、HibernateはJavaBeanスタイルのプロパティを永続化し、 <literal>getFoo</literal>, <literal>isFoo</literal>, <literal>setFoo</literal> 形式のメソッド名を認識します。 しかし必要なら、特定のプロパティに対して、直接のフィールドアクセスに切り替えることは可能です。"
|
||||
|
||||
#: 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 "プロパティはpublicで宣言する必要は <emphasis>ありません</emphasis> 。 Hibernateはデフォルト、<literal>protected</literal> もしくは <literal>private</literal> のget / setのペアを持つプロパティを永続化することができます。"
|
||||
|
||||
#: index.docbook:138
|
||||
msgid "Implementing inheritance"
|
||||
msgstr "継承の実装"
|
||||
|
||||
#: 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 "サブクラスも1番目と2番目のルールを守らなければなりません。 サブクラスはスーパークラス <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 "<literal>equals()</literal> と <literal>hashCode()</literal> の実装"
|
||||
|
||||
#: index.docbook:151
|
||||
msgid "You have to override the <literal>equals()</literal> and <literal>hashCode()</literal> methods if you"
|
||||
msgstr "以下の条件の場合、 <literal>equals()</literal> と <literal>hashCode()</literal> メソッドをオーバーライドしなければなりません、"
|
||||
|
||||
#: 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 "永続クラスのインスタンスを <literal>Set</literal> に置く場合。 (これは多値の関連を表現するおすすめの方法です) <emphasis>そして同時に</emphasis>"
|
||||
|
||||
#: index.docbook:164
|
||||
msgid "intend to use reattachment of detached instances"
|
||||
msgstr "分離インスタンスをセッションへ再追加する場合。"
|
||||
|
||||
#: 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は、永続ID(データベースの行)と、特定のセッションスコープ内に 限定ですがJavaIDとが等価であることを保証します。 ですから異なるセッションで検索したインスタンスを組み合わせる場合、 <literal>Set</literal> に意味のあるセマンティクスを持たせようと思っているなら すぐに<literal>equals()</literal> と <literal>hashCode()</literal> を実装しなければなりません。"
|
||||
|
||||
#: 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 "最も明白な方法は、両方のオブジェクトの識別子の値の比較によって <literal>equals()</literal>と <literal>hashCode()</literal> を実装する方法です。 値が同じなら、両者はデータベースの同じ行でなければならないため等しくなります。 (両者が <literal>Set</literal> に追加されても、 <literal>Set</literal> には1個の要素しかないことになります) 残念なことに、生成された識別子にはこのアプローチを使うことができません。 Hibernateは永続化されたオブジェクトへ識別子の値を代入するだけであり、 新しく作成されたインスタンスはどのような識別子の値も持っていません。 さらに、インスタンスがセーブされておらず、現在 <literal>Set</literal> の中にあれば、 セーブするとオブジェクトへ識別子の値を代入することになります。 もし <literal>equals()</literal> と <literal>hashCode()</literal> が識別子の値に基づいているなら、 ハッシュコードが変更されると <literal>Set</literal> の規約が破られます。 この問題についての完全な議論は、Hibernateのウェブサイトを見てください。 これはHibernateの問題ではなく、オブジェクトの同一性と等価性についての、 通常のJavaのセマンティクスであることに注意してください。"
|
||||
|
||||
#: 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 "<emphasis>ビジネスキーの等価性</emphasis> を使って、 <literal>equals()</literal> と <literal>hashCode()</literal> を実装することをお勧めします。 ビジネスキーの等価性とは、<literal>equals()</literal> メソッドが、ビジネスキー、 つまり現実の世界においてインスタンスを特定するキー(<emphasis>自然</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 "ビジネスキーはデータベースの主キー候補ほど安定である必要はないことに注意してください (<xref linkend=\"transactions-basics-identity\"/> を見てください)。 更新不可なプロパティやユニークなプロパティは、通常ビジネスキーのよい候補です。"
|
||||
|
||||
#: index.docbook:212
|
||||
msgid "Dynamic models"
|
||||
msgstr "動的モデル"
|
||||
|
||||
#: index.docbook:215
|
||||
msgid "Note that the following features are currently considered experimental and may change in the near future."
|
||||
msgstr "以下の機能は現在実験段階にあると見なされており、 近い将来変更される可能性があることに注意してください。"
|
||||
|
||||
#: 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 "永続エンティティは、必ずしも実行時にPOJOクラスやJavaBeanオブジェクトで表現する必要はありません。 Hibernateは(実行時に <literal>Map</literal> の <literal>Map</literal> を使う)動的モデルと、 DOM4Jツリーとしてのエンティティの表現もサポートします。 このアプローチを使うと永続クラスを書かず、マッピングファイルだけを書くことになります。"
|
||||
|
||||
#: 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 "デフォルトでは、Hibernateは通常のPOJOモードで動作します。 <literal>default_entity_mode</literal> 設定オプションを使って、 特定の <literal>SessionFactory</literal> に対するデフォルトのエンティティ表現モードを設定することができます (<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 "以下の例では <literal>Map</literal> を使った表現を紹介します。 まずマッピングファイルで、クラス名の代わりに(またはそれに加えて) <literal>entity-name</literal> を定義しなければなりません:"
|
||||
|
||||
#: 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 "関連がターゲットのクラス名を使って定義していたとしても、 関連のターゲット型も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 "<literal>SessionFactory</literal> に対してデフォルトのエンティティモードを <literal>dynamic-map</literal> に設定した後、 実行時に <literal>Map</literal> の <literal>Map</literal> を使うことができます:"
|
||||
|
||||
#: 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 "動的なマッピングの利点は、エンティティクラスの実装を必要としないため、 プロトタイピングに要するターンアラウンドタイムが早いということです。 しかしコンパイル時の型チェックがないので、実行時に非常に多くの例外処理を扱わなければならないでしょう。 Hibernateマッピングのおかげで、データベーススキーマは容易に正規化でき、健全になり、 後で適切なドメインモデルの実装を追加することが可能になります。"
|
||||
|
||||
#: index.docbook:265
|
||||
msgid "Entity representation modes can also be set on a per <literal>Session</literal> basis:"
|
||||
msgstr "エンティティ表現モードは <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 "<literal>EntityMode</literal> を使った <literal>getSession()</literal> の呼び出しは <literal>SessionFactory</literal> ではなく <literal>Session</literal> APIにあることに注意してください。 その方法では、新しい <literal>Session</literal> は、ベースとなるJDBCコネクション、 トランザクション、その他のコンテキスト情報を共有します。 これは2番目の <literal>Session</literal> では <literal>flush()</literal> と <literal>close()</literal> を呼ぶ必要がないということ、そのためトランザクションとコネクションの管理を 1番目の作業単位(Unit of Work)に任せることができるということです。"
|
||||
|
||||
#: index.docbook:283
|
||||
msgid "More information about the XML representation capabilities can be found in <xref linkend=\"xml\"/>."
|
||||
msgstr "XML表現の能力についてのさらなる情報は <xref linkend=\"xml\"/> で見つかります。"
|
||||
|
||||
#: index.docbook:291
|
||||
msgid "Tuplizers"
|
||||
msgstr "Tuplizer"
|
||||
|
||||
#: 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> とそのサブインターフェイスは、 表現の <literal>org.hibernate.EntityMode</literal> を利用して、 データ断片のある表現の管理に責任を持ちます。 与えられたデータ断片をデータ構造として考えるなら、Tuplizerはそのようなデータ構造を どのように作成するかを知り、そのようなデータ構造からどのように値を抽出し、 注入するかを知っています。 例えばPOJOエンティティモードでは、対応するTuplizerはコンストラクタを通して、 POJOをどのように作成するか、定義されたプロパティアクセサを使い、 POJOプロパティにどのようにアクセスするかを知ります。 Tuplizerには二つのハイレベルの型があります。 それらは、<literal>org.hibernate.tuple.EntityTuplizer</literal> と <literal>org.hibernate.tuple.ComponentTuplizer</literal> インターフェイスで表現されます。 <literal>EntityTuplizer</literal> は上で述べたようなエンティティに関する契約の管理に責任を持ちます。 一方、<literal>ComponentTuplizer</literal> はコンポーネントに関する契約の管理に責任を持ちます。"
|
||||
|
||||
#: 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 "ユーザは独自のTuplizerに差し替えることも可能です。 おそらくdynamic-map entity-modeの際に <literal>java.util.HashMap</literal> を使うのではなく、 <literal>java.util.Map</literal> の実装が必要でしょう。 もしくは、おそらくデフォルトのものではなく、別のプロキシ生成戦略の定義が必要でしょう。 両者とも、カスタムのTuplizer実装を定義することで達成されます。 Tuplizerの定義は、管理しようとするエンティティやコンポーネントのマッピングに結び付けられます。 顧客エンティティの例に戻ると:"
|
||||
|
||||
#: 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 "TODO: プロパティとプロキシパッケージのユーザ拡張フレームワークを文書化すること"
|
||||
|
||||
msgid "ROLES_OF_TRANSLATORS"
|
||||
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
|
||||
|
||||
msgid "CREDIT_FOR_TRANSLATORS"
|
||||
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue