how to add new row to already existing entity

日本語

/file/how to add new row to already existing entity/anr.png

Tidder
name diff html row

Tidder
name date diff html row
google datastore deals every records as if complete homogeneous. but actually every record is independent

Trying to add new attribute

It won't work. Those instance's Class Definition are already finalized and not re-movable.

        final PersistenceManager pm = PMF.get().getPersistenceManager();
        final javax.jdo.Query que = pm.newQuery("SELECT FROM " + Tidder.class.getName());
        final List<Tidder> list = (List<Tidder>) que.execute();
        for (final Tidder t : list)
        {
        	t.setDate(new Date());
        }
        pm.makePersistentAll(list);
        pm.flush();

Create new instance with new definition. grant reference to the newly created instance, abandon old entity.

This only works fine

        final List<Tidder> list = (List<Tidder>) que.execute();
        for (final Tidder t : list)
        {
        	Tidder t_new = new Tidder(t.name(), t.raw(), t.diff(), new Date());
        	t_new.key(t.key());
        	pm.makePersistent(t_new);
        }
        pm.flush();
    last modified: 11 July 2011 [ View wiki source Close ]
     
SEARCH DIFFERENCE ATTACHMENT RECENT POST