I want to convert a HashSet of Integer to Comma Separated String,
so I can use the same in where clause of a MySQL query.
//[MySQL - Sample table Schema]
my_table
state_id INTEGER
shop_id INTEGER
Set<Integer> uniqueShopIds = shopService.GetShopIds(); // This returns HashSet<Integer>
String inClause = ; // **How do i convert the uniqueShopIds to comma separated String**
String selectQuery = String.format("SELECT DISTINCT(state_id) FROM my_table WHERE shop_id IN (%s);", inClause);
If there's any other way, I can use the HashSet directly in IN CLAUSE of the PreparedStatment, please share.