⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tutorial.po

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 PO
📖 第 1 页 / 共 5 页
字号:
msgstr "El fichero de mapeo"#: index.docbook:119msgid """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 """Hibernate necesita saber c&#x00f3;mo cargar y almacenar objetos de la clase ""persistente. Aqu&#x00ed; es donde el fichero de mapeo de Hibernate entra en ""juego. El fichero de mapeo le dice a Hibernate a qu&#x00e9; tabla en la base ""de datos tiene que acceder, y qu&#x00e9; columnas en esta tabla debe usar."#: index.docbook:126msgid "The basic structure of a mapping file looks like this:"msgstr "La estructura b&#x00e1;sica de un fichero de mapeo se parece a esto:"#: index.docbook:130msgid """<![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""</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>\n""[...]\n""</hibernate-mapping>]]>"#: index.docbook:132msgid """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 """Observa que el DTD de Hibernate es muy sofisticado. Puedes usarlo para ""autocompleci&#x00f3;n de los elementos y atributos XML de mapeo en tu editor ""o IDE. Debes tambi&#x00e9;n abrir el fichero DTD en tu editor de texto. Es ""la forma m&#x00e1;s f&#x00e1;cil para tener un panorama de todos los ""elementos y atributos y ver los valores por defectos, as&#x00ed; como ""algunos comentarios. Nota que Hibernate no cargar&#x00e1; el fichero DTD de ""la web, sino que primero buscar&#x00e1; en el classpath de la ""aplicaci&#x00f3;n. El fichero DTD est&#x00e1; inclu&#x00ed;do en ""<literal>hibernate3.jar</literal> as&#x00ed; como tambi&#x00e9;n en el ""directorio <literal>src/</literal> de la distribuci&#x00f3;n de Hibernate."#: index.docbook:143msgid """We will omit the DTD declaration in future examples to shorten the code. It ""is of course not optional."msgstr """Omitiremos la declaraci&#x00f3;n de DTD en futuros ejemplos para acortar el ""c&#x00f3;digo. Por supuesto, no es opcional."#: index.docbook:148msgid """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 """Entre las dos etiquetas <literal>hibernate-mapping</literal>, incluye un ""elemento <literal>class</literal>. Todas las clases de entidad persistentes ""(de nuevo, podr&#x00ed;a haber m&#x00e1;s adelante clases dependientes, que ""no sean entidades de-primera-clase) necesitan dicho mapeo a una tabla en la ""base de datos SQL:"#: index.docbook:155msgid """<![CDATA[<hibernate-mapping>\n""\n""    <class name=\"events.Event\" table=\"EVENTS\">\n""\n""    </class>\n""\n""</hibernate-mapping>]]>"msgstr """<![CDATA[<hibernate-mapping>\n""\n""    <class name=\"Event\" table=\"EVENTS\">\n""\n""    </class>\n""\n""</hibernate-mapping>]]>"#: index.docbook:157msgid """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 """Hasta ahora dijimos a Hibernate c&#x00f3;mo persistir y cargar el objeto de ""clase <literal>Event</literal> a la tabla <literal>EVENTS</literal>, cada ""instancia representada por una fila en esta tabla. Ahora continuamos con un ""mapeo de la propiedad de identificado &#x00fa;nico a la clave primaria de la ""tabla. Adem&#x00e1;s, como no queremos cuidar del manejo de este ""identificador, configuramos la estrategia de generaci&#x00f3;n de ""identificadores para una columna clave primaria delegada:"#: index.docbook:165msgid """<![CDATA[<hibernate-mapping>\n""\n""    <class name=\"events.Event\" table=\"EVENTS\">\n""        <id name=\"id\" column=\"EVENT_ID\">\n""            <generator class=\"native\"/>\n""        </id>\n""    </class>\n""\n""</hibernate-mapping>]]>"msgstr """<![CDATA[<hibernate-mapping>\n""\n""    <class name=\"Event\" table=\"EVENTS\">\n""        <id name=\"id\" column=\"EVENT_ID\">\n""            <generator class=\"increment\"/>\n""        </id>\n""    </class>\n""\n""</hibernate-mapping>]]>"#: index.docbook:167msgid """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 """El elemento <literal>id</literal> el la declaraci&#x00f3;n de la propiedad ""identificadora, <literal>name=\"id\"</literal> declara el nombre de la ""propiedad Java. Hibernate usar&#x00e1; los m&#x00e9;todos getter y setter ""para acceder a la propiedad. El attributo de columna dice a Hibernate ""cu&#x00e1;l columna de la tabla <literal>EVENTS</literal> usamos para esta ""clave primaria. El elemento anidado <literal>generator</literal> especifica ""la estrategia de generaci&#x00f3;n de identificadores, en este caso usamos ""<literal>increment</literal>, que es un m&#x00e9;todo muy simple de ""incremento de n&#x00fa;mero en-memoria &#x00fa;til mayormente para testeo (y ""tutoriales). Hibernate tambi&#x0e9;n soporta identificadores generados por ""base de datos, globalmente &#x00fa;nicos, as&#x00ed; como tambi&#x00e9;n ""asignados por aplicaci&#x00f3;n (o cualquier estrategia para la que hayas ""escrito una extensi&#x00f3;n)."#: index.docbook:180msgid """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 """Finalmente inclu&#x00ed;mos declaraciones para las propiedades persistentes ""de la clases en el fichero de mapeo. Por defecto, ninguna propiedad de la ""clase se considera persistente:"#: index.docbook:186msgid """<![CDATA[\n""<hibernate-mapping>\n""\n""    <class name=\"events.Event\" table=\"EVENTS\">\n""        <id name=\"id\" column=\"EVENT_ID\">\n""            <generator class=\"native\"/>\n""        </id>\n""        <property name=\"date\" type=\"timestamp\" column=\"EVENT_DATE\"/>\n""        <property name=\"title\"/>\n""    </class>\n""\n""</hibernate-mapping>]]>"msgstr """<![CDATA[\n""<hibernate-mapping>\n""\n""    <class name=\"Event\" table=\"EVENTS\">\n""        <id name=\"id\" column=\"EVENT_ID\">\n""            <generator class=\"increment\"/>\n""        </id>\n""        <property name=\"date\" type=\"timestamp\" column=\"EVENT_DATE\"/>\n""        <property name=\"title\"/>\n""    </class>\n""\n""</hibernate-mapping>]]>"#: index.docbook:188msgid """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 """Al igual que con el elemento <literal>id</literal>, el atributo ""<literal>name</literal> del elemento <literal>property</literal> dice a ""Hibernate c&#x00e1;les m&#x00e9;todos getter y setter usar."#: index.docbook:195msgid """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 """¿Por qu&#x00e9; el mapeo de la propiedad <literal>date</literal> incluye el ""atributo <literal>column</literal>, pero el de la de <literal>title</""literal> no? Sin el atributo <literal>column</literal> Hibernate usa por ""defecto el nombre de propiedad como nombre de columna. Esto funciona bien ""para <literal>title</literal>. Sin embargo, However, <literal>date</literal> ""es una palabra reservada en la mayor&#x00ed;a de las bases de datos, ""as&#x00ed; que mejor la mapeamos a un nombre diferente."#: index.docbook:204msgid """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 """La pr&#x00f3;xima cosa interesante es que el mapeo de <literal>title</""literal> carece de un atributo <literal>type</literal>. Los tipos que ""declaramos y usamos en el fichero de mapeo no son, como podr&#x00ed;as ""esperar, tipos de datos Java. Tampoco son tipos de base de datos SQL. Estos ""tipos son los llamados as&#x00ed; <emphasis>Tipos de mapeo de Hibernate</""emphasis>, convertidores que pueden traducir de tipos Java a SQL y vice ""versa. De nuevo, Hibernate intentar&#x00e1; determinar la conversi&#x00f3;n ""y el mapeo mismo de tipo correctos si el atributo <literal>type</literal> no ""estuviese presente en el mapeo. En algunos casos esta detecci&#x00f3;n ""autom&#x00e1;tica (usando reflecci&#x00f3;n en la clase Java) puede no tener ""lo que esperas o necesitas. Este es el caso de la propiedad <literal>date</""literal>. Hibernate no puede saber is la propiedad mapear&#x00e1; a una ""columna <literal>date</literal>, <literal>timestamp</literal> o ""<literal>time</literal>. Declaramos que queremos preservar la ""informaci&#x00f3;n completa de fecha y hora mapeando la propiedad con un ""<literal>timestamp</literal>."#: index.docbook:220msgid """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 """Este fichero de mapeo debe ser salvado como <literal>Event.hbm.xml</""literal>, justo en el directorio pr&#x00f3;ximo al fichero de c&#x00f3;digo ""fuente de la clase Java <literal>Event</literal>. El nombrado de los ""ficheros de mapeo puede ser arbitrario, sin embargo, el sufijo <literal>hbm.""xml</literal> se ha vuelto una convenci&#x00f3;n el la comunidad de ""desarrolladores de Hibernate. La estructura de directorio debe ahora verse ""como esto:"#: index.docbook:228msgid """<![CDATA[.\n""+lib\n""  <Hibernate and third-party libraries>\n""+src\n""  +events\n""    Event.java\n""    Event.hbm.xml]]>"msgstr """<![CDATA[.\n""+lib\n""  <Hibernate and third-party libraries>\n""+src\n""  Event.java\n""  Event.hbm.xml]]>"#: index.docbook:230msgid "We continue with the main configuration of Hibernate."msgstr "Continuamos con la configuraci&#x00f3;n principal de Hibernate."#: index.docbook:237msgid "Hibernate configuration"msgstr "Configuraci&#x00f3;n de Hibernate"#: index.docbook:239msgid """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."

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -