playframework-2.1

Ebean ManyToMany query

江枫思渺然 提交于 2019-11-30 19:13:47
I have two classes, user and car. Both have ManyToMany mapping to each other. User: @Entity public class User extends Model { private int year; @ManyToMany(cascade=CascadeType.ALL) private List<Car> cars; } Car: @Entity public class Car extends Model { @ManyToMany(mappedBy = "cars", cascade=CascadeType.ALL ) private List<User> users; } Using ebean, I would like to query only those cars from year 1999 that have give user in their list. I do not want to iterate over the user's car list in Java code. I didn't find any documentation how many-to-many queries should look like. So I would something

Changing layout template in runtime

房东的猫 提交于 2019-11-30 14:54:24
In Kohana (PHP framework) the layout is implemented through Template_Controller which continas a member variable called $template, which serves as layout view. Then in the action method you can populate the $template with further sub-views, usually the content view. ( http://forum.kohanaframework.org/discussion/3612/kohana-layout-system/p1 ) This allows me to change the layout "theme" in the runtime. It is useful for multitenant system, where a tenant can select their own theme (two col, three col, etc.) How can I achieve that in playframework 2 Scala, with Scala template engine? In other

What is the equivalent to 'play stop' for Play Framework 2.1?

冷暖自知 提交于 2019-11-30 13:46:51
问题 What is the equivalent of play stop for Play 2.1? If I did play start , how do I cleanly terminate the process? 回答1: As stated in the doc: When you run the start command, Play forks a new JVM and runs the default Netty HTTP server. The standard output stream is redirected to the Play console, so you can monitor its status. The server’s process id is displayed at bootstrap and written to the RUNNING_PID file. To kill a running Play server, it is enough to send a SIGTERM to the process to

Handling freeform GET URL parameters in Play 2 routing

↘锁芯ラ 提交于 2019-11-30 13:02:55
问题 Let's say I have an action that optionally accepts two parameters: def foo(name: String, age: Integer) = Action { // name & age can both be null if not passed } How do I setup my route file to work with any of the following call syntaxes: /foo /foo?name=john /foo?age=18 /foo?name=john&age=18 /foo?authCode=bar&name=john&age=18 // The controller may have other implicit parameters What is the correct syntax for this? 回答1: Something like this should work: GET /foo controllers.MyController.foo

Custom JodaTime serializer using Play Framework's JSON library?

北城余情 提交于 2019-11-30 12:21:06
问题 How do I implement a custom JodaTime's DateTime serializer/deserializer for JSON? I'm inclined to use the Play Framework's JSON library (2.1.1). There is a default DateTime serializer, but it uses dt.getMillis instead of .toString which would return an ISO compliant String. Writing Reads[T] amd Writes[T] for case classes seems fairly straightforward, but I can't figure out how to do the same for DateTime. 回答1: I use Play 2.3.7 and define in companion object implicit reads/writes with string

Connect “computer-database-jpa” Play 2.1 sample application with MySQL

安稳与你 提交于 2019-11-30 10:02:07
I'm playing with computer-database-jpa (Java) Play Framework 2.1 sample application. Everything works fine when I'm using H2 in memory database but I had problems when I want to connect the application with MySQL. Some one had the same problem ( Help wanted getting sample app connected to MySQL ) but there was no solution. I've added mysql-connector (Build.scala): val appDependencies = Seq( .... "mysql" % "mysql-connector-java" % "5.1.18" ) and edited application.conf: db.default.url="jdbc:mysql://password:user@localhost/my-database" db.default.driver=com.mysql.jdbc.Driver When I start the

Play 2.1 SSL Configuration

独自空忆成欢 提交于 2019-11-30 09:37:52
I'm new to Play and in the process of configuring SSL for production. I can successfully run in dev mode with a self signed certificate, but when I try to use a signed certificate the initial client handshake fails and Play generates the following stack trace: play - Error loading HTTPS keystore from conf/keystore.jks java.security.NoSuchAlgorithmException: RSA KeyManagerFactory not available at sun.security.jca.GetInstance.getInstance(GetInstance.java:159) ~[na:1.7.0_11] at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:139) ~[na:1.7.0_11] at play.core.server.NettyServer

Handling freeform GET URL parameters in Play 2 routing

牧云@^-^@ 提交于 2019-11-30 05:14:24
Let's say I have an action that optionally accepts two parameters: def foo(name: String, age: Integer) = Action { // name & age can both be null if not passed } How do I setup my route file to work with any of the following call syntaxes: /foo /foo?name=john /foo?age=18 /foo?name=john&age=18 /foo?authCode=bar&name=john&age=18 // The controller may have other implicit parameters What is the correct syntax for this? Something like this should work: GET /foo controllers.MyController.foo(name: String ?= "", age: Int ?= 0) Since your parameters can be left off you need to provide default values for

Play 2.1 Json serialization for traits?

荒凉一梦 提交于 2019-11-30 05:10:24
I have this: package models import play.api.libs.json._ import play.api.libs.functional.syntax._ object ModelWrites { implicit val tmoWrites= Json.writes[TestModelObject] implicit val ihWrites = Json.writes[IntHolder] } case class TestModelObject(s1:String, s2:String) case class IntHolder(i1:Int, i2:Int) trait HasInts { val ints: List[IntHolder] } When I do this: scala> val tmo = new TestModelObject("hello", "world") with HasInts { val ints = List(IntHolder(1,2), IntHolder(3,4)) } scala> Json.toJson(tmo) res0: play.api.libs.json.JsValue = {"s1":"hello","s2":"world"} how can I implicity

Ebean ManyToMany query

╄→гoц情女王★ 提交于 2019-11-30 03:46:19
问题 I have two classes, user and car. Both have ManyToMany mapping to each other. User: @Entity public class User extends Model { private int year; @ManyToMany(cascade=CascadeType.ALL) private List<Car> cars; } Car: @Entity public class Car extends Model { @ManyToMany(mappedBy = "cars", cascade=CascadeType.ALL ) private List<User> users; } Using ebean, I would like to query only those cars from year 1999 that have give user in their list. I do not want to iterate over the user's car list in Java