private String getCollectionName(PersistentEntity persistentEntity, DBObject nativeEntry) { String collectionName; if (persistentEntity.isRoot()) { MongoSession mongoSession = (MongoSession) getSession(); collectionName = mongoSession.getCollectionName(persistentEntity); } else { MongoSession mongoSession = (MongoSession) getSession(); collectionName = mongoSession.getCollectionName(persistentEntity.getRootEntity()); } return collectionName; }
@Override protected PersistentEntity discriminatePersistentEntity( PersistentEntity persistentEntity, DBObject nativeEntry) { final Object o = nativeEntry.get(MONGO_CLASS_FIELD); if (o != null) { final String className = o.toString(); final PersistentEntity childEntity = getMappingContext() .getChildEntityByDiscriminator(persistentEntity.getRootEntity(), className); if (childEntity != null) { return childEntity; } } return super.discriminatePersistentEntity(persistentEntity, nativeEntry); }