|
Hibernate example source code file (component_mapping.pot)
This example Hibernate source code file (component_mapping.pot) 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.
The Hibernate component_mapping.pot source code
#
# AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: 0\n"
"POT-Creation-Date: 2010-02-11T05:38:15\n"
"PO-Revision-Date: 2010-02-11T05:38:15\n"
"Last-Translator: Automatically generated\n"
"Language-Team: None\n"
"MIME-Version: 1.0\n"
"Content-Type: application/x-publican; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#, no-c-format
msgid "Component Mapping"
msgstr ""
#. Tag: para
#, no-c-format
msgid "The notion of a <emphasis>component is re-used in several different contexts and purposes throughout Hibernate."
msgstr ""
#. Tag: title
#, no-c-format
msgid "Dependent objects"
msgstr ""
#. Tag: para
#, no-c-format
msgid "A component is a contained object that is persisted as a value type and not an entity reference. The term \"component\" refers to the object-oriented notion of composition and not to architecture-level components. For example, you can model a person like this:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "Now <literal>Name can be persisted as a component of Person. Name defines getter and setter methods for its persistent properties, but it does not need to declare any interfaces or identifier properties."
msgstr ""
#. Tag: para
#, no-c-format
msgid "Our Hibernate mapping would look like this:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "The person table would have the columns <literal>pid, birthday, initial, first and last."
msgstr ""
#. Tag: para
#, no-c-format
msgid "Like value types, components do not support shared references. In other words, two persons could have the same name, but the two person objects would contain two independent name objects that were only \"the same\" by value. The null value semantics of a component are <emphasis>ad hoc. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This is suitable for most purposes."
msgstr ""
#. Tag: para
#, no-c-format
msgid "The properties of a component can be of any Hibernate type (collections, many-to-one associations, other components, etc). Nested components should <emphasis>not be considered an exotic usage. Hibernate is intended to support a fine-grained object model."
msgstr ""
#. Tag: para
#, no-c-format
msgid "The <literal><component> element allows a <parent> subelement that maps a property of the component class as a reference back to the containing entity."
msgstr ""
#. Tag: title
#, no-c-format
msgid "Collections of dependent objects"
msgstr ""
#. Tag: para
#, no-c-format
msgid "Collections of components are supported (e.g. an array of type <literal>Name). Declare your component collection by replacing the <element> tag with a <composite-element> tag:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "If you define a <literal>Set of composite elements, it is important to implement equals() and hashCode() correctly."
msgstr ""
#. Tag: para
#, no-c-format
msgid "Composite elements can contain components but not collections. If your composite element contains components, use the <literal><nested-composite-element> tag. This case is a collection of components which themselves have components. You may want to consider if a one-to-many association is more appropriate. Remodel the composite element as an entity, but be aware that even though the Java model is the same, the relational model and persistence semantics are still slightly different."
msgstr ""
#. Tag: para
#, no-c-format
msgid "A composite element mapping does not support null-able properties if you are using a <literal><set>. There is no separate primary key column in the composite element table. Hibernate uses each column's value to identify a record when deleting objects, which is not possible with null values. You have to either use only not-null properties in a composite-element or choose a <list>, <map>, <bag> or <idbag>."
msgstr ""
#. Tag: para
#, no-c-format
msgid "A special case of a composite element is a composite element with a nested <literal><many-to-one> element. This mapping allows you to map extra columns of a many-to-many association table to the composite element class. The following is a many-to-many association from Order to Item, where purchaseDate, price and quantity are properties of the association:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "There cannot be a reference to the purchase on the other side for bidirectional association navigation. Components are value types and do not allow shared references. A single <literal>Purchase can be in the set of an Order, but it cannot be referenced by the Item at the same time."
msgstr ""
#. Tag: para
#, no-c-format
msgid "Even ternary (or quaternary, etc) associations are possible:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "Composite elements can appear in queries using the same syntax as associations to other entities."
msgstr ""
#. Tag: title
#, no-c-format
msgid "Components as Map indices"
msgstr ""
#. Tag: para
#, no-c-format
msgid "The <literal><composite-map-key> element allows you to map a component class as the key of a Map. Ensure that you override hashCode() and equals() correctly on the component class."
msgstr ""
#. Tag: title
#, no-c-format
msgid "Components as composite identifiers"
msgstr ""
#. Tag: para
#, no-c-format
msgid "You can use a component as an identifier of an entity class. Your component class must satisfy certain requirements:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "It must implement <literal>java.io.Serializable."
msgstr ""
#. Tag: para
#, no-c-format
msgid "It must re-implement <literal>equals() and hashCode() consistently with the database's notion of composite key equality."
msgstr ""
#. Tag: title
#, no-c-format
msgid "Note"
msgstr ""
#. Tag: para
#, no-c-format
msgid "In Hibernate3, although the second requirement is not an absolutely hard requirement of Hibernate, it is recommended."
msgstr ""
#. Tag: para
#, no-c-format
msgid "You cannot use an <literal>IdentifierGenerator to generate composite keys. Instead the application must assign its own identifiers."
msgstr ""
#. Tag: para
#, no-c-format
msgid "Use the <literal><composite-id> tag, with nested <key-property> elements, in place of the usual <id> declaration. For example, the OrderLine class has a primary key that depends upon the (composite) primary key of Order."
msgstr ""
#. Tag: para
#, no-c-format
msgid "Any foreign keys referencing the <literal>OrderLine table are now composite. Declare this in your mappings for other classes. An association to OrderLine is mapped like this:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "The <literal>column element is an alternative to the column attribute everywhere. Using the column element just gives more declaration options, which are mostly useful when utilizing hbm2ddl"
msgstr ""
#. Tag: para
#, no-c-format
msgid "A <literal>many-to-many association to OrderLine also uses the composite foreign key:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "The collection of <literal>OrderLines in Order would use:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "The <literal><one-to-many> element declares no columns."
msgstr ""
#. Tag: para
#, no-c-format
msgid "If <literal>OrderLine itself owns a collection, it also has a composite foreign key."
msgstr ""
#. Tag: title
#, no-c-format
msgid "Dynamic components"
msgstr ""
#. Tag: para
#, no-c-format
msgid "You can also map a property of type <literal>Map:"
msgstr ""
#. Tag: para
#, no-c-format
msgid "The semantics of a <literal><dynamic-component> mapping are identical to <component>. The advantage of this kind of mapping is the ability to determine the actual properties of the bean at deployment time just by editing the mapping document. Runtime manipulation of the mapping document is also possible, using a DOM parser. You can also access, and change, Hibernate's configuration-time metamodel via the Configuration object."
msgstr ""
Other Hibernate examples (source code examples)
Here is a short list of links related to this Hibernate component_mapping.pot source code file:
|