playframework-2.0

What data type does ebean map to BYTEA?

蓝咒 提交于 2020-01-14 14:49:11
问题 I have a Play! 2.0.2 application that needs to store some files in the database. we are using Ebean for our ORM. I believe I need a BYTEA column in my database to store the file, but I'm not sure what data type to use in my model. Should I be using some kind of Blob ? Or just a byte[] ? Or is there another data type I should be using? Thanks! 回答1: To create blob with Ebean you need to use byte array with @Lob annotation @Lob public byte[] image; You'll need to convert between File <-> byte

playframework - how to automatically increment evolutions

核能气质少年 提交于 2020-01-14 03:50:10
问题 So I'm using playframework 2.0 and my application is ready for release. as I have been developing I have noticed that: conf\evolutions\default\1.sql has been automatically changing each time I add/modify my model layer. As I am about to release my application I was wondering how do I set this to start adding it to 2.sql instead of 1? I would like to tag/branch the revision so that if I need to upgrade my release in the future the system will notice that it has 1.sql installed so it will only

Wrong sql script generated for sqlite database by ebean in the Play framework

孤街醉人 提交于 2020-01-14 03:45:08
问题 I am using the play framework 2.1 and using the evolution to automatically generate sql scripts for me. The database I use is sqlite3. It seems the evolution can't generate correct script for sqlite3. The incorrect script I got is: create table algorithm ( id bigint AUTOINCREMENT primary key, name varchar(255), description varchar(255)) ; I am new to sqlite3. By searching online I realized that: autoincrement can only works with Integer autoincrement should be placed after primary key So

serialize list<object> with manytoone & onetomany relational to json

雨燕双飞 提交于 2020-01-14 03:24:06
问题 I have class Menu, it's a self to self with manytoone and onetomany relational. package models; import java.util.*; import javax.persistence.*; import play.db.ebean.*; import play.data.format.*; import play.data.validation.*; import static play.data.validation.Constraints.*; import javax.validation.*; import org.codehaus.jackson.annotate.JsonBackReference; import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonManagedReference; import com.avaje.ebean.*;

Scala Spec2 Mockito: Argument matchers with complex types

泪湿孤枕 提交于 2020-01-13 23:29:34
问题 I'm trying to write a mock for a web service with Mockito. The mock should simulate a POST request using the play WS library. /** * Mock for the Web Service */ case class WSMock() extends Mockito { val wsRequestHolder: play.api.libs.ws.WS.WSRequestHolder = mock[play.api.libs.ws.WS.WSRequestHolder] val wsResponse: play.api.libs.ws.Response = mock[play.api.libs.ws.Response] wsResponse.status returns 200 wsResponse.body returns "BODY RESP FROM WS" val futureResponse = scala.concurrent.Future {

Play Framework: Async vs Sync performance

一曲冷凌霜 提交于 2020-01-13 19:20:28
问题 I have following code: def sync = Action { val t0 = System.nanoTime() Thread.sleep(100) val t1 = System.nanoTime() Ok("Elapsed time: " + (t1 - t0) / 1000000.0 + "ms") } def async = Action { val t0 = System.nanoTime() Async { Future{ Thread.sleep(100) val t1 = System.nanoTime() Ok("Elapsed time: " + (t1 - t0) / 1000000.0 + "ms") } } } Difference among above code is that sync will sleep on the thread that received request and async will sleep on the separate thread so that thread in charge of

Deploy a Play 2.0.2 application on Heroku

烂漫一生 提交于 2020-01-13 14:00:06
问题 I'm trying to deploy a fresh new application on Heroku. It was made using Play! framework 2.0.2. I followed all the steps of this page: https://github.com/playframework/Play20/wiki/ProductionHeroku But when I deployed it, got the following error > -----> Heroku receiving push -----> Play! app detected -----> WARNING: Play! version not specified in dependencies.yml. Default versio : 1.2.4 being used.... -----> Installing Play! 1.2.4..... -----> done -----> Installing ivysettings.xml..... done

unresolved dependency for postgresql 9.2 jar in play framework

爱⌒轻易说出口 提交于 2020-01-13 08:19:31
问题 I am using postgresql 9.2 with play framework 2.1 I downloaded the driver here: http://jdbc.postgresql.org/download.html (JDBC4 Postgresql Driver, Version 9.2-1002) My project/Build.scala file is as follows: import sbt._ import Keys._ import play.Project._ object ApplicationBuild extends Build { val appName = "myApp" val appVersion = "0.1" val appDependencies = Seq( "postgresql" % "postgresql" % "9.2-1002.jdbc4") val main = play.Project(appName, appVersion, appDependencies) } I have placed

Upload Files directly to S3 chunk-by-chunk using Play Scala using Iteratees

雨燕双飞 提交于 2020-01-13 06:05:13
问题 I have tried in vain to upload files directly to s3 using Iteratees. I am still new to functional programming, and finding it hard to piece together some working code. I have written an iteratee which process chunks of the uploaded file and sends them to S3. The upload fails at the end with an error. Please help me fix this. Below is the code I came up with Controller Handler def uploadFile = Action.async(BodyParser(rh => S3UploadHelper("bucket-name").s3Iteratee() )) { implicit request =>

Play framework 2.0 Form.bindFromRequest().get() returns empty model

 ̄綄美尐妖づ 提交于 2020-01-13 05:39:18
问题 I need to receive same POST data from a socket communication. This is the code that send the POST and receive the response, and seems to work correctly: String data = "t=" + URLEncoder.encode("Title", "UTF-8") + "&u=" + URLEncoder.encode("http://www.myurl.com", "UTF-8"); URL url = new URL("http://localhost:9000/adserver"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush();