This repository was archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Error java.lang.NoSuchMethodError when run the sample code #71
Copy link
Copy link
Open
Description
I got this error when I tried to use sorm. I tried to fix it but not success.
The connection to my database is fine.
So, can someone give me a solution to fix it ?
Thanks a lot.
Exception in thread "main" java.lang.NoSuchMethodError: scala.Product.$init$()V
at scala.tools.reflect.ToolBoxError.<init>(ToolBox.scala:136)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.liftedTree1$1(ToolBoxFactory.scala:349)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.compiler$lzycompute(ToolBoxFactory.scala:335)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.compiler(ToolBoxFactory.scala:334)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:361)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.parse(ToolBoxFactory.scala:418)
at sorm.persisted.PersistedClass$.createClass(PersistedClass.scala:107)
at sorm.persisted.PersistedClass$$anon$1$$anonfun$resolve$1.apply(PersistedClass.scala:125)
at sorm.persisted.PersistedClass$$anon$1$$anonfun$resolve$1.apply(PersistedClass.scala:125)
at scala.collection.mutable.MapLike$class.getOrElseUpdate(MapLike.scala:194)
at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:80)
at sorm.persisted.PersistedClass$$anon$1.resolve(PersistedClass.scala:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sorm.persisted.PersistedClass$.apply(PersistedClass.scala:129)
at sorm.Instance$Initialization$$anonfun$9$$anonfun$apply$16.apply(Instance.scala:239)
at sorm.Instance$Initialization$$anonfun$9$$anonfun$apply$16.apply(Instance.scala:239)
at embrace.package$EmbraceAny$.$$extension(package.scala:6)
at sorm.Instance$Initialization$$anonfun$9.apply(Instance.scala:239)
at sorm.Instance$Initialization$$anonfun$9.apply(Instance.scala:239)
at scala.collection.immutable.Set$Set2.foreach(Set.scala:128)
at sorm.Instance$Initialization.<init>(Instance.scala:239)
at sorm.Instance.<init>(Instance.scala:38)
I am using scala version 2.11.8
Here is the sample code with some little bit modifies
/**
* Created by voqua on 5/17/2016.
*/
// Declare a model:
case class Artist( name : String, genres : Set[Genre] )
case class Genre( name : String )
import sorm._
object Db extends Instance(
entities = Set( Entity[Artist](), Entity[Genre]() ),
url = "jdbc:postgresql://localhost:5432/playdb",
user = "hoa",
password = "hoa123456",
initMode = InitMode.Create
)
object DBTest{
def main(args:Array[String])={
println(util.Properties.versionString)
// 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) ) )
println("Saved")
// 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()
println(metallica)
println(rockArtists)
}
}
Build sbt file
name := "DBPlay"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies += "org.sorm-framework" % "sorm" % "0.3.19"
Metadata
Metadata
Assignees
Labels
No labels