English 中文(简体)
JQPL: 从多个表格中产生新目标
原标题:JQPL: Create new Object within the Query from multiple tables

I m目前试图用JQPL收集数据。 我的祝福

SELECT NEW com.test.CustomObject(t1.name, CASE WHEN(t2 IS NOT NULL) THEN true ELSE false END) FROM table1 t1, table2 t2 WHERE t1.id = :id1 AND t2.id = :id2

当然,这两个实体都有一个工作点。 具有固定价值的产品也可发挥作用:

SELECT NEW com.test.CustomObject(t1.name, false) FROM table1 t1 WHERE t1.id = :id1

我的问题是,如果:id2没有现成的价值,我就得不到回报。 不向习俗构造者提供虚假信息,而是完全省略。

What else could I do to gain knowledge if parameter id2 has a row in table2 to pass this as a boolean value to the custom constructor?

当然可以提供进一步的信息。

最佳回答

我可以与极端主义者一道解决问题:

SELECT NEW com.test.CustomObject(t1.name, CASE WHEN EXISTS(SELECT t2.id FROM table2 t2 WHERE t2.id = :id2) THEN true ELSE false END) FROM table1 t1 WHERE t1.id = :id1
问题回答

你们必须利用JOIN连接表1至表2。 如果加入的右侧存在的话,这也会使手边成为结果的一部分。 在这种情况下,从右侧(例如t2.id)得出的价值就是无效的。

同样,把id定为两倍(假设你想要的是1.id=t2.id)。 正当使用一度加入并设定了直截面参数。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签