issue 307

here a fix and a unit test for issue 307

https://github.com/mybatis/mybatis-3/issues/307