| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

可扩展的Scala ORM框架:SORM

SORM是一个Scala的ORM框架,旨在消除样板代码和解决可扩展性问题,通过高层次的抽象和函数式编程风格。

特性:

  • 完全抽象的关系概念. You work with case classes, collections and other standard Scala data types instead of tables, rows, foreign keys and relations.
  • 从持久层完全分离的域模型. There are no annotations, special types or any other dependencies on persistence layer present in model declaration. This house is clear!
  • 一个直观和集中的连接无关的API. No tangled implicit constructions polluting your namespace and functionality scattered across multiple components. No manual management of connections.
  • Concurrency. A single SORM instance can safely be used across multiple threads and seamlessly integrates into actor-based concurrent systems, like Akka.
  • 集成连接池. Scalable just by setting a “poolSize” parameter.
  • 自动生成数据库结构
下面是一个完整的例子:
// 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() 

项目主页:http://www.open-open.com/lib/view/home/1371526720703

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1371526720703.html
SORM 持久层框架