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

📄 tutorial.po

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 PO
📖 第 1 页 / 共 5 页
字号:
msgstr """Cette classe ne produit pas seulement la <literal>SessionFactory</literal> ""globale dans un initialiseur statique (appelé une seule fois par la JVM ""lorsque la classe est chargée), elle masque le fait qu'elle exploite un ""singleton. Elle pourrait aussi obtenir la <literal>SessionFactory</literal> ""depuis JNDI dans un serveur d'applications."#. Tag: para#: tutorial.xml:361#, no-c-formatmsgid """If you give the <literal>SessionFactory</literal> a name in your ""configuration file, Hibernate will in fact try to bind it to JNDI after it ""has been built. To avoid this code completely you could also use JMX ""deployment and let the JMX-capable container instantiate and bind a ""<literal>HibernateService</literal> to JNDI. These advanced options are ""discussed in the Hibernate reference documentation."msgstr """Si vous nommez la <literal>SessionFactory</literal> dans votre fichier de ""configuration, Hibernate tentera la récupération depuis JNDI. Pour éviter ce ""code, vous pouvez aussi utiliser un déploiement JMX et laisser le conteneur ""(compatible JMX) instancier et lier un <literal>HibernateService</literal> à ""JNDI. Ces options avancées sont détaillées dans la documentation de ""référence Hibernate."#. Tag: para#: tutorial.xml:370#, no-c-formatmsgid """Place <literal>HibernateUtil.java</literal> in the development source ""directory, in a package next to <literal>events</literal>:"msgstr """Placez <literal>HibernateUtil.java</literal> dans le répertoire source de ""développement, et ensuite <literal>Event.java</literal> :"#. Tag: programlisting#: tutorial.xml:375#, no-c-formatmsgid """<![CDATA[.\n""+lib\n""  <Hibernate and third-party libraries>\n""+src\n""  +events\n""    Event.java\n""    Event.hbm.xml\n""  +util\n""    HibernateUtil.java\n""  hibernate.cfg.xml\n""+data\n""build.xml]]>"msgstr ""#. Tag: para#: tutorial.xml:377#, no-c-formatmsgid """This should again compile without problems. We finally need to configure a ""logging system - Hibernate uses commons logging and leaves you the choice ""between Log4j and JDK 1.4 logging. Most developers prefer Log4j: copy ""<literal>log4j.properties</literal> from the Hibernate distribution (it's in ""the <literal>etc/</literal> directory) to your <literal>src</literal> ""directory, next to <literal>hibernate.cfg.xml</literal>. Have a look at the ""example configuration and change the settings if you like to have more ""verbose output. By default, only Hibernate startup message are shown on ""stdout."msgstr """Cela devrait encore compiler sans problème. Nous avons finalement besoin de ""configurer le système de \"logs\" - Hibernate utilise commons-logging et ""vous laisse le choix entre log4j et le système de logs du JDK 1.4. La ""plupart des développeurs préfèrent log4j : copiez <literal>log4j.properties</""literal> de la distribution d'Hibernate (il est dans le répertoire ""<literal>etc/</literal>) dans votre répertoire <literal>src</literal>, puis ""faites de même avec <literal>hibernate.cfg.xml</literal>. Regardez la ""configuration d'exemple et changez les paramètres si vous voulez une sortie ""plus verbeuse. Par défaut, seul le message de démarrage d'Hibernate est ""affiché sur la sortie standard."#. Tag: para#: tutorial.xml:387#, no-c-formatmsgid """The tutorial infrastructure is complete - and we are ready to do some real ""work with Hibernate."msgstr """L'infrastructure de ce didacticiel est complète - et nous sommes prêts à ""effectuer un travail réel avec Hibernate."#. Tag: title#: tutorial.xml:395#, no-c-formatmsgid "Loading and storing objects"msgstr "Charger et stocker des objets"#. Tag: para#: tutorial.xml:397#, no-c-formatmsgid """Finally, we can use Hibernate to load and store objects. We write an ""<literal>EventManager</literal> class with a <literal>main()</literal> ""method:"msgstr """Finalement nous pouvons utiliser Hibernate pour charger et stocker des ""objets. Nous écrivons une classe <literal>EventManager</literal> avec une ""méthode <literal>main()</literal> :"#. Tag: programlisting#: tutorial.xml:402#, no-c-formatmsgid """<![CDATA[package events;\n""import org.hibernate.Session;\n""\n""import java.util.Date;\n""\n""import util.HibernateUtil;\n""\n""public class EventManager {\n""\n""    public static void main(String[] args) {\n""        EventManager mgr = new EventManager();\n""\n""        if (args[0].equals(\"store\")) {\n""            mgr.createAndStoreEvent(\"My Event\", new Date());\n""        }\n""\n""        HibernateUtil.getSessionFactory().close();\n""    }\n""\n""    private void createAndStoreEvent(String title, Date theDate) {\n""\n""        Session session = HibernateUtil.getSessionFactory().getCurrentSession""();\n""\n""        session.beginTransaction();\n""\n""        Event theEvent = new Event();\n""        theEvent.setTitle(title);\n""        theEvent.setDate(theDate);\n""\n""        session.save(theEvent);\n""\n""        session.getTransaction().commit();\n""    }\n""\n""}]]>"msgstr ""#. Tag: para#: tutorial.xml:404#, no-c-formatmsgid """We create a new <literal>Event</literal> object, and hand it over to ""Hibernate. Hibernate now takes care of the SQL and executes <literal>INSERT</""literal>s on the database. Let's have a look at the <literal>Session</""literal> and <literal>Transaction</literal>-handling code before we run this."msgstr """Nous créons un nouvel objet <literal>Event</literal>, et le remettons à ""Hibernate. Hibernate s'occupe maintenant du SQL et exécute les ""<literal>INSERT</literal>s dans la base de données. Regardons le code de ""gestion de la <literal>Session</literal> et de la <literal>Transaction</""literal> avant de lancer ça."#. Tag: para#: tutorial.xml:411#, no-c-formatmsgid """A <literal>Session</literal> is a single unit of work. For now we'll keep ""things simple and assume a one-to-one granularity between a Hibernate ""<literal>Session</literal> and a database transaction. To shield our code ""from the actual underlying transaction system (in this case plain JDBC, but ""it could also run with JTA) we use the <literal>Transaction</literal> API ""that is available on the Hibernate <literal>Session</literal>."msgstr """Une <literal>Session</literal> est une unité de travail. Pour le moment, ""nous allons faire les choses simplement et assumer une granularité un-un ""entre une <literal>Session</literal> hibernate et une transaction à la base ""de données. Pour isoler notre code du système de transaction sous-jacent ""(dans notre cas, du pure JDBC, mais cela pourrait être JTA), nous utilisons ""l'API <literal>Transaction</literal> qui est disponible depuis la ""<literal>Session</literal> Hibernate."#. Tag: para#: tutorial.xml:419#, no-c-formatmsgid """What does <literal>sessionFactory.getCurrentSession()</literal> do? First, ""you can call it as many times and anywhere you like, once you get hold of ""your <literal>SessionFactory</literal> (easy thanks to ""<literal>HibernateUtil</literal>). The <literal>getCurrentSession()</""literal> method always returns the \"current\" unit of work. Remember that ""we switched the configuration option for this mechanism to \"thread\" in ""<literal>hibernate.cfg.xml</literal>? Hence, the current unit of work is ""bound to the current Java thread that executes our application. However, ""this is not the full picture, you also have to consider scope, when a unit ""of work begins and when it ends."msgstr """Que fait <literal>sessionFactory.getCurrentSession()</literal> ? ""Premièrement, vous pouvez l'invoquer autant de fois que vous le voulez et ""n'importe où du moment que vous avez votre <literal>SessionFactory</literal> ""(facile grâce à <literal>HibernateUtil</literal>). La méthode ""<literal>getCurrentSession()</literal> renvoie toujours l'unité de travail ""courante. Souvenez vous que nous avons basculé notre option de configuration ""au mécanisme basé sur le \"thread\" dans <literal>hibernate.cfg.xml</""literal>. Par conséquent, le scope de l'unité de travail courante est le ""thread java courant d'exécution. Ceci n'est pas totalement vrai."#. Tag: para#: tutorial.xml:430#, no-c-formatmsgid """A <literal>Session</literal> begins when it is first needed, when the first ""call to <literal>getCurrentSession()</literal> is made. It is then bound by ""Hibernate to the current thread. When the transaction ends, either through ""commit or rollback, Hibernate automatically unbinds the <literal>Session</""literal> from the thread and closes it for you. If you call ""<literal>getCurrentSession()</literal> again, you get a new ""<literal>Session</literal> and can start a new unit of work. This ""<emphasis>thread-bound</emphasis> programming model is the most popular way ""of using Hibernate, as it allows flexible layering of your code (transaction ""demarcation code can be separated from data access code, we'll do this later ""in this tutorial)."msgstr """Une <literal>Session</literal> commence lorsqu'elle est vraiment utilisée la ""première fois, Lorsque nous appelons pour la première fois ""<literal>getCurrentSession()</literal>. Ensuite, elle est liée, par ""Hibernate, au thread courant. Lorsque la transaction s'achève (commit ou ""rollback), Hibernate délie la <literal>Session</literal> du thread et la ""ferme pour vous. Si vous invoquez <literal>getCurrentSession()</literal> une ""autre fois, vous obtenez une nouvelle <literal>Session</literal> et pouvez ""entamer une nouvelle unité de travail. Ce modèle de programmation ""\"<emphasis>thread-bound</emphasis>\" est le moyen le plus populaire ""d'utiliser Hibernate."#. Tag: para#: tutorial.xml:441#, no-c-formatmsgid """Related to the unit of work scope, should the Hibernate <literal>Session</""literal> be used to execute one or several database operations? The above ""example uses one <literal>Session</literal> for one operation. This is pure ""coincidence, the example is just not complex enough to show any other ""approach. The scope of a Hibernate <literal>Session</literal> is flexible ""but you should never design your application to use a new Hibernate ""<literal>Session</literal> for <emphasis>every</emphasis> database ""operation. So even if you see it a few more times in the following (very ""trivial) examples, consider <emphasis>session-per-operation</emphasis> an ""anti-pattern. A real (web) application is shown later in this tutorial."msgstr """UNTRANSLATED ! Related to the unit of work scope, should the Hibernate ""<literal>Session</literal> be used to execute one or several database ""operations? The above example uses one <literal>Session</literal> for one ""operation. This is pure coincidence, the example is just not complex enough ""to show any other approach. The scope of a Hibernate <literal>Session</""literal> is flexible but you should never design your application to use a ""new Hibernate <literal>Session</literal> for <emphasis>every</emphasis> ""database operation. So even if you see it a few more times in the following ""(very trivial) examples, consider <emphasis>session-per-operation</emphasis> ""an anti-pattern. A real (web) application is shown later in this tutorial."#. Tag: para#: tutorial.xml:452#, no-c-formatmsgid """Have a look at <xref linkend=\"transactions\"/> for more information about ""transaction handling and demarcation. We also skipped any error handling and ""rollback in the previous example."msgstr """Lisez <xref linkend=\"transactions\"/> pour plus d'informations sur la ""gestion des transactions et leur démarcations. Nous n'avons pas géré les ""erreurs et rollback sur l'exemple précédent."#. Tag: para#: tutorial.xml:458#, no-c-formatmsgid """To run this first routine we have to add a callable target to the Ant build ""file:"msgstr """Pour lancer cette première routine, nous devons ajouter une cible appelable ""dans le fichier de construction de Ant :"#. Tag: programlisting#: tutorial.xml:462#, no-c-formatmsgid """<![CDATA[<target name=\"run\" depends=\"compile\">\n""    <java fork=\"true\" classname=\"events.EventManager\" classpathref=""\"libraries\">\n""        <classpath path=\"${targetdir}\"/>\n""        <arg value=\"${action}\"/>\n""    </java>\n""</target>]]>"msgstr ""#. Tag: para#: tutorial.xml:464#, no-c-formatmsgid """The value of the <literal>action</literal> argument is set on the command ""line when calling the target:"msgstr """La valeur de l'argument <literal>action</literal> correspond à la ligne de ""commande qui appelle la cible :"#. Tag: programlisting#: tutorial.xml:469#, no-c-formatmsgid "<![CDATA[C:\\hibernateTutorial\\>ant run -Daction=store]]>"msgstr ""#. Tag: para#: tutorial.xml:471#, no-c-formatmsgid """You should see, after compilation, Hibernate starting up and, depending on ""your configuration, lots of log output. At the end you will find the ""following line:"msgstr """Vous devriez voir, après la compilation, Hibernate démarrer et, en fonction ""de votre configuration, beaucoup de traces sur la sortie. À la fin vous ""trouverez la ligne suivante :"#. Tag: programlisting#: tutorial.xml:476#, no-c-formatmsgid """<![CDATA[[java] Hibernate: insert into EVENTS (EVENT_DATE, title, EVENT_ID) ""values (?, ?, ?)]]>"msgstr ""

⌨️ 快捷键说明

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