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

📄 configuration.pot

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 POT
📖 第 1 页 / 共 5 页
字号:
msgstr ""#. Tag: para#: configuration.xml:1341#, no-c-formatmsgid "The XML configuration file is by default expected to be in the root o your <literal>CLASSPATH</literal>. Here is an example:"msgstr ""#. Tag: programlisting#: configuration.xml:1346#, no-c-formatmsgid ""      "<![CDATA[<?xml version='1.0' encoding='utf-8'?>\n"      "<!DOCTYPE hibernate-configuration PUBLIC\n"      "    \"-//Hibernate/Hibernate Configuration DTD//EN\"\n"      "    \"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\">\n"      "\n"      "<hibernate-configuration>\n"      "\n"      "    <!-- a SessionFactory instance listed as /jndi/name -->\n"      "    <session-factory\n"      "        name=\"java:hibernate/SessionFactory\">\n"      "\n"      "        <!-- properties -->\n"      "        <property name=\"connection.datasource\">java:/comp/env/jdbc/MyDB</property>\n"      "        <property name=\"dialect\">org.hibernate.dialect.MySQLDialect</property>\n"      "        <property name=\"show_sql\">false</property>\n"      "        <property name=\"transaction.factory_class\">\n"      "            org.hibernate.transaction.JTATransactionFactory\n"      "        </property>\n"      "        <property name=\"jta.UserTransaction\">java:comp/UserTransaction</property>\n"      "\n"      "        <!-- mapping files -->\n"      "        <mapping resource=\"org/hibernate/auction/Item.hbm.xml\"/>\n"      "        <mapping resource=\"org/hibernate/auction/Bid.hbm.xml\"/>\n"      "\n"      "        <!-- cache settings -->\n"      "        <class-cache class=\"org.hibernate.auction.Item\" usage=\"read-write\"/>\n"      "        <class-cache class=\"org.hibernate.auction.Bid\" usage=\"read-only\"/>\n"      "        <collection-cache collection=\"org.hibernate.auction.Item.bids\" usage=\"read-write\"/>\n"      "\n"      "    </session-factory>\n"      "\n"      "</hibernate-configuration>]]>"msgstr ""#. Tag: para#: configuration.xml:1348#, no-c-formatmsgid "As you can see, the advantage of this approach is the externalization of the mapping file names to configuration. The <literal>hibernate.cfg.xml</literal> is also more convenient once you have to tune the Hibernate cache. Note that is your choice to use either <literal>hibernate.properties</literal> or <literal>hibernate.cfg.xml</literal>, both are equivalent, except for the above mentioned benefits of using the XML syntax."msgstr ""#. Tag: para#: configuration.xml:1357#, no-c-formatmsgid "With the XML configuration, starting Hibernate is then as simple as"msgstr ""#. Tag: programlisting#: configuration.xml:1361#, no-c-formatmsgid "<![CDATA[SessionFactory sf = new Configuration().configure().buildSessionFactory();]]>"msgstr ""#. Tag: para#: configuration.xml:1363#, no-c-formatmsgid "You can pick a different XML configuration file using"msgstr ""#. Tag: programlisting#: configuration.xml:1367#, no-c-formatmsgid ""      "<![CDATA[SessionFactory sf = new Configuration()\n"      "    .configure(\"catdb.cfg.xml\")\n"      "    .buildSessionFactory();]]>"msgstr ""#. Tag: title#: configuration.xml:1372#, no-c-formatmsgid "J2EE Application Server integration"msgstr ""#. Tag: para#: configuration.xml:1374#, no-c-formatmsgid "Hibernate has the following integration points for J2EE infrastructure:"msgstr ""#. Tag: para#: configuration.xml:1380#, no-c-formatmsgid "<emphasis>Container-managed datasources</emphasis>: Hibernate can use JDBC connections managed by the container and provided through JNDI. Usually, a JTA compatible <literal>TransactionManager</literal> and a <literal>ResourceManager</literal> take care of transaction management (CMT), esp. distributed transaction handling across several datasources. You may of course also demarcate transaction boundaries programmatically (BMT) or you might want to use the optional Hibernate <literal>Transaction</literal> API for this to keep your code portable."msgstr ""#. Tag: para#: configuration.xml:1395#, no-c-formatmsgid "<emphasis>Automatic JNDI binding</emphasis>: Hibernate can bind its <literal>SessionFactory</literal> to JNDI after startup."msgstr ""#. Tag: para#: configuration.xml:1404#, no-c-formatmsgid "<emphasis>JTA Session binding:</emphasis> The Hibernate <literal>Session</literal> may be automatically bound to the scope of JTA transactions. Simply lookup the <literal>SessionFactory</literal> from JNDI and get the current <literal>Session</literal>. Let Hibernate take care of flushing and closing the <literal>Session</literal> when your JTA transaction completes. Transaction demarcation is either declarative (CMT) or programmatic (BMT/UserTransaction)."msgstr ""#. Tag: para#: configuration.xml:1417#, no-c-formatmsgid "<emphasis>JMX deployment:</emphasis> If you have a JMX capable application server (e.g. JBoss AS), you can chose to deploy Hibernate as a managed MBean. This saves you the one line startup code to build your <literal>SessionFactory</literal> from a <literal>Configuration</literal>. The container will startup your <literal>HibernateService</literal>, and ideally also take care of service dependencies (Datasource has to be available before Hibernate starts, etc)."msgstr ""#. Tag: para#: configuration.xml:1428#, no-c-formatmsgid "Depending on your environment, you might have to set the configuration option <literal>hibernate.connection.aggressive_release</literal> to true if your application server shows \"connection containment\" exceptions."msgstr ""#. Tag: title#: configuration.xml:1435#, no-c-formatmsgid "Transaction strategy configuration"msgstr ""#. Tag: para#: configuration.xml:1437#, no-c-formatmsgid "The Hibernate <literal>Session</literal> API is independent of any transaction demarcation system in your architecture. If you let Hibernate use JDBC directly, through a connection pool, you may begin and end your transactions by calling the JDBC API. If you run in a J2EE application server, you might want to use bean-managed transactions and call the JTA API and <literal>UserTransaction</literal> when needed."msgstr ""#. Tag: para#: configuration.xml:1445#, no-c-formatmsgid "To keep your code portable between these two (and other) environments we recommend the optional Hibernate <literal>Transaction</literal> API, which wraps and hides the underlying system. You have to specify a factory class for <literal>Transaction</literal> instances by setting the Hibernate configuration property <literal>hibernate.transaction.factory_class</literal>."msgstr ""#. Tag: para#: configuration.xml:1452#, no-c-formatmsgid "There are three standard (built-in) choices:"msgstr ""#. Tag: literal#: configuration.xml:1458#, no-c-formatmsgid "org.hibernate.transaction.JDBCTransactionFactory"msgstr ""#. Tag: para#: configuration.xml:1460#, no-c-formatmsgid "delegates to database (JDBC) transactions (default)"msgstr ""#. Tag: literal#: configuration.xml:1464#, no-c-formatmsgid "org.hibernate.transaction.JTATransactionFactory"msgstr ""#. Tag: para#: configuration.xml:1466#, no-c-formatmsgid "delegates to container-managed transaction if an existing transaction is underway in this context (e.g. EJB session bean method), otherwise a new transaction is started and bean-managed transaction are used."msgstr ""#. Tag: literal#: configuration.xml:1474#, no-c-formatmsgid "org.hibernate.transaction.CMTTransactionFactory"msgstr ""#. Tag: para#: configuration.xml:1476#, no-c-formatmsgid "delegates to container-managed JTA transactions"msgstr ""#. Tag: para#: configuration.xml:1481#, no-c-formatmsgid "You may also define your own transaction strategies (for a CORBA transaction service, for example)."msgstr ""#. Tag: para#: configuration.xml:1486#, no-c-formatmsgid "Some features in Hibernate (i.e. the second level cache, Contextual Sessions with JTA, etc.) require access to the JTA <literal>TransactionManager</literal> in a managed environment. In an application server you have to specify how Hibernate should obtain a reference to the <literal>TransactionManager</literal>, since J2EE does not standardize a single mechanism:"msgstr ""#. Tag: title#: configuration.xml:1494#, no-c-formatmsgid "JTA TransactionManagers"msgstr ""#. Tag: entry#: configuration.xml:1500#, no-c-formatmsgid "Transaction Factory"msgstr ""#. Tag: entry#: configuration.xml:1501#, no-c-formatmsgid "Application Server"msgstr ""#. Tag: literal#: configuration.xml:1506#, no-c-formatmsgid "org.hibernate.transaction.JBossTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1507#, no-c-formatmsgid "JBoss"msgstr ""#. Tag: literal#: configuration.xml:1510#, no-c-formatmsgid "org.hibernate.transaction.WeblogicTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1511#, no-c-formatmsgid "Weblogic"msgstr ""#. Tag: literal#: configuration.xml:1514#, no-c-formatmsgid "org.hibernate.transaction.WebSphereTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1515#, no-c-formatmsgid "WebSphere"msgstr ""#. Tag: literal#: configuration.xml:1518#, no-c-formatmsgid "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"msgstr ""#. Tag: entry#: configuration.xml:1519#, no-c-formatmsgid "WebSphere 6"msgstr ""#. Tag: literal#: configuration.xml:1522#, no-c-formatmsgid "org.hibernate.transaction.OrionTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1523#, no-c-formatmsgid "Orion"msgstr ""#. Tag: literal#: configuration.xml:1526#, no-c-formatmsgid "org.hibernate.transaction.ResinTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1527#, no-c-formatmsgid "Resin"msgstr ""#. Tag: literal#: configuration.xml:1530#, no-c-formatmsgid "org.hibernate.transaction.JOTMTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1531#, no-c-formatmsgid "JOTM"msgstr ""#. Tag: literal#: configuration.xml:1534#, no-c-formatmsgid "org.hibernate.transaction.JOnASTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1535#, no-c-formatmsgid "JOnAS"msgstr ""#. Tag: literal#: configuration.xml:1538#, no-c-formatmsgid "org.hibernate.transaction.JRun4TransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1539#, no-c-formatmsgid "JRun4"msgstr ""#. Tag: literal#: configuration.xml:1542#, no-c-formatmsgid "org.hibernate.transaction.BESTransactionManagerLookup"msgstr ""#. Tag: entry#: configuration.xml:1543#, no-c-formatmsgid "Borland ES"msgstr ""#. Tag: title#: configuration.xml:1552#, no-c-formatmsgid "JNDI-bound <literal>SessionFactory</literal>"msgstr ""#. Tag: para#: configuration.xml:1554#, no-c-formatmsgid "A JNDI bound Hibernate <literal>SessionFactory</literal> can simplify the lookup of the factory and the creation of new <literal>Session</literal>s. Note that this is not related to a JNDI bound <literal>Datasource</literal>, both simply use the same registry!"msgstr ""#. Tag: para#: configuration.xml:1561#, no-c-formatmsgid "If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify a name (eg. <literal>java:hibernate/SessionFactory</literal>) using the property <literal>hibernate.session_factory_name</literal>. If this property is omitted, the <literal>SessionFactory</literal> will not be bound to JNDI. (This is especially useful in environments with a read-only JNDI default implementation, e.g. Tomcat.)"msgstr ""#. Tag: para#: configuration.xml:1569#, no-c-formatmsgid "When binding the <literal>SessionFactory</literal> to JNDI, Hibernate will use the values of <literal>hibernate.jndi.url</literal>, <literal>hibernate.jndi.class</literal> to instantiate an initial context. If they are not specified, the default <literal>InitialContext</literal> will be used."msgstr ""#. Tag: para#: configuration.xml:1576#, no-c-formatmsgid "Hibernate will automatically place the <literal>SessionFactory</literal> in JNDI after you call <literal>cfg.buildSessionFactory()</literal>. This means you will at least have this call in some startup code (or utility class) in your application, unless you use JMX deployment with the <literal>HibernateService</literal> (discussed later)."msgstr ""#. Tag: para#: configuration.xml:1583#, no-c-formatmsgid "If you use a JNDI <literal>SessionFactory</literal>, an EJB or any other class may obtain the <literal>SessionFactory</literal> using a JNDI lookup."msgstr ""#. Tag: para#: configuration.xml:1588#, no-c-formatmsgid "We recommend that you bind the <literal>SessionFactory</literal> to JNDI in a managed environment and use a <literal>static</literal> singleton otherwise. To shield your application code from these details, we also recommend to hide the actual lookup code for a <literal>SessionFactory</literal> in a helper class, such as <literal>HibernateUtil.getSessionFactory()</literal>. Note that such a class is also a convenient way to startup Hibernate&mdash;see chapter 1."msgstr ""#. Tag: title#: configuration.xml:1600#, no-c-formatmsgid "Current Session context management with JTA"msgstr ""#. Tag: para#: configuration.xml:1602#, no-c-formatmsgid "The easiest way to handle <literal>Session</literal>s and transactions is Hibernates automatic \"current\" <literal>Session</literal> management. See the discussion of <link linkend=\"architecture-current-session\">current sessions</link>. Using the <literal>\"jta\"</literal> session context, if there is no Hibernate <literal>Session</literal> associated with the current JTA transaction, one will be started and associated with that JTA transaction the first time you call <literal>sessionFactory.getCurrentSession()</literal>. The <literal>Session</literal>s retrieved via <literal>getCurrentSession()</literal> in <literal>\"jta\"</literal> context will be set to automatically flush before the transaction completes, close after the transaction completes, and aggressively release JDBC connections after each statement. This allows the <literal>Session</literal>s to be managed by the life cycle of the JTA transaction to which it is associated, keeping user code clean of such management concerns. Your code can either use JTA programmatically through <literal>UserTransaction</literal>, or (recommended for portable code) use the Hibernate <literal>Transaction</literal> API to set transaction boundaries. If you run in an EJB container, declarative transaction demarcation with CMT is preferred."msgstr ""#. Tag: title#: configuration.xml:1625#, no-c-formatmsgid "JMX deployment"msgstr ""#. Tag: para#: configuration.xml:1627#, no-c-formatmsgid "The line <literal>cfg.buildSessionFactory()</literal> still has to be executed somewhere to get a <literal>SessionFactory</literal> into JNDI. You can do this either in a <literal>static</literal> initializer block (like the one in <literal>HibernateUtil</literal>) or you deploy Hibernate as a <emphasis>managed service</emphasis>."msgstr ""#. Tag: para#: configuration.xml:1635#, no-c-formatmsgid "Hibernate is distributed with <literal>org.hibernate.jmx.HibernateService</literal> for deployment on an application server with JMX capabilities, such as JBoss AS. The actual deployment and configuration is vendor specific. Here is an example <literal>jboss-service.xml</literal> for JBoss 4.0.x:"msgstr ""#. Tag: programlisting#: configuration.xml:1642#, no-c-formatmsgid ""      "<![CDATA[<?xml version=\"1.0\"?>\n"      "<server>\n"      "\n"      "<mbean code=\"org.hibernate.jmx.HibernateService\"\n"      "    name=\"jboss.jca:service=HibernateFactory,name=HibernateFactory\">\n"      "\n"      "    <!-- Required services -->\n"      "    <depends>jboss.jca:service=RARDeployer</depends>\n"      "    <depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends>\n"      "\n"      "    <!-- Bind the Hibernate service to JNDI -->\n"      "    <attribute name=\"JndiName\">java:/hibernate/SessionFactory</attribute>\n"      "\n"      "    <!-- Datasource settings -->\n"      "    <attribute name=\"Datasource\">java:HsqlDS</attribute>\n"      "    <attribute name=\"Dialect\">org.hibernate.dialect.HSQLDialect</attribute>\n"      "\n"      "    <!-- Transaction integration -->\n"      "    <attribute name=\"TransactionStrategy\">\n"      "        org.hibernate.transaction.JTA

⌨️ 快捷键说明

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