📄 tutorial.po
字号:
#: tutorial.xml:126#, no-c-formatmsgid "The basic structure of a mapping file looks like this:"msgstr "A estrutura básica de um arquivo de mapeamento é parecida com:"#. Tag: programlisting#: tutorial.xml:130#, no-c-formatmsgid """<![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 ""#. Tag: para#: tutorial.xml:132#, no-c-formatmsgid """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 """Note que o Hibernate DTD é muito sofisticado. Você pode usar isso para auto-""conclusão no mapeamento XML dos elementos e atributos no seu editor ou IDE. ""Você também pode abrir o arquivo DTD no seu editor – é a maneira mais fácil ""de ter uma visão geral de todos os elementos e atributos e dos padrões, como ""também alguns comentários. Note que o Hibernate não irá carregar o arquivo ""DTD da web, e sim do diretório da aplicação (classpath). O arquivo DTD está ""incluído no <literal>hibernate3.jar</literal> como também no diretório ""<literal>src/</literal> da distribuição do Hibernate."#. Tag: para#: tutorial.xml:143#, no-c-formatmsgid """We will omit the DTD declaration in future examples to shorten the code. It ""is of course not optional."msgstr """Nós omitiremos a declaração do DTD nos exemplos futuros para encurtar o ""código. Isto, é claro, não é opcional."#. Tag: para#: tutorial.xml:148#, no-c-formatmsgid """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 os dois tags <literal>hibernate-mapping</literal>, inclua um elemento ""<literal>class</literal>. Todas as classes persistentes da entidade ""(novamente, poderá haver mais tarde, dependências sobre as classes que não ""são classes-primárias de entidades) necessitam do tal mapeamento, para uma ""tabela na base de dados SQL"#. Tag: programlisting#: tutorial.xml:155#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"events.Event\" table=\"EVENTS\">\n""\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:157#, no-c-formatmsgid """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 """Mais adiante iremos dizer ao Hibernate como fazer para persistir e carregar ""objetos da classe <literal>Event</literal> da tabela <literal>EVENTS</""literal>, cada instancia representada por uma coluna na tabela. Agora, ""continuaremos com o mapeamento de uma única propriedade identificadora para ""as chaves primárias da tabela. Além disso, nós não iremos se importar com ""esta propriedade identificadora, nós iremos configurar uma estratégia de ""geração de id’s para uma chave primária de uma surrogate key:"#. Tag: programlisting#: tutorial.xml:165#, no-c-formatmsgid """<![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 ""#. Tag: para#: tutorial.xml:167#, no-c-formatmsgid """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 """O elemento <literal>id</literal> é a declaração da propriedade ""identificadora, o <literal>name=\"id\"</literal> declara o nome da ""propriedade Java – o Hibernate irá usar os métodos getter e setter para ""acessar a propriedade. O atributo da coluna informa ao Hibernate qual coluna ""da tabela <literal>EVENTS</literal> nós iremos usar como chave primária. O ""elemento <literal>generator</literal> especifica a estratégia de geração do ""identificador, neste caso usaremos <literal>native</literal>, que escolhe a ""melhor estratégia dependendo da base de dados (dialeto) configurada. O ""Hibernate suporta a base de dados gerada, globalmente única, bem como a ""atribuição aos identificadores da aplicação (ou toda estratégia escrita para ""uma extensão)."#. Tag: para#: tutorial.xml:180#, no-c-formatmsgid """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 incluiremos as declarações para as propriedades persistentes da ""classe no arquivo mapeado. Por default, nenhuma das propriedades da classe é ""considerada persistente:"#. Tag: programlisting#: tutorial.xml:186#, no-c-formatmsgid """<![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 ""#. Tag: para#: tutorial.xml:188#, no-c-formatmsgid """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 """Da mesma maneira que com o elemento <literal>id</literal>, o atributo ""<literal>name</literal> do elemento <literal>property</literal> informa ao ""Hibernate qual método getter e setter deverá usar. Assim, neste caso, o ""Hibernate irá procurar pelo <literal>getDate()/setDate()</literal>, como ""também pelo <literal>getTitle()/setTitle()</literal>."#. Tag: para#: tutorial.xml:195#, no-c-formatmsgid """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 """Porque fazer o mapeamento da propriedade <literal>date</literal> incluído no ""atributo <literal>column</literal>, e no title não fazer? Sem o atributo ""<literal>column</literal> o Hibernate por padrão usa o nome da propriedade ""como o nome da coluna. Isto trabalha muito bem para o <literal>title</""literal>. Entretanto o <literal>date</literal> é uma palavra-chave reservada ""na maioria dos bancos de dados, assim nós melhoramos o mapeamentos disto com ""um nome diferente."#. Tag: para#: tutorial.xml:204#, no-c-formatmsgid """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 """A próxima coisa interessante é que mapemanto do <literal>title</literal> ""também falta o atributo <literal>type</literal>. O tipo que declaramos e o ""uso nos arquivos mapeados, não são como você pôde esperar, atributos de ""dados Java. Eles não são como os tipos de base de dados SQL. Esses tipos ""podem ser chamados de <emphasis>Tipos de mapeamento Hibernate</emphasis>, ""que são conversores que podem traduzir tipos de dados do Java para os tipos ""de dados SQL e vice-versa. Novamente, o Hibernate irá tentar determinar a ""conversão correta e mapeará o <literal>type</literal> próprio, caso o tipo ""do atributo não estiver presente no mapeamento. Em alguns casos, esta ""detecção automática (que usa Reflection sobre as classes Java) poderá não ""ter padrão que você espera ou necessita. Este é o caso com a propriedade ""<literal>date</literal>. O Hibernate não pode saber se a propriedade (que é ""do <literal>java.util.Date</literal>) pode mapear para uma coluna do tipo ""<literal>date</literal> do SQL, <literal>timestamp</literal>, ou ""<literal>time</literal> . Nós preservamos a informação cheia de datas e ""horas pelo mapeamento da propriedade com um conversor <literal>timestamp</""literal>."#. Tag: para#: tutorial.xml:220#, no-c-formatmsgid """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 arquivo de mapeamento deve ser salvo como <literal>Event.hbm.xml</""literal>, corretamente no diretório próximo ao arquivo fonte da Classe Java ""<literal>Event</literal>. O nomeamento dos arquivos de mapeamento podem ser ""arbitrários, porém o sufixo <literal>hbm.xml</literal> é uma convenção da ""comunidade dos desenvolvedores do Hibernate. Esta estrutura do diretório ""deve agora se parecer com isso:"#. Tag: programlisting#: tutorial.xml:228#, no-c-formatmsgid """<![CDATA[.\n""+lib\n"" <Hibernate and third-party libraries>\n""+src\n"" +events\n"" Event.java\n"" Event.hbm.xml]]>"msgstr ""#. Tag: para#: tutorial.xml:230#, no-c-formatmsgid "We continue with the main configuration of Hibernate."msgstr "Nós iremos continuar com a configuração principal do Hibernate."#. Tag: title#: tutorial.xml:237#, no-c-formatmsgid "Hibernate configuration"msgstr "Configuração do Hibernate"#. Tag: para#: tutorial.xml:239#, no-c-formatmsgid """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 """Agora nós temos uma classe persistente e este arquivo de mapeamento no ""lugar. Está na hora de configurar o Hibernate. Antes de fazermos isso, ""iremos precisar de uma base de dados. O HSQL DB, um SQL DBMS feito em java, ""pode ser baixado através do site do HSQL DB(http://hsqldb.org/). Atualmente, ""você só precisa baixar o <literal>hsqldb.jar</literal>. Coloque este arquivo ""no diretório da pasta de desenvolvimento <literal>lib/</literal>."#. Tag: para#: tutorial.xml:247#, no-c-formatmsgid """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 """Crie um diretório chamado <literal>data</literal> no diretório root de ""desenvolvimento – Isto será onde o HSQL DB irá armazenar arquivos de dados. ""Agora iremos iniciar o banco de dados executando <literal>java -classpath ../""lib/hsqldb.jar org.hsqldb.Server</literal> neste diretório de dados. Você ""pode ver ele iniciando e conectando ao socket TCP/IP, isto será onde nossa ""aplicação irá se conectar depois. Se você deseja iniciar uma nova base de ""dados durante este tutorial, finalize o HSQL DB(pressionando o <literal>CTRL ""+ C</literal> na janela), delete todos os arquivos no diretório ""<literal>data/</literal>, e inicie o HSQL BD novamente."#. Tag: para#: tutorial.xml:257
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -