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

📄 query_criteria.po

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 PO
📖 第 1 页 / 共 2 页
字号:
"null valued properties are excluded."msgstr """Version properties, identifiers and associations are ignored. By default, ""null valued properties are excluded."#. Tag: para#: query_criteria.xml:150#, no-c-formatmsgid "You can adjust how the <literal>Example</literal> is applied."msgstr "You can adjust how the <literal>Example</literal> is applied."#. Tag: programlisting#: query_criteria.xml:154#, no-c-formatmsgid """<![CDATA[Example example = Example.create(cat)\n""    .excludeZeroes()           //exclude zero valued properties\n""    .excludeProperty(\"color\")  //exclude the property named \"color\"\n""    .ignoreCase()              //perform case insensitive string ""comparisons\n""    .enableLike();             //use like for string comparisons\n""List results = session.createCriteria(Cat.class)\n""    .add(example)\n""    .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:156#, no-c-formatmsgid "You can even use examples to place criteria upon associated objects."msgstr "You can even use examples to place criteria upon associated objects."#. Tag: programlisting#: query_criteria.xml:160#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .add( Example.create(cat) )\n""    .createCriteria(\"mate\")\n""        .add( Example.create( cat.getMate() ) )\n""    .list();]]>"msgstr ""#. Tag: title#: query_criteria.xml:165#, no-c-formatmsgid "Projections, aggregation and grouping"msgstr "Projections, aggregation and grouping"#. Tag: para#: query_criteria.xml:166#, no-c-formatmsgid """The class <literal>org.hibernate.criterion.Projections</literal> is a ""factory for <literal>Projection</literal> instances. We apply a projection ""to a query by calling <literal>setProjection()</literal>."msgstr """The class <literal>org.hibernate.criterion.Projections</literal> is a ""factory for <literal>Projection</literal> instances. We apply a projection ""to a query by calling <literal>setProjection()</literal>."#. Tag: programlisting#: query_criteria.xml:172#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .setProjection( Projections.rowCount() )\n""    .add( Restrictions.eq(\"color\", Color.BLACK) )\n""    .list();]]>"msgstr ""#. Tag: programlisting#: query_criteria.xml:174#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .setProjection( Projections.projectionList()\n""        .add( Projections.rowCount() )\n""        .add( Projections.avg(\"weight\") )\n""        .add( Projections.max(\"weight\") )\n""        .add( Projections.groupProperty(\"color\") )\n""    )\n""    .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:176#, no-c-formatmsgid """There is no explicit \"group by\" necessary in a criteria query. Certain ""projection types are defined to be <emphasis>grouping projections</""emphasis>, which also appear in the SQL <literal>group by</literal> clause."msgstr """There is no explicit \"group by\" necessary in a criteria query. Certain ""projection types are defined to be <emphasis>grouping projections</""emphasis>, which also appear in the SQL <literal>group by</literal> clause."#. Tag: para#: query_criteria.xml:182#, no-c-formatmsgid """An alias may optionally be assigned to a projection, so that the projected ""value may be referred to in restrictions or orderings. Here are two ""different ways to do this:"msgstr """An alias may optionally be assigned to a projection, so that the projected ""value may be referred to in restrictions or orderings. Here are two ""different ways to do this:"#. Tag: programlisting#: query_criteria.xml:188#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .setProjection( Projections.alias( Projections.groupProperty(\"color\"), ""\"colr\" ) )\n""    .addOrder( Order.asc(\"colr\") )\n""    .list();]]>"msgstr ""#. Tag: programlisting#: query_criteria.xml:190#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .setProjection( Projections.groupProperty(\"color\").as(\"colr\") )\n""    .addOrder( Order.asc(\"colr\") )\n""    .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:192#, no-c-formatmsgid """The <literal>alias()</literal> and <literal>as()</literal> methods simply ""wrap a projection instance in another, aliased, instance of ""<literal>Projection</literal>. As a shortcut, you can assign an alias when ""you add the projection to a projection list:"msgstr """The <literal>alias()</literal> and <literal>as()</literal> methods simply ""wrap a projection instance in another, aliased, instance of ""<literal>Projection</literal>. As a shortcut, you can assign an alias when ""you add the projection to a projection list:"#. Tag: programlisting#: query_criteria.xml:199#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .setProjection( Projections.projectionList()\n""        .add( Projections.rowCount(), \"catCountByColor\" )\n""        .add( Projections.avg(\"weight\"), \"avgWeight\" )\n""        .add( Projections.max(\"weight\"), \"maxWeight\" )\n""        .add( Projections.groupProperty(\"color\"), \"color\" )\n""    )\n""    .addOrder( Order.desc(\"catCountByColor\") )\n""    .addOrder( Order.desc(\"avgWeight\") )\n""    .list();]]>"msgstr ""#. Tag: programlisting#: query_criteria.xml:201#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Domestic.class, \"cat\")\n""    .createAlias(\"kittens\", \"kit\")\n""    .setProjection( Projections.projectionList()\n""        .add( Projections.property(\"cat.name\"), \"catName\" )\n""        .add( Projections.property(\"kit.name\"), \"kitName\" )\n""    )\n""    .addOrder( Order.asc(\"catName\") )\n""    .addOrder( Order.asc(\"kitName\") )\n""    .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:203#, no-c-formatmsgid """You can also use <literal>Property.forName()</literal> to express ""projections:"msgstr """You can also use <literal>Property.forName()</literal> to express ""projections:"#. Tag: programlisting#: query_criteria.xml:207#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .setProjection( Property.forName(\"name\") )\n""    .add( Property.forName(\"color\").eq(Color.BLACK) )\n""    .list();]]>"msgstr ""#. Tag: programlisting#: query_criteria.xml:209#, no-c-formatmsgid """<![CDATA[List results = session.createCriteria(Cat.class)\n""    .setProjection( Projections.projectionList()\n""        .add( Projections.rowCount().as(\"catCountByColor\") )\n""        .add( Property.forName(\"weight\").avg().as(\"avgWeight\") )\n""        .add( Property.forName(\"weight\").max().as(\"maxWeight\") )\n""        .add( Property.forName(\"color\").group().as(\"color\" )\n""    )\n""    .addOrder( Order.desc(\"catCountByColor\") )\n""    .addOrder( Order.desc(\"avgWeight\") )\n""    .list();]]>"msgstr ""#. Tag: title#: query_criteria.xml:214#, no-c-formatmsgid "Detached queries and subqueries"msgstr "Detached queries and subqueries"#. Tag: para#: query_criteria.xml:215#, no-c-formatmsgid """The <literal>DetachedCriteria</literal> class lets you create a query ""outside the scope of a session, and then later execute it using some ""arbitrary <literal>Session</literal>."msgstr """The <literal>DetachedCriteria</literal> class lets you create a query ""outside the scope of a session, and then later execute it using some ""arbitrary <literal>Session</literal>."#. Tag: programlisting#: query_criteria.xml:220#, no-c-formatmsgid """<![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)\n""    .add( Property.forName(\"sex\").eq('F') );\n""    \n""Session session = ....;\n""Transaction txn = session.beginTransaction();\n""List results = query.getExecutableCriteria(session).setMaxResults(100).list""();\n""txn.commit();\n""session.close();]]>"msgstr ""#. Tag: para#: query_criteria.xml:222#, no-c-formatmsgid """A <literal>DetachedCriteria</literal> may also be used to express a ""subquery. Criterion instances involving subqueries may be obtained via ""<literal>Subqueries</literal> or <literal>Property</literal>."msgstr """A <literal>DetachedCriteria</literal> may also be used to express a ""subquery. Criterion instances involving subqueries may be obtained via ""<literal>Subqueries</literal> or <literal>Property</literal>."#. Tag: programlisting#: query_criteria.xml:228#, no-c-formatmsgid """<![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)\n""    .setProjection( Property.forName(\"weight\").avg() );\n""session.createCriteria(Cat.class)\n""    .add( Property.forName(\"weight\").gt(avgWeight) )\n""    .list();]]>"msgstr ""#. Tag: programlisting#: query_criteria.xml:230#, no-c-formatmsgid """<![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)\n""    .setProjection( Property.forName(\"weight\") );\n""session.createCriteria(Cat.class)\n""    .add( Subqueries.geAll(\"weight\", weights) )\n""    .list();]]>"msgstr ""#. Tag: para#: query_criteria.xml:232#, no-c-formatmsgid "Even correlated subqueries are possible:"msgstr "Even correlated subqueries are possible:"#. Tag: programlisting#: query_criteria.xml:236#, no-c-formatmsgid """<![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat.""class, \"cat2\")\n""    .setProjection( Property.forName(\"weight\").avg() )\n""    .add( Property.forName(\"cat2.sex\").eqProperty(\"cat.sex\") );\n""session.createCriteria(Cat.class, \"cat\")\n""    .add( Property.forName(\"weight\").gt(avgWeightForSex) )\n""    .list();]]>"msgstr ""#. Tag: title#: query_criteria.xml:245#, no-c-formatmsgid "Queries by natural identifier"msgstr "Queries by natural identifier"#. Tag: para#: query_criteria.xml:247#, no-c-formatmsgid """For most queries, including criteria queries, the query cache is not very ""efficient, because query cache invalidation occurs too frequently. However, ""there is one special kind of query where we can optimize the cache ""invalidation algorithm: lookups by a constant natural key. In some ""applications, this kind of query occurs frequently. The criteria API ""provides special provision for this use case."msgstr """For most queries, including criteria queries, the query cache is not very ""efficient, because query cache invalidation occurs too frequently. However, ""there is one special kind of query where we can optimize the cache ""invalidation algorithm: lookups by a constant natural key. In some ""applications, this kind of query occurs frequently. The criteria API ""provides special provision for this use case."#. Tag: para#: query_criteria.xml:255#, no-c-formatmsgid """First, you should map the natural key of your entity using <literal>&lt;""natural-id&gt;</literal>, and enable use of the second-level cache."msgstr """First, you should map the natural key of your entity using <literal>&lt;""natural-id&gt;</literal>, and enable use of the second-level cache."#. Tag: programlisting#: query_criteria.xml:260#, no-c-formatmsgid """<![CDATA[<class name=\"User\">\n""    <cache usage=\"read-write\"/>\n""    <id name=\"id\">\n""        <generator class=\"increment\"/>\n""    </id>\n""    <natural-id>\n""        <property name=\"name\"/>\n""        <property name=\"org\"/>\n""    </natural-id>\n""    <property name=\"password\"/>\n""</class>]]>"msgstr ""#. Tag: para#: query_criteria.xml:262#, no-c-formatmsgid """Note that this functionality is not intended for use with entities with ""<emphasis>mutable</emphasis> natural keys."msgstr """Note that this functionality is not intended for use with entities with ""<emphasis>mutable</emphasis> natural keys."#. Tag: para#: query_criteria.xml:267#, no-c-formatmsgid "Next, enable the Hibernate query cache."msgstr "Next, enable the Hibernate query cache."#. Tag: para#: query_criteria.xml:271#, no-c-formatmsgid """Now, <literal>Restrictions.naturalId()</literal> allows us to make use of ""the more efficient cache algorithm."msgstr """Now, <literal>Restrictions.naturalId()</literal> allows us to make use of ""the more efficient cache algorithm."#. Tag: programlisting#: query_criteria.xml:276#, no-c-formatmsgid """<![CDATA[session.createCriteria(User.class)\n""    .add( Restrictions.naturalId()\n""        .set(\"name\", \"gavin\")\n""        .set(\"org\", \"hb\") \n""    ).setCacheable(true)\n""    .uniqueResult();]]>"msgstr ""

⌨️ 快捷键说明

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