Closed derjust closed 4 years ago
I had the same problem although I found a different solution. I manually exposed the existing MappingContext from the DynamoDBRepositoryFactoryBean:
@SuppressWarnings("rawtypes")
@Autowired
private DynamoDBRepositoryFactoryBean dynamoDBRepositoryFactoryBean;
@Bean
public MappingContext<?, ?> getPrivateDynamoDbMappingContext(){
return (MappingContext<?, ?>)FieldUtils.getProtectedFieldValue("mappingContext", dynamoDBRepositoryFactoryBean);
}
Not the best solution either, but it works. (And if the DynamoDBMappingContext changes by any reason later, it will still work.)
Without this - PUT requests won't work to update entities. I think this is a bug in the current implementation and needs adressing. I used the solution from @Selindek to work around it as well.
Hi! Thanks for this project!
I tried to integrate it with spring-data-rest to expose my entities. It worked quite well with minor adoptions:
org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.persistentEntities()
searches forMappingContext
s whereas theDynamoDBMappingContext
is created withnew
inorg.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactoryBean<T, S, ID>
org.socialsignin.spring.data.dynamodb.mapping.DynamoDBMappingContext.hasPersistentEntityFor(Class<?>)
always returns false before a class is manually added.To workaround those two problems, I added to my own
ConfigurationBean
the following code:I can't really judge if that is cleaver because that leads to multiple
DynamoDBContext
s floating around but as they are usually only delegating to another constructor that seems fine to me.Is there a better way to do it? Can this somehow be incorporated into the library itself so that it is out-of-the-box Spring-Boot compatible?
Used versions: