squeryl

Scala/Play/Squeryl Retrieve multiple params

喜欢而已 提交于 2020-01-07 02:35:12
问题 I have the following url : http://localhost/api/books/?bookId=21&bookId=62?authorId=2 I want to retrieve all the bookId values with Scala and then use Squeryl to do a fetch in a the database. I'm using the PlayFrameWork as the WebServer, so here's my code : val params = request.queryString.map { case (k, v) => k -> v(0) } // Retrieve only one the first occurence of a param So params.get("bookId") will only get the last value in the bookId params. e-g : 62 . To retrieve all my bookId params i

Squeryl and PostgreSQL's autoincrement

删除回忆录丶 提交于 2020-01-05 07:11:24
问题 When I try to insert a new record in a PostgreSQL table using Squeryl's Table.insert, it fires this query: insert into "users" ("id", "email", "fullname") values (nextval('"s_users_id"'),?,?) This doesn't work, as I did not define a sequence and instead defined the id column to be "autoincrement": CREATE TABLE Users ( id BIGSERIAL, email varchar(255) NOT NULL, fullname varchar(255), PRIMARY KEY (id) ); I read some old post in another forum about this issue, and I was wondering what the status

Scala reflection and Squeryl

本秂侑毒 提交于 2020-01-03 02:27:29
问题 I'm working on my first substantial project using Scala, Scalatra, and Squeryl, and happened upon the following problem: I wanted to have an abstract base class for my DAOs that provided a simple implementation of the basic CRUD operations (create, read, update, delete), so I needed a way for said abstract base class to be aware of which table to reference. With Squeryl, you map your data classes to actual tables in a singleton object that extends squeryl.Schema, and your DAOs are generally

Squeryl fails to reflect in debug mode only

柔情痞子 提交于 2020-01-02 08:16:09
问题 I can't debug (simple run works fine) my unit tests. Squeryl fails with the following exception: error while reflecting on metadata for (Some(private scala.Option com.company.play.model.db.mapping.Position.orgUnit2id),Some(public scala.Option com.company.play.model.db.mapping.Position.orgUnit2id()),None,Set(@org.squeryl.annotations.ColumnBase(optionType=class java.lang.Object, name=, length=-1, scale=-1, value=ORG_UNIT2ID))) of class com.company.play.model.db.mapping.Position java.lang

Squeryl fails to reflect in debug mode only

这一生的挚爱 提交于 2020-01-02 08:16:06
问题 I can't debug (simple run works fine) my unit tests. Squeryl fails with the following exception: error while reflecting on metadata for (Some(private scala.Option com.company.play.model.db.mapping.Position.orgUnit2id),Some(public scala.Option com.company.play.model.db.mapping.Position.orgUnit2id()),None,Set(@org.squeryl.annotations.ColumnBase(optionType=class java.lang.Object, name=, length=-1, scale=-1, value=ORG_UNIT2ID))) of class com.company.play.model.db.mapping.Position java.lang

Dynamically generate case class in Scala

孤者浪人 提交于 2019-12-31 02:54:46
问题 I want to read a rather large csv file and process it (slice, dice, summarize etc.) interactively (data exploration). My idea is to read the file into a database (H2) and use SQL to process it: Read the file: I use Ostermiller csv parser Determine the type of each column: I select randomly 50 rows and derive the type (int, long, double, date, string) of each column I want to use Squeryl to process. To do so I need to create a case class dynamically. That's the bottleneck so far! I upload the

Squeryl dynamic join clauses

只谈情不闲聊 提交于 2019-12-25 07:35:10
问题 What I'm looking for seems fairly common but I can't seem to figure it out through the Squeryl api. I need to have a conditional piece to my on statement for a join. def getAllJoined( hasFallback:Option[String] = None ):List[(Type1,Type2)] = transaction{ join(mainTable, table2, table3, table3, table4.leftOuter, table4.leftOuter, table5, table6)((main, attr1, attr2, attr3, attr4, attr5, attr6, attr7) => select(main,attr1,attr2,attr3,attr4,attr5,attr6,attr7) on( //if(hasFallback.isDefined)

ClassCastException when trying to insert with Squeryl

本小妞迷上赌 提交于 2019-12-24 20:36:54
问题 This may be due to my misunderstanding of how Squeryl works. My entity is defined as: case class Wallet(userid: Int, amount: Long) extends KeyedEntity[Int] with Optimistic { def id = userid } My table variable is defined as: val walletTable = table[Wallet]("wallets") on(walletTable) { w => declare { w.userid is (primaryKey) } } Then I'm just calling a method to try to add money to the wallet: val requestedWallet = wallet.copy(amount = wallet.amount + amount) try { inTransaction { walletTable

Can I auto generate Squeryl data objects to reflect an existing MySql schema?

谁都会走 提交于 2019-12-22 09:48:43
问题 I have an existing Schema definition in MySql database. I created the schema using MySql Workbench. I wish to access the schema from my Lift-Scala-Squeryl code. I know that a simple way would be to manually define the schema structure using Squeryl data objects. Is there an automated way to generate Squeryl data objects out of existing MySql schema? I've found the following general question, but I'm sure there can be a way to generate a naive structure, although not accurate, it will allow a

Prevent Mixin overriding equals from breaking case class equality

我的未来我决定 提交于 2019-12-21 17:48:03
问题 Squeryl defines a trait KeyedEntity which overrides equals , checking for several conditions in an if and calling super.equals in the end. Since super is Object , it will always fail. Consider: trait T { override def equals(z: Any):Boolean = super.equals(z)} } case class A(a: Int) extends T val a = A(1); val b = A(1) a==b // false Thus, if you declare case class Record(id: Long, name: String ...) extends KeyedEntity[Long] { ... } -- and you create several Record instances but do not persist