srom 介绍
scala的orm框架,相比其他orm更为简洁
// Declare a model: case class Artist( name : String, genres : Set[Genre] ) case class Genre( name : String ) // Initialize SORM, automatically generating schema: import sorm._ object Db extends Instance( entities = Set( Entity[Artist](), Entity[Genre]() ), url = "jdbc:h2:mem:test" ) // Store values in the db: val Metal = Db.save( Genre("Metal") ) val rock = Db.save( Genre("Rock") ) Db.save( Artist("Metallica", Set(Metal, rock) ) ) Db.save( Artist("Dire Straits", Set(rock) ) ) // Retrieve values from the db: // Option[Artist with Persisted]: val Metallica = Db.query[Artist].whereEqual("name", "Metallica").fetchOne() // Stream[Artist with Persisted]: val rockArtists = Db.query[Artist].whereEqual("genres.item.name", "Rock").fetch()
srom 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。