📄 collection_mapping.po
字号:
#: collection_mapping.xml:764#, no-c-formatmsgid """A final alternative is to use composite elements, which we will discuss ""later."msgstr """Uma alternativa final é usar os elementos compostos, que nós discutiremos ""mais tarde."#. Tag: literal#: collection_mapping.xml:771#, no-c-formatmsgid "Using an <idbag>"msgstr "Usando o <idbag>"#. Tag: para#: collection_mapping.xml:773#, no-c-formatmsgid """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 """Se você concorda com nossa visão que chaves compostas são uma coisa ruim e ""que as entidades devem ter identificadores sintéticos (surrogate keys), ""então você deve estar achando um pouco estranho que as associações muitos ""para muitos usando coleções de valores que nós mostramos estejam mapeadas ""com chaves compostas! Bem, este ponto é bastante discutível; um simples ""tabela de associação não parece se beneficiar muito de uma surrogate key ""(entretanto uma coleção de valores compostos <emphasis>sim</emphasis>). ""Opcionalmente, o Hibernate prove uma maneira de mapear uma associação muitos ""para muitos com uma coleção de valores para uma tabela com uma surrogate key."#. Tag: para#: collection_mapping.xml:784#, no-c-formatmsgid """The <literal><idbag></literal> element lets you map a <literal>List</""literal> (or <literal>Collection</literal>) with bag semantics."msgstr """O elemento <literal><idbag></literal> permite mapear um <literal>List</""literal> (ou uma <literal>Collection</literal> com uma semântica de bag."#. Tag: programlisting#: collection_mapping.xml:789#, no-c-formatmsgid """<![CDATA[<idbag name=\"lovers\" table=\"LOVERS\">\n"" <collection-id column=\"ID\" type=\"long\">\n"" <generator class=\"sequence\"/>\n"" </collection-id>\n"" <key column=\"PERSON1\"/>\n"" <many-to-many column=\"PERSON2\" class=\"Person\" fetch=\"join\"/>\n""</idbag>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:791#, no-c-formatmsgid """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 """Como você pode ver, um <literal><idbag></literal> possui um gerador de ""id sintético, igual uma classe de entidade! Uma surrogate key diferente é ""associada para cada elemento de coleção. Porém, o Hibernate não prove nenhum ""mecanismo para descobrir qual a surrogate key de uma linha em particular."#. Tag: para#: collection_mapping.xml:798#, no-c-formatmsgid """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 """Note que o desempenho de atualização de um <literal><idbag></literal> ""é <emphasis>much</emphasis> melhor que um <literal><bag></literal> ""normal! O Hibernate pode localizar uma linha individual eficazmente e ""atualizar ou deletar individualmente, como um list, map ou set."#. Tag: para#: collection_mapping.xml:805#, no-c-formatmsgid """In the current implementation, the <literal>native</literal> identifier ""generation strategy is not supported for <literal><idbag></literal> ""collection identifiers."msgstr """Na implementação atual, a estratégia de geração de identificador ""<literal>native</literal> não é suportada para identificadores de coleção ""usando o <literal><idbag></literal>."#. Tag: title#: collection_mapping.xml:829#, no-c-formatmsgid "Collection examples"msgstr "Exemplos de coleções"#. Tag: para#: collection_mapping.xml:831#, no-c-formatmsgid """The previous sections are pretty confusing. So lets look at an example. This ""class:"msgstr """As seções anteriores são uma grande confusão. Assim sendo vejamos uma ""exemplo. Essa classe:"#. Tag: programlisting#: collection_mapping.xml:836#, no-c-formatmsgid """<![CDATA[package eg;\n""import java.util.Set;\n""\n""public class Parent {\n"" private long id;\n"" private Set children;\n""\n"" public long getId() { return id; }\n"" private void setId(long id) { this.id=id; }\n""\n"" private Set getChildren() { return children; }\n"" private void setChildren(Set children) { this.children=children; }\n""\n"" ....\n"" ....\n""}]]>"msgstr ""#. Tag: para#: collection_mapping.xml:838#, no-c-formatmsgid """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 """tem uma coleção de instancias de <literal>Child</literal>. Se cada Child ""tiver no máximo um parent, o mapeamento natural é uma associação um para ""muitos:"#. Tag: programlisting#: collection_mapping.xml:844#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"Parent\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <set name=\"children\">\n"" <key column=\"parent_id\"/>\n"" <one-to-many class=\"Child\"/>\n"" </set>\n"" </class>\n""\n"" <class name=\"Child\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <property name=\"name\"/>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:846#, no-c-formatmsgid "This maps to the following table definitions:"msgstr "Esse mapeamento gera a seguinte definição de tabelas"#. Tag: programlisting#: collection_mapping.xml:850#, no-c-formatmsgid """<![CDATA[create table parent ( id bigint not null primary key )\n""create table child ( id bigint not null primary key, name varchar(255), ""parent_id bigint )\n""alter table child add constraint childfk0 (parent_id) references parent]]>"msgstr ""#. Tag: para#: collection_mapping.xml:852#, no-c-formatmsgid """If the parent is <emphasis>required</emphasis>, use a bidirectional one-to-""many association:"msgstr """Se o parent for <emphasis>obrigatório</emphasis>, use uma associação ""bidirecional um para muitos:"#. Tag: programlisting#: collection_mapping.xml:857#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"Parent\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <set name=\"children\" inverse=\"true\">\n"" <key column=\"parent_id\"/>\n"" <one-to-many class=\"Child\"/>\n"" </set>\n"" </class>\n""\n"" <class name=\"Child\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <property name=\"name\"/>\n"" <many-to-one name=\"parent\" class=\"Parent\" column=\"parent_id\" ""not-null=\"true\"/>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:859#, no-c-formatmsgid "Notice the <literal>NOT NULL</literal> constraint:"msgstr "Repare na constraint <literal>NOT NULL</literal>:"#. Tag: programlisting#: collection_mapping.xml:863#, no-c-formatmsgid """<![CDATA[create table parent ( id bigint not null primary key )\n""create table child ( id bigint not null\n"" primary key,\n"" name varchar(255),\n"" parent_id bigint not null )\n""alter table child add constraint childfk0 (parent_id) references parent]]>"msgstr ""#. Tag: para#: collection_mapping.xml:865#, no-c-formatmsgid """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 """Uma outra alternativa, no caso de você insistir que esta associação devea ""ser unidirecional, você pode declarar a constraint como <literal>NOT NULL</""literal> na tag <literal><key></literal> do mapeamento:"#. Tag: programlisting#: collection_mapping.xml:871#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"Parent\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <set name=\"children\">\n"" <key column=\"parent_id\" not-null=\"true\"/>\n"" <one-to-many class=\"Child\"/>\n"" </set>\n"" </class>\n""\n"" <class name=\"Child\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <property name=\"name\"/>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:873#, no-c-formatmsgid """On the other hand, if a child might have multiple parents, a many-to-many ""association is appropriate:"msgstr """Por outro lado, se uma child puder ter os múltiplos parents, a associação ""apropriada é muitos-para-muitos:"#. Tag: programlisting#: collection_mapping.xml:878#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"Parent\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <set name=\"children\" table=\"childset\">\n"" <key column=\"parent_id\"/>\n"" <many-to-many class=\"Child\" column=\"child_id\"/>\n"" </set>\n"" </class>\n""\n"" <class name=\"Child\">\n"" <id name=\"id\">\n"" <generator class=\"sequence\"/>\n"" </id>\n"" <property name=\"name\"/>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:880#, no-c-formatmsgid "Table definitions:"msgstr "Definições das tabelas:"#. Tag: programlisting#: collection_mapping.xml:884#, no-c-formatmsgid """<![CDATA[create table parent ( id bigint not null primary key )\n""create table child ( id bigint not null primary key, name varchar(255) )\n""create table childset ( parent_id bigint not null,\n"" child_id bigint not null,\n"" primary key ( parent_id, child_id ) )\n""alter table childset add constraint childsetfk0 (parent_id) references ""parent\n""alter table childset add constraint childsetfk1 (child_id) references child]]"">"msgstr ""#. Tag: para#: collection_mapping.xml:886#, no-c-formatmsgid """For more examples and a complete walk-through a parent/child relationship ""mappin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -