Skip to content

Simple CRUD & DAO implementation for play2 - this fork is heavily modified from the play2-crud project to use Spring and Spring Data JPA instead of Guice and Ebean

License

Notifications You must be signed in to change notification settings

eljaydub/play2-crud

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

play2-crud - Spring and Spring Data JPA

Join the chat at https://gitter.im/hakandilek/play2-crud

This play2-crud fork has been refactored to use Spring and Spring Data JPA instead of Guice and Ebean. You will need to modify at least the GlobalCRUDSpring and ClasspathScanningModelRegistry to make this sub-project work inside your own Play2-Spring project. Also note that I have replaced generic references to <K, M> to <M, K extends Serializable> in order to be consistent with Spring Data JPA conventions. At the very least I hope it is useful to you as an example.

Powerful CRUD & DAO implementation with REST interface for play framework 2.x

For the Typesafe Activator check play2-crud-activator.

Some screenshots

  • index page crud-index page

  • create page create page

  • list page list page

Quick Start

Follow these steps to use play2-crud. You can also use it partially just for DAO or CRUD controllers. If you think any part needs further explanation, please report a new issue.

Add play2-crud dependency

You can begin with adding play2-crud dependency inside build.sbt file.

  • Add app dependency:
    libraryDependencies ++= Seq(
        javaCore, 
        javaJdbc, 
        javaEbean,
        "play2-crud" % "play2-crud_2.10" % "0.7.0" exclude("org.scala-stm", "scala-stm_2.10.0") exclude("com.typesafe.akka", "akka-slf4j_2.10") exclude("com.typesafe.akka", "akka-actor_2.10"),
    )

  • Dependency version is defined for version 0.7.0, but you can use the latest version.

  • Add custom maven repositories:

    resolvers ++= Seq(
      "release repository" at  "http://hakandilek.github.com/maven-repo/releases/",
      "snapshot repository" at "http://hakandilek.github.com/maven-repo/snapshots/"
   )

Associate Global settings

####Direct reference If you don't want to override the play application launcher, you just have to notice to play that the class to use as launcher is now GlobalCRUDSettings. Change the application.global configuration key in the conf/application.conf file, and use play.utils.crud.GlobalCRUDSettings:

...
application.global=play.utils.crud.GlobalCRUDSettings
...

Define routes

# CRUD Controllers
->     /app             play.crud.Routes

# REST API
->     /api             play.rest.Routes

Define model

  • Model class has to implement play.utils.dao.BasicModel with the type parameter indicating the type of the @Id field.
@Entity
public class Sample extends Model implements BasicModel<Long> {

   @Id
   private Long key;

   @Basic
   @Required
   private String name;

   public Long getKey() {
      return key;
   }

   public void setKey(Long key) {
      this.key = key;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }
}
  • Here the Sample model class implements BasicModel<Long> where key field indicated with @Id is Long.

... call http://localhost:9000/app and voila!

Samples

HOW-TO

Here you can find some HOW-TO documents introducing some powerful functionality:

About

Simple CRUD & DAO implementation for play2 - this fork is heavily modified from the play2-crud project to use Spring and Spring Data JPA instead of Guice and Ebean

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 81.1%
  • HTML 13.6%
  • JavaScript 2.8%
  • Scala 1.8%
  • Other 0.7%