code: public <E> E insert(E entity) {
      try {
        entityManager.executeEntityListeners(CallbackType.PRE_INSERT, entity);
        FullEntity<?> nativeEntity = (FullEntity<?>) Marshaller.marshal(entityManager, entity,
            Intent.INSERT);
        Entity insertedNativeEntity = nativeWriter.add(nativeEntity);
        @SuppressWarnings("unchecked")
        E insertedEntity = (E) Unmarshaller.unmarshal(insertedNativeEntity, entity.getClass());
        entityManager.executeEntityListeners(CallbackType.POST_INSERT, insertedEntity);
        return insertedEntity;
      } catch (DatastoreException exp) {
        throw DatastoreUtils.wrap(exp);
      }
    }
docs: Inserts the given entity into the Cloud Datastore.
  
  @param entity
  the entity to insert
  @return the inserted entity. The inserted entity will not be same as the passed in entity. For
  example, the inserted entity may contain any generated ID, key, parent key, etc.
  @throws EntityManagerException
  if any error occurs while inserting.