⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collection_mapping.pot

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 POT
📖 第 1 页 / 共 4 页
字号:
# SOME DESCRIPTIVE TITLE.# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.##, fuzzymsgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""Report-Msgid-Bugs-To: http://bugs.kde.org\n""POT-Creation-Date: 2008-08-14 15:28+0000\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <kde-i18n-doc@kde.org>\n""MIME-Version: 1.0\n""Content-Type: application/x-xml2pot; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#. Tag: title#: collection_mapping.xml:29#, no-c-formatmsgid "Collection Mapping"msgstr ""#. Tag: title#: collection_mapping.xml:32#, no-c-formatmsgid "Persistent collections"msgstr ""#. Tag: para#: collection_mapping.xml:34#, no-c-formatmsgid "Hibernate requires that persistent collection-valued fields be declared as an interface type, for example:"msgstr ""#. Tag: programlisting#: collection_mapping.xml:39#, no-c-formatmsgid ""      "<![CDATA[public class Product {\n"      "    private String serialNumber;\n"      "    private Set parts = new HashSet();\n"      "    \n"      "    public Set getParts() { return parts; }\n"      "    void setParts(Set parts) { this.parts = parts; }\n"      "    public String getSerialNumber() { return serialNumber; }\n"      "    void setSerialNumber(String sn) { serialNumber = sn; }\n"      "}]]>"msgstr ""#. Tag: para#: collection_mapping.xml:41#, no-c-formatmsgid "The actual interface might be <literal>java.util.Set</literal>, <literal>java.util.Collection</literal>, <literal>java.util.List</literal>, <literal>java.util.Map</literal>, <literal>java.util.SortedSet</literal>, <literal>java.util.SortedMap</literal> or ... anything you like! (Where \"anything you like\" means you will have to write an implementation of <literal>org.hibernate.usertype.UserCollectionType</literal>.)"msgstr ""#. Tag: para#: collection_mapping.xml:50#, no-c-formatmsgid "Notice how we initialized the instance variable with an instance of <literal>HashSet</literal>. This is the best way to initialize collection valued properties of newly instantiated (non-persistent) instances. When you make the instance persistent - by calling <literal>persist()</literal>, for example - Hibernate will actually replace the <literal>HashSet</literal> with an instance of Hibernate's own implementation of <literal>Set</literal>. Watch out for errors like this:"msgstr ""#. Tag: programlisting#: collection_mapping.xml:60#, no-c-formatmsgid ""      "<![CDATA[Cat cat = new DomesticCat();\n"      "Cat kitten = new DomesticCat();\n"      "....\n"      "Set kittens = new HashSet();\n"      "kittens.add(kitten);\n"      "cat.setKittens(kittens);\n"      "session.persist(cat);\n"      "kittens = cat.getKittens(); // Okay, kittens collection is a Set\n"      "(HashSet) cat.getKittens(); // Error!]]>"msgstr ""#. Tag: para#: collection_mapping.xml:62#, no-c-formatmsgid "The persistent collections injected by Hibernate behave like <literal>HashMap</literal>, <literal>HashSet</literal>, <literal>TreeMap</literal>, <literal>TreeSet</literal> or <literal>ArrayList</literal>, depending upon the interface type."msgstr ""#. Tag: para#: collection_mapping.xml:69#, no-c-formatmsgid "Collections instances have the usual behavior of value types. They are automatically persisted when referenced by a persistent object and automatically deleted when unreferenced. If a collection is passed from one persistent object to another, its elements might be moved from one table to another. Two entities may not share a reference to the same collection instance. Due to the underlying relational model, collection-valued properties do not support null value semantics; Hibernate does not distinguish between a null collection reference and an empty collection."msgstr ""#. Tag: para#: collection_mapping.xml:80#, no-c-formatmsgid "You shouldn't have to worry much about any of this. Use persistent collections the same way you use ordinary Java collections. Just make sure you understand the semantics of bidirectional associations (discussed later)."msgstr ""#. Tag: title#: collection_mapping.xml:89#, no-c-formatmsgid "Collection mappings"msgstr ""#. Tag: para#: collection_mapping.xml:92#, no-c-formatmsgid "There are quite a range of mappings that can be generated for collections, covering many common relational models. We suggest you experiment with the schema generation tool to get a feeling for how various mapping declarations translate to database tables."msgstr ""#. Tag: para#: collection_mapping.xml:99#, no-c-formatmsgid "The Hibernate mapping element used for mapping a collection depends upon the type of the interface. For example, a <literal>&lt;set&gt;</literal> element is used for mapping properties of type <literal>Set</literal>."msgstr ""#. Tag: programlisting#: collection_mapping.xml:105#, no-c-formatmsgid ""      "<![CDATA[<class name=\"Product\">\n"      "    <id name=\"serialNumber\" column=\"productSerialNumber\"/>\n"      "    <set name=\"parts\">\n"      "        <key column=\"productSerialNumber\" not-null=\"true\"/>\n"      "        <one-to-many class=\"Part\"/>\n"      "    </set>\n"      "</class>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:107#, no-c-formatmsgid "Apart from <literal>&lt;set&gt;</literal>, there is also <literal>&lt;list&gt;</literal>, <literal>&lt;map&gt;</literal>, <literal>&lt;bag&gt;</literal>, <literal>&lt;array&gt;</literal> and <literal>&lt;primitive-array&gt;</literal> mapping elements. The <literal>&lt;map&gt;</literal> element is representative:"msgstr ""#. Tag: programlisting#: collection_mapping.xml:132#, no-c-formatmsgid ""      "<![CDATA[<map\n"      "    name=\"propertyName\"\n"      "    table=\"table_name\"\n"      "    schema=\"schema_name\"\n"      "    lazy=\"true|extra|false\"\n"      "    inverse=\"true|false\"\n"      "    cascade=\"all|none|save-update|delete|all-delete-orphan|delete-orphan\"\n"      "    sort=\"unsorted|natural|comparatorClass\"\n"      "    order-by=\"column_name asc|desc\"\n"      "    where=\"arbitrary sql where condition\"\n"      "    fetch=\"join|select|subselect\"\n"      "    batch-size=\"N\"\n"      "    access=\"field|property|ClassName\"\n"      "    optimistic-lock=\"true|false\"\n"      "    mutable=\"true|false\"\n"      "    node=\"element-name|.\"\n"      "    embed-xml=\"true|false\"\n"      ">\n"      "\n"      "    <key .... />\n"      "    <map-key .... />\n"      "    <element .... />\n"      "</map>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:135#, no-c-formatmsgid "<literal>name</literal> the collection property name"msgstr ""#. Tag: para#: collection_mapping.xml:140#, no-c-formatmsgid "<literal>table</literal> (optional - defaults to property name) the name of the collection table (not used for one-to-many associations)"msgstr ""#. Tag: para#: collection_mapping.xml:146#, no-c-formatmsgid "<literal>schema</literal> (optional) the name of a table schema to override the schema declared on the root element"msgstr ""#. Tag: para#: collection_mapping.xml:152#, no-c-formatmsgid "<literal>lazy</literal> (optional - defaults to <literal>true</literal>) may be used to disable lazy fetching and specify that the association is always eagerly fetched, or to enable \"extra-lazy\" fetching where most operations do not initialize the collection (suitable for very large collections)"msgstr ""#. Tag: para#: collection_mapping.xml:161#, no-c-formatmsgid "<literal>inverse</literal> (optional - defaults to <literal>false</literal>) mark this collection as the \"inverse\" end of a bidirectional association"msgstr ""#. Tag: para#: collection_mapping.xml:167#, no-c-formatmsgid "<literal>cascade</literal> (optional - defaults to <literal>none</literal>) enable operations to cascade to child entities"msgstr ""#. Tag: para#: collection_mapping.xml:173#, no-c-formatmsgid "<literal>sort</literal> (optional) specify a sorted collection with <literal>natural</literal> sort order, or a given comparator class"msgstr ""#. Tag: para#: collection_mapping.xml:179#, no-c-formatmsgid "<literal>order-by</literal> (optional, JDK1.4 only) specify a table column (or columns) that define the iteration order of the <literal>Map</literal>, <literal>Set</literal> or bag, together with an optional <literal>asc</literal> or <literal>desc</literal>"msgstr ""#. Tag: para#: collection_mapping.xml:186#, no-c-formatmsgid "<literal>where</literal> (optional) specify an arbitrary SQL <literal>WHERE</literal> condition to be used when retrieving or removing the collection (useful if the collection should contain only a subset of the available data)"msgstr ""#. Tag: para#: collection_mapping.xml:193#, no-c-formatmsgid "<literal>fetch</literal> (optional, defaults to <literal>select</literal>) Choose between outer-join fetching, fetching by sequential select, and fetching by sequential subselect."msgstr ""#. Tag: para#: collection_mapping.xml:200#, no-c-formatmsgid "<literal>batch-size</literal> (optional, defaults to <literal>1</literal>) specify a \"batch size\" for lazily fetching instances of this collection."msgstr ""#. Tag: para#: collection_mapping.xml:206#, no-c-formatmsgid "<literal>access</literal> (optional - defaults to <literal>property</literal>): The strategy Hibernate should use for accessing the collection property value."msgstr ""#. Tag: para#: collection_mapping.xml:212#, no-c-formatmsgid "<literal>optimistic-lock</literal> (optional - defaults to <literal>true</literal>): Species that changes to the state of the collection results in increment of the owning entity's version. (For one to many associations, it is often reasonable to disable this setting.)"msgstr ""#. Tag: para#: collection_mapping.xml:220#, no-c-formatmsgid "<literal>mutable</literal> (optional - defaults to <literal>true</literal>): A value of <literal>false</literal> specifies that the elements of the collection never change (a minor performance optimization in some cases)."msgstr ""#. Tag: title#: collection_mapping.xml:230#, no-c-formatmsgid "Collection foreign keys"msgstr ""#. Tag: para#: collection_mapping.xml:232#, no-c-formatmsgid "Collection instances are distinguished in the database by the foreign key of the entity that owns the collection. This foreign key is referred to as the <emphasis>collection key column</emphasis> (or columns) of the collection table. The collection key column is mapped by the <literal>&lt;key&gt;</literal> element."msgstr ""#. Tag: para#: collection_mapping.xml:240#, no-c-formatmsgid "There may be a nullability constraint on the foreign key column. For most collections, this is implied. For unidirectional one to many associations, the foreign key column is nullable by default, so you might need to specify <literal>not-null=\"true\"</literal>."msgstr ""#. Tag: programlisting#: collection_mapping.xml:247#, no-c-formatmsgid "<![CDATA[<key column=\"productSerialNumber\" not-null=\"true\"/>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:249#, no-c-formatmsgid "The foreign key constraint may use <literal>ON DELETE CASCADE</literal>."msgstr ""#. Tag: programlisting#: collection_mapping.xml:253#, no-c-formatmsgid "<![CDATA[<key column=\"productSerialNumber\" on-delete=\"cascade\"/>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:255#, no-c-formatmsgid "See the previous chapter for a full definition of the <literal>&lt;key&gt;</literal> element."msgstr ""#. Tag: title#: collection_mapping.xml:263#, no-c-formatmsgid "Collection elements"msgstr ""#. Tag: para#: collection_mapping.xml:265#, no-c-formatmsgid "Collections may contain almost any other Hibernate type, including all basic types, custom types, components, and of course, references to other entities. This is an important distinction: an object in a collection might be handled with \"value\" semantics (its life cycle fully depends on the collection owner) or it might be a reference to another entity, with its own life cycle. In the latter case, only the \"link\" between the two objects is considered to be state held by the collection."msgstr ""#. Tag: para

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -