[info] 12:24:51.110 [main] DEBUG ru.circumflex.orm - SELECT LASTVAL() AS this_1
[error] java.lang.ClassCastException: java.lang.Long cannot be cast to
java.lang.Integer
[error] at scala.runtime.BoxesRunTime.unboxToInt(Unknown Source)
[error] at scala.Tuple2._2$mcI$sp(Tuple2.scala:22)
[error] at com.pod.db.DbSetup$$anonfun$mock$1.apply$mcV$sp(db.scala:37)
[error] at com.pod.db.DbSetup$$anonfun$mock$1.apply(db.scala:34)
[error] at com.pod.db.DbSetup$$anonfun$mock$1.apply(db.scala:34)
[error] at
ru.circumflex.orm.package$$anonfun$using$1.apply(package.scala:41)
[error] at
ru.circumflex.orm.package$$anonfun$using$1.apply(package.scala:39)
[error] at ru.circumflex.core.Context$.executeInNew(context.scala:83)
...
This happens when I have a simple model:
class Account extends Record[Int, Account] with IdentityGenerator[Int,
Account] {
val id = "id".INTEGER.NOT_NULL.AUTO_INCREMENT
val name = "name".TEXT
def PRIMARY_KEY = id
def relation = Account
}
object Account extends Account with Table[Int, Account]
and run the following:
val a = new Account
a.name := "Yang"
a.save()
val aid = a.id() // failure here
Are you also seeing this?
--
Yang Zhang
http://yz.mit.edu/
As you've probably already figured, neither IdentityGenerator nor the corresponding part of Dialect object contains explicit declaration of type `Long` expected from database query. What database are you using? Maybe you should override `identityLastIdQuery` in dialect to provide more specific database type? E.g. `new Select(expr[PK]("LASTVAL() :: INTEGER"))`
Best regards
Boris Okunskiy
I'm using Postgresql.
This does seem to be more of a detail that I would expect the ORM to
mask, since it's safe to just make this cast knowing that the PK is an
Int, and since I would expect many users naturally use INTEGERs as
PKs. Maybe at least a mention in the documentation would be merited?
Just my 2c.
BTW, massive documentation update and Circumflex book is on our top priority list, but we simply can't afford this work right now.
Best regards,
Boris Okunskiy