📄 query_criteria.po
字号:
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""Report-Msgid-Bugs-To: http://bugs.kde.org\n""POT-Creation-Date: 2007-10-25 01:01+0000\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <LL@li.org>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#. Tag: title#: query_criteria.xml:5#, no-c-formatmsgid "Criteria Queries"msgstr "条件查询(Criteria Queries)"#. Tag: para#: query_criteria.xml:7#, no-c-formatmsgid "Hibernate features an intuitive, extensible criteria query API."msgstr "具有一个直观的、可扩展的条件查询API是Hibernate的特色。"#. Tag: title#: query_criteria.xml:12#, no-c-formatmsgid "Creating a <literal>Criteria</literal> instance"msgstr "创建一个<literal>Criteria</literal> 实例"#. Tag: para#: query_criteria.xml:14#, no-c-formatmsgid """The interface <literal>org.hibernate.Criteria</literal> represents a query ""against a particular persistent class. The <literal>Session</literal> is a ""factory for <literal>Criteria</literal> instances."msgstr """<literal>org.hibernate.Criteria</literal>接口表示特定持久类的一个查询。""<literal>Session</literal>是 <literal>Criteria</literal>实例的工厂。"#. Tag: programlisting#: query_criteria.xml:20#, no-c-formatmsgid """<![CDATA[Criteria crit = sess.createCriteria(Cat.class);\n""crit.setMaxResults(50);\n""List cats = crit.list();]]>"msgstr ""#. Tag: title#: query_criteria.xml:25#, no-c-formatmsgid "Narrowing the result set"msgstr "限制结果集内容"#. Tag: para#: query_criteria.xml:27#, no-c-formatmsgid """An individual query criterion is an instance of the interface <literal>org.""hibernate.criterion.Criterion</literal>. The class <literal>org.hibernate.""criterion.Restrictions</literal> defines factory methods for obtaining ""certain built-in <literal>Criterion</literal> types."msgstr """一个单独的查询条件是<literal>org.hibernate.criterion.Criterion</literal> 接口""的一个实例。<literal>org.hibernate.criterion.Restrictions</literal>类 定义了""获得某些内置<literal>Criterion</literal>类型的工厂方法。"#. Tag: programlisting#: query_criteria.xml:35#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"" .add( Restrictions.between(\"weight\", minWeight, maxWeight) )\n"" .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:37#, no-c-formatmsgid "Restrictions may be grouped logically."msgstr "约束可以按逻辑分组。"#. Tag: programlisting#: query_criteria.xml:41#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"" .add( Restrictions.or(\n"" Restrictions.eq( \"age\", new Integer(0) ),\n"" Restrictions.isNull(\"age\")\n"" ) )\n"" .list();]]>"msgstr ""#. Tag: programlisting#: query_criteria.xml:43#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.in( \"name\", new String[] { \"Fritz\", \"Izi\", \"Pk""\" } ) )\n"" .add( Restrictions.disjunction()\n"" .add( Restrictions.isNull(\"age\") )\n"" .add( Restrictions.eq(\"age\", new Integer(0) ) )\n"" .add( Restrictions.eq(\"age\", new Integer(1) ) )\n"" .add( Restrictions.eq(\"age\", new Integer(2) ) )\n"" ) )\n"" .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:45#, no-c-formatmsgid """There are quite a range of built-in criterion types (<literal>Restrictions</""literal> subclasses), but one that is especially useful lets you specify SQL ""directly."msgstr """Hibernate提供了相当多的内置criterion类型(<literal>Restrictions</literal> 子""类), 但是尤其有用的是可以允许你直接使用SQL。"#. Tag: programlisting#: query_criteria.xml:50#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.sqlRestriction(\"lower({alias}.name) like lower(?)\", ""\"Fritz%\", Hibernate.STRING) )\n"" .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:52#, no-c-formatmsgid """The <literal>{alias}</literal> placeholder with be replaced by the row alias ""of the queried entity."msgstr "<literal>{alias}</literal>占位符应当被替换为被查询实体的列别名。"#. Tag: para#: query_criteria.xml:57#, no-c-formatmsgid """An alternative approach to obtaining a criterion is to get it from a ""<literal>Property</literal> instance. You can create a <literal>Property</""literal> by calling <literal>Property.forName()</literal>."msgstr """<literal>Property</literal>实例是获得一个条件的另外一种途径。你可以通过调用""<literal>Property.forName()</literal> 创建一个<literal>Property</literal>。"#. Tag: programlisting#: query_criteria.xml:63#, no-c-formatmsgid """<![CDATA[\n""Property age = Property.forName(\"age\");\n""List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.disjunction()\n"" .add( age.isNull() )\n"" .add( age.eq( new Integer(0) ) )\n"" .add( age.eq( new Integer(1) ) )\n"" .add( age.eq( new Integer(2) ) )\n"" ) )\n"" .add( Property.forName(\"name\").in( new String[] { \"Fritz\", \"Izi\", ""\"Pk\" } ) )\n"" .list();]]>"msgstr ""#. Tag: title#: query_criteria.xml:68#, no-c-formatmsgid "Ordering the results"msgstr "结果集排序"#. Tag: para#: query_criteria.xml:70#, no-c-formatmsgid """You may order the results using <literal>org.hibernate.criterion.Order</""literal>."msgstr """你可以使用<literal>org.hibernate.criterion.Order</literal>来为查询结果排序。"#. Tag: programlisting#: query_criteria.xml:74#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.like(\"name\", \"F%\")\n"" .addOrder( Order.asc(\"name\") )\n"" .addOrder( Order.desc(\"age\") )\n"" .setMaxResults(50)\n"" .list();]]>"msgstr ""#. Tag: programlisting#: query_criteria.xml:76#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Property.forName(\"name\").like(\"F%\") )\n"" .addOrder( Property.forName(\"name\").asc() )\n"" .addOrder( Property.forName(\"age\").desc() )\n"" .setMaxResults(50)\n"" .list();]]>"msgstr ""#. Tag: title#: query_criteria.xml:81#, no-c-formatmsgid "Associations"msgstr "关联"#. Tag: para#: query_criteria.xml:83#, no-c-formatmsgid """You may easily specify constraints upon related entities by navigating ""associations using <literal>createCriteria()</literal>."msgstr """你可以使用<literal>createCriteria()</literal>非常容易的在互相关联的实体间建""立 约束。"#. Tag: programlisting#: query_criteria.xml:88#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.like(\"name\", \"F%\") )\n"" .createCriteria(\"kittens\")\n"" .add( Restrictions.like(\"name\", \"F%\") )\n"" .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:90#, no-c-formatmsgid """note that the second <literal>createCriteria()</literal> returns a new ""instance of <literal>Criteria</literal>, which refers to the elements of the ""<literal>kittens</literal> collection."msgstr """注意第二个 <literal>createCriteria()</literal>返回一个新的 ""<literal>Criteria</literal>实例,该实例引用<literal>kittens</literal> 集合中""的元素。"#. Tag: para#: query_criteria.xml:96#, no-c-formatmsgid "The following, alternate form is useful in certain circumstances."msgstr "接下来,替换形态在某些情况下也是很有用的。"#. Tag: programlisting#: query_criteria.xml:100#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .createAlias(\"kittens\", \"kt\")\n"" .createAlias(\"mate\", \"mt\")\n"" .add( Restrictions.eqProperty(\"kt.name\", \"mt.name\") )\n"" .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:102#, no-c-formatmsgid """(<literal>createAlias()</literal> does not create a new instance of ""<literal>Criteria</literal>.)"msgstr """(<literal>createAlias()</literal>并不创建一个新的 <literal>Criteria</literal>""实例。)"#. Tag: para#: query_criteria.xml:107#, no-c-formatmsgid """Note that the kittens collections held by the <literal>Cat</literal> ""instances returned by the previous two queries are <emphasis>not</emphasis> ""pre-filtered by the criteria! If you wish to retrieve just the kittens that ""match the criteria, you must use a <literal>ResultTransformer</literal>."msgstr """<literal>Cat</literal>实例所保存的之前两次查询所返回的kittens集合是 ""<emphasis>没有</emphasis>被条件预过滤的。如果你希望只获得符合条件的kittens, ""你必须使用<literal>ResultTransformer</literal>。"#. Tag: programlisting#: query_criteria.xml:114#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .createCriteria(\"kittens\", \"kt\")\n"" .add( Restrictions.eq(\"name\", \"F%\") )\n"" .setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)\n"" .list();\n""Iterator iter = cats.iterator();\n""while ( iter.hasNext() ) {\n"" Map map = (Map) iter.next();\n"" Cat cat = (Cat) map.get(Criteria.ROOT_ALIAS);\n"" Cat kitten = (Cat) map.get(\"kt\");\n""}]]>"msgstr ""#. Tag: title#: query_criteria.xml:119#, no-c-formatmsgid "Dynamic association fetching"msgstr "动态关联抓取"#. Tag: para#: query_criteria.xml:121#, no-c-formatmsgid """You may specify association fetching semantics at runtime using ""<literal>setFetchMode()</literal>."msgstr """你可以使用<literal>setFetchMode()</literal>在运行时定义动态关联抓取的语义。"#. Tag: programlisting#: query_criteria.xml:126#, no-c-formatmsgid """<![CDATA[List cats = sess.createCriteria(Cat.class)\n"" .add( Restrictions.like(\"name\", \"Fritz%\") )\n"" .setFetchMode(\"mate\", FetchMode.EAGER)\n"" .setFetchMode(\"kittens\", FetchMode.EAGER)\n"" .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:128#, no-c-formatmsgid """This query will fetch both <literal>mate</literal> and <literal>kittens</""literal> by outer join. See <xref linkend=\"performance-fetching\"/> for ""more information."msgstr """这个查询可以通过外连接抓取<literal>mate</literal>和<literal>kittens</""literal>。 查看<xref linkend=\"performance-fetching\"/>可以获得更多信息。"#. Tag: title#: query_criteria.xml:136#, no-c-formatmsgid "Example queries"msgstr "查询示例"#. Tag: para#: query_criteria.xml:138#, no-c-formatmsgid """The class <literal>org.hibernate.criterion.Example</literal> allows you to ""construct a query criterion from a given instance."msgstr """<literal>org.hibernate.criterion.Example</literal>类允许你通过一个给定实例 构""建一个条件查询。"#. Tag: programlisting#: query_criteria.xml:143#, no-c-formatmsgid """<![CDATA[Cat cat = new Cat();\n""cat.setSex('F');\n""cat.setColor(Color.BLACK);\n""List results = session.createCriteria(Cat.class)\n"" .add( Example.create(cat) )\n"" .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:145#, no-c-formatmsgid ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -