logo

PlayFramework 2.x support

PlayFramework 2.x support

This project source code is available on github at https://github.com/deanhiller/playorm.

PlayOrm now includes support for playframework 2.1 in similar way as it supported playframework 1.2.x

The properties you need for in-memory version in your application.conf file are the following:

nosql.nosqltype=inmemory
#nosql.nosqltype=cassandra
#nosql.cassandra.clusterName=TestCluster
#nosql.cassandra.keyspace=databus5
#nosql.cassandra.seeds="a:9160,b:9160,c:9160"

You can use cassandra by simply removing the nosql.nosqltype=inmemory and removing all the # above and it will work with cassandra.

Enabling the plugin

To enable the plugin:
1. Build the project using ‘gradlew build’.
2. Make sure the above properties are added in your application.conf
3. Your playorm.jar should be in project/lib folder
4. Also, copy src/resources/play2plugin/plugin2.1.jar to your project/lib directory
5. In your project/conf directory add a file called play.plugins with the following content

5000:com.alvazan.play2.Play2Plugin

6. Please note that this is supported for Play 2.10. If you are using Play 2.0.x, then upgrade it to Play 2.10 else open an issue to get an old plugin
7. Playorm.jar comes with a default plugin for Play1.0. So it has a dependency on Play1.2.5.jar. Please make sure that you remove that jar related to Play1.x from your classpath or project’s ‘lib’ folder otherwise it will cause issues
8. Scala users must add “javaCore” to appDependencies
9. You may also want to add “com.alvazan” % “playorm” % “1.5″ to appDependencies to download all the playorm’s dependency else copy all the jar from output/jardist/*.jar to your project/lib folder

Disabling the plugin
Enter following line into application.conf

playormplugin=disabled

Use the plugin

1. Import “com.alvazan.play.NoSql” class in your code and use the static method em() to get the NoSqlEntityManager. i.e, just use NoSql.em() to get the NoSqlEntityManager. You don’t need to instantiate ManagerFactory etc as the plugin does it for you.
2. Do remember to add a blank nosql.Persistence.java class in the same jar(or folder structure) where you have your model classes.
3. You can use different configurations for development, QA and production by adding below properties.  (Change mode to qa or prod).

application.mode=dev
%prod.nosql.nosqltype=cassandra
%prod.nosql.cassandra.clusterName=ProjectCluster
%prod.nosql.cassandra.seeds=a1:9160,a2:9160,a3:9160,a4:9160,a5:9160,a6:9160,a7:9160,a8:9160,a9:9160,a10:9160,a12:9160
%qa.nosql.nosqltype=cassandra
%qa.nosql.cassandra.clusterName=QACluster
%qa.nosql.cassandra.seeds=sdi-prod-01:9160,sdi-prod-02:9160,sdi-prod-03:9160,sdi-prod-04:9160

Example project

If you are facing some issues, you can see an example given at https://github.com/easility/play2pluginexample which shows the plugin’s usage with Play2.1.0.

You can use our in-memory database for development and use either Cassandra or Mongodb for Production.

<< Back to Documentation Index