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

📄 persistent_classes.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 3 页
字号:
"The following examples demonstrates the representation using <literal>Map</""literal>s. First, in the mapping file, an <literal>entity-name</literal> has ""to be declared instead of (or in addition to) a class name:"msgstr """以下の例では <literal>Map</literal> を使った表現を紹介します。 まずマッピング""ファイルで、クラス名の代わりに(またはそれに加えて) <literal>entity-name</""literal> を定義しなければなりません:"#. Tag: programlisting#: persistent_classes.xml:240#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n""    <class entity-name=\"Customer\">\n""\n""        <id name=\"id\"\n""            type=\"long\"\n""            column=\"ID\">\n""            <generator class=\"sequence\"/>\n""        </id>\n""\n""        <property name=\"name\"\n""            column=\"NAME\"\n""            type=\"string\"/>\n""\n""        <property name=\"address\"\n""            column=\"ADDRESS\"\n""            type=\"string\"/>\n""\n""        <many-to-one name=\"organization\"\n""            column=\"ORGANIZATION_ID\"\n""            class=\"Organization\"/>\n""\n""        <bag name=\"orders\"\n""            inverse=\"true\"\n""            lazy=\"false\"\n""            cascade=\"all\">\n""            <key column=\"CUSTOMER_ID\"/>\n""            <one-to-many class=\"Order\"/>\n""        </bag>\n""\n""    </class>\n""    \n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: persistent_classes.xml:242#, no-c-formatmsgid """Note that even though associations are declared using target class names, ""the target type of an associations may also be a dynamic entity instead of a ""POJO."msgstr """関連がターゲットのクラス名を使って定義していたとしても、 関連のターゲット型も""POJOではなく動的なエンティティでも構わないことに注意してください。"#. Tag: para#: persistent_classes.xml:249#, no-c-formatmsgid """After setting the default entity mode to <literal>dynamic-map</literal> for ""the <literal>SessionFactory</literal>, we can at runtime work with ""<literal>Map</literal>s of <literal>Map</literal>s:"msgstr """<literal>SessionFactory</literal> に対してデフォルトのエンティティモードを ""<literal>dynamic-map</literal> に設定した後、 実行時に <literal>Map</""literal> の <literal>Map</literal> を使うことができます:"#. Tag: programlisting#: persistent_classes.xml:255#, no-c-formatmsgid """<![CDATA[Session s = openSession();\n""Transaction tx = s.beginTransaction();\n""Session s = openSession();\n""\n""// Create a customer\n""Map david = new HashMap();\n""david.put(\"name\", \"David\");\n""\n""// Create an organization\n""Map foobar = new HashMap();\n""foobar.put(\"name\", \"Foobar Inc.\");\n""\n""// Link both\n""david.put(\"organization\", foobar);\n""\n""// Save both\n""s.save(\"Customer\", david);\n""s.save(\"Organization\", foobar);\n""\n""tx.commit();\n""s.close();]]>"msgstr ""#. Tag: para#: persistent_classes.xml:257#, no-c-formatmsgid """The advantages of a dynamic mapping are quick turnaround time for ""prototyping without the need for entity class implementation. However, you ""lose compile-time type checking and will very likely deal with many ""exceptions at runtime. Thanks to the Hibernate mapping, the database schema ""can easily be normalized and sound, allowing to add a proper domain model ""implementation on top later on."msgstr """動的なマッピングの利点は、エンティティクラスの実装を必要としないため、 プロト""タイピングに要するターンアラウンドタイムが早いということです。 しかしコンパイ""ル時の型チェックがないので、実行時に非常に多くの例外処理を扱わなければならな""いでしょう。 Hibernateマッピングのおかげで、データベーススキーマは容易に正規""化でき、健全になり、 後で適切なドメインモデルの実装を追加することが可能になり""ます。"#. Tag: para#: persistent_classes.xml:265#, no-c-formatmsgid """Entity representation modes can also be set on a per <literal>Session</""literal> basis:"msgstr """エンティティ表現モードは <literal>Session</literal> ごとに設定することも可能""です。"#. Tag: programlisting#: persistent_classes.xml:270#, no-c-formatmsgid """<![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);\n""\n""// Create a customer\n""Map david = new HashMap();\n""david.put(\"name\", \"David\");\n""dynamicSession.save(\"Customer\", david);\n""...\n""dynamicSession.flush();\n""dynamicSession.close()\n""...\n""// Continue on pojoSession\n""]]>"msgstr ""#. Tag: para#: persistent_classes.xml:273#, no-c-formatmsgid """Please note that the call to <literal>getSession()</literal> using an ""<literal>EntityMode</literal> is on the <literal>Session</literal> API, not ""the <literal>SessionFactory</literal>. That way, the new <literal>Session</""literal> shares the underlying JDBC connection, transaction, and other ""context information. This means you don't have tocall <literal>flush()</""literal> and <literal>close()</literal> on the secondary <literal>Session</""literal>, and also leave the transaction and connection handling to the ""primary unit of work."msgstr """<literal>EntityMode</literal> を使った <literal>getSession()</literal> の呼び""出しは <literal>SessionFactory</literal> ではなく <literal>Session</literal> ""APIにあることに注意してください。 その方法では、新しい <literal>Session</""literal> は、ベースとなるJDBCコネクション、 トランザクション、その他のコンテ""キスト情報を共有します。 これは2番目の <literal>Session</literal> では ""<literal>flush()</literal> と <literal>close()</literal> を呼ぶ必要がないとい""うこと、そのためトランザクションとコネクションの管理を 1番目の作業単位(Unit ""of Work)に任せることができるということです。"#. Tag: para#: persistent_classes.xml:283#, no-c-formatmsgid """More information about the XML representation capabilities can be found in ""<xref linkend=\"xml\"/>."msgstr """XML表現の能力についてのさらなる情報は <xref linkend=\"xml\"/> で見つかりま""す。"#. Tag: title#: persistent_classes.xml:291#, no-c-formatmsgid "Tuplizers"msgstr "Tuplizer"#. Tag: para#: persistent_classes.xml:293#, no-c-formatmsgid """<literal>org.hibernate.tuple.Tuplizer</literal>, and its sub-interfaces, are ""responsible for managing a particular representation of a piece of data, ""given that representation's <literal>org.hibernate.EntityMode</literal>. If ""a given piece of data is thought of as a data structure, then a tuplizer is ""the thing which knows how to create such a data structure and how to extract ""values from and inject values into such a data structure. For example, for ""the POJO entity mode, the correpsonding tuplizer knows how create the POJO ""through its constructor and how to access the POJO properties using the ""defined property accessors. There are two high-level types of Tuplizers, ""represented by the <literal>org.hibernate.tuple.entity.EntityTuplizer</""literal> and <literal>org.hibernate.tuple.component.ComponentTuplizer</""literal> interfaces. <literal>EntityTuplizer</literal>s are responsible for ""managing the above mentioned contracts in regards to entities, while ""<literal>ComponentTuplizer</literal>s do the same for components."msgstr """<literal>org.hibernate.tuple.Tuplizer</literal> とそのサブインターフェイス""は、 表現の <literal>org.hibernate.EntityMode</literal> を利用して、 データ断""片のある表現の管理に責任を持ちます。 与えられたデータ断片をデータ構造として考""えるなら、Tuplizerはそのようなデータ構造を どのように作成するかを知り、そのよ""うなデータ構造からどのように値を抽出し、 注入するかを知っています。 例えば""POJOエンティティモードでは、対応するTuplizerはコンストラクタを通して、 POJOを""どのように作成するか、定義されたプロパティアクセサを使い、 POJOプロパティにど""のようにアクセスするかを知ります。 Tuplizerには二つのハイレベルの型がありま""す。 それらは、<literal>org.hibernate.tuple.EntityTuplizer</literal> と ""<literal>org.hibernate.tuple.ComponentTuplizer</literal> インターフェイスで表""現されます。 <literal>EntityTuplizer</literal> は上で述べたようなエンティティ""に関する契約の管理に責任を持ちます。 一方、<literal>ComponentTuplizer</""literal> はコンポーネントに関する契約の管理に責任を持ちます。"#. Tag: para#: persistent_classes.xml:308#, no-c-formatmsgid """Users may also plug in their own tuplizers. Perhaps you require that a ""<literal>java.util.Map</literal> implementation other than <literal>java.""util.HashMap</literal> be used while in the dynamic-map entity-mode; or ""perhaps you need to define a different proxy generation strategy than the ""one used by default. Both would be achieved by defining a custom tuplizer ""implementation. Tuplizers definitions are attached to the entity or ""component mapping they are meant to manage. Going back to the example of our ""customer entity:"msgstr """ユーザは独自のTuplizerに差し替えることも可能です。 おそらくdynamic-map ""entity-modeの際に <literal>java.util.HashMap</literal> を使うのではなく、 ""<literal>java.util.Map</literal> の実装が必要でしょう。 もしくは、おそらくデ""フォルトのものではなく、別のプロキシ生成戦略の定義が必要でしょう。 両者とも、""カスタムのTuplizer実装を定義することで達成されます。 Tuplizerの定義は、管理し""ようとするエンティティやコンポーネントのマッピングに結び付けられます。 顧客エ""ンティティの例に戻ると:"#. Tag: programlisting#: persistent_classes.xml:317#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""    <class entity-name=\"Customer\">\n""        <!--\n""            Override the dynamic-map entity-mode\n""            tuplizer for the customer entity\n""        -->\n""        <tuplizer entity-mode=\"dynamic-map\"\n""                class=\"CustomMapTuplizerImpl\"/>\n""\n""        <id name=\"id\" type=\"long\" column=\"ID\">\n""            <generator class=\"sequence\"/>\n""        </id>\n""\n""        <!-- other properties -->\n""        ...\n""    </class>\n""</hibernate-mapping>\n""\n""\n""public class CustomMapTuplizerImpl\n""        extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {\n""    // override the buildInstantiator() method to plug in our custom map...\n""    protected final Instantiator buildInstantiator(\n""            org.hibernate.mapping.PersistentClass mappingInfo) {\n""        return new CustomMapInstantiator( mappingInfo );\n""    }\n""\n""    private static final class CustomMapInstantiator\n""            extends org.hibernate.tuple.DynamicMapInstantitor {\n""        // override the generateMap() method to return our custom map...\n""            protected final Map generateMap() {\n""                    return new CustomMap();\n""            }\n""    }\n""}]]>"msgstr ""#. Tag: para#: persistent_classes.xml:322#, no-c-formatmsgid """TODO: Document user-extension framework in the property and proxy packages"msgstr """TODO: プロパティとプロキシパッケージのユーザ拡張フレームワークを文書化するこ""と"

⌨️ 快捷键说明

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