How can one use Amazon's DynamoDBMapper in Scala?

The DynamoDB mapper uses reflection to find the getters and setters. The SDK assumes Java-style conventions, i.e. that your getters and setters start with "get" or "is", and setters start with "set". You can see the reflection code on github.

I've been able to get it working, but it feels just like writing Java :(

@DynamoDBTable(tableName = "awesome_table")
class TheBestClass {
  private var id : Integer = _

  @DynamoDBHashKey
  def getId() = id
  def setId(_id: Integer) = id = _id
}

I had to do this:

import annotation.meta.beanGetter
import beans.BeanProperty

import com.amazonaws.services.dynamodbv2.datamodeling._

@DynamoDBTable(tableName="DEMOTAB")
case class DemoItem(  // it's a case class for the free stuff, but can be ordinary class
    @(DynamoDBHashKey @beanGetter)  // would not work without meta annotation
    @BeanProperty var id:String,    // must be var or mapper can't instantiate one

    @BeanProperty var number:Integer
) {
  def this() = this(null, null)     // needed by DynamoDB Mapper to instantiate
}