Hello all,

I have a little problem.
I use scala and akka. I have a list with instances and each instance 
creates a orient instance:
val db = new OObjectDatabaseTx(uri)

BUT! If I start a save action or a select, I get the error I have to do 
this: Database instance is not set in current thread. Assure to set it 
with: ODatabaseRecordThreadLocal.INSTANCE.set(db);

So now the problem! in the router instance I use this:


class OODatabaseActor(uri: String) extends Actor {
>
>   //val db = OObjectDatabasePool.global().acquire(uri, "admin", 
> "admin");//new OObjectDatabaseTx(uri)
>
>   val db = new OObjectDatabaseTx(uri)
>   if( db.exists() ){
>     db.open("admin","admin")
>     ODatabaseRecordThreadLocal.INSTANCE.set(db.getUnderlying)
>     //db.open("admin","admin")
>   } else {
>     db.create()
>   }
>   db.getEntityManager.registerEntityClass(classOf[Customer])
>   db.getEntityManager.registerEntityClass(classOf[Address])
>   db.getEntityManager.registerEntityClass(classOf[Article])
>   db.getEntityManager.registerEntityClass(classOf[ArticleAttribute])
>   db.getEntityManager.registerEntityClass(classOf[Price])
>
>   implicit def dbWrapper(db: OObjectDatabaseTx) = new {
>     def queryBySql[T](sql: String, params: AnyRef*): List[T] = {
>       val params4java = params.toArray
>       val results: java.util.List[T] = db.query(new 
> OSQLSynchQuery[T](sql), params4java: _*)
>       results.asScala.toList
>     }
>   }
>
>   //private val uri = "local:/home/andre/Ysop/orientdb2" //+ new 
> File("").getAbsolutePath + File.separator + "orientDB"
>   //private val db = new OObjectDatabaseTx(uri)
>   //initiateDB()
>
>   /*def initiateDB() {
>     if( db.exists() ){
>       db.open("admin","admin")
>     } else {
>       db.create()
>     }
>     db.getEntityManager.registerEntityClass(classOf[Customer])
>     db.getEntityManager.registerEntityClass(classOf[Address])
>     db.getEntityManager.registerEntityClass(classOf[Article])
>     db.getEntityManager.registerEntityClass(classOf[ArticleAttribute])
>     db.getEntityManager.registerEntityClass(classOf[Price])
>   }*/
>
>   override def receive = {
>     case Safe(a) => db.save(a)
>       sender ! true
>     case LoadAllProducts => val s = sender()
>       println("suche")
>       println( db.countClass(classOf[Article]) )
>       val buffer = ListBuffer[Article]()
>       db.browseClass(classOf[Article]).iterator().foreach(a => buffer += a)
>       println(buffer.size + " " + buffer.head.toString)
>       //s ! tmp
>       s ! buffer
>     case _ => //
>   }
>
>   override def postStop() {
>     db.close()
>   }
>
> }
>
 
BUT if I want so send the list back to the sender, I got the error above! 
Even I send a buffer or I iterate over the list. What to hell is going on?

Thanks for your help.

André

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to