📄 collection_mapping.po
字号:
"Note that the value of the <literal>order-by</literal> attribute is an SQL ""ordering, not a HQL ordering!"#. Tag: para#: collection_mapping.xml:639#, no-c-formatmsgid """Associations may even be sorted by some arbitrary criteria at runtime using ""a collection <literal>filter()</literal>."msgstr """Associations may even be sorted by some arbitrary criteria at runtime using ""a collection <literal>filter()</literal>."#. Tag: programlisting#: collection_mapping.xml:644#, no-c-formatmsgid """<![CDATA[sortedUsers = s.createFilter( group.getUsers(), \"order by this.name""\" ).list();]]>"msgstr ""#. Tag: title#: collection_mapping.xml:649#, no-c-formatmsgid "Bidirectional associations"msgstr "Bidirectional associations"#. Tag: para#: collection_mapping.xml:651#, fuzzy, no-c-formatmsgid """A <emphasis>bidirectional association</emphasis> allows navigation from both ""\"ends\" of the association. Two kinds of bidirectional association are ""supported:"msgstr """A <emphasis>bidirectional association</emphasis> allows navigation from both ""\"ends\" of the association. Two kinds of bidirectional association are ""supported: <placeholder-1/>"#. Tag: term#: collection_mapping.xml:658#, no-c-formatmsgid "one-to-many"msgstr "one-to-many"#. Tag: para#: collection_mapping.xml:660#, no-c-formatmsgid "set or bag valued at one end, single-valued at the other"msgstr "set or bag valued at one end, single-valued at the other"#. Tag: term#: collection_mapping.xml:666#, no-c-formatmsgid "many-to-many"msgstr "many-to-many"#. Tag: para#: collection_mapping.xml:668#, no-c-formatmsgid "set or bag valued at both ends"msgstr "set or bag valued at both ends"#. Tag: para#: collection_mapping.xml:677#, no-c-formatmsgid """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 """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)."#. Tag: para#: collection_mapping.xml:684#, no-c-formatmsgid """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 """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:"#. Tag: programlisting#: collection_mapping.xml:689#, no-c-formatmsgid """<![CDATA[<class name=\"Category\">\n"" <id name=\"id\" column=\"CATEGORY_ID\"/>\n"" ...\n"" <bag name=\"items\" table=\"CATEGORY_ITEM\">\n"" <key column=\"CATEGORY_ID\"/>\n"" <many-to-many class=\"Item\" column=\"ITEM_ID\"/>\n"" </bag>\n""</class>\n""\n""<class name=\"Item\">\n"" <id name=\"id\" column=\"ITEM_ID\"/>\n"" ...\n""\n"" <!-- inverse end -->\n"" <bag name=\"categories\" table=\"CATEGORY_ITEM\" inverse=\"true\">\n"" <key column=\"ITEM_ID\"/>\n"" <many-to-many class=\"Category\" column=\"CATEGORY_ID\"/>\n"" </bag>\n""</class>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:691#, no-c-formatmsgid """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 """As mudanças feitas somente de um lado da associação <emphasis>não</emphasis> ""são persistidas. Isto significa que o Hibernate tem duas representações na ""memória para cada associação bidirecional, uma associação de A para B e uma ""outra associação de B para A. Isto é mais fácil de compreender se você pensa ""sobre o modelo do objetos do Java e como nós criamos um relacionamento ""muitos para muitos em Java:"#. Tag: programlisting#: collection_mapping.xml:699#, no-c-formatmsgid """<![CDATA[\n""category.getItems().add(item); // The category now \"knows\" about ""the relationship\n""item.getCategories().add(category); // The item now \"knows\" about the ""relationship\n""\n""session.persist(item); // The relationship won't be ""saved!\n""session.persist(category); // The relationship will be saved]]>"msgstr ""#. Tag: para#: collection_mapping.xml:701#, no-c-formatmsgid """The non-inverse side is used to save the in-memory representation to the ""database."msgstr """A outra ponta é usada salvar a representação em memória à base de dados."#. Tag: para#: collection_mapping.xml:705#, no-c-formatmsgid """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 """Você pode definir uma associação bidirecional um para muitos através de uma ""associação um-para-muitos indicando as mesmas colunas da tabela que à ""associação muitos-para-um e declarando a propriedade <literal>inverse=\"true""\"</literal>"#. Tag: programlisting#: collection_mapping.xml:711#, no-c-formatmsgid """<![CDATA[<class name=\"Parent\">\n"" <id name=\"id\" column=\"parent_id\"/>\n"" ....\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\" column=\"child_id\"/>\n"" ....\n"" <many-to-one name=\"parent\" \n"" class=\"Parent\" \n"" column=\"parent_id\"\n"" not-null=\"true\"/>\n""</class>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:713#, no-c-formatmsgid """Mapping one end of an association with <literal>inverse=\"true\"</literal> ""doesn't affect the operation of cascades, these are orthogonal concepts!"msgstr """Mapear apenas uma das pontas da associação com <literal>inverse=\"true\"</""literal> não afeta as operações em cascata, isso é um conceito ortogonal."#. Tag: title#: collection_mapping.xml:721#, no-c-formatmsgid "Bidirectional associations with indexed collections"msgstr "Associações bidirecionais com coleções indexadas"#. Tag: para#: collection_mapping.xml:722#, no-c-formatmsgid """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 """Uma associação bidirecional onde uma dos lados e representa pôr uma ""<literal><list></literal> ou <literal><map></literal> requer uma ""consideração especial. Se houver uma propriedade da classe filha que faça o ""mapeamento da coluna do índice, sem problema, pode-se continuar usando ""<literal>inverse=\"true\"</literal> no mapeamento da coleção."#. Tag: programlisting#: collection_mapping.xml:729#, no-c-formatmsgid """<![CDATA[<class name=\"Parent\">\n"" <id name=\"id\" column=\"parent_id\"/>\n"" ....\n"" <map name=\"children\" inverse=\"true\">\n"" <key column=\"parent_id\"/>\n"" <map-key column=\"name\" \n"" type=\"string\"/>\n"" <one-to-many class=\"Child\"/>\n"" </map>\n""</class>\n""\n""<class name=\"Child\">\n"" <id name=\"id\" column=\"child_id\"/>\n"" ....\n"" <property name=\"name\" \n"" not-null=\"true\"/>\n"" <many-to-one name=\"parent\" \n"" class=\"Parent\" \n"" column=\"parent_id\"\n"" not-null=\"true\"/>\n""</class>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:731#, no-c-formatmsgid """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 """Mas, se não houver nenhuma propriedade na classe filha, não podemos ver essa ""associação como verdadeiramente bidirecional (há uma informação disponível ""em um lado da associação que não está disponível no extremo oposto). Nesse ""caso, nos não podemos mapear a coleção usando <literal>inverse=\"true\"</""literal>. Nos devemos usar o seguinte mapeamento:"#. Tag: programlisting#: collection_mapping.xml:738#, no-c-formatmsgid """<![CDATA[<class name=\"Parent\">\n"" <id name=\"id\" column=\"parent_id\"/>\n"" ....\n"" <map name=\"children\">\n"" <key column=\"parent_id\"\n"" not-null=\"true\"/>\n"" <map-key column=\"name\" \n"" type=\"string\"/>\n"" <one-to-many class=\"Child\"/>\n"" </map>\n""</class>\n""\n""<class name=\"Child\">\n"" <id name=\"id\" column=\"child_id\"/>\n"" ....\n"" <many-to-one name=\"parent\" \n"" class=\"Parent\" \n"" column=\"parent_id\"\n"" insert=\"false\"\n"" update=\"false\"\n"" not-null=\"true\"/>\n""</class>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:740#, no-c-formatmsgid """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 """Veja que neste mapeamento, que um dos lado da associação, a coleção, é ""responsável pela atualização da chave estrangeira. TODO: Isso realmente ""resulta em updates desnecessários ?."#. Tag: title#: collection_mapping.xml:748#, no-c-formatmsgid "Ternary associations"msgstr "Associações Ternárias"#. Tag: para#: collection_mapping.xml:750#, no-c-formatmsgid """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 """Há três meios possíveis de se mapear uma associação ternária. Uma é usar um ""<literal>Map</literal> com uma associação como seu índice:"#. Tag: programlisting#: collection_mapping.xml:755#, no-c-formatmsgid """<![CDATA[<map name=\"contracts\">\n"" <key column=\"employer_id\" not-null=\"true\"/>\n"" <map-key-many-to-many column=\"employee_id\" class=\"Employee\"/>\n"" <one-to-many class=\"Contract\"/>\n""</map>]]>"msgstr ""#. Tag: programlisting#: collection_mapping.xml:757#, no-c-formatmsgid """<![CDATA[<map name=\"connections\">\n"" <key column=\"incoming_node_id\"/>\n"" <map-key-many-to-many column=\"outgoing_node_id\" class=\"Node\"/>\n"" <many-to-many column=\"connection_id\" class=\"Connection\"/>\n""</map>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:759#, no-c-formatmsgid """A second approach is to simply remodel the association as an entity class. ""This is the approach we use most commonly."msgstr """A segunda maneira é simplesmente remodelar a associação das classes da ""entidade. Esta é a maneira que nós usamos de uma maneira geral."#. Tag: para
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -