English 中文(简体)
以连连修改 sql 到 hql
原标题:Changing sql to hql with joins

我的hql查询有问题吗?

String queryString = "SELECT A.INITIAL, A.NUMBER, A.OWNR_SCAC , A.INITIAL||A.NUMBER AS CAR," + 
            "A.LESSEE_SCAC, A.TRUK_CNT, A.EQP_TYP_CD, A.AXL_CNT, B.STABILITY_DEV_EQP," +
            "A.C_CNT, A.G_WGT, B.TRUK_AXL_CNT, A.EIN FROM DS.E_UT AS A" +
            "LEFT JOIN DS.E_PRIMARY AS B" +
            "WHERE A.INITIAL||A.NUMBER IN (:carList) AND A.INITIAL IN {:initList) AND A.NUMBER IN (:numberList)" + 
            "AND B.TRUK_AXL_CNT > 0";

错误:

g.hibertate.hql. intern.ast. QuerySyndexcutive: 意想不到的标记: 靠近第1行的第263列

我想这是在 DS.E_UT AS A 之后的 A

最佳回答

在 HQL 中,您要提供表格和列名称,而要提供 Java 类名称和成员变量名称(或getter/set) 以及您绘制到表格和列的类别和成员变量名称(或geter/set)。

问题回答

我认为你应该在每条新线上加点空间

"A.C_CNT, A.G_WGT, B.TRUK_AXL_CNT, A.EIN FROM DS.E_UT AS A" +
"LEFT JOIN DS.E_PRIMARY AS B"

将变成:

A.C_CNT, A.G_WGT, B.TRUK_AXL_CNT, A.EIN FROM DS.E_UT AS ALEFT JOIN DS.E_PRIMARY AS B

注意 ACEFT 注释

我不完全相信你的策略,或者这是你要找的, 但你可以一起绘制您的组合表格。 这样可以让事情变得简单一些, 你不需要明确地加入到你的查询中来。

http://tadtech.blogspot.com/2007/02/hiberate-annotation-many-to-one forforeign.html" rel="nofollow"。 这里举个小例子

从该示例中抽取的样本查询可能看起来像 :

SELECT p 
    FROM Person 
WHERE p.name like :name 
AND p.address.street like :street




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签