Skip to content

EmbeddedEntity fields and MemcacheStatsServlet with authentication #8

Open
husayt wants to merge 11 commits intoobjectify:masterfrom
husayt:master
Open

EmbeddedEntity fields and MemcacheStatsServlet with authentication #8
husayt wants to merge 11 commits intoobjectify:masterfrom
husayt:master

Conversation

@husayt
Copy link

@husayt husayt commented Nov 6, 2013

  • Added GAE authentication to MemcacheStatsServlet.java
  • Added support for fields as EmbeddedEntity. WIth this any class implementing IEmbeddedEntity can be used as a field for Entity

With this, the following is possible :

ofy().save().entity(h);

where,

@Entity
 public  class House {
    @Id
    public Long id;
    public String name;
    public Room room;
 }

 public  class Room implements IEmbeddedEntity<Room> {

    public long number;
    public String owner;

    @Override
    public EmbeddedEntity createEmbeddedEntity() {
        final EmbeddedEntity embeddedEntity = new EmbeddedEntity();
        embeddedEntity.setProperty("number", this.number);
        embeddedEntity.setProperty("owner", this.owner);
        return embeddedEntity;
    }

    @Override
    public Room setFieldsFrom(EmbeddedEntity embeddedEntity) {
        number = (Long) embeddedEntity.getProperty("number");
        owner = (String) embeddedEntity.getProperty("owner");
        return this;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants