|
Spring Data Document | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.document.mongodb.convert.MappingMongoConverter
public class MappingMongoConverter
MongoConverter
that uses a MappingContext
to do sophisticated mapping of domain objects to
DBObject
.
Nested Class Summary | |
---|---|
protected class |
MappingMongoConverter.PersistentPropertyWrapper
|
Field Summary | |
---|---|
protected ApplicationContext |
applicationContext
|
protected GenericConversionService |
conversionService
|
protected Map<Class<?>,Class<?>> |
customTypeMapping
|
protected String |
defaultDatabase
|
protected static org.apache.commons.logging.Log |
log
|
protected org.springframework.data.mapping.model.MappingContext |
mappingContext
|
protected Mongo |
mongo
|
protected SpelExpressionParser |
spelExpressionParser
|
protected boolean |
useFieldAccessOnly
|
Constructor Summary | |
---|---|
MappingMongoConverter(org.springframework.data.mapping.model.MappingContext mappingContext)
Creates a new MappingMongoConverter with the given MappingContext . |
Method Summary | ||
---|---|---|
void |
afterPropertiesSet()
|
|
ObjectId |
convertObjectId(Object id)
Returns the ObjectId instance for the given id. |
|
|
convertObjectId(ObjectId id,
Class<T> targetType)
Converts the given ObjectId to the given target type. |
|
protected DBRef |
createDBRef(Object target,
DBRef dbref)
|
|
protected Class<?> |
findTypeToBeUsed(DBObject dbObject)
Returns the type to be used to convert the DBObject given to. |
|
String |
getDefaultDatabase()
|
|
org.springframework.data.mapping.model.MappingContext |
getMappingContext()
|
|
Mongo |
getMongo()
|
|
protected Object |
getValueInternal(org.springframework.data.mapping.model.PersistentProperty prop,
DBObject dbo,
StandardEvaluationContext ctx,
Value spelExpr)
|
|
boolean |
isUseFieldAccessOnly()
|
|
|
read(Class<S> clazz,
DBObject dbo)
Ready from the native MongoDB DBObject representation to an instance of the class T. |
|
void |
setApplicationContext(ApplicationContext applicationContext)
|
|
void |
setConverters(List<Converter<?,?>> converters)
Add custom Converter or ConverterFactory instances to be used that will take presidence over
metadata driven conversion between of objects to/from DBObject |
|
void |
setDefaultDatabase(String defaultDatabase)
|
|
void |
setMongo(Mongo mongo)
|
|
void |
setUseFieldAccessOnly(boolean useFieldAccessOnly)
|
|
void |
write(Object obj,
DBObject dbo)
Write the given object of type T to the native MongoDB object representation DBObject. |
|
protected void |
write(Object obj,
DBObject dbo,
org.springframework.data.mapping.model.PersistentEntity<?> entity)
|
|
protected void |
writeMapInternal(Map<Object,Object> obj,
DBObject dbo)
|
|
protected void |
writePropertyInternal(org.springframework.data.mapping.model.PersistentProperty prop,
Object obj,
DBObject dbo)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
protected final GenericConversionService conversionService
protected final Map<Class<?>,Class<?>> customTypeMapping
protected final org.springframework.data.mapping.model.MappingContext mappingContext
protected SpelExpressionParser spelExpressionParser
protected ApplicationContext applicationContext
protected boolean useFieldAccessOnly
protected Mongo mongo
protected String defaultDatabase
Constructor Detail |
---|
public MappingMongoConverter(org.springframework.data.mapping.model.MappingContext mappingContext)
MappingMongoConverter
with the given MappingContext
.
mappingContext
- Method Detail |
---|
public void setConverters(List<Converter<?,?>> converters)
Converter
or ConverterFactory
instances to be used that will take presidence over
metadata driven conversion between of objects to/from DBObject
converters
- public org.springframework.data.mapping.model.MappingContext getMappingContext()
public Mongo getMongo()
public void setMongo(Mongo mongo)
public String getDefaultDatabase()
public void setDefaultDatabase(String defaultDatabase)
public boolean isUseFieldAccessOnly()
public void setUseFieldAccessOnly(boolean useFieldAccessOnly)
public <T> T convertObjectId(ObjectId id, Class<T> targetType)
MongoConverter
ObjectId
to the given target type.
convertObjectId
in interface MongoConverter
T
- the actual type to createid
- the source ObjectId
targetType
- the target type to convert the ObjectId
to
public ObjectId convertObjectId(Object id)
MongoConverter
ObjectId
instance for the given id.
convertObjectId
in interface MongoConverter
public <S> S read(Class<S> clazz, DBObject dbo)
MongoReader
DBObject
into it. So in case there's no real valid data inside
DBObject
for the given type, just return an empty instance of the given type.
read
in interface MongoReader<Object>
clazz
- the type of the return valuedbo
- theDBObject
public void write(Object obj, DBObject dbo)
MongoWriter
write
in interface MongoWriter<Object>
obj
- The object to convert to a DBObjectdbo
- The DBObject to use for writing.protected void write(Object obj, DBObject dbo, org.springframework.data.mapping.model.PersistentEntity<?> entity)
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
protected void writePropertyInternal(org.springframework.data.mapping.model.PersistentProperty prop, Object obj, DBObject dbo)
protected void writeMapInternal(Map<Object,Object> obj, DBObject dbo)
protected DBRef createDBRef(Object target, DBRef dbref)
protected Object getValueInternal(org.springframework.data.mapping.model.PersistentProperty prop, DBObject dbo, StandardEvaluationContext ctx, Value spelExpr)
protected Class<?> findTypeToBeUsed(DBObject dbObject)
dbObject
-
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
|
Spring Data Document | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |