📄 query_sql.pot
字号:
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""POT-Creation-Date: 2007-10-19 10:34-0500\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"#: query_sql.xml:5(title) msgid "Native SQL"msgstr ""#: query_sql.xml:7(para) msgid "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 ""#: query_sql.xml:13(para) msgid "Hibernate3 allows you to specify handwritten SQL (including stored procedures) for all create, update, delete, and load operations."msgstr ""#: query_sql.xml:17(title) msgid "Using a <literal>SQLQuery</literal>"msgstr ""#: query_sql.xml:19(para) msgid "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 ""#: query_sql.xml:25(title) msgid "Scalar queries"msgstr ""#: query_sql.xml:27(para) msgid "The most basic SQL query is to get a list of scalars (values)."msgstr ""#: query_sql.xml:34(para) msgid "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 ""#: query_sql.xml:39(para) msgid "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 ""#: query_sql.xml:49(para) query_sql.xml:101(para) query_sql.xml:195(para) query_sql.xml:354(para) msgid "This query specified:"msgstr ""#: query_sql.xml:53(para) query_sql.xml:105(para) query_sql.xml:358(para) msgid "the SQL query string"msgstr ""#: query_sql.xml:57(para) msgid "the columns and types to return"msgstr ""#: query_sql.xml:61(para) msgid "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 ""#: query_sql.xml:69(para) msgid "It is possible to leave out the type information for all or some of the scalars."msgstr ""#: query_sql.xml:78(para) msgid "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 ""#: query_sql.xml:82(para) msgid "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 ""#: query_sql.xml:90(title) msgid "Entity queries"msgstr ""#: query_sql.xml:92(para) msgid "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 ""#: query_sql.xml:109(para) msgid "the entity returned by the query"msgstr ""#: query_sql.xml:113(para) msgid "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 ""#: query_sql.xml:117(para) msgid "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 ""#: query_sql.xml:128(para) msgid "This will allow cat.getDog() to function properly."msgstr ""#: query_sql.xml:132(title) msgid "Handling associations and collections"msgstr ""#: query_sql.xml:134(para) msgid "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 ""#: query_sql.xml:144(para) msgid "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 ""#: query_sql.xml:157(p) msgid "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 ""#: query_sql.xml:165(title) msgid "Returning multiple entities"msgstr ""#: query_sql.xml:167(para) msgid "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 ""#: query_sql.xml:172(para) msgid "Column alias injection is needed in the following query (which most likely will fail):"msgstr ""#: query_sql.xml:180(para) msgid "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 ""#: query_sql.xml:187(para) msgid "The following form is not vulnerable to column name duplication:"msgstr ""#: query_sql.xml:199(para) msgid "the SQL query string, with placeholders for Hibernate to inject column aliases"msgstr ""#: query_sql.xml:204(para) msgid "the entities returned by the query"msgstr ""#: query_sql.xml:208(para) msgid "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 ""#: query_sql.xml:227(title) msgid "Alias and property references"msgstr ""#: query_sql.xml:229(para) msgid "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 ""#: query_sql.xml:234(para) msgid "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 ""#: query_sql.xml:240(title) msgid "Alias injection names"msgstr ""#: query_sql.xml:251(entry) msgid "Description"msgstr ""#: query_sql.xml:253(entry) msgid "Syntax"msgstr ""#: query_sql.xml:255(entry) msgid "Example"msgstr ""#: query_sql.xml:261(entry) msgid "A simple property"msgstr ""#: query_sql.xml:263(literal) msgid "{[aliasname].[propertyname]"msgstr ""#: query_sql.xml:265(literal) msgid "A_NAME as {item.name}"msgstr ""#: query_sql.xml:269(entry) msgid "A composite property"msgstr ""#: query_sql.xml:271(literal) msgid "{[aliasname].[componentname].[propertyname]}"msgstr ""#: query_sql.xml:273(literal) msgid "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}"msgstr ""#: query_sql.xml:278(entry) msgid "Discriminator of an entity"msgstr ""#: query_sql.xml:280(literal) msgid "{[aliasname].class}"msgstr ""#: query_sql.xml:282(literal) msgid "DISC as {item.class}"msgstr ""#: query_sql.xml:286(entry) msgid "All properties of an entity"msgstr ""#: query_sql.xml:288(literal) query_sql.xml:336(literal) msgid "{[aliasname].*}"msgstr ""#: query_sql.xml:290(literal) msgid "{item.*}"msgstr ""#: query_sql.xml:294(entry) msgid "A collection key"msgstr ""#: query_sql.xml:296(literal) msgid "{[aliasname].key}"msgstr ""#: query_sql.xml:298(literal) msgid "ORGID as {coll.key}"msgstr ""#: query_sql.xml:302(entry) msgid "The id of an collection"msgstr ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -