Skip to content
Advertisement

How to create sql using IN condition include two columns (doma)

I use Doma.

then, I want to create sql like below.

select * from 
table 
where (col1, col2) in (('val1', 'val2'), ('val3', 'val4'));

can I do this? Do you know anything to solve it ? thanks.

Advertisement

Answer

Yes, you can do that with Doma Criteria API.

See my example:

https://github.com/nakamura-to/getting-started/blob/in-condition/java-8/src/main/java/boilerplate/java8/repository/EmployeeRepository.java#L31-L32

The above example issues the following sql statement:

select t0_.id, t0_.name, t0_.age, t0_.version from Employee t0_ where (t0_.id, t0_.version) in ((1, 0), (2, 0))
Advertisement