Explorar el Código

Update World entities individually.

Donovan Muller hace 10 años
padre
commit
58dba85c99

+ 8 - 1
frameworks/Java/play2-java/play2-java-ebean-bonecp/app/models/World.java

@@ -6,7 +6,9 @@ import play.db.ebean.Model;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 @Entity
 public class World extends Model {
@@ -22,7 +24,12 @@ public class World extends Model {
     );
 
     public static List<World> save(final List<World> worlds) throws Throwable {
-        Ebean.save(worlds);
+        Set<String> updateProperties = new HashSet<>();
+        updateProperties.add("randomNumber");
+
+        for (World world : worlds) {
+            Ebean.update(world, updateProperties);
+        }
 
         return worlds;
     }

+ 8 - 1
frameworks/Java/play2-java/play2-java-ebean-hikaricp/app/models/World.java

@@ -6,7 +6,9 @@ import play.db.ebean.Model;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 @Entity
 public class World extends Model {
@@ -22,7 +24,12 @@ public class World extends Model {
     );
 
     public static List<World> save(final List<World> worlds) throws Throwable {
-        Ebean.save(worlds);
+        Set<String> updateProperties = new HashSet<>();
+        updateProperties.add("randomNumber");
+
+        for (World world : worlds) {
+            Ebean.update(world, updateProperties);
+        }
 
         return worlds;
     }