-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update all play2-java benchmark projects (#3061)
- Loading branch information
1 parent
592b326
commit 4401dfb
Showing
46 changed files
with
362 additions
and
599 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,3 @@ test-result | |
server.pid | ||
*.iml | ||
*.eml | ||
|
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
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
37 changes: 0 additions & 37 deletions
37
frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/inject/AppModule.java
This file was deleted.
Oops, something went wrong.
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
33 changes: 25 additions & 8 deletions
33
frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/World.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,47 @@ | ||
package models; | ||
|
||
import com.avaje.ebean.Ebean; | ||
import com.avaje.ebean.Model; | ||
import java.util.List; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import java.util.List; | ||
|
||
import io.ebean.Finder; | ||
import io.ebean.Model; | ||
import io.ebean.Transaction; | ||
|
||
@Entity | ||
public class World extends Model { | ||
|
||
private static final Finder<Long, World> find = new Finder<>(World.class); | ||
|
||
@Id | ||
public Long id; | ||
|
||
@Column(name = "randomNumber") | ||
public Long randomNumber; | ||
|
||
public static World find(Long id) { | ||
return Ebean.find(World.class, id); | ||
public static World find(final Long id) { | ||
return find.byId(id); | ||
} | ||
|
||
public static List<World> save(final List<World> worlds) { | ||
worlds.forEach(Ebean::update); | ||
final int batchSize = 25; | ||
final int batches = ((worlds.size() / batchSize) + 1); | ||
for ( int i = 0 ; i < batches ; ++i ) { | ||
final Transaction transaction = World.db().beginTransaction(); | ||
try { | ||
transaction.setBatchMode(true); | ||
transaction.setBatchSize(batchSize); | ||
for(int j = i * batchSize ; j < Math.min((i + 1) * batchSize, worlds.size()); ++j) { | ||
World.db().update(worlds.get(j), transaction); | ||
} | ||
transaction.commit(); | ||
} finally { | ||
transaction.end(); | ||
} | ||
} | ||
|
||
return worlds; | ||
} | ||
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/DatabaseExecutionContext.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package utils; | ||
|
||
import javax.inject.Inject; | ||
|
||
import akka.actor.ActorSystem; | ||
import play.libs.concurrent.CustomExecutionContext; | ||
|
||
public class DatabaseExecutionContext extends CustomExecutionContext { | ||
|
||
@Inject | ||
public DatabaseExecutionContext(final ActorSystem actorSystem) { | ||
super(actorSystem, "database.dispatcher"); | ||
} | ||
|
||
} |
21 changes: 0 additions & 21 deletions
21
frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Headers.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/utils/Predicate.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.