Home > General > Using In Clause with MyBatis and Scala

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'
AND h.id IN
<foreach item="item" collection="ids" open="(" separator="," close=")"> 
                {"#{item}"}
            </foreach> 
}

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

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

UPDATE
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.

About these ads
Categories: General Tags: ,
  1. May 22, 2013 at 5:29 pm

    A 1950’s Working degree online programs Mum’s Answer to Children Biting.

  2. June 4, 2013 at 2:24 am

    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.

  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: