Look at the code snippet below:

// entity class

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ChildEnt {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
//    @Extension(vendorName="datanucleus", key="gae.encoded-
pk",value="true")
    private Key encodedKey;

    private String info;

        public Key getEncodedKey() {
                return encodedKey;
        }

        public void setEncodedKey(Key encodedKey) {
                this.encodedKey = encodedKey;
        }

        public String getInfo() {
                return info;
        }

        public void setInfo(String info) {
                this.info = info;
        }
}

// transaction code

        PersistenceManager pm = PMF.get().getPersistenceManager();

        Key parkey = KeyFactory.createKey("Parent","P01");

        ChildEnt e1 = new ChildEnt();
        ChildEnt e2 = new ChildEnt();
        ChildEnt e3 = new ChildEnt();
        Key k1 = KeyFactory.createKey(parkey,ChildEnt.class.getSimpleName(),
1);
        Key k2 = KeyFactory.createKey(parkey,ChildEnt.class.getSimpleName(),
2);
        Key k3 = KeyFactory.createKey(parkey,ChildEnt.class.getSimpleName(),
3);
        e1.setEncodedKey(k1);
        e1.setInfo("info1");
        e2.setEncodedKey(k2);
        e2.setInfo("info2");
        e3.setEncodedKey(k3);
        e3.setInfo("info3");
        pm.currentTransaction().begin();
        pm.makePersistent(e1);
        pm.makePersistent(e2);
        pm.makePersistent(e3);
        pm.currentTransaction().commit();
        pm.close();
--~--~---------~--~----~------------~-------~--~----~
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-java@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to