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

el, el, esto, hibernate, hibernate, in, null, tag, tag, the, the, this, we, you

The Hibernate example_parentchild.po source code

# translation of example_parentchild.po to
# Michael H. Smith <mhideo@redhat.com>, 2007.
# Angela Garcia <agarcia@redhat.com>, 2009, 2010.
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
# translation of Collection_Mapping.po to
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-15 12:56+1000\n"
"Last-Translator: Angela Garcia <agarcia@redhat.com>\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 "Ejemplo: Padre/Hijo"

#. 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 ""
"Una de las primeras cosas que los usuarios nuevos intentan hacer con "
"Hibernate es modelar una relación de tipo padre / hijo. Para esto existen "
"dos enfoques diferentes. El enfoque más conveniente, especialmente para los "
"usuarios nuevos, es modelar tanto <literal>Parent como "
"<literal>Child como clases de entidad con una asociación "
"<literal><one-to-many> desde Parent a "
"<literal>Child. El enfoque opcional es declarar el Child<composite-element>. La semántica "
"prederterminada de una asociación uno-a-muchos en Hibernate es mucho menos "
"cercana a la semántica usual de una relación padre / hijo que la de un mapeo "
"de elementos compuestos. Explicaremos cómo utilizar una <emphasis>asociación "
"uno-a-muchos bidireccional con tratamiento en cascada</emphasis> para "
"modelar una relación padre / hijo de manera eficiente y elegante."

#. Tag: title
#, no-c-format
msgid "A note about collections"
msgstr "Nota sobre las colecciones"

#. 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 ""
"Se considera que las colecciones de Hibernate son una parte lógica de la "
"entidad que las posee y no de las entidades contenidas. Note que esta es una "
"diferencia crucial y que esto tiene las siguientes consecuencias:"

#. 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 ""
"Cuando se elimina/agrega un objeto desde/a una colección, se incrementa el "
"número de la versión del dueño de la colección."

#. 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 ""
"Si un objeto que fue eliminado de una colección es una instancia de un tipo "
"de valor (por ejemplo, un elemento compuesto), ese objeto cesará de ser "
"persistente y su estado será completamente eliminado de la base de datos. "
"Asimismo, añadir una instancia de tipo de valor a la colección causará que "
"su estado sea persistente inmediatamente."

#. 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 otro lado, si se elimina una entidad de una colección (una asociación "
"uno-a-muchos o muchos-a-muchos), no se borrará por defecto. Este "
"comportamiento es completamente consistente; un cambio en el estado interno "
"de otra entidad no hace desaparecer la entidad asociada. Asimismo, el "
"agregar una entidad a una colección no causa que la entidad se vuelva "
"persistente por defecto."

#. 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 ""
"El comportamiento por defecto es que al agregar una entidad a una colección "
"se crea un enlace entre las dos entidades. Al eliminar la entidad se "
"eliminará el enlace. Esto es muy apropiado para todos los tipos de casos. "
"Sin embargo, no apropiado en el caso de una relación padre / hijo. En este "
"caso la vida del hijo se encuentra vinculada al ciclo de vida del padre."

#. Tag: title
#, no-c-format
msgid "Bidirectional one-to-many"
msgstr "Uno-a-muchos bidireccional"

#. Tag: para
#, no-c-format
msgid ""
"Suppose we start with a simple <literal><one-to-many> "
"association from <literal>Parent to Child."
msgstr ""
"Supónga que empezamos con una asociación simple <literal><one-to-many>"
"</literal> desde Parent a Child."

#. Tag: para
#, no-c-format
msgid "If we were to execute the following code:"
msgstr "Si ejecutásemos el siguiente código:"

#. Tag: para
#, no-c-format
msgid "Hibernate would issue two SQL statements:"
msgstr "Hibernate publicaría dos declaraciones SQL:"

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

#. Tag: para
#, no-c-format
msgid ""
"an <literal>UPDATE to create the link from p to "
"<literal>c"
msgstr ""
"un <literal>UPDATE para crear el enlace desde p "
"a <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 ""
"Esto no es sólo ineficiente, sino que además viola cualquier restricción "
"<literal>NOT NULL en la columna parent_id. "
"Puede arreglar la violación de restricción de nulabilidad especificando "
"<literal>not-null=\"true\" en el mapeo de la colección:"

