Scweery是Scala一个封装了JDBC操作用来从SQL中创建Scala对象的工具包。
示例代码:
using(petsDB){connection=>valfindHogsQuery="selectname,genderfrompetswherefamily='erinaceidae'orderbycuteness"vallistOfHedgehogs=connection.inferListOf[Hedgehog](findHogsQuery){row=>newHedgehog(row.string("name"),row.string("gender"))}listOfHedgehogs.foreach(_.hug)}
评论