alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (example_parentchild.po)

This example Hibernate source code file (example_parentchild.po) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

a, a, hibernate, hibernate, in, no, null, o, tag, tag, the, the, this, you

The Hibernate example_parentchild.po source code

# translation of example_parentchild.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2006.
# , 2007.
# , 2007.
# , 2007.
# , 2007.
# , 2007.
# , 2007.
# , 2007.
# , 2007.
# , 2007.
# Michael H. Smith <mhideo@redhat.com>, 2007.
# Glaucia Cintra <gcintra@redhat.com>, 2007.
msgid ""
msgstr ""
"Project-Id-Version: example_parentchild\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-02-10T07:25:35\n"
"PO-Revision-Date: 2010-03-17 14:42+1000\n"
"Last-Translator: \n"
"Language-Team:  <en@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"

#. Tag: title
#, no-c-format
msgid "Example: Parent/Child"
msgstr "Exemplo: Pai/Filho"

#. Tag: para
#, no-c-format
msgid ""
"One of the first things that new users want to do with Hibernate is to model "
"a parent/child type relationship. There are two different approaches to "
"this. The most convenient approach, especially for new users, is to model "
"both <literal>Parent and Child as entity "
"classes with a <literal><one-to-many> association from "
"<literal>Parent to Child. The alternative "
"approach is to declare the <literal>Child as a <"
"composite-element></literal>. The 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."
msgstr ""
"Uma das primeiras coisas que um usuário tenta fazer com o Hibernate é "
"modelar um tipo de relacionamento Pai/Filho. Existem duas abordagens "
"diferentes para isto. Por diversas razões diferentes, a abordagem mais "
"conveniente, especialmente para novos usuários, é modelar ambos os "
"<literal>Parent e Child como classes de "
"entidade com uma associação <literal><one-to-many> a partir "
"do <literal>Parent para o Child. A abordagem "
"alternativa é declarar o <literal>Child como um <"
"composite-element></literal>. As semânticas padrões da associação um para "
"muitos (no Hibernate), são muito menos parecidas com as semânticas comuns de "
"um relacionamento pai/filho do que aqueles de um mapeamento de elemento de "
"composição. Explicaremos como utilizar uma <emphasis>associação bidirecional "
"um para muitos com cascatas</emphasis> para modelar um relacionamento pai/"
"filho de forma eficiente e elegante."

#. Tag: title
#, no-c-format
msgid "A note about collections"
msgstr "Uma nota sobre as coleções"

#. Tag: para
#, no-c-format
msgid ""
"Hibernate collections are considered to be a logical part of their owning "
"entity and not of the contained entities. Be aware that this is a critical "
"distinction that has the following consequences:"
msgstr ""
"As coleções do Hibernate são consideradas uma parte lógica de suas próprias "
"entidades, nunca das entidades contidas. Saiba que esta é uma distinção que "
"possui as seguintes conseqüências:"

#. Tag: para
#, no-c-format
msgid ""
"When you remove/add an object from/to a collection, the version number of "
"the collection owner is incremented."
msgstr ""
"Quando removemos ou adicionamos um objeto da/na coleção, o número da versão "
"do proprietário da coleção é incrementado. "

#. Tag: para
#, no-c-format
msgid ""
"If an object that was removed from a collection is an instance of a value "
"type (e.g. 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 ""
"Se um objeto removido de uma coleção for uma instância de um tipo de valor "
"(ex.: um elemento de composição), este objeto irá parar de ser persistente e "
"seu estado será completamente removido do banco de dados. Da mesma forma, ao "
"adicionar uma instância de tipo de valor à coleção, causará ao estado uma "
"persistência imediata. "

#. Tag: para
#, no-c-format
msgid ""
"Conversely, 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 behavior 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 outro lado, se uma entidade é removida de uma coleção (uma associação um-"
"para-muitos ou muitos-para-muitos), ela não será deletada por padrão. Este "
"comportamento é completamente consistente, uma mudança para o estado interno "
"de uma outra entidade não deve fazer com que a entidade associada "
"desapareça. Da mesma forma, ao adicionar uma entidade à coleção, não faz com "
"que a entidade se torne persistente, por padrão. "

#. Tag: para
#, no-c-format
msgid ""
"Adding an entity to a collection, by default, merely creates a link between "
"the two entities. Removing the entity will remove the link. This is "
"appropriate for all sorts of cases. However, it is not appropriate in the "
"case of a parent/child relationship. In this case, the life of the child is "
"bound to the life cycle of the parent."
msgstr ""
"A adição de uma entidade à coleção, por padrão, meramente cria um link entre "
"as duas entidades. A remoção da entidade, removerá o link. Isto é muito "
"apropriado para alguns tipos de casos. No entanto, não é apropriado o caso "
"de um relacionamento pai/filho. Neste caso, a vida do filho está vinculada "
"ao ciclo de vida do pai."