#. Tag: para
#, no-c-format
msgid "However, this is not the recommended solution."
msgstr "Sin embargo, esta no es la solución 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 ""
"El caso subyacente de este comportamiento es que el enlace (la clave foránea "
"<literal>parent_id) de p a c "
"no se considera parte del estado del objeto <literal>Child y por "
"lo tanto no se crea en el <literal>INSERT. De modo que la solución "
"es hacer que el enlace sea parte del mapeo del <literal>Child. "

#. Tag: para
#, no-c-format
msgid ""
"You also need to add the <literal>parent property to the "
"<literal>Child class."
msgstr ""
"También necesita agregar la propiedad <literal>parent a la clase "
"<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 ""
"Ahora que la entidad <literal>Child está administrando el estado "
"del enlace, le decimos a la colección que no actualice el enlace. Usamos el "
"atributo <literal>inverse para hacer esto:"

#. Tag: para
#, no-c-format
msgid "The following code would be used to add a new <literal>Child:"
msgstr ""
"El siguiente código se podría utilizar para agregar un nuevo <literal>Child would now be issued."
msgstr "Sólo se emitiría un <literal>INSERT de SQL."

#. Tag: para
#, no-c-format
msgid ""
"You could also create an <literal>addChild() method of "
"<literal>Parent."
msgstr ""
"También podría crear un método <literal>addChild() de "
"<literal>Parent."

#. Tag: para
#, no-c-format
msgid "The code to add a <literal>Child looks like this:"
msgstr "El código para agregar un <literal>Child se ve así:"

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

#. Tag: para
#, no-c-format
msgid ""
"You can address the frustrations of the explicit call to <literal>save(). The following removes p. Lo siguiente elimina p y todos "
"sus hijos de la base de datos."

#. Tag: para
#, no-c-format
msgid "However, the following code:"
msgstr "Sin embargo, el siguiente 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 ""
"no eliminará <literal>c de la base de datos. En este caso, sólo "
"quitará el enlace a <literal>p y causará una violación a una "
"restricción <literal>NOT NULL. Necesita borrar el hijo "
"explícitamente llamando a <literal>delete() en 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 ""
"En nuestro caso, un <literal>Child no puede existir realmente sin "
"su padre. De modo que si eliminamos un <literal>Child de la "
"colección, realmente queremos que sea borrado. Para esto, tenemos que "
"utilizar <literal>cascade=\"all-delete-orphan\"."

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

#. Tag: title
#, no-c-format
msgid "Cascades and <literal>unsaved-value"
msgstr "Cascadas y <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. en una "
"<literal>Session, hemos realizado algunos cambios en una acción UI "
"y deseamos hacer persistentes estos cambios en una nueva sesión llamando a "
"<literal>update(). El Parent contendrá una "
"colección de hijos y ya que está habilitado el tratamiento en cascada, "
"Hibernate necesita saber qué hijos están recién instanciados y cuáles "
"representan filas existentes en la base de datos. También vamos a asumir que "
"tanto <literal>Parent como Child tienen "
"propiedades identificadoras generadas de tipo <literal>Long. "
"Hibernate usará el identificador y el valor de la propiedad de versión/sello "
"de fecha para determinar cuáles de los hijos son nuevos, (consulte la <xref linkend="
"\"objectstate-saveorupdate\" />). <emphasis>En Hibernate3, ya no es "
"necesario especificar un <literal>unsaved-value explícitamente. and childnewChild:"
msgstr ""
"El siguiente código actualizará <literal>parent y 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 ""
"Todo eso es apropiado para el caso de un identificador generado, pero ¿qué "
"de los identificadores asignados y de los identificadores compuestos? Esto "
"es más difícil, ya que Hibernate no puede usar la propiedad identificadora "
"para distinguir entre un objeto recién instanciado, con un identificador "
"asignado por el usuario y un objeto cargado en una sesión previa. En este "
"caso, Hibernate utilizará la propiedad de versión o sello de fecha, o bien "
"consultará realmente el caché de segundo nivel, o bien, en el peor de los "
"casos, consultará la base de datos, para ver si la fila existe."

#. Tag: title
#, no-c-format
msgid "Conclusion"
msgstr "Conclusión"

#. 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 ""
"Las secciones que acabamos de cubrir pueden parecer un poco confusas. Sin "
"embargo, en la práctica, todo funciona muy bien. La mayoría de las "
"aplicaciones de Hibernate utilizan el patrón padre / hijo en muchos sitios."

#. 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 ""
"Mencionamos una opción en el primer párrafo. Ninguno de los temas anteriores "
"existe en el caso de los mapeos <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.