📄 session_api.po
字号:
#: index.docbook:409msgid """A collection <emphasis>filter</emphasis> is a special type of query that may ""be applied to a persistent collection or array. The query string may refer ""to <literal>this</literal>, meaning the current collection element."msgstr """Un <emphasis>filtro</emphasis> de colección es un tipo especial de ""consulta que puede ser aplicado a una colección persistente o array. ""La cadena de consulta puede referirse a <literal>this</literal>, ""significando el elemento de colección actual."#: index.docbook:415msgid """<![CDATA[Collection blackKittens = session.createFilter(\n"" pk.getKittens(), \n"" \"where this.color = ?\")\n"" .setParameter( Color.BLACK, Hibernate.custom(ColorUserType.class) )\n"" .list()\n"");]]>"msgstr """<![CDATA[Collection blackKittens = session.createFilter(\n"" pk.getKittens(), \n"" \"where this.color = ?\")\n"" .setParameter( Color.BLACK, Hibernate.custom(ColorUserType.class) )\n"" .list()\n"");]]>"#: index.docbook:417msgid """The returned collection is considered a bag, and it's a copy of the given ""collection. The original collection is not modified (this is contrary to the ""implication of the name \"filter\", but consistent with expected behavior)."msgstr """La colección devuelta es considerada un bag, y es una copia de la ""colección dada. La colección original no es modificada (esto ""es contrario a la implicación del nombre \"filtro\", pero consistente ""con el comportamiento esperado)."#: index.docbook:423msgid """Observe that filters do not require a <literal>from</literal> clause (though ""they may have one if required). Filters are not limited to returning the ""collection elements themselves."msgstr """Observa que los filtros no requieren una cláusula <literal>from</""literal> (aunque pueden tener uno si se requiere). Los filtros no está""n limitados a devolver los elementos de colección por sí ""mismos."#: index.docbook:428msgid """<![CDATA[Collection blackKittenMates = session.createFilter(\n"" pk.getKittens(), \n"" \"select this.mate where this.color = eg.Color.BLACK.intValue\")\n"" .list();]]>"msgstr """<![CDATA[Collection blackKittenMates = session.createFilter(\n"" pk.getKittens(), \n"" \"select this.mate where this.color = eg.Color.BLACK.intValue\")\n"" .list();]]>"#: index.docbook:430msgid """Even an empty filter query is useful, e.g. to load a subset of elements in a ""huge collection:"msgstr """Incluso una consulta de filtro vacío es útil, por ejemplo, ""para cargar un subconjunto de elementos en una colección enorme:"#: index.docbook:435msgid """<![CDATA[Collection tenKittens = session.createFilter(\n"" mother.getKittens(), \"\")\n"" .setFirstResult(0).setMaxResults(10)\n"" .list();]]>"msgstr """<![CDATA[Collection tenKittens = session.createFilter(\n"" mother.getKittens(), \"\")\n"" .setFirstResult(0).setMaxResults(10)\n"" .list();]]>"#: index.docbook:440msgid "Criteria queries"msgstr "Consultas de criterios"#: index.docbook:442msgid """HQL is extremely powerful but some developers prefer to build queries ""dynamically, using an object-oriented API, rather than building query ""strings. Hibernate provides an intuitive <literal>Criteria</literal> query ""API for these cases:"msgstr """HQL es extremadamente potente pero algunos desarrolladores prefieren ""construir consultas dinámicamente usando una API orientada a objetos, ""en vez construir cadenas de consulta. Hibernate provee una API intuitiva de ""consulta <literal>Criteria</literal> para estos casos:"#: index.docbook:448msgid """<![CDATA[Criteria crit = session.createCriteria(Cat.class);\n""crit.add( Restrictions.eq( \"color\", eg.Color.BLACK ) );\n""crit.setMaxResults(10);\n""List cats = crit.list();]]>"msgstr """<![CDATA[Criteria crit = session.createCriteria(Cat.class);\n""crit.add( Restrictions.eq( \"color\", eg.Color.BLACK ) );\n""crit.setMaxResults(10);\n""List cats = crit.list();]]>"#: index.docbook:450msgid """The <literal>Criteria</literal> and the associated <literal>Example</""literal> API are discussed in more detail in <xref linkend=\"querycriteria\"/"">."msgstr """Las APIs de <literal>Criteria</literal> y la asociada <literal>Example</""literal> son discutidas en más detalle en <xref linkend=""\"querycriteria\"/>."#: index.docbook:458msgid "Queries in native SQL"msgstr "Consultas en SQL nativo"#: index.docbook:460msgid """You may express a query in SQL, using <literal>createSQLQuery()</literal> ""and let Hibernate take care of the mapping from result sets to objects. Note ""that you may at any time call <literal>session.connection()</literal> and ""use the JDBC <literal>Connection</literal> directly. If you chose to use the ""Hibernate API, you must enclose SQL aliases in braces:"msgstr """Puedes expresar una consulta en SQL, usando <literal>createSQLQuery()</""literal> y dejando que Hibernate cuide del mapeo de los conjuntos resultado ""a objetos. Nota que puedes llamar en cualquier momento a <literal>session.""connection()</literal> y usar la <literal>Connection</literal> JDBC ""directamente. Si eliges usar la API de Hibernate, debes encerrar los alias ""de SQL entre llaves:"#: index.docbook:468msgid """<![CDATA[List cats = session.createSQLQuery(\"SELECT {cat.*} FROM CAT {cat} ""WHERE ROWNUM<10\")\n"" .addEntity(\"cat\", Cat.class)\n"".list();]]>"msgstr """<![CDATA[List cats = session.createSQLQuery(\"SELECT {cat.*} FROM CAT {cat} ""WHERE ROWNUM<10\")\n"" .addEntity(\"cat\", Cat.class)\n"".list();]]>"#: index.docbook:470msgid """<![CDATA[List cats = session.createSQLQuery(\n"" \"SELECT {cat}.ID AS {cat.id}, {cat}.SEX AS {cat.sex}, \" +\n"" \"{cat}.MATE AS {cat.mate}, {cat}.SUBCLASS AS {cat.class}, ... \" ""+\n"" \"FROM CAT {cat} WHERE ROWNUM<10\")\n"" .addEntity(\"cat\", Cat.class)\n"".list()]]>"msgstr """<![CDATA[List cats = session.createSQLQuery(\n"" \"SELECT {cat}.ID AS {cat.id}, {cat}.SEX AS {cat.sex}, \" +\n"" \"{cat}.MATE AS {cat.mate}, {cat}.SUBCLASS AS {cat.class}, ... \" ""+\n"" \"FROM CAT {cat} WHERE ROWNUM<10\")\n"" .addEntity(\"cat\", Cat.class)\n"".list()]]>"#: index.docbook:472msgid """SQL queries may contain named and positional parameters, just like Hibernate ""queries. More information about native SQL queries in Hibernate can be found ""in <xref linkend=\"querysql\"/>."msgstr """Las consultas SQL pueden contener parámetros con nombre y ""posicionales, al igual que las consultas de Hibernate. Puede encontrarse ""más información sobre consultas en SQL nativo en <xref linkend=""\"querysql\"/>."#: index.docbook:483msgid "Modifying persistent objects"msgstr "Modificando objetos persistentes"#: index.docbook:485msgid """<emphasis>Transactional persistent instances</emphasis> (ie. objects loaded, ""saved, created or queried by the <literal>Session</literal>) may be ""manipulated by the application and any changes to persistent state will be ""persisted when the <literal>Session</literal> is <emphasis>flushed</""emphasis> (discussed later in this chapter). There is no need to call a ""particular method (like <literal>update()</literal>, which has a different ""purpose) to make your modifications persistent. So the most straightforward ""way to update the state of an object is to <literal>load()</literal> it, and ""then manipulate it directly, while the <literal>Session</literal> is open:"msgstr """Las <emphasis>instancias persistentes transaccionales</emphasis> (es decir, ""objetos cargados, creados o consultados por la <literal>Session</literal>) ""pueden ser manipulados por la aplicación y cualquier cambio al estado ""persistente será persistido cuando la <literal>Session</literal> sea ""<emphasis>limpiada (flushed)</emphasis> (discutido más adelante en ""este capítulo). No hay necesidad de llamar un método en ""particular (como <literal>update()</literal>, que tiene un propósito ""diferente) para hacer persistentes tus modificaciones. De modo que la forma ""más directa de actualizar el estado de un objeto es cargarlo con ""<literal>load()</literal>, y entonces manipularlo directamente, mientras la ""<literal>Session</literal> está abierta:"#: index.docbook:496msgid """<![CDATA[DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long""(69) );\n""cat.setName(\"PK\");\n""sess.flush(); // changes to cat are automatically detected and persisted]]>"msgstr """<![CDATA[DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long""(69) );\n""cat.setName(\"PK\");\n""sess.flush(); // changes to cat are automatically detected and persisted]]>"#: index.docbook:498msgid """Sometimes this programming model is inefficient since it would require both ""an SQL <literal>SELECT</literal> (to load an object) and an SQL ""<literal>UPDATE</literal> (to persist its updated state) in the same ""session. Therefore Hibernate offers an alternate approach, using detached ""instances."msgstr """A veces este modelo de programación es ineficiente pues podría ""requerir una <literal>SELECT</literal> de SQL (para cargar un objeto) y un ""<literal>UPDATE</literal> de SQL (para hacer persistentes sus datos ""actualizados) en la misma sesión. Por lo tanto, Hibernate ofrece un ""enfoque alternativo, usando instancias separadas (detached)."#: index.docbook:506msgid """Note that Hibernate does not offer its own API for direct execution of ""<literal>UPDATE</literal> or <literal>DELETE</literal> statements. Hibernate ""is a <emphasis>state management</emphasis> service, you don't have to think ""in <emphasis>statements</emphasis> to use it. JDBC is a perfect API for ""executing SQL statements, you can get a JDBC <literal>Connection</literal> ""at any time by calling <literal>session.connection()</literal>. Furthermore, ""the notion of mass operations conflicts with object/relational mapping for ""online transaction processing-oriented applications. Future versions of ""Hibernate may however provide special mass operation functions. See <xref ""linkend=\"batch\"/> for some possible batch operation tricks."msgstr """Nota que Hibernate no ofreve su propia API para ejecución directa de ""sentencias <literal>UPDATE</literal> o <literal>DELETE</literal>. Hibernate ""es un servicio de <emphasis>gestión de estado</emphasis>, no tienes ""que pensar en <literal>sentencias</literal> para usarlo. JDBC es una API ""perfecta para ejecutar sentencias SQL; puedes obtener una ""<literal>Connection</literal> JDBC en cualquier momento llamando a ""<literal>session.connection()</literal>. Además, la noción de ""operaciones masivas entra en conflicto con el mapeo objeto/relacional en ""aplicaciones en línea orientadas al procesamiento de transacciones. ""Versiones futuras de Hibernate pueden, sin embargo, proveer funciones de ""operación masiva especiales. Ver <xref linkend=\"batch\"/> por ""algunos trucos de operación en lote (batch) posibles."#: index.docbook:521msgid "Modifying detached objects"msgstr "Modificando objetos separados"#: index.docbook:523msgid """Many applications need to retrieve an object in one transaction, send it to ""the UI layer for manipulation, then save the changes in a new transaction. ""Applications that use this kind of approach in a high-concurrency ""environment usually use versioned data to ensure isolation for the \"long\" ""unit of work."msgstr """Muchas aplicaciones necesitan recuperar un objeto en una transacción, ""enviarla a la capa de UI para su manipulación, y entonces salvar los ""cambios en una nueva transacción. Las aplicaciones que usan este tipo ""de enfoque en un entorno de alta concurrencia usualmente usan datos ""versionados para asegurar el aislamiento de la unidad de trabajo \"larga\"."#: index.docbook:530msgid """Hibernate supports this model by providing for reattachment of detached ""instances using the <literal>Session.update()</literal> or <literal>Session.""merge()</literal> methods:"msgstr """Hibernate soporta este modelo al proveer re-unión de instancias ""separadas usando los métodos <literal>Session.update()</literal> o ""<literal>Session.merge()</literal>:"#: index.docbook:536msgid """<![CDATA[// in the first session\n""Cat cat = (Cat) firstSession.load(Cat.class, catId);\n""Cat potentialMate = new Cat();\n""firstSession.save(potentialMate);\n""\n""// in a higher layer of the application\n""cat.setMate(potentialMate);\n""\n""// later, in a new session\n""secondSession.update(cat); // update cat\n""secondSession.update(mate); // update mate]]>"msgstr """<![CDATA[// in the first session\n""Cat cat = (Cat) firstSession.load(Cat.class, catId);\n""Cat potentialMate = new Cat();\n""firstSession.save(potentialMate);\n""\n""// in a higher layer of the application\n""cat.setMate(potentialMate);\n""\n""// later, in a new session\n""secondSession.update(cat); // update cat\n""secondSession.update(mate); // update mate]]>"#: index.docbook:538
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -