📄 basic_mapping.pot
字号:
# 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#: basic_mapping.xml:29#, no-c-formatmsgid "Basic O/R Mapping"msgstr ""#. Tag: title#: basic_mapping.xml:32#, no-c-formatmsgid "Mapping declaration"msgstr ""#. Tag: para#: basic_mapping.xml:34#, no-c-formatmsgid "Object/relational mappings are usually defined in an XML document. The mapping document is designed to be readable and hand-editable. The mapping language is Java-centric, meaning that mappings are constructed around persistent class declarations, not table declarations."msgstr ""#. Tag: para#: basic_mapping.xml:41#, no-c-formatmsgid "Note that, even though many Hibernate users choose to write the XML by hand, a number of tools exist to generate the mapping document, including XDoclet, Middlegen and AndroMDA."msgstr ""#. Tag: para#: basic_mapping.xml:47#, no-c-formatmsgid "Lets kick off with an example mapping:"msgstr ""#. Tag: programlisting#: basic_mapping.xml:51#, no-c-formatmsgid "" "<![CDATA[<?xml version=\"1.0\"?>\n" "<!DOCTYPE hibernate-mapping PUBLIC\n" " \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n" " \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n" "\n" "<hibernate-mapping package=\"eg\">\n" "\n" " <class name=\"Cat\"\n" " table=\"cats\"\n" " discriminator-value=\"C\">\n" "\n" " <id name=\"id\">\n" " <generator class=\"native\"/>\n" " </id>\n" "\n" " <discriminator column=\"subclass\"\n" " type=\"character\"/>\n" "\n" " <property name=\"weight\"/>\n" "\n" " <property name=\"birthdate\"\n" " type=\"date\"\n" " not-null=\"true\"\n" " update=\"false\"/>\n" "\n" " <property name=\"color\"\n" " type=\"eg.types.ColorUserType\"\n" " not-null=\"true\"\n" " update=\"false\"/>\n" "\n" " <property name=\"sex\"\n" " not-null=\"true\"\n" " update=\"false\"/>\n" "\n" " <property name=\"litterId\"\n" " column=\"litterId\"\n" " update=\"false\"/>\n" "\n" " <many-to-one name=\"mother\"\n" " column=\"mother_id\"\n" " update=\"false\"/>\n" "\n" " <set name=\"kittens\"\n" " inverse=\"true\"\n" " order-by=\"litter_id\">\n" " <key column=\"mother_id\"/>\n" " <one-to-many class=\"Cat\"/>\n" " </set>\n" "\n" " <subclass name=\"DomesticCat\"\n" " discriminator-value=\"D\">\n" "\n" " <property name=\"name\"\n" " type=\"string\"/>\n" "\n" " </subclass>\n" "\n" " </class>\n" "\n" " <class name=\"Dog\">\n" " <!-- mapping for Dog could go here -->\n" " </class>\n" "\n" "</hibernate-mapping>]]>"msgstr ""#. Tag: para#: basic_mapping.xml:53#, no-c-formatmsgid "We will now discuss the content of the mapping document. We will only describe the document elements and attributes that are used by Hibernate at runtime. The mapping document also contains some extra optional attributes and elements that affect the database schemas exported by the schema export tool. (For example the <literal> not-null</literal> attribute.)"msgstr ""#. Tag: title#: basic_mapping.xml:64#, no-c-formatmsgid "Doctype"msgstr ""#. Tag: para#: basic_mapping.xml:66#, no-c-formatmsgid "All XML mappings should declare the doctype shown. The actual DTD may be found at the URL above, in the directory <literal>hibernate-x.x.x/src/org/hibernate </literal> or in <literal>hibernate3.jar</literal>. Hibernate will always look for the DTD in its classpath first. If you experience lookups of the DTD using an Internet connection, check your DTD declaration against the contents of your claspath."msgstr ""#. Tag: title#: basic_mapping.xml:76#, no-c-formatmsgid "EntityResolver"msgstr ""#. Tag: para#: basic_mapping.xml:77#, no-c-formatmsgid "As mentioned previously, Hibernate will first attempt to resolve DTDs in its classpath. The manner in which it does this is by registering a custom <literal>org.xml.sax.EntityResolver</literal> implementation with the SAXReader it uses to read in the xml files. This custom <literal>EntityResolver</literal> recognizes two different systemId namespaces."msgstr ""#. Tag: para#: basic_mapping.xml:85#, no-c-formatmsgid "a <literal>hibernate namespace</literal> is recognized whenever the resolver encounteres a systemId starting with <literal>http://hibernate.sourceforge.net/</literal>; the resolver attempts to resolve these entities via the classlaoder which loaded the Hibernate classes."msgstr ""#. Tag: para#: basic_mapping.xml:94#, no-c-formatmsgid "a <literal>user namespace</literal> is recognized whenever the resolver encounteres a systemId using a <literal>classpath://</literal> URL protocol; the resolver will attempt to resolve these entities via (1) the current thread context classloader and (2) the classloader which loaded the Hibernate classes."msgstr ""#. Tag: para#: basic_mapping.xml:103#, no-c-formatmsgid "An example of utilizing user namespacing:"msgstr ""#. Tag: programlisting#: basic_mapping.xml:106#, no-c-formatmsgid "" "<![CDATA[<?xml version=\"1.0\"?>\n" "<!DOCTYPE hibernate-mapping PUBLIC\n" " \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n" " \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\" [\n" " <!ENTITY types SYSTEM \"classpath://your/domain/types.xml\">\n" "]>\n" "\n" "<hibernate-mapping package=\"your.domain\">\n" " <class name=\"MyEntity\">\n" " <id name=\"id\" type=\"my-custom-id-type\">\n" " ...\n" " </id>\n" " <class>\n" " &types;\n" "</hibernate-mapping>]]>"msgstr ""#. Tag: para#: basic_mapping.xml:107#, no-c-formatmsgid "Where <literal>types.xml</literal> is a resource in the <literal>your.domain</literal> package and contains a custom <link linkend=\"mapping-types-custom\">typedef</link>."msgstr ""#. Tag: title#: basic_mapping.xml:115#, no-c-formatmsgid "hibernate-mapping"msgstr ""#. Tag: para#: basic_mapping.xml:117#, no-c-formatmsgid "This element has several optional attributes. The <literal>schema</literal> and <literal>catalog</literal> attributes specify that tables referred to in this mapping belong to the named schema and/or catalog. If specified, tablenames will be qualified by the given schema and catalog names. If missing, tablenames will be unqualified. The <literal>default-cascade</literal> attribute specifies what cascade style should be assumed for properties and collections which do not specify a <literal>cascade</literal> attribute. The <literal>auto-import</literal> attribute lets us use unqualified class names in the query language, by default."msgstr ""#. Tag: programlisting#: basic_mapping.xml:138#, no-c-formatmsgid "" "<![CDATA[<hibernate-mapping\n" " schema=\"schemaName\"\n" " catalog=\"catalogName\"\n" " default-cascade=\"cascade_style\"\n" " default-access=\"field|property|ClassName\"\n" " default-lazy=\"true|false\"\n" " auto-import=\"true|false\"\n" " package=\"package.name\"\n" " />]]>"msgstr ""#. Tag: para#: basic_mapping.xml:141#, no-c-formatmsgid "<literal>schema</literal> (optional): The name of a database schema."msgstr ""#. Tag: para#: basic_mapping.xml:146#, no-c-formatmsgid "<literal>catalog</literal> (optional): The name of a database catalog."msgstr ""#. Tag: para#: basic_mapping.xml:151#, no-c-formatmsgid "<literal>default-cascade</literal> (optional - defaults to <literal>none</literal>): A default cascade style."msgstr ""#. Tag: para#: basic_mapping.xml:157#, no-c-formatmsgid "<literal>default-access</literal> (optional - defaults to <literal>property</literal>): The strategy Hibernate should use for accessing all properties. Can be a custom implementation of <literal>PropertyAccessor</literal>."msgstr ""#. Tag: para#: basic_mapping.xml:164#, no-c-formatmsgid "<literal>default-lazy</literal> (optional - defaults to <literal>true</literal>): The default value for unspecifed <literal>lazy</literal> attributes of class and collection mappings."msgstr ""#. Tag: para#: basic_mapping.xml:171#, no-c-formatmsgid "<literal>auto-import</literal> (optional - defaults to <literal>true</literal>): Specifies whether we can use unqualified class names (of classes in this mapping) in the query language."msgstr ""#. Tag: para#: basic_mapping.xml:178#, no-c-formatmsgid "<literal>package</literal> (optional): Specifies a package prefix to assume for unqualified class names in the mapping document."msgstr ""#. Tag: para#: basic_mapping.xml:186#, no-c-formatmsgid "If you have two persistent classes with the same (unqualified) name, you should set <literal>auto-import=\"false\"</literal>. Hibernate will throw an exception if you attempt to assign two classes to the same \"imported\" name."msgstr ""#. Tag: para#: basic_mapping.xml:192#, no-c-formatmsgid "Note that the <literal>hibernate-mapping</literal> element allows you to nest several persistent <literal><class></literal> mappings, as shown above. It is however good practice (and expected by some tools) to map only a single persistent class (or a single class hierarchy) in one mapping file and name it after the persistent superclass, e.g. <literal>Cat.hbm.xml</literal>, <literal>Dog.hbm.xml</literal>, or if using inheritance, <literal>Animal.hbm.xml</literal>."msgstr ""#. Tag: title#: basic_mapping.xml:205#, no-c-formatmsgid "<title>class</title>"msgstr ""#. Tag: para#: basic_mapping.xml:207#, no-c-formatmsgid "You may declare a persistent class using the <literal>class</literal> element:"msgstr ""#. Tag: programlisting#: basic_mapping.xml:235#, no-c-formatmsgid "" "<![CDATA[<class\n" " name=\"ClassName\"\n" " table=\"tableName\"\n" " discriminator-value=\"discriminator_value\"\n" " mutable=\"true|false\"\n" " schema=\"owner\"\n" " catalog=\"catalog\"\n" " proxy=\"ProxyInterface\"\n" " dynamic-update=\"true|false\"\n" " dynamic-insert=\"true|false\"\n" " select-before-update=\"true|false\"\n" " polymorphism=\"implicit|explicit\"\n" " where=\"arbitrary sql where condition\"\n" " persister=\"PersisterClass\"\n" " batch-size=\"N\"\n" " optimistic-lock=\"none|version|dirty|all\"\n" " lazy=\"true|false\"\n" " entity-name=\"EntityName\"\n" " check=\"arbitrary sql check condition\"\n" " rowid=\"rowid\"\n" " subselect=\"SQL expression\"\n" " abstract=\"true|false\"\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -