Using In Clause with MyBatis and Scala

Had a bit of struggle to get this to work, logging the solution here so that it will be helpful to someone else. I am using Scala 2.9.1 and mybatis-scala-core 1.0.0.

val findOpenGroups = new SelectListBy[GroupIds,Group] {
def xsql = SELECT h.xxxxxx AS id,
h.xxxxxx AS launchedDate
FROM USA_xxxx_xxxx_xxxx h
WHERE h.new_status = 'Open'
<foreach item="item" collection="ids" open="(" separator="," close=")"> 

GroupIds is a simple class, just make sure you are using the java.util.List.

class GroupIds(val ids:java.util.List[Int]){}

Frank Martínez pointed out to me that you can also do {"item" ?} instead of {"#{item}"} but you will need to import org.mybatis.scala.mapping.Binding._ Thanks Frank.

3 thoughts on “Using In Clause with MyBatis and Scala

  1. However, the expansion of rooftop solar installations on apartment complexes
    and commercial buildings, schools, hospitals or in community housing because of the substantial reduction of industrial
    greenhouse gas emissions. 70 per gallon discount
    for wholesale gasoline through all of the animal; so you might want to grow a
    low-cost platform. Ajay Sabherwal Oh, yes. Can you just give us kind
    of what you’re referring to for the back half of next year. As we indicated on the last call, lease rates were north of $3, 000 per acre.

  2. Thanks for the tip. I was struggling to find out to do this using scala-mybatis and your article was exactly what I needed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s