playframework

proper way of writing FunctionalTest in playframework

徘徊边缘 提交于 2020-01-24 14:40:07
问题 While writing FunctionalTest for a webapp based on play1.2.4,I was a little confused as to how to code it properly.The confusion is regarding the transaction boundary involved.I read somewhere that each test has its own transaction. In my app,a User can login and add some items to the cart.Then he can give an Address sothat the items can be sent to him. I created private helper methods like below private Cart buyItemsAsCustomer(String email,String pass) { User user = User.find("byEmail",

Anorm Mysql Stored Procedure calling

烈酒焚心 提交于 2020-01-24 13:20:06
问题 This is my simple stored procedure , DELIMITER $$ USE `TestDB`$$ DROP PROCEDURE IF EXISTS `test123`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `test123`(id INT(11) , user_name VARCHAR(15), branch VARCHAR(15)) BEGIN INSERT INTO Testlog(id,user_name,branch) VALUES(id,user_name,branch); END$$ DELIMITER ; i can run above stored procedure with below command in mysql CALL `TestDB`.test123(3,"swap","desc") but using anorm how to do that?? DB.withConnection { implicit c => SQL("EXCE test123 {id},

Anorm Mysql Stored Procedure calling

若如初见. 提交于 2020-01-24 13:20:01
问题 This is my simple stored procedure , DELIMITER $$ USE `TestDB`$$ DROP PROCEDURE IF EXISTS `test123`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `test123`(id INT(11) , user_name VARCHAR(15), branch VARCHAR(15)) BEGIN INSERT INTO Testlog(id,user_name,branch) VALUES(id,user_name,branch); END$$ DELIMITER ; i can run above stored procedure with below command in mysql CALL `TestDB`.test123(3,"swap","desc") but using anorm how to do that?? DB.withConnection { implicit c => SQL("EXCE test123 {id},

How can I access request in Play Guice Module?

十年热恋 提交于 2020-01-24 09:10:08
问题 I am writing an application which handles multiple systems. The user can choose the system which he wants to work with and I store that system ID in session (client session) Now I have Service classes, lets say CustomerService. class CustomerService(val systemID: String) { // Implementation } I want to use Guice to inject the Customer instance to the Controllers. But I want to instantiate the CustomerService with SystemID which is stored in the session. How can I access request.session in

How can I access request in Play Guice Module?

瘦欲@ 提交于 2020-01-24 09:10:06
问题 I am writing an application which handles multiple systems. The user can choose the system which he wants to work with and I store that system ID in session (client session) Now I have Service classes, lets say CustomerService. class CustomerService(val systemID: String) { // Implementation } I want to use Guice to inject the Customer instance to the Controllers. But I want to instantiate the CustomerService with SystemID which is stored in the session. How can I access request.session in

SQLException: Timed out waiting for a free available connection

匆匆过客 提交于 2020-01-24 03:09:43
问题 I'm building an app in java with Play Framework 2.0.4 . The app is deployed in heroku with cleardb database. Users keep getting this occasional error: PlayException: Execution exception [[PersistenceException: java.sql.SQLException: Timed out waiting for a free available connection.]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) at akka.actor.Actor$class.apply(Actor.scala:318) at play.core

Parse JSON Array in Scala

前提是你 提交于 2020-01-23 18:00:17
问题 I have this jsArray (json Array) and I am using import play.api.libs.json._ library. [{”device”:”Samsung S8”,”android”:true}, {”device”:”iPhone 8”,”android”:false}, {”device”:”MacBook Air Pro”,”android”:false}, {”device”:”Dell XPS”,”android”:false}] I want to traverse through this json array in Scala. This array is assigned to var dependency . I want to get the device names which are android. How do I do that? 回答1: You can try something like this: val jsonString: String = "[{\"device\":\

EhCache instance with name 'play' already exists

时光总嘲笑我的痴心妄想 提交于 2020-01-23 12:34:10
问题 I faced the issue with the Play framework default cache ( EHCache ) when working with asynchronous couchdatabase java driver. Play crashes on the hot reload with the error: Error in custom provider, play.api.cache.EhCacheExistsException: An EhCache instance with name 'play' already exists. I found this could be not only with the couchdatabase driver but also in some other scenarios, like https://groups.google.com/forum/#!topic/pac4j-dev/2_EUOCrov7M. 回答1: I figure out a solution - force cache

Routing overloaded functions in Play Framework 2.0

落花浮王杯 提交于 2020-01-23 08:35:14
问题 In Play, when overloading controller methods, those individual methods cant be routed more than once cause the complier doesn't like it. Is there a possible way to get around this? Say if I had two functions in my Product controller: getBy(String name) and getBy(long id) . And I had two different routes for these functions declared in routes : GET /p/:id controllers.Product.getBy(id: Long) GET /p/:name controllers.Product.getBy(name: String) I want to use the "same" function for different

Neo4j cypher to count and display all the relationship between two given nodes

筅森魡賤 提交于 2020-01-23 07:57:43
问题 Here I am using neo4j rest api, in first step I want to collect information like how many relationships are there between two given nodes. Sample : MATCH (n:Node {id: {parameter1}})-[r:someType]-(m:Node {id: {parameter2}}) RETURN COUNT(r) Then I would like to collect all the values assigned to the edges so I can calculate further calculations. I need all the different types of relationships and their properties between two given nodes. If it is possible I would like to do it in single cypher.