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

📄 session_api.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 5 页
字号:
#, no-c-formatmsgid "they are self-documenting"msgstr "它们本身是自我说明的"#. Tag: programlisting#: session_api.xml:350#, no-c-formatmsgid """<![CDATA[//named parameter (preferred)\n""Query q = sess.createQuery(\"from DomesticCat cat where cat.name = :name""\");\n""q.setString(\"name\", \"Fritz\");\n""Iterator cats = q.iterate();]]>"msgstr ""#. Tag: programlisting#: session_api.xml:352#, no-c-formatmsgid """<![CDATA[//positional parameter\n""Query q = sess.createQuery(\"from DomesticCat cat where cat.name = ?\");\n""q.setString(0, \"Izi\");\n""Iterator cats = q.iterate();]]>"msgstr ""#. Tag: programlisting#: session_api.xml:354#, no-c-formatmsgid """<![CDATA[//named parameter list\n""List names = new ArrayList();\n""names.add(\"Izi\");\n""names.add(\"Fritz\");\n""Query q = sess.createQuery(\"from DomesticCat cat where cat.name in (:""namesList)\");\n""q.setParameterList(\"namesList\", names);\n""List cats = q.list();]]>"msgstr ""#. Tag: title#: session_api.xml:359#, no-c-formatmsgid "Pagination"msgstr "分页"#. Tag: para#: session_api.xml:361#, no-c-formatmsgid """If you need to specify bounds upon your result set (the maximum number of ""rows you want to retrieve and / or the first row you want to retrieve) you ""should use methods of the <literal>Query</literal> interface:"msgstr """如果你需要指定结果集的范围(希望返回的最大行数/或开始的行数),应该使用""<literal>Query</literal>接口提供的方法:"#. Tag: programlisting#: session_api.xml:367#, no-c-formatmsgid """<![CDATA[Query q = sess.createQuery(\"from DomesticCat cat\");\n""q.setFirstResult(20);\n""q.setMaxResults(10);\n""List cats = q.list();]]>"msgstr ""#. Tag: para#: session_api.xml:369#, no-c-formatmsgid """Hibernate knows how to translate this limit query into the native SQL of ""your DBMS."msgstr """Hibernate 知道如何将这个有限定条件的查询转换成你的数据库的原生SQL(native ""SQL)。"#. Tag: title#: session_api.xml:377#, no-c-formatmsgid "Scrollable iteration"msgstr "可滚动遍历(Scrollable iteration)"#. Tag: para#: session_api.xml:379#, no-c-formatmsgid """If your JDBC driver supports scrollable <literal>ResultSet</literal>s, the ""<literal>Query</literal> interface may be used to obtain a ""<literal>ScrollableResults</literal> object, which allows flexible ""navigation of the query results."msgstr """如果你的JDBC驱动支持可滚动的<literal>ResuleSet</literal>,<literal>Query</""literal>接口可以使用<literal>ScrollableResults</literal>,允许你在查询结果中""灵活游走。"#. Tag: programlisting#: session_api.xml:386#, no-c-formatmsgid """<![CDATA[Query q = sess.createQuery(\"select cat.name, cat from DomesticCat ""cat \" +\n""                            \"order by cat.name\");\n""ScrollableResults cats = q.scroll();\n""if ( cats.first() ) {\n""\n""    // find the first name on each page of an alphabetical list of cats by ""name\n""    firstNamesOfPages = new ArrayList();\n""    do {\n""        String name = cats.getString(0);\n""        firstNamesOfPages.add(name);\n""    }\n""    while ( cats.scroll(PAGE_SIZE) );\n""\n""    // Now get the first page of cats\n""    pageOfCats = new ArrayList();\n""    cats.beforeFirst();\n""    int i=0;\n""    while( ( PAGE_SIZE > i++ ) && cats.next() ) pageOfCats.add( cats.get""(1) );\n""\n""}\n""cats.close()]]>"msgstr ""#. Tag: para#: session_api.xml:388#, no-c-formatmsgid """Note that an open database connection (and cursor) is required for this ""functionality, use <literal>setMaxResult()</literal>/<literal>setFirstResult""()</literal> if you need offline pagination functionality."msgstr """请注意,使用此功能需要保持数据库连接(以及游标(cursor))处于一直打开状态。 如""果你需要断开连接使用分页功能,请使用<literal>setMaxResult()</literal>/""<literal>setFirstResult()</literal>"#. Tag: title#: session_api.xml:397#, no-c-formatmsgid "Externalizing named queries"msgstr "外置命名查询(Externalizing named queries)"#. Tag: para#: session_api.xml:399#, no-c-formatmsgid """You may also define named queries in the mapping document. (Remember to use ""a <literal>CDATA</literal> section if your query contains characters that ""could be interpreted as markup.)"msgstr """你可以在映射文件中定义命名查询(named queries)。 (如果你的查询串中包含可能被""解释为XML标记(markup)的字符,别忘了用<literal>CDATA</literal>包裹起来。)"#. Tag: programlisting#: session_api.xml:405#, no-c-formatmsgid """<![CDATA[<query name=\"ByNameAndMaximumWeight\"><![CDATA[\n""    from eg.DomesticCat as cat\n""        where cat.name = ?\n""        and cat.weight > ?\n""] ]></query>]]>"msgstr ""#. Tag: para#: session_api.xml:407#, no-c-formatmsgid "Parameter binding and executing is done programatically:"msgstr "参数绑定及执行以编程方式(programatically)完成:"#. Tag: programlisting#: session_api.xml:411#, no-c-formatmsgid """<![CDATA[Query q = sess.getNamedQuery(\"ByNameAndMaximumWeight\");\n""q.setString(0, name);\n""q.setInt(1, minWeight);\n""List cats = q.list();]]>"msgstr ""#. Tag: para#: session_api.xml:413#, no-c-formatmsgid """Note that the actual program code is independent of the query language that ""is used, you may also define native SQL queries in metadata, or migrate ""existing queries to Hibernate by placing them in mapping files."msgstr """请注意实际的程序代码与所用的查询语言无关,你也可在元数据中定义原生SQL(native ""SQL)查询, 或将原有的其他的查询语句放在配置文件中,这样就可以让Hibernate统一""管理,达到迁移的目的。"#. Tag: para#: session_api.xml:419#, no-c-formatmsgid """Also note that a query declaration inside a <literal>&lt;hibernate-""mapping&gt;</literal> element requires a global unique name for the query, ""while a query declaration inside a <literal>&lt;class&gt;</literal> element ""is made unique automatically by prepending the fully qualified name of the ""class, for example <literal>eg.Cat.ByNameAndMaximumWeight</literal>."msgstr """也请注意在<literal>&lt;hibernate-mapping&gt;</literal>元素中声明的查询必须有""一个全局唯一的名字,而在<literal>&lt;class&gt;</literal>元素中声明的查询自动具""有全局名,是通过类的全名加以限定的。比如<literal>eg.Cat.""ByNameAndMaximumWeight</literal>。"#. Tag: title#: session_api.xml:432#, no-c-formatmsgid "Filtering collections"msgstr "过滤集合"#. Tag: para#: session_api.xml:433#, no-c-formatmsgid """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 """集合<emphasis>过滤器(filter)</emphasis>是一种用于一个持久化集合或者数组的特殊""的查询。查询字符串中可以使用<literal>\"this\"</literal>来引用集合中的当前元""素。"#. Tag: programlisting#: session_api.xml:439#, no-c-formatmsgid """<![CDATA[Collection blackKittens = session.createFilter(\n""    pk.getKittens(), \n""    \"where this.color = ?\")\n""    .setParameter( Color.BLACK, Hibernate.custom(ColorUserType.class) )\n""    .list()\n"");]]>"msgstr ""#. Tag: para#: session_api.xml:441#, no-c-formatmsgid """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 """返回的集合可以被认为是一个包(bag, 无顺序可重复的集合(collection)),它是所给集""合的副本。 原来的集合不会被改动(这与“过滤器(filter)”的隐含的含义不符,不过与""我们期待的行为一致)。"#. Tag: para#: session_api.xml:447#, no-c-formatmsgid """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 """请注意过滤器(filter)并不需要<literal>from</literal>子句(当然需要的话它们也可""以加上)。过滤器(filter)不限定于只能返回集合元素本身。"#. Tag: programlisting#: session_api.xml:452#, no-c-formatmsgid """<![CDATA[Collection blackKittenMates = session.createFilter(\n""    pk.getKittens(), \n""    \"select this.mate where this.color = eg.Color.BLACK.intValue\")\n""    .list();]]>"msgstr ""#. Tag: para#: session_api.xml:454#, no-c-formatmsgid """Even an empty filter query is useful, e.g. to load a subset of elements in a ""huge collection:"msgstr """即使无条件的过滤器(filter)也是有意义的。例如,用于加载一个大集合的子集:"#. Tag: programlisting#: session_api.xml:459#, no-c-formatmsgid """<![CDATA[Collection tenKittens = session.createFilter(\n""    mother.getKittens(), \"\")\n""    .setFirstResult(0).setMaxResults(10)\n""    .list();]]>"msgstr ""#. Tag: title#: session_api.xml:464#, no-c-formatmsgid "Criteria queries"msgstr "条件查询(Criteria queries)"#. Tag: para#: session_api.xml:466#, no-c-formatmsgid """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极为强大,但是有些人希望能够动态的使用一种面向对象API创建查询,而非在他们""的Java代码中嵌入字符串。对于那部分人来说,Hibernate提供了直观的""<literal>Criteria</literal>查询API。"#. Tag: programlisting#: session_api.xml:472#, no-c-formatmsgid """<![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 ""#. Tag: para#: session_api.xml:474#, no-c-formatmsgid """The <literal>Criteria</literal> and the associated <literal>Example</""literal> API are discussed in more detail in <xref linkend=\"querycriteria\"/"">."msgstr """<literal>Criteria</literal>以及相关的<literal>样例(Example)</literal>API将会""再<xref linkend=\"querycriteria\"/>中详细讨论。"#. Tag: title#: session_api.xml:482#, no-c-formatmsgid "Queries in native SQL"msgstr "使用原生SQL的查询"#. Tag: para#: session_api.xml:484#, no-c-formatmsgid """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 "

⌨️ 快捷键说明

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