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

📄 query_sql.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 4 页
字号:
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_sql.xml:5#, no-c-formatmsgid "Native SQL"msgstr "Native SQL查询"#. Tag: para#: query_sql.xml:7#, no-c-formatmsgid """You may also express queries in the native SQL dialect of your database. ""This is useful if you want to utilize database specific features such as ""query hints or the <literal>CONNECT</literal> keyword in Oracle. It also ""provides a clean migration path from a direct SQL/JDBC based application to ""Hibernate."msgstr """你也可以使用你的数据库的Native SQL语言来查询数据。这对你在要使用数据库的某些""特性的时候(比如说在查询提示或者Oracle中的 <literal>CONNECT</literal>关键字),""这是非常有用的。这就能够扫清你把原来直接使用SQL/JDBC 的程序迁移到基于 ""Hibernate应用的道路上的障碍。"#. Tag: para#: query_sql.xml:13#, no-c-formatmsgid """Hibernate3 allows you to specify handwritten SQL (including stored ""procedures) for all create, update, delete, and load operations."msgstr """Hibernate3允许你使用手写的sql来完成所有的create,update,delete,和load操作(包""括存储过程)"#. Tag: title#: query_sql.xml:17#, no-c-formatmsgid "Using a <literal>SQLQuery</literal>"msgstr "使用<literal>SQLQuery</literal>"#. Tag: para#: query_sql.xml:19#, no-c-formatmsgid """Execution of native SQL queries is controlled via the <literal>SQLQuery</""literal> interface, which is obtained by calling <literal>Session.""createSQLQuery()</literal>. The following describes how to use this API for ""querying."msgstr """对原生SQL查询执行的控制是通过<literal>SQLQuery</literal>接口进行的,通过执行""<literal>Session.createSQLQuery()</literal>获取这个接口。下面来描述如何使用这""个API进行查询。"#. Tag: title#: query_sql.xml:25#, no-c-formatmsgid "Scalar queries"msgstr "标量查询(Scalar queries)"#. Tag: para#: query_sql.xml:27#, no-c-formatmsgid "The most basic SQL query is to get a list of scalars (values)."msgstr "最基本的SQL查询就是获得一个标量(数值)的列表。"#. Tag: programlisting#: query_sql.xml:30#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\").list();\n""sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE FROM CATS\").list();\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:32#, no-c-formatmsgid """These will both return a List of Object arrays (Object[]) with scalar values ""for each column in the CATS table. Hibernate will use ResultSetMetadata to ""deduce the actual order and types of the returned scalar values."msgstr """它们都将返回一个Object数组(Object[])组成的List,数组每个元素都是CATS表的一个""字段值。Hibernate会使用ResultSetMetadata来判定返回的标量值的实际顺序和类型。"#. Tag: para#: query_sql.xml:37#, no-c-formatmsgid """To avoid the overhead of using <literal>ResultSetMetadata</literal> or ""simply to be more explicit in what is returned one can use <literal>addScalar""()</literal>."msgstr """如果要避免过多的使用<literal>ResultSetMetadata</literal>,或者只是为了更加明确""的指名返回值,可以使用<literal>addScalar()</literal>。"#. Tag: programlisting#: query_sql.xml:41#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\")\n"" .addScalar(\"ID\", Hibernate.LONG)\n"" .addScalar(\"NAME\", Hibernate.STRING)\n"" .addScalar(\"BIRTHDATE\", Hibernate.DATE)\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:43 query_sql.xml:89 query_sql.xml:170 query_sql.xml:321#, fuzzy, no-c-formatmsgid "This query specified:"msgstr """#-#-#-#-#  - (PACKAGE VERSION)  #-#-#-#-#\n""这个查询指定了:\n""#-#-#-#-#  - (PACKAGE VERSION)  #-#-#-#-#\n""这个查询指定:\n""#-#-#-#-#  - (PACKAGE VERSION)  #-#-#-#-#\n""这个查询指明:\n""#-#-#-#-#  - (PACKAGE VERSION)  #-#-#-#-#\n""这个查询指定:"#. Tag: para#: query_sql.xml:47 query_sql.xml:93 query_sql.xml:325#, no-c-formatmsgid "the SQL query string"msgstr "SQL查询字符串"#. Tag: para#: query_sql.xml:51#, no-c-formatmsgid "the columns and types to return"msgstr "要返回的字段和类型"#. Tag: para#: query_sql.xml:55#, no-c-formatmsgid """This will still return Object arrays, but now it will not use ""<literal>ResultSetMetdata</literal> but will instead explicitly get the ID, ""NAME and BIRTHDATE column as respectively a Long, String and a Short from ""the underlying resultset. This also means that only these three columns will ""be returned, even though the query is using <literal>*</literal> and could ""return more than the three listed columns."msgstr """它仍然会返回Object数组,但是此时不再使用<literal>ResultSetMetdata</literal>,而""是明确的将ID,NAME和BIRTHDATE按照Long,String和Short类型从resultset中取出。同""时,也指明了就算query是使用<literal>*</literal>来查询的,可能获得超过列出的这""三个字段,也仅仅会返回这三个字段。"#. Tag: para#: query_sql.xml:63#, no-c-formatmsgid """It is possible to leave out the type information for all or some of the ""scalars."msgstr "对全部或者部分的标量值不设置类型信息也是可以的。"#. Tag: programlisting#: query_sql.xml:66#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\")\n"" .addScalar(\"ID\", Hibernate.LONG)\n"" .addScalar(\"NAME\")\n"" .addScalar(\"BIRTHDATE\")\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:68#, no-c-formatmsgid """This is essentially the same query as before, but now ""<literal>ResultSetMetaData</literal> is used to decide the type of NAME and ""BIRTHDATE where as the type of ID is explicitly specified."msgstr """基本上这和前面一个查询相同,只是此时使用<literal>ResultSetMetaData</literal>来""决定NAME和BIRTHDATE的类型,而ID的类型是明确指出的。"#. Tag: para#: query_sql.xml:72#, no-c-formatmsgid """How the java.sql.Types returned from ResultSetMetaData is mapped to ""Hibernate types is controlled by the Dialect. If a specific type is not ""mapped or does not result in the expected type it is possible to customize ""it via calls to <literal>registerHibernateType</literal> in the Dialect."msgstr """关于从ResultSetMetaData返回的java.sql.Types是如何映射到Hibernate类型,是由方""言(Dialect)控制的。假若某个指定的类型没有被映射,或者不是你所预期的类型,你可""以通过Dialet的<literal>registerHibernateType</literal>调用自行定义。"#. Tag: title#: query_sql.xml:80#, no-c-formatmsgid "Entity queries"msgstr "实体查询(Entity queries)"#. Tag: para#: query_sql.xml:82#, no-c-formatmsgid """The above queries were all about returning scalar values, basically ""returning the \"raw\" values from the resultset. The following shows how to ""get entity objects from a native sql query via <literal>addEntity()</""literal>."msgstr """上面的查询都是返回标量值的,也就是从resultset中返回的“裸”数据。下面展示如何通""过<literal>addEntity()</literal>让原生查询返回实体对象。"#. Tag: programlisting#: query_sql.xml:87#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT * FROM CATS\").addEntity(Cat.class);\n""sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE FROM CATS\").addEntity(Cat.""class);\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:97#, no-c-formatmsgid "the entity returned by the query"msgstr "要返回的实体"#. Tag: para#: query_sql.xml:101#, no-c-formatmsgid """Assuming that Cat is mapped as a class with the columns ID, NAME and ""BIRTHDATE the above queries will both return a List where each element is a ""Cat entity."msgstr """假设Cat被映射为拥有ID,NAME和BIRTHDATE三个字段的类,以上的两个查询都返回一个""List,每个元素都是一个Cat实体。"#. Tag: para#: query_sql.xml:105#, no-c-formatmsgid """If the entity is mapped with a <literal>many-to-one</literal> to another ""entity it is required to also return this when performing the native query, ""otherwise a database specific \"column not found\" error will occur. The ""additional columns will automatically be returned when using the * notation, ""but we prefer to be explicit as in the following example for a <literal>many-""to-one</literal> to a <literal>Dog</literal>:"msgstr """假若实体在映射时有一个<literal>many-to-one</literal>的关联指向另外一个实体,""在查询时必须也返回那个实体,否则会导致发生一个\"column not found\"的数据库错""误。这些附加的字段可以使用*标注来自动返回,但我们希望还是明确指明,看下面这个""具有指向<literal>Dog</literal>的<literal>many-to-one</literal>的例子:"#. Tag: programlisting#: query_sql.xml:113#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS""\").addEntity(Cat.class);\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:115#, no-c-formatmsgid "This will allow cat.getDog() to function properly."msgstr "这样cat.getDog()就能正常运作。"#. Tag: title#: query_sql.xml:119#, no-c-formatmsgid "Handling associations and collections"msgstr "处理关联和集合类(Handling associations and collections)"#. Tag: para#: query_sql.xml:121#, no-c-formatmsgid """It is possible to eagerly join in the <literal>Dog</literal> to avoid the ""possible extra roundtrip for initializing the proxy. This is done via the ""<literal>addJoin()</literal> method, which allows you to join in an ""association or collection."msgstr """通过提前抓取将<literal>Dog</literal>连接获得,而避免初始化proxy带来的额外开销""也是可能的。这是通过<literal>addJoin()</literal>方法进行的,这个方法可以让你""将关联或集合连接进来。"#. Tag: programlisting#: query_sql.xml:126#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT c.ID, NAME, BIRTHDATE, DOG_ID, D_ID, ""D_NAME FROM CATS c, DOGS d WHERE c.DOG_ID = d.D_ID\")\n"" .addEntity(\"cat\", Cat.class)\n"" .addJoin(\"cat.dog\");\n""]]>"msgstr ""#. Tag: para#: query_sql.xml:128#, no-c-formatmsgid """In this example the returned <literal>Cat</literal>'s will have their ""<literal>dog</literal> property fully initialized without any extra ""roundtrip to the database. Notice that we added a alias name (\"cat\") to be ""able to specify the target property path of the join. It is possible to do ""the same eager joining for collections, e.g. if the <literal>Cat</literal> ""had a one-to-many to <literal>Dog</literal> instead."msgstr """上面这个例子中,返回的<literal>Cat</literal>对象,其<literal>dog</literal>属""性被完全初始化了,不再需要数据库的额外操作。注意,我们加了一个别名(\"cat\"),""以便指明join的目标属性路径。通过同样的提前连接也可以作用于集合类,例如,假若""<literal>Cat</literal>有一个指向<literal>Dog</literal>的一对多关联。"#. Tag: programlisting#: query_sql.xml:136#, no-c-formatmsgid """<![CDATA[sess.createSQLQuery(\"SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, ""CAT_ID FROM CATS c, DOGS d WHERE c.ID = d.CAT_ID\")\n"" .addEntity(\"cat\", Cat.class)\n"" .addJoin(\"cat.dogs\");\n""]]>"msgstr ""#. Tag: p#: query_sql.xml:138#, no-c-formatmsgid """At this stage we are reaching the limits of what is possible with native ""queries without starting to enhance the sql queries to make them usable in ""Hibernate; the problems starts to arise when returning multiple entities of ""the same type or when the default alias/column names are not enough."msgstr """到此为止,我们碰到了天花板:若不对SQL查询进行增强,这些已经是在Hibernate中使""用原生SQL查询所能做到的最大可能了。下面的问题即将出现:返回多个同样类型的实体""怎么办?或者默认的别名/字段不够又怎么办?"#. Tag: title#: query_sql.xml:146#, no-c-formatmsgid "Returning multiple entities"msgstr "返回多个实体(Returning multiple entities)"#. Tag: para#: query_sql.xml:148#, no-c-formatmsgid ""

⌨️ 快捷键说明

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