8000 Entity `Nothing` is not registered · Issue #67 · sorm/sorm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 31, 2022. It is now read-only.

Entity Nothing is not registered #67

Open
kelebra opened this issue Mar 8, 2016 · 4 comments
Open

Entity Nothing is not registered #67

kelebra opened this issue Mar 8, 2016 · 4 comments

Comments

@kelebra
Copy link
kelebra commented Mar 8, 2016

Hi, guys,

I am pretty much new to sorm framework and decided to try it because of its API simplicity but unfortunately get this exception during 'fetch by id' operation. Please provide some advice on code below:

  object Database extends Instance(
    entities = Set(Entity[Post]()),
    url = config.getString("db.url"),
    user = config.getString("db.user"),
    password = config.getString("db.password"),
    initMode = if (config.getBoolean("db.init")) InitMode.DropAllCreate else InitMode.DoNothing
  ) {}
import org.h2.tools.Server
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpec}

class DatabaseSpec extends WordSpec with Matchers with BeforeAndAfterAll {

  "Database" should {

    "provide value by id" in {
      val post = Post("title", "azaza")
      val saved = Database.save(post)
      println(Database.fetchById(saved.id))
    }
  }

  override protected def beforeAll(): Unit = Server.createTcpServer("-tcpAllowOthers").start()
}

Please find full stack trace below:

[info] - should provide value by id *** FAILED ***
[info]   sorm.core.SormException: Entity `Nothing` is not registered
[info]   at sorm.Instance$Api$$anonfun$mapping$1$1.apply(Instance.scala:57)
[info]   at sorm.Instance$Api$$anonfun$mapping$1$1.apply(Instance.scala:57)
[info]   at scala.Option.getOrElse(Option.scala:121)
[info]   at sorm.Instance$Api$class.mapping$1(Instance.scala:56)
[info]   at sorm.Instance$Api$class.sorm$Instance$Api$$mapping(Instance.scala:61)
[info]   at sorm.Instance$Api$$anonfun$fetchById$1$$anonfun$apply$10.apply(Instance.scala:117)
[info]   at sorm.Instance$Api$$anonfun$fetchById$1$$anonfun$apply$10.apply(Instance.scala:117)
[info]   at embrace.package$EmbraceAny$.$$extension(package.scala:6)
[info]   at sorm.Instance$Api$$anonfun$fetchById$1.apply(Instance.scala:117)
[info]   at sorm.Instance$Api$$anonfun$fetchById$1.apply(Instance.scala:116)

Thanks in advance,
Oleksii

@nikita-volkov
Copy link
Contributor

What's the definition of Post?

@kelebra
Copy link
Author
kelebra commented Mar 8, 2016

Post is just case class:
case class Post(title: String, content:String)

@nikita-volkov
Copy link
Contributor

Hmm.. Which version of Scala are you using?

@kelebra
Copy link
Author
kelebra commented Mar 9, 2016

2.11.7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0