/** * Creates a {@link MongoMappingContext} equipped with entity classes scanned from the mapping base package. * * @see #getMappingBasePackages() * @return * @throws ClassNotFoundException */ @Bean public MongoMappingContext mongoMappingContext() throws ClassNotFoundException { MongoMappingContext mappingContext = new MongoMappingContext(); mappingContext.setInitialEntitySet(getInitialEntitySet()); mappingContext.setSimpleTypeHolder(customConversions().getSimpleTypeHolder()); mappingContext.setFieldNamingStrategy(fieldNamingStrategy()); mappingContext.setAutoIndexCreation(autoIndexCreation()); return mappingContext; }
/** * Creates a {@link MongoMappingContext} equipped with entity classes scanned from the mapping base package. * * @see #getMappingBasePackages() * @return * @throws ClassNotFoundException */ @Bean public MongoMappingContext mongoMappingContext() throws ClassNotFoundException { MongoMappingContext mappingContext = new MongoMappingContext(); mappingContext.setInitialEntitySet(getInitialEntitySet()); mappingContext.setSimpleTypeHolder(customConversions().getSimpleTypeHolder()); mappingContext.setFieldNamingStrategy(fieldNamingStrategy()); return mappingContext; }
/** * Helper method to create the underlying collection/list. * * @param collection the collection to write. * @param prop the property information. * @return the created couchbase list. */ private CouchbaseList createCollection(final Collection<?> collection, final CouchbasePersistentProperty prop) { return writeCollectionInternal(collection, new CouchbaseList(conversions.getSimpleTypeHolder()), prop.getTypeInformation()); }
/** * Helper method to create the underlying collection/list. * * @param collection the collection to write. * @param prop the property information. * @return the created couchbase list. */ private CouchbaseList createCollection(final Collection<?> collection, final CouchbasePersistentProperty prop) { return writeCollectionInternal(collection, new CouchbaseList(conversions.getSimpleTypeHolder()), prop.getTypeInformation()); }
@Bean default ArangoMappingContext arangoMappingContext() throws Exception { final ArangoMappingContext context = new ArangoMappingContext(); context.setInitialEntitySet(getInitialEntitySet()); context.setFieldNamingStrategy(fieldNamingStrategy()); context.setSimpleTypeHolder(customConversions().getSimpleTypeHolder()); return context; }
@Bean default ArangoMappingContext arangoMappingContext() throws Exception { final ArangoMappingContext context = new ArangoMappingContext(); context.setInitialEntitySet(getInitialEntitySet()); context.setFieldNamingStrategy(fieldNamingStrategy()); context.setSimpleTypeHolder(customConversions().getSimpleTypeHolder()); return context; }
/** * Creates a {@link CouchbaseMappingContext} equipped with entity classes scanned from the mapping base package. * * @throws Exception on Bean construction failure. */ @Bean(name = BeanNames.COUCHBASE_MAPPING_CONTEXT) public CouchbaseMappingContext couchbaseMappingContext() throws Exception { CouchbaseMappingContext mappingContext = new CouchbaseMappingContext(); mappingContext.setInitialEntitySet(getInitialEntitySet()); mappingContext.setSimpleTypeHolder(customConversions().getSimpleTypeHolder()); mappingContext.setFieldNamingStrategy(fieldNamingStrategy()); return mappingContext; }
/** * Creates a {@link CouchbaseMappingContext} equipped with entity classes scanned from the mapping base package. * * @throws Exception on Bean construction failure. */ @Bean(name = BeanNames.COUCHBASE_MAPPING_CONTEXT) public CouchbaseMappingContext couchbaseMappingContext() throws Exception { CouchbaseMappingContext mappingContext = new CouchbaseMappingContext(); mappingContext.setInitialEntitySet(getInitialEntitySet()); mappingContext.setSimpleTypeHolder(customConversions().getSimpleTypeHolder()); mappingContext.setFieldNamingStrategy(fieldNamingStrategy()); return mappingContext; }
writeSimpleInternal(val, target, simpleKey); } else if (val instanceof Collection || val.getClass().isArray()) { target.put(simpleKey, writeCollectionInternal(asCollection(val), new CouchbaseList(conversions.getSimpleTypeHolder()), type.getMapValueType())); } else { CouchbaseDocument embeddedDoc = new CouchbaseDocument();
writeSimpleInternal(val, target, simpleKey); } else if (val instanceof Collection || val.getClass().isArray()) { target.put(simpleKey, writeCollectionInternal(asCollection(val), new CouchbaseList(conversions.getSimpleTypeHolder()), type.getMapValueType())); } else { CouchbaseDocument embeddedDoc = new CouchbaseDocument();
/** * Return the {@link MappingContext} instance to map Entities to properties. * * @throws ClassNotFoundException if the Cassandra Entity class type identified by name cannot be found during the * scan. * @see CassandraMappingContext */ @Bean public CassandraMappingContext cassandraMapping() throws ClassNotFoundException { Cluster cluster = getRequiredCluster(); CassandraMappingContext mappingContext = new CassandraMappingContext( new SimpleUserTypeResolver(cluster, getKeyspaceName()), new SimpleTupleTypeFactory(cluster)); Optional.ofNullable(this.beanClassLoader).ifPresent(mappingContext::setBeanClassLoader); mappingContext.setInitialEntitySet(getInitialEntitySet()); CustomConversions customConversions = customConversions(); mappingContext.setCustomConversions(customConversions); mappingContext.setSimpleTypeHolder(customConversions.getSimpleTypeHolder()); return mappingContext; }
/** * Helper method to write the internal collection. * * @param source the source object. * @param target the target document. * @param type the type information for the document. * @return the created couchbase list. */ private CouchbaseList writeCollectionInternal(final Collection<?> source, final CouchbaseList target, final TypeInformation<?> type) { TypeInformation<?> componentType = type == null ? null : type.getComponentType(); for (Object element : source) { Class<?> elementType = element == null ? null : element.getClass(); if (elementType == null || conversions.isSimpleType(elementType)) { target.put(getPotentiallyConvertedSimpleWrite(element)); } else if (element instanceof Collection || elementType.isArray()) { target.put(writeCollectionInternal(asCollection(element), new CouchbaseList(conversions.getSimpleTypeHolder()), componentType)); } else { CouchbaseDocument embeddedDoc = new CouchbaseDocument(); writeInternal(element, embeddedDoc, componentType); target.put(embeddedDoc); } } return target; }
/** * Helper method to write the internal collection. * * @param source the source object. * @param target the target document. * @param type the type information for the document. * @return the created couchbase list. */ private CouchbaseList writeCollectionInternal(final Collection<?> source, final CouchbaseList target, final TypeInformation<?> type) { TypeInformation<?> componentType = type == null ? null : type.getComponentType(); for (Object element : source) { Class<?> elementType = element == null ? null : element.getClass(); if (elementType == null || conversions.isSimpleType(elementType)) { target.put(getPotentiallyConvertedSimpleWrite(element)); } else if (element instanceof Collection || elementType.isArray()) { target.put(writeCollectionInternal(asCollection(element), new CouchbaseList(conversions.getSimpleTypeHolder()), componentType)); } else { CouchbaseDocument embeddedDoc = new CouchbaseDocument(); writeInternal(element, embeddedDoc, componentType); target.put(embeddedDoc); } } return target; }