📄 persistent_classes.po
字号:
#, no-c-formatmsgid """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>dynamic-map</literal>为<literal>SessionFactory</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""映射,它使得数 据库的schema能容易的规格化和合理化,并允许稍后在此之上添加合适""的领域模型实现。"#. 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>Session</literal>的API中,而不是<literal>SessionFactory</""literal>。 这样,新的<literal>Session</literal>共享底层的JDBC连接,事务,和其""他的上下文信 息。这意味着,你不需要在第二个<literal>Session</literal>中调用 ""<literal>flush()</literal>和<literal>close()</literal>,同样的,把事务和连接""的处理 交给原来的工作单元。"#. 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 "元组片断映射(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>,以及其子接口,负责根据给定的""<literal>org.hibernate.EntityMode</literal>,来复现片断数据。如果给定的片断数""据被认为其是一种数据结构,\"tuplizer\"就是一个知道如何创建这样的数据结构,以""及如何给这个数据结构赋值的东西。比如说,对于POJO这种Entity Mode,对应的""tuplizer知道通过其构造方法来创建一个POJO,再通过其属性访问器来访问POJO属性。""有两大类高层Tuplizer,分别是<literal>org.hibernate.tuple.entity.""EntityTuplizer</literal> 和<literal>org.hibernate.tuple.entity.""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>实现;或许您需要与默认策略不同的代理生成策略(proxy generation ""strategy)。通过自定义tuplizer实现,这两个目标您都可以达到。Tuplizer定义被附加""到它们期望管理的entity或者component映射中。回到我们的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:property和proxy包里的用户扩展框架文档。"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -