Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JOOQ Play 2.1 Module
# JOOQ Play 2.3 Module

This project provides a very simple Play plugin that will invoke the JOOQ generation for a database.
The plugin will be invoked on startup of a Play app but will not be executed in Prod mode.
Expand Down
4 changes: 2 additions & 2 deletions project-code/app/org/jooq/play/JooqPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import play.core._
import play.api._

import db.{DBApi, DBPlugin}
import play.api.mvc.{SimpleResult, RequestHeader}
import play.api.mvc.{Result, RequestHeader}
import java.io.File
import org.jooq.util.GenerationTool
import org.jooq.util.jaxb.{Target, Database, Generator}
Expand Down Expand Up @@ -43,7 +43,7 @@ class JooqPlugin(val app: Application) extends Plugin with HandleWebCommandSuppo
}
}

def handleWebCommand(request: RequestHeader, sbtLink: SBTLink, path: File): Option[SimpleResult] = {
def handleWebCommand(request: RequestHeader, sbtLink: BuildLink, path: File): Option[Result] = {

val applyGeneration = """/@jooq/generate""".r

Expand Down
16 changes: 16 additions & 0 deletions project-code/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name := """play-jooq"""

version := "1.0-SNAPSHOT"

organization := "org.jooq"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.2"

libraryDependencies ++= Seq(
javaJdbc,
"org.jooq" % "jooq" % "3.4.2",
"org.jooq" % "jooq-meta" % "3.4.2",
"org.jooq" % "jooq-codegen" % "3.4.2"
)
27 changes: 0 additions & 27 deletions project-code/project/Build.scala

This file was deleted.

2 changes: 1 addition & 1 deletion project-code/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.0
sbt.version=0.13.5
2 changes: 1 addition & 1 deletion project-code/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ logLevel := Level.Warn
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.4")
6 changes: 3 additions & 3 deletions samples/play-jooq-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ It's using Guice to inject the correct implementation of a helper that executes

To run the h2 version simple do:

> play
> activator
[play-jooq-sample] $ run

To run the mysql version you can either run it in Dev mode with the following:

> play
> activator
[play-jooq-sample] $ run -Dconfig.file=conf/application.mysql.conf

Or run it in Production mode with

> play
> activator
[play-jooq-sample] $ start -Dconfig.file=conf/application.mysql.conf
10 changes: 8 additions & 2 deletions samples/play-jooq-sample/app/controllers/Application.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
package controllers;

import models.task.Task;
import models.task.TaskHelper;
import play.mvc.Controller;
import play.mvc.Result;
import scala.collection.JavaConverters;
import views.html.index;

import javax.inject.Inject;
import java.util.List;

import static play.data.Form.form;
import static play.data.Form.*;

public class Application extends Controller {

@Inject
TaskHelper taskHelper;

public Result index() {
return ok(index.render(taskHelper.getAll()));
List<Task> tasks = taskHelper.getAll();
scala.collection.immutable.List<Task> convertedTasks =
JavaConverters.asScalaBufferConverter(tasks).asScala().toList();
return ok(index.render(convertedTasks));
}

public Result createTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import org.jooq.ConnectionProvider;
import org.jooq.exception.DataAccessException;
import play.Logger;
import play.db.DB;
import play.api.Play;
import play.api.db.DB;

import java.sql.Connection;
import java.sql.SQLException;
Expand All @@ -20,7 +21,7 @@ public class PlayConnectionProvider implements ConnectionProvider {
@Override
public Connection acquire() throws DataAccessException {
if (connection == null) {
connection = DB.getConnection();
connection = DB.getConnection("default", true, Play.current());
}
return connection;
}
Expand Down
2 changes: 1 addition & 1 deletion samples/play-jooq-sample/app/models/generated/h2/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* A class modelling foreign key relationships between tables of the <code>PUBLIC</code>
* schema
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Keys {
Expand Down
6 changes: 3 additions & 3 deletions samples/play-jooq-sample/app/models/generated/h2/Public.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Public extends org.jooq.impl.SchemaImpl {

private static final long serialVersionUID = 706109300;
private static final long serialVersionUID = 385647136;

/**
* The singleton instance of <code>PUBLIC</code>
Expand All @@ -34,7 +34,7 @@ public final java.util.List<org.jooq.Sequence<?>> getSequences() {

private final java.util.List<org.jooq.Sequence<?>> getSequences0() {
return java.util.Arrays.<org.jooq.Sequence<?>>asList(
models.generated.h2.Sequences.SYSTEM_SEQUENCE_481007AC_A7F8_4495_A921_F5321346FC31);
models.generated.h2.Sequences.SYSTEM_SEQUENCE_70298E0C_BC7D_4C45_9454_2511C6EE3F0D);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
*
* Convenience access to all sequences in PUBLIC
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Sequences {

/**
* The sequence <code>PUBLIC.SYSTEM_SEQUENCE_481007AC_A7F8_4495_A921_F5321346FC31</code>
* The sequence <code>PUBLIC.SYSTEM_SEQUENCE_70298E0C_BC7D_4C45_9454_2511C6EE3F0D</code>
*/
public static final org.jooq.Sequence<java.lang.Long> SYSTEM_SEQUENCE_481007AC_A7F8_4495_A921_F5321346FC31 = new org.jooq.impl.SequenceImpl<java.lang.Long>("SYSTEM_SEQUENCE_481007AC_A7F8_4495_A921_F5321346FC31", models.generated.h2.Public.PUBLIC, org.jooq.impl.SQLDataType.BIGINT);
public static final org.jooq.Sequence<java.lang.Long> SYSTEM_SEQUENCE_70298E0C_BC7D_4C45_9454_2511C6EE3F0D = new org.jooq.impl.SequenceImpl<java.lang.Long>("SYSTEM_SEQUENCE_70298E0C_BC7D_4C45_9454_2511C6EE3F0D", models.generated.h2.Public.PUBLIC, org.jooq.impl.SQLDataType.BIGINT);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* Convenience access to all tables in PUBLIC
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Tables {
Expand Down
33 changes: 24 additions & 9 deletions samples/play-jooq-sample/app/models/generated/h2/tables/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Task extends org.jooq.impl.TableImpl<models.generated.h2.tables.records.TaskRecord> {

private static final long serialVersionUID = 915945629;
private static final long serialVersionUID = 170638844;

/**
* The singleton instance of <code>PUBLIC.TASK</code>
Expand All @@ -27,27 +27,35 @@ public java.lang.Class<models.generated.h2.tables.records.TaskRecord> getRecordT
}

/**
* The column <code>PUBLIC.TASK.ID</code>.
* The column <code>PUBLIC.TASK.ID</code>.
*/
public final org.jooq.TableField<models.generated.h2.tables.records.TaskRecord, java.lang.Long> ID = createField("ID", org.jooq.impl.SQLDataType.BIGINT, this);
public final org.jooq.TableField<models.generated.h2.tables.records.TaskRecord, java.lang.Long> ID = createField("ID", org.jooq.impl.SQLDataType.BIGINT.nullable(false).defaulted(true), this, "");

/**
* The column <code>PUBLIC.TASK.LABEL</code>.
* The column <code>PUBLIC.TASK.LABEL</code>.
*/
public final org.jooq.TableField<models.generated.h2.tables.records.TaskRecord, java.lang.String> LABEL = createField("LABEL", org.jooq.impl.SQLDataType.VARCHAR.length(255), this);
public final org.jooq.TableField<models.generated.h2.tables.records.TaskRecord, java.lang.String> LABEL = createField("LABEL", org.jooq.impl.SQLDataType.VARCHAR.length(255).defaulted(true), this, "");

/**
* Create a <code>PUBLIC.TASK</code> table reference
*/
public Task() {
super("TASK", models.generated.h2.Public.PUBLIC);
this("TASK", null);
}

/**
* Create an aliased <code>PUBLIC.TASK</code> table reference
*/
public Task(java.lang.String alias) {
super(alias, models.generated.h2.Public.PUBLIC, models.generated.h2.tables.Task.TASK);
this(alias, models.generated.h2.tables.Task.TASK);
}

private Task(java.lang.String alias, org.jooq.Table<models.generated.h2.tables.records.TaskRecord> aliased) {
this(alias, aliased, null);
}

private Task(java.lang.String alias, org.jooq.Table<models.generated.h2.tables.records.TaskRecord> aliased, org.jooq.Field<?>[] parameters) {
super(alias, models.generated.h2.Public.PUBLIC, aliased, parameters, "");
}

/**
Expand Down Expand Up @@ -79,6 +87,13 @@ public java.util.List<org.jooq.UniqueKey<models.generated.h2.tables.records.Task
*/
@Override
public models.generated.h2.tables.Task as(java.lang.String alias) {
return new models.generated.h2.tables.Task(alias);
return new models.generated.h2.tables.Task(alias, this);
}

/**
* Rename this table
*/
public models.generated.h2.tables.Task rename(java.lang.String name) {
return new models.generated.h2.tables.Task(name, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TaskRecord extends org.jooq.impl.UpdatableRecordImpl<models.generated.h2.tables.records.TaskRecord> implements org.jooq.Record2<java.lang.Long, java.lang.String> {

private static final long serialVersionUID = 1025693091;
private static final long serialVersionUID = -96768823;

/**
* Setter for <code>PUBLIC.TASK.ID</code>.
* Setter for <code>PUBLIC.TASK.ID</code>.
*/
public void setId(java.lang.Long value) {
setValue(0, value);
}

/**
* Getter for <code>PUBLIC.TASK.ID</code>.
* Getter for <code>PUBLIC.TASK.ID</code>.
*/
public java.lang.Long getId() {
return (java.lang.Long) getValue(0);
}

/**
* Setter for <code>PUBLIC.TASK.LABEL</code>.
* Setter for <code>PUBLIC.TASK.LABEL</code>.
*/
public void setLabel(java.lang.String value) {
setValue(1, value);
}

/**
* Getter for <code>PUBLIC.TASK.LABEL</code>.
* Getter for <code>PUBLIC.TASK.LABEL</code>.
*/
public java.lang.String getLabel() {
return (java.lang.String) getValue(1);
Expand Down Expand Up @@ -105,6 +105,32 @@ public java.lang.String value2() {
return getLabel();
}

/**
* {@inheritDoc}
*/
@Override
public TaskRecord value1(java.lang.Long value) {
setId(value);
return this;
}

/**
* {@inheritDoc}
*/
@Override
public TaskRecord value2(java.lang.String value) {
setLabel(value);
return this;
}

/**
* {@inheritDoc}
*/
@Override
public TaskRecord values(java.lang.Long value1, java.lang.String value2) {
return this;
}

// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
Expand All @@ -115,4 +141,14 @@ public java.lang.String value2() {
public TaskRecord() {
super(models.generated.h2.tables.Task.TASK);
}

/**
* Create a detached, initialised TaskRecord
*/
public TaskRecord(java.lang.Long id, java.lang.String label) {
super(models.generated.h2.tables.Task.TASK);

setValue(0, id);
setValue(1, label);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* A class modelling foreign key relationships between tables of the <code>tasks</code>
* schema
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Keys {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* Convenience access to all tables in tasks
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.1.0" },
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Tables {
Expand Down
Loading