#. Tag: title
#, no-c-format
msgid "Bidirectional one-to-many"
msgstr "Bidirecional um-para-muitos"

#. Tag: para
#, no-c-format
msgid ""
"Suppose we start with a simple <literal><one-to-many> "
"association from <literal>Parent to Child."
msgstr ""
"Suponha que começamos uma associação <literal><one-to-many> "
"simples de <literal>Parent para Child."

#. Tag: para
#, no-c-format
msgid "If we were to execute the following code:"
msgstr "Se fossemos executar o seguinte código:"

#. Tag: para
#, no-c-format
msgid "Hibernate would issue two SQL statements:"
msgstr "O Hibernate editaria duas instruções SQL"

#. Tag: para
#, no-c-format
msgid "an <literal>INSERT to create the record for c"
msgstr "um <literal>INSERT para criar um registro para c"

#. Tag: para
#, no-c-format
msgid ""
"an <literal>UPDATE to create the link from p to "
"<literal>c"
msgstr ""
"um <literal>UPDATE para criar um link de p para "
"<literal>c"

#. Tag: para
#, no-c-format
msgid ""
"This is not only inefficient, but also violates any <literal>NOT NULLparent_id column. You can fix "
"the nullability constraint violation by specifying <literal>not-null=\"true"
"\"</literal> in the collection mapping:"
msgstr ""
"Isto não é somente ineficiente como também viola qualquer restrição "
"<literal>NOT NULL na coluna parent_id. Nós "
"podemos concertar a violação da restrição de nulabilidade, especificando um "
"<literal>not-null=\"true\" no mapeamento da coleção:"

#. Tag: para
#, no-c-format
msgid "However, this is not the recommended solution."
msgstr "No entanto, esta não é uma solução recomendada."

#. Tag: para
#, no-c-format
msgid ""
"The underlying cause of this behavior is that the link (the foreign key "
"<literal>parent_id) from p to cChild "
"object and is therefore not created in the <literal>INSERT. The "
"solution is to make the link part of the <literal>Child mapping."
msgstr ""
"As causas subjacentes deste comportamento é que o link (a chave exterior "
"<literal>parent_id) de p para cChildINSERT. Então a "
"solução é fazer uma parte de link do mapeamento do <literal>Child."

#. Tag: para
#, no-c-format
msgid ""
"You also need to add the <literal>parent property to the "
"<literal>Child class."
msgstr ""
"Nós também precisamos adicionar a propriedade <literal>parent à "
"classe do <literal>Child."

#. Tag: para
#, no-c-format
msgid ""
"Now that the <literal>Child entity is managing the state of the "
"link, we tell the collection not to update the link. We use the "
"<literal>inverse attribute to do this:"
msgstr ""
"Agora que a entidade <literal>Child está gerenciando o estado do "
"link, informaremos à coleção para não atualizar o link. Utilizamos o "
"atributo <literal>inverse para isto:"

#. Tag: para
#, no-c-format
msgid "The following code would be used to add a new <literal>Child:"
msgstr ""
"O seguinte código seria usado para adicionar um novo <literal>Child would now be issued."
msgstr "E agora, somente um SQL <literal>INSERT seria editado."

#. Tag: para
#, no-c-format
msgid ""
"You could also create an <literal>addChild() method of "
"<literal>Parent."
msgstr ""
"Para assegurar tudo isto, podemos criar um método de <literal>addChild()Parent. "

#. Tag: para
#, no-c-format
msgid "The code to add a <literal>Child looks like this:"
msgstr "Agora, o código que adiciona um <literal>Child se parece com este: "

#. Tag: title
#, no-c-format
msgid "Cascading life cycle"
msgstr "Ciclo de vida em Cascata "

#. Tag: para
#, no-c-format
msgid ""
"You can address the frustrations of the explicit call to <literal>save() ainda é incômoda. Iremos "
"nos referir a ela utilizando cascatas."

#. Tag: para
#, no-c-format
msgid "This simplifies the code above to:"
msgstr "Isto simplifica o código acima para:"

#. Tag: para
#, no-c-format
msgid ""
"Similarly, we do not need to iterate over the children when saving or "
"deleting a <literal>Parent. The following removes p. O comando seguinte irá remover o "
"<literal>p e todos os seus filhos do banco de dados. "

#. Tag: para
#, no-c-format
msgid "However, the following code:"
msgstr "No entanto, este código:"

