Then source code it is: Source for the involved class:
package elemental.data; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; import com.google.appengine.api.datastore.Key; import java.util.Random; import elemental.support.PMF; @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Base { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key id; @Persistent private Integer server; @Persistent private Key userId; @Persistent private Integer size; @Persistent private String name; @Persistent private Date lastAction; @Persistent private Date lastResourceUpdate; @Persistent private double stone; @Persistent private Integer location; @Persistent private Integer currentBuild = -1; @Persistent private Date currentBuildDone = new Date(); @Override public String toString() { return "Base [buildings=" + buildings + ", crystal=" + crystal + ", food=" + food + ", id=" + id + ", lastAction=" + lastAction + ", lastResourceUpdate=" + lastResourceUpdate + ", location=" + location + ", name=" + name + ", size=" + size + ", stone=" + stone + ", userId=" + userId + ", wood=" + wood + "]"; } @Persistent private double food; @Persistent private double crystal; @Persistent private double wood; @Persistent(serialized = "true") private List<Integer> buildings = new ArrayList<Integer>(); @SuppressWarnings("unchecked") public Base(String name, Key userId, Integer size, Integer server, Integer location) { this.name = name; this.userId = userId; this.size = size; this.wood = 500; this.stone = 500; this.food = 100; this.lastResourceUpdate = new Date(); this.setServer(server); PersistenceManager pm = PMF.get().getPersistenceManager(); List<Base> o = null; if (location < 0) { Random r = new Random(); do { location = 20000 * r.nextInt(50) + 400 * r.nextInt(40) + r.nextInt(10); Query q = pm.newQuery(Base.class, "location == locationParam && server == serverParam"); q .declareParameters("Integer locationParam, Integer serverParam"); o = (List<Base>) q.execute(location, server); } while (o.size() > 0); } Query q = pm.newQuery(Technology.class,"type == 1"); List<Technology> buildings = (List<Technology>) q.execute(); if(!buildings.isEmpty()) { for(Technology b : buildings) this.buildings.add(b.getIdNo(), 0); } this.location = location; this.lastAction = new Date(); } public void setId(Key id) { this.id = id; } public Key getId() { return id; } public void setUserId(Key userId) { this.userId = userId; } public Key getUserId() { return userId; } public void setSize(Integer size) { this.size = size; } public Integer getSize() { return size; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setLastAction() { this.lastAction = new Date(); this.doResourceUpdate(); } public Date getLastAction() { return lastAction; } public void setStone(double stone) { this.stone = stone; } public double getStone() { return stone; } public void setFood(double food) { this.food = food; } public double getFood() { return food; } public void setCrystals(double crystals) { this.crystal = crystals; } public double getCrystals() { return crystal; } public void setBuildings(Integer i, Integer l) { this.buildings.set(i, l); } public Integer getBuildings(Integer i) { return buildings.get(i); } public void setWood(double wood) { this.wood = wood; } public double getWood() { return wood; } public void setLastResourceUpdate(Date lastResourceUpdate) { this.lastResourceUpdate = new Date(); } public Date getLastResourceUpdate() { return lastResourceUpdate; } public void setLocation(Integer location) { this.location = location; } public void setLocation(Integer[] location) { this.location = 20000 * location[0] + 400 * location[1] + location [2]; } public Integer getLocation() { return location; } public Integer[] getLocationArray() { Integer[] o = new Integer[3]; o[0] = this.location / 20000; o[1] = (this.location % 20000) / 400; o[2] = (this.location % 20000) % 400; return o; } public String getLocationDisplay() { String o = ""; Integer[] l = this.getLocationArray(); o = (l[0] + 1) + ":" + (l[1] + 1) + ":" + (l[2]+1); return o; } public void setServer(Integer server) { this.server = server; } public Integer getServer() { return server; } public void doResourceUpdate() { Long lastUpdate = this.lastResourceUpdate.getTime(); Long current = java.lang.System.currentTimeMillis(); Long elapsed = (current - lastUpdate); // Don't update more than once every five seconds if(elapsed < 5000) return; Double t = elapsed.doubleValue(); double partialHour = t / (60*60*1000); double partialDay = partialHour / 24; // Daily decay of food this.food = this.food * Math.pow(0.9,partialDay); // Stone Double stoneMine = (double) this.buildings.get(0); this.stone += partialHour*(20 + 20*(Math.pow(1.3, stoneMine) - 1)); // Wood Double lumberCamp = (double) this.buildings.get(1); this.wood += partialHour*(10+ 20*(Math.pow(1.2, lumberCamp) - 1)); // Food Double farm = (double) this.buildings.get(2); this.food += 15*(Math.pow(1.2, farm)-1) * partialHour; this.setLastResourceUpdate(new Date()); } public void setCurrentBuildDone(Date currentBuildDone) { this.currentBuildDone = currentBuildDone; } public Date getCurrentBuildDone() { return currentBuildDone; } public void setCurrentBuild(Integer currentBuild) { this.currentBuild = currentBuild; } public Integer getCurrentBuild() { return currentBuild; } } List<Integer> buildings is not saved, the rest is. On Jan 19, 5:09 pm, Raphael André Bauer <raphael.andre.ba...@gmail.com> wrote: > On Tue, Jan 19, 2010 at 4:55 PM, Bert Peters <bert.ljpet...@gmail.com> wrote: > > Alright, here we go. > > Somewhere in execution, 2 dates, 4 double fields and an integer list > > are updated to new values. During checkup in the rest of the program, > > everything seems OK. > > Then, upon finish, at pm.close(), all updated variables are saved, > > except for the integer list. Enough information? > > Not really.. source code is always better... > > Did you already look into default fetch groups? > (@Persistent(defaultFetchGroup = "true"). > > I guess your list is simply not fetched by default and your integer > list is null... > > Raphael > > > > > On Jan 19, 2:22 pm, John Patterson <jdpatter...@gmail.com> wrote: > >> On 19 Jan 2010, at 19:43, Bert Peters wrote: > > >> > A class, handled by some other > >> > class, saves only partial updates. > > >> I think you'll need to give a bit more context. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google App Engine for Java" group. > > To post to this group, send email to google-appengine-j...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-appengine-java+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/google-appengine-java?hl=en.
-- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.