Multiple Columns In Clause Parameters [DATAJPA-1278]
See original GitHub issueooxaam opened DATAJPA-1278 and commented
I’m new to spring jpa and what I’m trying to do is that:
I have a list of accounts and currency and I want to search from table based on both of these params by passing them “IN” clause.
What I’m doing right now is :
@Query(nativeQuery = true, value = "select a.* from ACC a where (a.iban, a.currency) in (:iban , :curr)")
List<ACC> getAccount(@Param("iban") List<String> ibans, @Param("curr") List<String> currencies);
Expecting a query like this:
select * from table where (iban, curr) in (('accnum1', 'currency1'),('accnum2', 'currency2'), ('accnum3', 'currency3'));
Actually query is getting generated like this:
select * from table where (iban, curr) in (('accnum1', 'accnum2', 'accnum3'),('currency1', 'currency2', 'currency3'));
No further details from DATAJPA-1278
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Parameterized IN clause using multiple columns
I have a query along these lines, where I am trying to filter the result set by comparing tuples (like SQL multiple columns...
Read more >Selecting Multiple Columns Based On Condition in SQL
When we have to select multiple columns along with some condition, we put a WHERE clause and write our condition inside that clause....
Read more >SELECT - Snowflake Documentation
As a clause, SELECT defines the set of columns returned by a query. ... 'Dana', 2); INSERT INTO department_table (department_ID, department_name) VALUES (1, ......
Read more >selecting where two columns are in a set - DBA Stack Exchange
works in PostgreSQL, DB2, SQL Server SELECT t.whatever FROM t JOIN ( VALUES (val1a, val2a), (val1b, val2b), ...) AS x (col1, col2) ON...
Read more >Sorting on multiple columns - IBM
The default is still ascending, and the column that is listed first in the ORDER BY clause takes precedence. The following query and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Jens Schauder commented
Could you try
where
params
gets passed the tuples as 2-element-arrays.I don’t think how this is supposed to behave is specified in any relevant standard.
The “Bugfix” would need to come for JPA by actually specifying how to achieve something like this with JPQL. In the meantime, I’d recommend falling back to Springs
JdbcTemplate
which supports this kind of query. See https://stackoverflow.com/questions/23305553/how-to-bind-a-list-of-tuples-using-spring-jdbctemplateJens Schauder commented
Batch closing resolved issue without a fix version and a resolution indicating that there is nothing to release (Won’t fix, Invalid …)