📄 session_api.po
字号:
"<![CDATA[Cat cat = new DomesticCat();\n""// load pk's state into cat\n""sess.load( cat, new Long(pkId) );\n""Set kittens = cat.getKittens();]]>"msgstr ""#. Tag: para#: session_api.xml:192#, no-c-formatmsgid """Note that <literal>load()</literal> will throw an unrecoverable exception if ""there is no matching database row. If the class is mapped with a proxy, ""<literal>load()</literal> just returns an uninitialized proxy and does not ""actually hit the database until you invoke a method of the proxy. This ""behaviour is very useful if you wish to create an association to an object ""without actually loading it from the database. It also allows multiple ""instances to be loaded as a batch if <literal>batch-size</literal> is ""defined for the class mapping."msgstr """Notez que <literal>load()</literal> lèvera une exception irrécupérable s'il ""n'y a pas de ligne correspondante dans la base de données. Si la classe est ""mappée avec un proxy, <literal>load()</literal> retourne juste un proxy non ""initialisé et n'accède en fait pas à la base de données jusqu'à ce que vous ""invoquiez une méthode du proxy. Ce comportement est très utile si vous ""souhaitez créer une association vers un objet sans réellement le charger à ""partir de la base de données. Cela permet aussi à de multiples instances ""d'être chargées comme un lot si <literal>batch-size</literal> est défini ""pour le mapping de la classe."#. Tag: para#: session_api.xml:203#, no-c-formatmsgid """If you are not certain that a matching row exists, you should use the ""<literal>get()</literal> method, which hits the database immediately and ""returns null if there is no matching row."msgstr """Si vous n'êtes pas certain qu'une ligne correspondante existe, vous devriez ""utiliser la méthode <literal>get()</literal>, laquelle accède à la base de ""données immédiatement et retourne null s'il n'y a pas de ligne ""correspondante."#. Tag: programlisting#: session_api.xml:209#, no-c-formatmsgid """<![CDATA[Cat cat = (Cat) sess.get(Cat.class, id);\n""if (cat==null) {\n"" cat = new Cat();\n"" sess.save(cat, id);\n""}\n""return cat;]]>"msgstr ""#. Tag: para#: session_api.xml:211#, no-c-formatmsgid """You may even load an object using an SQL <literal>SELECT ... FOR UPDATE</""literal>, using a <literal>LockMode</literal>. See the API documentation for ""more information."msgstr """Vous pouvez même charger un objet en employant un <literal>SELECT ... FOR ""UPDATE</literal> SQL, en utilisant un <literal>LockMode</literal>. Voir la ""documentation de l'API pour plus d'informations."#. Tag: programlisting#: session_api.xml:216#, no-c-formatmsgid "<![CDATA[Cat cat = (Cat) sess.get(Cat.class, id, LockMode.UPGRADE);]]>"msgstr ""#. Tag: para#: session_api.xml:218#, no-c-formatmsgid """Note that any associated instances or contained collections are ""<emphasis>not</emphasis> selected <literal>FOR UPDATE</literal>, unless you ""decide to specify <literal>lock</literal> or <literal>all</literal> as a ""cascade style for the association."msgstr """Notez que n'importe quelles instances associées ou collections contenues ""<emphasis>ne sont pas</emphasis> sélectionnées par <literal>FOR UPDATE</""literal>, à moins que vous ne décidiez de spécifier <literal>lock</literal> ""ou <literal>all</literal> en tant que style de cascade pour l'association."#. Tag: para#: session_api.xml:225#, no-c-formatmsgid """It is possible to re-load an object and all its collections at any time, ""using the <literal>refresh()</literal> method. This is useful when database ""triggers are used to initialize some of the properties of the object."msgstr """Il est possible de re-charger un objet et toutes ses collections à n'importe ""quel moment, en utilisant la méthode <literal>refresh()</literal>. C'est ""utile lorsque des \"triggers\" de base de données sont utilisés pour ""initiliser certains propriétés de l'objet."#. Tag: programlisting#: session_api.xml:231#, no-c-formatmsgid """<![CDATA[sess.save(cat);\n""sess.flush(); //force the SQL INSERT\n""sess.refresh(cat); //re-read the state (after the trigger executes)]]>"msgstr ""#. Tag: para#: session_api.xml:233#, no-c-formatmsgid """An important question usually appears at this point: How much does Hibernate ""load from the database and how many SQL <literal>SELECT</literal>s will it ""use? This depends on the <emphasis>fetching strategy</emphasis> and is ""explained in <xref linkend=\"performance-fetching\"/>."msgstr """Une question importante apparaît généralement à ce point : combien (NdT : de ""données) Hibernate charge-t-il de la base de données et combient de ""<literal>SELECT</literal>s utilisera-t-il ? Cela dépent de la ""<emphasis>stratégie de récupération</emphasis> et cela est expliqué dans ""<xref linkend=\"performance-fetching\"/>."#. Tag: title#: session_api.xml:243#, no-c-formatmsgid "Querying"msgstr "Requêtage"#. Tag: para#: session_api.xml:245#, no-c-formatmsgid """If you don't know the identifiers of the objects you are looking for, you ""need a query. Hibernate supports an easy-to-use but powerful object oriented ""query language (HQL). For programmatic query creation, Hibernate supports a ""sophisticated Criteria and Example query feature (QBC and QBE). You may also ""express your query in the native SQL of your database, with optional support ""from Hibernate for result set conversion into objects."msgstr """Si vous ne connaissez par les identifiants des objets que vous recherchez, ""vous avez besoin d'une requête. Hibernate supporte un langage de requêtes ""orientées objet facile à utiliser mais puissant. Pour la création de ""requêtes par programmation, Hibernate supporte une fonction de requêtage ""sophistiqué Criteria et Example (QBC et QBE). Vous pouvez aussi exprimez ""votre requête dans le SQL natif de votre base de données, avec un support ""optionnel d'Hibernate pour la conversion des ensembles de résultats en ""objets."#. Tag: title#: session_api.xml:255#, no-c-formatmsgid "Executing queries"msgstr "Exécution de requêtes"#. Tag: para#: session_api.xml:257#, no-c-formatmsgid """HQL and native SQL queries are represented with an instance of <literal>org.""hibernate.Query</literal>. This interface offers methods for parameter ""binding, result set handling, and for the execution of the actual query. You ""always obtain a <literal>Query</literal> using the current <literal>Session</""literal>:"msgstr """Les requêtes HQL et SQL natives sont représentées avec une instance de ""<literal>org.hibernate.Query</literal>. L'interface offre des méthodes pour ""la liaison des paramètres, la gestion des ensembles de resultats, et pour ""l'exécution de la requête réelle. Vous obtenez toujours une <literal>Query</""literal> en utilisant la <literal>Session</literal> courante :"#. Tag: programlisting#: session_api.xml:264#, no-c-formatmsgid """<![CDATA[List cats = session.createQuery(\n"" \"from Cat as cat where cat.birthdate < ?\")\n"" .setDate(0, date)\n"" .list();\n""\n""List mothers = session.createQuery(\n"" \"select mother from Cat as cat join cat.mother as mother where cat.name ""= ?\")\n"" .setString(0, name)\n"" .list();\n""\n""List kittens = session.createQuery(\n"" \"from Cat as cat where cat.mother = ?\")\n"" .setEntity(0, pk)\n"" .list();\n""\n""Cat mother = (Cat) session.createQuery(\n"" \"select cat.mother from Cat as cat where cat = ?\")\n"" .setEntity(0, izi)\n"" .uniqueResult();]]\n""\n""Query mothersWithKittens = (Cat) session.createQuery(\n"" \"select mother from Cat as mother left join fetch mother.kittens\");\n""Set uniqueMothers = new HashSet(mothersWithKittens.list());]]>"msgstr ""#. Tag: para#: session_api.xml:266#, no-c-formatmsgid """A query is usually executed by invoking <literal>list()</literal>, the ""result of the query will be loaded completely into a collection in memory. ""Entity instances retrieved by a query are in persistent state. The ""<literal>uniqueResult()</literal> method offers a shortcut if you know your ""query will only return a single object. Note that queries that make use of ""eager fetching of collections usually return duplicates of the root objects ""(but with their collections initialized). You can filter these duplicates ""simply through a <literal>Set</literal>."msgstr """Une requête est généralement exécutée en invoquant <literal>list()</""literal>, le résultat de la requête sera chargée complètement dans une ""collection en mémoire. Les intances d'entités recupérées par une requête ""sont dans un état persistant. La méthode <literal>uniqueResult()</literal> ""offre un raccourci si vous savez que votre requête retournera seulement un ""seul objet."#. Tag: title#: session_api.xml:278#, no-c-formatmsgid "Iterating results"msgstr "Itération de résultats"#. Tag: para#: session_api.xml:280#, no-c-formatmsgid """Occasionally, you might be able to achieve better performance by executing ""the query using the <literal>iterate()</literal> method. This will only ""usually be the case if you expect that the actual entity instances returned ""by the query will already be in the session or second-level cache. If they ""are not already cached, <literal>iterate()</literal> will be slower than ""<literal>list()</literal> and might require many database hits for a simple ""query, usually <emphasis>1</emphasis> for the initial select which only ""returns identifiers, and <emphasis>n</emphasis> additional selects to ""initialize the actual instances."msgstr """Occasionnellement, vous pourriez être capable d'obtenir de meilleures ""performances en exécutant la requête avec la méthode <literal>iterate()</""literal>. Ce sera généralement seulement le cas si vous espérez que les ""intances réelles d'entité retournées par la requête soient déjà chargées ""dans la session ou le cache de second niveau. Si elles ne sont pas cachées, ""<literal>iterate()</literal> sera plus lent que <literal>list()</literal> et ""pourrait nécessiter plusieurs accès à la base de données pour une simple ""requête, généralement <emphasis>1</emphasis> pour le select initial qui ""retourne seulement les identifiants, et <emphasis>n</emphasis> selects ""supplémentaires pour initialiser les instances réelles."#. Tag: programlisting#: session_api.xml:292#, no-c-formatmsgid """<![CDATA[// fetch ids\n""Iterator iter = sess.createQuery(\"from eg.Qux q order by q.likeliness\").""iterate();\n""while ( iter.hasNext() ) {\n"" Qux qux = (Qux) iter.next(); // fetch the object\n"" // something we couldnt express in the query\n"" if ( qux.calculateComplicatedAlgorithm() ) {\n"" // delete the current instance\n"" iter.remove();\n"" // dont need to process the rest\n"" break;\n"" }\n""}]]>"msgstr ""#. Tag: title#: session_api.xml:296#, no-c-formatmsgid "Queries that return tuples"msgstr "Requêtes qui retournent des tuples"#. Tag: para#: session_api.xml:298#, no-c-formatmsgid """Hibernate queries sometimes return tuples of objects, in which case each ""tuple is returned as an array:"msgstr """Les requêtes d'Hibernate retournent parfois des tuples d'objets, auquel cas ""chaque tuple est retourné comme un tableau :"#. Tag: programlisting#: session_api.xml:303#, no-c-formatmsgid """<![CDATA[Iterator kittensAndMothers = sess.createQuery(\n"" \"select kitten, mother from Cat kitten join kitten.mother mother""\")\n"" .list()\n"" .iterator();\n""\n""while ( kittensAndMothers.hasNext() ) {\n"" Object[] tuple = (Object[]) kittensAndMothers.next();\n"" Cat kitten = (Cat) tuple[0];\n"" Cat mother = (Cat) tuple[1];\n"" ....\n""}]]>"msgstr ""#. Tag: title#: session_api.xml:308#, no-c-formatmsgid "Scalar results"msgstr "Résultats scalaires"#. Tag: para#: session_api.xml:310#, no-c-formatmsgid """Queries may specify a property of a class in the <literal>select</literal> ""clause. They may even call SQL aggregate functions. Properties or aggregates ""are considered \"scalar\" results (and not entities in persistent state)."msgstr """Des requêtes peuvent spécifier une propriété d'une classe dans la clause ""<literal>select</literal>. Elles peuvent même appeler des fonctions ""d'aggrégat SQL. Les propriétés ou les aggrégats sont considérés comme des ""résultats \"scalaires\" (et pas des entités dans un état persistant)."#. Tag: programlisting#: session_api.xml:316#, no-c-formatmsgid """<![CDATA[Iterator results = sess.createQuery(\n"" \"select cat.color, min(cat.birthdate), count(cat) from Cat cat \" ""+\n"" \"group by cat.color\")\n"" .list()\n"" .iterator();\n""\n""while ( results.hasNext() ) {\n"" Object[] row = (Object[]) results.next();\n"" Color type = (Color) row[0];\n"" Date oldest = (Date) row[1];\n"" Integer count = (Integer) row[2];\n"" .....\n""}]]>"msgstr ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -