Using Java models with Scala. (value findById is not a member of object)
Ok I've found that using Java models is a lot easier than the whole Scala Anorm stack. I want to use Java models with Scala controllers. Scala finds the methods I've written in the model but not the inherited methods like findById. I've read some documentation that talks about QueryOn.
Another that talks about.
import play.db.jpa.asScala
import models._
asScala[Tree].findAll
None of these seem to work for me. Thanks for开发者_开发技巧 any help.
You can use JPA with Scala, there is no need to do something "tricky", simply extend Model and use the JPA annotations as if it was Java.
so do you have JPA models written in Java and you would like to use them in scala controllers? That should work! As long as User extends play.db.jpa.Model, you would have a handle on findById.
If you have created models in Scala, you would need a class and an object (class should extend Model, object should extend QueryOn).
精彩评论