Code Monkey home page Code Monkey logo

simpleds's Introduction

SimpleDS provides a simple persistence framework for Google AppEngine that gets as little in the way as possible. It is barely a wrapper around Datastore APIs, providing mapping between Entity and Java classes.

You can explore the details about SimpleDS at our presentation for Codemotion 2012.

There is also a demo application on GitHub.

Analytics

Features

  • Supports Guice, Spring or plain Java configuration.
  • Support for embedded classes serialized as properties or in JSON format.
  • ==, <, <=, >, <=, IN, != and left like are supported.
  • Easy transformations between Java Objects and Datastore Entities.
  • Easy support for Cursors.
  • Validations of expected ancestors
  • Transaction support
  • Level 1 and 2 Cache
  • Cacheable queries

Examples

This is a brief comparison between SimpleDS and JPA:

// JPA retrieve by key
Model m1 = entityManager.find(Model.class, key);
Model m2 = entityManager.find(Model.class, key2);

// SimpleDS retrieve by key
Model m1 = entityManager.get(key);
Map<Key, Model> l = entityManager.get(key1, key2);

// JPA persist changes
entityManager.merge(m1);
entityManager.persist(m2);

// SimpleDS persist changes
entityManager.put(m1);
entityManager.put(ImmutableList.of(m1, m2));
Model m3 = new Model();
entityManager.put(parentKey, m3);

// JPA remove
Model m1 = entityManager.find(Model.class, key);
entityManager.remove(m1);

// SimpleDS remove
entityManager.remove(ImmutableList.of(key1, key2, key3));

Queries

// JPA
Query query = entityManager.createQuery(
   "select m from Model m where m.createdAt<=?1 and m.createdBy=?"
);
query.setParameter(1, new Date());
query.setParameter(2, userKey);
return query.getResultList();

// SimpleDS
return entityManager.createQuery(Model.class)
  .lessThan("createdAt", new Date())
  .equal("createdBy", userKey)
  .asList();

// retrieve just keys
return entityManager.createQuery(Model.class)
  .keysOnly()
  .asList();

// with limits
return entityManager.createQuery(Model.class)
  .withOffset(10)
  .withLimit(100)
  .asList();

simpleds's People

Contributors

icoloma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

simpleds's Issues

Remove org.simpleds.bg

The whole background task concept is outdated. This package will be removed for 1.3 with no replacement.

Remove MultivaluedIndex

As experiment it was OK, but the current focus on functional programming and transformation of Collection makes this feature obsolete. It can safely be removed.

CursorList is not being cached

We are caching asList() and asSingleEntity(), but not asCursorList().

Also, the result type should be part of the cache key.

Add SimpleQuery.populateCache()

Imagine the following scenario:

  • Save an entity
  • Immediately redirect to the entity page, but querying for some field that is not the primary key.

Under HRD, this query may be successful or not (for some seconds). A workaround is to populate the contents of a query in the datastore, but this must be done "by hand". The proposed syntax is:

entityManager.createQuery(MyClass.class)
   .equal("foo", "bar")
  .withCacheSeconds(3600)
  .populateCache(Lists.immutableList(key1, key2));

Add support for projected queries

To be able to specify the fields that should be retrieved. This possibility has been there since 1.7.x, and is a much cheaper operation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.