#. Tag: para
#, no-c-format
msgid ""
"will not remove <literal>c from the database. In this case, it "
"will only remove the link to <literal>p and cause a NOT "
"NULL</literal> constraint violation. You need to explicitly delete()"
"</literal> the Child."
msgstr ""
"não irá remover <literal>c do banco de dados. Neste caso, ele "
"somente removerá o link para <literal>p e causará uma violação de "
"restrição <literal>NOT NULL). Você precisará delete()Child."

#. Tag: para
#, no-c-format
msgid ""
"In our case, a <literal>Child cannot exist without its parent. So "
"if we remove a <literal>Child from the collection, we do want it "
"to be deleted. To do this, we must use <literal>cascade=\"all-delete-orphan"
"\"</literal>."
msgstr ""
"Agora, no seu caso, um <literal>Child não pode existir sem seu "
"pai. Então, se removermos um <literal>Child da coleção, não iremos "
"mais querer que ele seja deletado. Devido a isto, devemos utilizar um "
"<literal>cascade=\"all-delete-orphan\"."

#. Tag: para
#, no-c-format
msgid ""
"Even though the collection mapping specifies <literal>inverse=\"true\" não é o bastante."

#. Tag: title
#, no-c-format
msgid "Cascades and <literal>unsaved-value"
msgstr "Cascatas e <literal>unsaved-value"

#. Tag: para
#, no-c-format
msgid ""
"Suppose we loaded up a <literal>Parent in one Session. The "
"<literal>Parent will contain a collection of children and, since "
"the cascading update is enabled, Hibernate needs to know which children are "
"newly instantiated and which represent existing rows in the database. We "
"will also assume that both <literal>Parent and ChildLongIn Hibernate3, it is no longer "
"necessary to specify an <literal>unsaved-value explicitly. em uma "
"<literal>Session, fizemos algumas mudanças em uma ação UI e "
"desejamos que persista estas mudanças em uma sessão nova, chamando um "
"<literal>update(). O Parent irá conter uma "
"coleção de filhos e uma vez que a atualização da cascata esteja habilitada, "
"o Hibernate precisará saber qual filho foi instanciado mais recentemente e "
"qual representa a linha existente no banco de dados. Vamos supor que ambos "
"os <literal>Parent e Child tenham gerado "
"propriedades de identificador do tipo <literal>Long. O Hibernate "
"usará o identificador e o valor de propriedade da versão/carimbo de data e "
"hora para determinar qual filho é novo. (Veja <xref linkend="
"\"objectstate-saveorupdate\" />.) <emphasis>No Hibernate3, não é mais necessário "
"especificar um <literal>unsaved-value explicitamente. "

#. Tag: para
#, no-c-format
msgid ""
"The following code will update <literal>parent and childnewChild:"
msgstr ""
"O seguinte código atualizará o <literal>parent e o childnewChild:"

#. Tag: para
#, no-c-format
msgid ""
"This may be suitable for the case of a generated identifier, but what about "
"assigned identifiers and composite identifiers? This is more difficult, "
"since Hibernate cannot 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 ""
"Bem, isto cabe bem no caso de um identificador gerado, mas e os "
"identificadores atribuídos e os identificadores de composição? Isto é mais "
"difícil, pois uma vez que o Hibernate não pode utilizar a propriedade do "
"identificador para distinguir entre um objeto instanciado recentemente, com "
"um identificador atribuído pelo usuário, e um objeto carregado em uma sessão "
"anterior. Neste caso, o Hibernate usará tanto um carimbo de data e hora "
"(timestamp) ou uma propriedade de versão, ou irá na verdade consultar um "
"cache de segundo nível, ou no pior dos casos, o banco de dados, para ver se "
"a linha existe. "

#. Tag: title
#, no-c-format
msgid "Conclusion"
msgstr "Conclusão"

#. Tag: para
#, no-c-format
msgid ""
"The sections we have just covered can be a bit confusing. However, in "
"practice, it all works out nicely. Most Hibernate applications use the "
"parent/child pattern in many places."
msgstr ""
"Há muito o que digerir aqui e pode parecer confuso na primeira vez. No "
"entanto, na prática, funciona muito bem. A maioria dos aplicativos do "
"Hibernate utiliza o modelo pai/filho em muitos lugares.  "

#. Tag: para
#, no-c-format
msgid ""
"We mentioned an alternative in the first paragraph. None of the above issues "
"exist in the case of <literal><composite-element> mappings, "
"which have exactly the semantics of a parent/child relationship. "
"Unfortunately, there are two big limitations with composite element classes: "
"composite elements cannot own collections and they should not be the child "
"of any entity other than the unique parent."
msgstr ""
"Nós mencionamos uma alternativa neste primeiro parágrafo. Nenhum dos casos "
"acima existem no caso de mapeamentos <literal><composite-element>

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate example_parentchild.po source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.