|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.mongodb.core.convert.AbstractMongoConverter org.springframework.data.mongodb.core.convert.MappingMongoConverter
public class MappingMongoConverter
MongoConverter
that uses a MappingContext
to do sophisticated mapping of domain objects to
DBObject
.
Field Summary | |
---|---|
protected org.springframework.context.ApplicationContext |
applicationContext
|
protected QueryMapper |
idMapper
|
protected static org.apache.commons.logging.Log |
log
|
protected org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> |
mappingContext
|
protected MongoDbFactory |
mongoDbFactory
|
protected org.springframework.expression.spel.standard.SpelExpressionParser |
spelExpressionParser
|
protected MongoTypeMapper |
typeMapper
|
protected boolean |
useFieldAccessOnly
|
Fields inherited from class org.springframework.data.mongodb.core.convert.AbstractMongoConverter |
---|
conversions, conversionService |
Constructor Summary | |
---|---|
MappingMongoConverter(MongoDbFactory mongoDbFactory,
org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext)
Creates a new MappingMongoConverter given the new MongoDbFactory and MappingContext . |
Method Summary | ||
---|---|---|
protected void |
addCustomTypeKeyIfNecessary(org.springframework.data.util.TypeInformation<?> type,
Object value,
com.mongodb.DBObject dbObject)
Adds custom type information to the given DBObject if necessary. |
|
Object |
convertToMongoType(Object obj)
Converts the given object into one Mongo will be able to store natively. |
|
protected com.mongodb.DBObject |
createCollection(Collection<?> collection,
MongoPersistentProperty property)
Writes the given Collection using the given MongoPersistentProperty information. |
|
protected com.mongodb.DBRef |
createDBRef(Object target,
DBRef dbref)
|
|
org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> |
getMappingContext()
|
|
protected Object |
getValueInternal(MongoPersistentProperty prop,
com.mongodb.DBObject dbo,
org.springframework.expression.spel.support.StandardEvaluationContext ctx,
String spelExpr)
|
|
com.mongodb.BasicDBList |
maybeConvertList(Iterable<?> source)
|
|
|
read(Class<S> clazz,
com.mongodb.DBObject dbo)
|
|
protected
|
read(org.springframework.data.util.TypeInformation<S> type,
com.mongodb.DBObject dbo)
|
|
protected Map<Object,Object> |
readMap(org.springframework.data.util.TypeInformation<?> type,
com.mongodb.DBObject dbObject)
Reads the given DBObject into a Map . |
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
|
|
void |
setTypeMapper(MongoTypeMapper typeMapper)
Configures the MongoTypeMapper to be used to add type information to DBObject s created by the
converter and how to lookup type information from DBObject s when reading them. |
|
void |
setUseFieldAccessOnly(boolean useFieldAccessOnly)
Configures whether to use field access only for entity mapping. |
|
protected
|
unwrapList(com.mongodb.BasicDBList dbList,
org.springframework.data.util.TypeInformation<T> targetType)
|
|
void |
write(Object obj,
com.mongodb.DBObject dbo)
Root entry method into write conversion. |
|
protected void |
writeInternal(Object obj,
com.mongodb.DBObject dbo,
MongoPersistentEntity<?> entity)
|
|
protected void |
writeInternal(Object obj,
com.mongodb.DBObject dbo,
org.springframework.data.util.TypeInformation<?> typeHint)
Internal write conversion method which should be used for nested invocations. |
|
protected com.mongodb.DBObject |
writeMapInternal(Map<Object,Object> obj,
com.mongodb.DBObject dbo,
org.springframework.data.util.TypeInformation<?> propertyType)
Writes the given Map to the given DBObject considering the given TypeInformation . |
|
protected void |
writePropertyInternal(Object obj,
com.mongodb.DBObject dbo,
MongoPersistentProperty prop)
|
Methods inherited from class org.springframework.data.mongodb.core.convert.AbstractMongoConverter |
---|
afterPropertiesSet, getConversionService, setCustomConversions |
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 org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext
protected final org.springframework.expression.spel.standard.SpelExpressionParser spelExpressionParser
protected final MongoDbFactory mongoDbFactory
protected final QueryMapper idMapper
protected org.springframework.context.ApplicationContext applicationContext
protected boolean useFieldAccessOnly
protected MongoTypeMapper typeMapper
Constructor Detail |
---|
public MappingMongoConverter(MongoDbFactory mongoDbFactory, org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext)
MappingMongoConverter
given the new MongoDbFactory
and MappingContext
.
mongoDbFactory
- must not be null.mappingContext
- must not be null.Method Detail |
---|
public void setTypeMapper(MongoTypeMapper typeMapper)
MongoTypeMapper
to be used to add type information to DBObject
s created by the
converter and how to lookup type information from DBObject
s when reading them. Uses a
DefaultMongoTypeMapper
by default. Setting this to null will reset the TypeMapper
to the
default one.
typeMapper
- the typeMapper to setpublic org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> getMappingContext()
getMappingContext
in interface org.springframework.data.convert.EntityConverter<MongoPersistentEntity<?>,MongoPersistentProperty,Object,com.mongodb.DBObject>
public void setUseFieldAccessOnly(boolean useFieldAccessOnly)
MongoConverter
to not go through getters or setters even if they are present for getting and setting
property values.
useFieldAccessOnly
- public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public <S> S read(Class<S> clazz, com.mongodb.DBObject dbo)
read
in interface org.springframework.data.convert.EntityReader<Object,com.mongodb.DBObject>
protected <S> S read(org.springframework.data.util.TypeInformation<S> type, com.mongodb.DBObject dbo)
public void write(Object obj, com.mongodb.DBObject dbo)
DBObject
. Shouldn't be called for
nested conversions.
write
in interface org.springframework.data.convert.EntityWriter<Object,com.mongodb.DBObject>
org.springframework.data.mongodb.core.core.convert.MongoWriter#write(java.lang.Object, com.mongodb.DBObject)
protected void writeInternal(Object obj, com.mongodb.DBObject dbo, org.springframework.data.util.TypeInformation<?> typeHint)
obj
- dbo
- protected void writeInternal(Object obj, com.mongodb.DBObject dbo, MongoPersistentEntity<?> entity)
protected void writePropertyInternal(Object obj, com.mongodb.DBObject dbo, MongoPersistentProperty prop)
protected com.mongodb.DBObject createCollection(Collection<?> collection, MongoPersistentProperty property)
Collection
using the given MongoPersistentProperty
information.
collection
- must not be null.property
- must not be null.
protected com.mongodb.DBObject writeMapInternal(Map<Object,Object> obj, com.mongodb.DBObject dbo, org.springframework.data.util.TypeInformation<?> propertyType)
Map
to the given DBObject
considering the given TypeInformation
.
obj
- must not be null.dbo
- must not be null.propertyType
- must not be null.
protected void addCustomTypeKeyIfNecessary(org.springframework.data.util.TypeInformation<?> type, Object value, com.mongodb.DBObject dbObject)
DBObject
if necessary. That is if the value is not the same as
the one given. This is usually the case if you store a subtype of the actual declared type of the property.
type
- value
- must not be null.dbObject
- must not be null.protected com.mongodb.DBRef createDBRef(Object target, DBRef dbref)
protected Object getValueInternal(MongoPersistentProperty prop, com.mongodb.DBObject dbo, org.springframework.expression.spel.support.StandardEvaluationContext ctx, String spelExpr)
protected Map<Object,Object> readMap(org.springframework.data.util.TypeInformation<?> type, com.mongodb.DBObject dbObject)
DBObject
into a Map
. will recursively resolve nested Map
s as well.
type
- the Map
TypeInformation
to be used to unmarshall this DBObject
.dbObject
-
protected <T> List<?> unwrapList(com.mongodb.BasicDBList dbList, org.springframework.data.util.TypeInformation<T> targetType)
public Object convertToMongoType(Object obj)
MongoWriter
convertToMongoType
in interface MongoWriter<Object>
public com.mongodb.BasicDBList maybeConvertList(Iterable<?> source)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |