📄 persistent_classes.po
字号:
"to be declared instead of (or in addition to) a class name:"msgstr """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:"#. 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 """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."#. 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 """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:"#. 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 """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."#. Tag: para#: persistent_classes.xml:265#, no-c-formatmsgid """Entity representation modes can also be set on a per <literal>Session</""literal> basis:"msgstr """Entity representation modes can also be set on a per <literal>Session</""literal> basis:"#. 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 """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."#. Tag: para#: persistent_classes.xml:283#, no-c-formatmsgid """More information about the XML representation capabilities can be found in ""<xref linkend=\"xml\"/>."msgstr """More information about the XML representation capabilities can be found in ""<xref linkend=\"xml\"/>."#. Tag: title#: persistent_classes.xml:291#, no-c-formatmsgid "Tuplizers"msgstr "Tuplizers"#. 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>, 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.EntityTuplizer</literal> and ""<literal>org.hibernate.tuple.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."#. 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 """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:"#. 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: Document user-extension framework in the property and proxy packages"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -