sorm

How to model an entity with many children in Sorm?

微笑、不失礼 提交于 2019-12-18 05:14:20
问题 I have a Workspace and Document entities, with the idea that a workspace can contain zero, one, or more documents. My first approach to model this was: case class Workspace(name: String, documents: Seq[Document]) but this will not scale well since my workspaces may contain many documents. Fortunately, my business requirement allow me to treat workspaces and documents separately (in the sense that when I have a workspace, there is no reason or invariant that forces me to consider all documents

SORM: How can I declare foreign keys?

送分小仙女□ 提交于 2019-12-10 13:45:01
问题 I'm very interested in SORM, but when I try to use it I bump into problem. Suppose I have two entities: case class User(login: String, firstName: String, lastName: String) case class UserSite(userId: Int, name: String, url: String) How can I declare foreign key relation UserSite.userId -> User.id? I see class ForeignKey, but there are no any example of using it. Thank you. 回答1: A very nice opportunity to exhibit the powers of SORM. As indicated in the Features of SORM, it abstracts away from

Fetch object by plain SQL query with SORM

不问归期 提交于 2019-12-10 03:19:02
问题 Is it possible to fetch items by plain SQL query instead of building query by DSL using SORM? For example is there an API for making something like val metallica = Db.query[Artist].fromString("SELECT * FROM artist WHERE name = ?", "Metallica").fetchOne() // Option[Artist] instead of val metallica = Db.query[Artist].whereEqual("name", "Metallica").fetchOne() // Option[Artist] 回答1: Since populating an entity with collections and other structured values involves fetching data from multiple

How can I create a different entity type using the original entity id in sorm?

孤者浪人 提交于 2019-12-08 07:56:33
问题 I have the following classes: case class Product( title : String, description: String, contract: Contract) case class Contract(contractType: ContractType, price: Int ) case class ContractType(description: String) and these DTOs: case class ProductDto(id: Long, title: String, description: String, contractType: ContractTypeDto, price: Int) case class ContractTypeDto(id: Long, description: String) I need to create a method that returns the list of products but with the data filled in DTOs,

Using SORM with Play Framework 2.3.8

一曲冷凌霜 提交于 2019-12-07 02:32:24
问题 I am going through the Video introduction to Play Framework and, but I am stuck creating a DB object with SORM because the import fails. I tried to add the dependencies in plugins.sbt , and relaunched activator, but it seems that activator cannot find the dependencies and I get and I get an unresolved error : addSbtPlugin("org.sorm-framework" % "sorm" % "0.3.14") addSbtPlugin("com.h2database" % "h2" % "1.4.181") I got the versions from the Yvis repository. I also tried other versions with no

Using SORM with Play Framework 2.3.8

陌路散爱 提交于 2019-12-05 08:12:10
I am going through the Video introduction to Play Framework and, but I am stuck creating a DB object with SORM because the import fails. I tried to add the dependencies in plugins.sbt , and relaunched activator, but it seems that activator cannot find the dependencies and I get and I get an unresolved error : addSbtPlugin("org.sorm-framework" % "sorm" % "0.3.14") addSbtPlugin("com.h2database" % "h2" % "1.4.181") I got the versions from the Yvis repository . I also tried other versions with no better luck. should be add as libraryDependencies += "org.sorm-framework" % "sorm" % "0.3.16" in build

Using SORM with Play Framework causes reflection exceptions to be thrown

半城伤御伤魂 提交于 2019-12-04 01:44:41
问题 I've been trying to get SORM working with Play Framework 2.2-SNAPSHOT as well as 2.1.1. Currently I'm trying to run a minimalistic sample application that I created in order to track down the issue more easily. Unfortunately the error message I receive doesn't help me at all. val appDependencies = Seq( "org.sorm-framework" % "sorm" % "0.3.8", "com.h2database" % "h2" % "1.3.168" ) # Database configuration # db.default.driver=org.h2.Driver db.default.url="jdbc:h2:mem:play" # db.default.user=sa

How to use SORM framework with Play Framework?

半世苍凉 提交于 2019-12-02 00:42:02
问题 I find SORM very Interesting and promising but I cant find a way to Integrate It with play any guides? 回答1: Install Play >= 2.1.0. Generate a project using Play's guides Add appropriate SORM's and chosen database's dependencies to the generated project/Build.scala , e.g.: val appDependencies = Seq( "org.sorm-framework" % "sorm" % "0.3.8", "com.h2database" % "h2" % "1.3.168" ) In the same file make sure that your project depends on the same Scala version, on which SORM depends (for SORM 0.3.8

How to use SORM framework with Play Framework?

大城市里の小女人 提交于 2019-12-01 22:27:37
I find SORM very Interesting and promising but I cant find a way to Integrate It with play any guides? Nikita Volkov Install Play >= 2.1.0. Generate a project using Play's guides Add appropriate SORM's and chosen database's dependencies to the generated project/Build.scala , e.g.: val appDependencies = Seq( "org.sorm-framework" % "sorm" % "0.3.8", "com.h2database" % "h2" % "1.3.168" ) In the same file make sure that your project depends on the same Scala version, on which SORM depends (for SORM 0.3.8 it's Scala 2.10.1): val main = play.Project(appName, appVersion, appDependencies).settings(

Using SORM with Play Framework causes reflection exceptions to be thrown

谁说我不能喝 提交于 2019-12-01 09:07:46
I've been trying to get SORM working with Play Framework 2.2-SNAPSHOT as well as 2.1.1. Currently I'm trying to run a minimalistic sample application that I created in order to track down the issue more easily. Unfortunately the error message I receive doesn't help me at all. val appDependencies = Seq( "org.sorm-framework" % "sorm" % "0.3.8", "com.h2database" % "h2" % "1.3.168" ) # Database configuration # db.default.driver=org.h2.Driver db.default.url="jdbc:h2:mem:play" # db.default.user=sa # db.default.password="" case class Car( brand: String, wheels: Int ) object Db extends Instance( Seq(