org.mongodb.morphia.Key Java Examples
The following examples show how to use
org.mongodb.morphia.Key.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JenkinsEmbeddedMapper.java From DotCi with MIT License | 6 votes |
@Override public void fromDBObject(final DBObject dbObject, final MappedField mf, final Object entity, final EntityCache cache, final Mapper mapper) { final Key key = extractKey(mapper, mf, (DBObject) dbObject.get(mf.getNameToStore())); if (key != null && cache.getEntity(key) != null) { final Object object = cache.getEntity(key); mf.setFieldValue(entity, object); } else if (this.customMappers.containsKey(mf.getType())) { this.customMappers.get(mf.getType()).fromDBObject(dbObject, mf, entity, cache, mapper); } else if (isAwkwardMap(mf)) { this.awkwardMapper.fromDBObject(dbObject, mf, entity, cache, mapper); } else { // the first two conditions (isMap and isMultipleValues) are part of the hack to fix handling primitives if (mf.isMap()) { readMap(dbObject, mf, entity, cache, mapper); } else if (mf.isMultipleValues()) { readCollection(dbObject, mf, entity, cache, mapper); } else { mapper.getOptions().getEmbeddedMapper().fromDBObject(dbObject, mf, entity, cache, mapper); } this.serializationMethodInvoker.callReadResolve(mf.getFieldValue(entity)); } }
Example #2
Source File: JenkinsEmbeddedMapper.java From DotCi with MIT License | 5 votes |
private Key extractKey(final Mapper mapper, final MappedField mf, final DBObject dbObject) { if (mapper == null || mf == null || dbObject == null || (dbObject instanceof BasicDBList)) return null; final ObjectId objectId = (ObjectId) dbObject.get(mapper.ID_KEY); //HACKY GET RID OF SOON final Object obj = mapper.getOptions().getObjectFactory().createInstance(mapper, mf, dbObject); if (objectId == null || obj == null) return null; return new Key(obj.getClass(), objectId); }
Example #3
Source File: MongoBaseService.java From game-server with MIT License | 4 votes |
public Key<T> save(T entity) { return baseDao.save(entity); }
Example #4
Source File: TaskRepository.java From katharsis-framework with Apache License 2.0 | 4 votes |
public <S extends Task> S save(S entity) { Key<Task> saveKey = (Key<Task>) datastore.save(entity); return (S) datastore.getByKey(Task.class, saveKey); }
Example #5
Source File: TaskRepository.java From katharsis-framework with Apache License 2.0 | 4 votes |
public Task findOne(ObjectId id, QueryParams requestParams) { return datastore.getByKey(Task.class, new Key<>(Task.class, id)); }
Example #6
Source File: ProjectRepository.java From katharsis-framework with Apache License 2.0 | 4 votes |
public <S extends Project> S save(S entity) { Key<Project> saveKey = (Key<Project>) datastore.save(entity); return (S) datastore.getByKey(Project.class, saveKey); }
Example #7
Source File: ProjectRepository.java From katharsis-framework with Apache License 2.0 | 4 votes |
public Project findOne(ObjectId id, QueryParams requestParams) { return datastore.getByKey(Project.class, new Key<>(Project.class, id)); }
Example #8
Source File: MongoTemplate.java From light-task-scheduler with Apache License 2.0 | 4 votes |
public <T> Key<T> save(final String collName, final T entity) { return ds.save(getCollName(collName), entity); }
Example #9
Source File: MongoTemplate.java From light-task-scheduler with Apache License 2.0 | 4 votes |
public <T> Key<T> save(final T entity) { return save(null, entity); }