Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Spring Data Spanner Repositories In clause queries support #1701

Closed
don-mayur opened this issue Jun 17, 2019 · 4 comments · Fixed by #1703
Closed

Spring Data Spanner Repositories In clause queries support #1701

don-mayur opened this issue Jun 17, 2019 · 4 comments · Fixed by #1703
Assignees

Comments

@don-mayur
Copy link

don-mayur commented Jun 17, 2019

Spring data spanner gives java.lang.UnsupportedOperationException: The statement type: IN (1): [IsIn, In] is not supported. when trying to use IN for selecting columns part of a composite key in a SpannerRepository interface
@Query("select * from <TableName> t where t.<columnName1>= @param1 AND t.columnName2 IN (@param2)")
Set<OnHandInventory> findBy<ColumnName1>And<ColumnName2>In(@Param("param1") String columnOneValue,@Param("param2") Set<Long> column2Values);

Note: Exception being thrown at SpannerStatementQueryExecutor.java

@ChengyuanZhao ChengyuanZhao self-assigned this Jun 18, 2019
@ChengyuanZhao
Copy link
Contributor

ChengyuanZhao commented Jun 18, 2019

EDIT:

@dmitry-s @meltsufin

EDIT2:

Looks like we can use the "IN UNEST()" expression and bind a single ARRAY type param.

Note that the user can always just specify a query using the IN clause using @Query and specify a fixed number of param tags himself. In that case we would be completely oblivious to the IN clause.

@ChengyuanZhao
Copy link
Contributor

@don-mayur

By the way it looks like your example method name is actually a @Query annotated SQL string, which means Spring Data Spanner wouldn't be aware of the contents of the string and the IN clause at all.

It is only if you part-tree/name-convention query method like "findByCol1AndCol2In" without @Query annotation that the parsing would hit on that IsIn/In keyword keyword.

@don-mayur
Copy link
Author

@ChengyuanZhao Thanks for taking up on this issue, I have tried using method name such as findByCol1AndCol2In and then using some different name with @Query on top of it by referring some of Spring Data JPA examples. Unfortunately, none of the approaches worked.

@ChengyuanZhao
Copy link
Contributor

@don-mayur I added support in the referenced PR.

ChengyuanZhao added a commit that referenced this issue Jun 20, 2019
fixes #1701
array param binding in queries. and IN clause
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants