Created
April 8, 2011 14:20
-
-
Save scompt/909935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers; | |
import play.*; | |
import play.mvc.*; | |
import java.util.*; | |
import models.*; | |
import jobs.*; | |
public class Application extends Controller { | |
public static void index() { | |
Blah blah = new Blah(); | |
blah.name = "woo"; | |
blah.save(); | |
blah.em().flush(); // with or without, same result | |
// Works, but then I have to reload all of my entities | |
// JPAPlugin.closeTx(false); JPAPlugin.startTx(false); | |
// | |
// blah.name = "woo2"; | |
// blah.save(); | |
new DumbJob(blah.id).now(); | |
new DumbJob(blah.id).in(5); | |
render(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
import play.db.jpa.Model; | |
import javax.persistence.*; | |
@Entity | |
public class Blah extends Model { | |
public String name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jobs; | |
import play.jobs.Job; | |
import models.Blah; | |
public class DumbJob extends Job { | |
private long id; | |
public DumbJob(long id) { | |
this.id = id; | |
} | |
@Override | |
public void doJob() { | |
System.out.println("ID: " + id); | |
System.out.println("Found: " + Blah.findById(id)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16:18:54,361 INFO ~ Application 'tester' is now started ! | |
ID: 7 | |
Found: null | |
ID: 7 | |
Found: Blah[7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment