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

📄 query_sql.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 4 页
字号:
"Until now the result set column names are assumed to be the same as the ""column names specified in the mapping document. This can be problematic for ""SQL queries which join multiple tables, since the same column names may ""appear in more than one table."msgstr """到目前为止,结果集字段名被假定为和映射文件中指定的的字段名是一致的。假若SQL查""询连接了多个表,同一个字段名可能在多个表中出现多次,这就会造成问题。"#. Tag: para#: query_sql.xml:153#, no-c-formatmsgid """Column alias injection is needed in the following query (which most likely ""will fail):"msgstr "下面的查询中需要使用字段别名注射(这个例子本身会失败):"#. Tag: programlisting#: query_sql.xml:156#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT c.*, m.*  FROM CATS c, CATS m WHERE c.""MOTHER_ID = c.ID\")\n"" .addEntity(\"cat\", Cat.class)\n"" .addEntity(\"mother\", Cat.class)\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:158#, no-c-formatmsgid """The intention for this query is to return two Cat instances per row, a cat ""and its mother. This will fail since there is a conflict of names since they ""are mapped to the same column names and on some databases the returned ""column aliases will most likely be on the form \"c.ID\", \"c.NAME\", etc. ""which are not equal to the columns specificed in the mappings (\"ID\" and ""\"NAME\")."msgstr """这个查询的本意是希望每行返回两个Cat实例,一个是cat,另一个是它的妈妈。但是因为""它们的字段名被映射为相同的,而且在某些数据库中,返回的字段别名是“c.ID”,\"c.""NAME\"这样的形式,而它们和在映射文件中的名字(\"ID\"和\"NAME\")不匹配,这就""会造成失败。"#. Tag: para#: query_sql.xml:165#, no-c-formatmsgid "The following form is not vulnerable to column name duplication:"msgstr "下面的形式可以解决字段名重复:"#. Tag: programlisting#: query_sql.xml:168#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT {cat.*}, {mother.*}  FROM CATS c, CATS ""m WHERE c.MOTHER_ID = c.ID\")\n"" .addEntity(\"cat\", Cat.class)\n"" .addEntity(\"mother\", Cat.class)\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:174#, no-c-formatmsgid """the SQL query string, with placeholders for Hibernate to inject column ""aliases"msgstr "SQL查询语句,其中包含占位附来让Hibernate注射字段别名"#. Tag: para#: query_sql.xml:179#, no-c-formatmsgid "the entities returned by the query"msgstr "查询返回的实体"#. Tag: para#: query_sql.xml:183#, no-c-formatmsgid """The {cat.*} and {mother.*} notation used above is a shorthand for \"all ""properties\". Alternatively, you may list the columns explicity, but even in ""this case we let Hibernate inject the SQL column aliases for each property. ""The placeholder for a column alias is just the property name qualified by ""the table alias. In the following example, we retrieve Cats and their ""mothers from a different table (cat_log) to the one declared in the mapping ""metadata. Notice that we may even use the property aliases in the where ""clause if we like."msgstr """上面使用的{cat.*}和{mother.*}标记是作为“所有属性”的简写形式出现的。当然你也可""以明确地罗列出字段名,但在这个例子里面我们让Hibernate来为每个属性注射SQL字段""别名。字段别名的占位符是属性名加上表别名的前缀。在下面的例子中,我们从另外一""个表(cat_log)中通过映射元数据中的指定获取Cat和它的妈妈。注意,要是我们愿""意,我们甚至可以在where子句中使用属性别名。"#. Tag: programlisting#: query_sql.xml:192#, no-c-formatmsgid """<![CDATA[String sql = \"SELECT ID as {c.id}, NAME as {c.name}, \" + \n""         \"BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} ""\" +\n""         \"FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID\";\n""\n""List loggedCats = sess.createSQLQuery(sql)\n""        .addEntity(\"cat\", Cat.class)\n""        .addEntity(\"mother\", Cat.class).list()\n""]]>"msgstr ""#. Tag: title#: query_sql.xml:195#, no-c-formatmsgid "Alias and property references"msgstr "别名和属性引用(Alias and property references)"#. Tag: para#: query_sql.xml:197#, no-c-formatmsgid """For most cases the above alias injection is needed, but for queries relating ""to more complex mappings like composite properties, inheritance ""discriminators, collections etc. there are some specific aliases to use to ""allow Hibernate to inject the proper aliases."msgstr """大多数情况下,都需要上面的属性注射,但在使用更加复杂的映射,比如复合属性、通""过标识符构造继承树,以及集合类等等情况下,也有一些特别的别名,来允许Hibernate""注射合适的别名。"#. Tag: para#: query_sql.xml:202#, no-c-formatmsgid """The following table shows the different possibilities of using the alias ""injection. Note: the alias names in the result are examples, each alias will ""have a unique and probably different name when used."msgstr """下表列出了使用别名注射参数的不同可能性。注意:下面结果中的别名只是示例,实用""时每个别名需要唯一并且不同的名字。"#. Tag: title#: query_sql.xml:208#, no-c-formatmsgid "Alias injection names"msgstr "别名注射(alias injection names)"#. Tag: entry#: query_sql.xml:219#, no-c-formatmsgid "Description"msgstr "描述"#. Tag: entry#: query_sql.xml:221#, no-c-formatmsgid "Syntax"msgstr "语法"#. Tag: entry#: query_sql.xml:223#, no-c-formatmsgid "Example"msgstr "示例"#. Tag: entry#: query_sql.xml:229#, no-c-formatmsgid "A simple property"msgstr "简单属性"#. Tag: literal#: query_sql.xml:231#, no-c-formatmsgid "{[aliasname].[propertyname]"msgstr "{[aliasname].[propertyname]"#. Tag: literal#: query_sql.xml:233#, no-c-formatmsgid "A_NAME as {item.name}"msgstr "A_NAME as {item.name}"#. Tag: entry#: query_sql.xml:237#, no-c-formatmsgid "A composite property"msgstr "复合属性"#. Tag: literal#: query_sql.xml:239#, no-c-formatmsgid "{[aliasname].[componentname].[propertyname]}"msgstr "{[aliasname].[componentname].[propertyname]}"#. Tag: literal#: query_sql.xml:241#, no-c-formatmsgid "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}"msgstr "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}"#. Tag: entry#: query_sql.xml:246#, no-c-formatmsgid "Discriminator of an entity"msgstr "实体辨别器(Discriminator of an entity)"#. Tag: literal#: query_sql.xml:248#, no-c-formatmsgid "{[aliasname].class}"msgstr "{[aliasname].class}"#. Tag: literal#: query_sql.xml:250#, no-c-formatmsgid "DISC as {item.class}"msgstr "DISC as {item.class}"#. Tag: entry#: query_sql.xml:254#, no-c-formatmsgid "All properties of an entity"msgstr "实体的所有属性"#. Tag: literal#: query_sql.xml:256 query_sql.xml:304#, no-c-formatmsgid "{[aliasname].*}"msgstr "{[aliasname].*}"#. Tag: literal#: query_sql.xml:258#, no-c-formatmsgid "{item.*}"msgstr "{item.*}"#. Tag: entry#: query_sql.xml:262#, no-c-formatmsgid "A collection key"msgstr "集合键(collection key)"#. Tag: literal#: query_sql.xml:264#, no-c-formatmsgid "{[aliasname].key}"msgstr "{[aliasname].key}"#. Tag: literal#: query_sql.xml:266#, no-c-formatmsgid "ORGID as {coll.key}"msgstr "ORGID as {coll.key}"#. Tag: entry#: query_sql.xml:270#, no-c-formatmsgid "The id of an collection"msgstr "集合id"#. Tag: literal#: query_sql.xml:272#, no-c-formatmsgid "{[aliasname].id}"msgstr "{[aliasname].id}"#. Tag: literal#: query_sql.xml:274#, no-c-formatmsgid "EMPID as {coll.id}"msgstr "EMPID as {coll.id}"#. Tag: entry#: query_sql.xml:278#, no-c-formatmsgid "The element of an collection"msgstr "集合元素"#. Tag: literal#: query_sql.xml:280#, no-c-formatmsgid "{[aliasname].element}"msgstr "{[aliasname].element}"#. Tag: literal#: query_sql.xml:282#, no-c-formatmsgid "XID as {coll.element}"msgstr "XID as {coll.element}"#. Tag: entry#: query_sql.xml:286#, no-c-formatmsgid "roperty of the element in the collection"msgstr "集合元素的属性"#. Tag: literal#: query_sql.xml:288#, no-c-formatmsgid "{[aliasname].element.[propertyname]}"msgstr "{[aliasname].element.[propertyname]}"#. Tag: literal#: query_sql.xml:290#, no-c-formatmsgid "NAME as {coll.element.name}"msgstr "NAME as {coll.element.name}"#. Tag: entry#: query_sql.xml:294#, no-c-formatmsgid "All properties of the element in the collection"msgstr "集合元素的所有属性"#. Tag: literal#: query_sql.xml:296#, no-c-formatmsgid "{[aliasname].element.*}"msgstr "{[aliasname].element.*}"#. Tag: literal#: query_sql.xml:298#, no-c-formatmsgid "{coll.element.*}"msgstr "{coll.element.*}"#. Tag: entry#: query_sql.xml:302#, no-c-formatmsgid "All properties of the the collection"msgstr "集合的所有属性"#. Tag: literal#: query_sql.xml:306#, no-c-formatmsgid "{coll.*}"msgstr "{coll.*}"#. Tag: title#: query_sql.xml:315#, no-c-formatmsgid "Returning non-managed entities"msgstr "返回非受管实体(Returning non-managed entities)"#. Tag: para#: query_sql.xml:317#, no-c-formatmsgid """It is possible to apply a ResultTransformer to native sql queries. Allowing ""it to e.g. return non-managed entities."msgstr """可以对原生sql 查询使用ResultTransformer。这会返回不受Hibernate管理的实体。"#. Tag: programlisting#: query_sql.xml:319#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT NAME, BIRTHDATE FROM CATS\")\n""        .setResultTransformer(Transformers.aliasToBean(CatDTO.class))]]>"

⌨️ 快捷键说明

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