You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have implemented an extension of SpringDataMongodbQuery which in turn is used by QueryDSL that fires afterLoad and afterConvert events to the ApplicationContext
public CtvSpringDataMongodbQuery(final ApplicationEventPublisher eventPublisher, final MongoOperations operations, final Class<? extends T> type) {
this(eventPublisher, operations, type, operations.getCollectionName(type));
}
public CtvSpringDataMongodbQuery(final ApplicationEventPublisher eventPublisher, final MongoOperations operations, final Class<? extends T> type, String collectionName) {
super(operations.getCollection(collectionName), new Function<DBObject, T>() {
public T apply(DBObject input) {
eventPublisher.publishEvent(new AfterLoadEvent<T>(input, (Class<T>)type));
T read = operations.getConverter().read(type, input);
eventPublisher.publishEvent(new AfterConvertEvent<T>(input, read));
return read;
}
}, new CtvSpringDataMongodbSerializer(operations.getConverter()));
this.operations = operations;
}
I think that it would be quite useful to trigger lifecycle events in all cases, actually I think that QueryDSL is the missing part in all the work done in this area
Issue Links:
DATAMONGO-1848 Migrate to Document API-based Querydsl implementation
("depends on")
DATAMONGO-700 Events not triggered during Querydsl repository usage
Now that MongoRepositoryFactoryBean needs to be modified (https://jira.spring.io/browse/DATAMONGO-1566) because of changes done in RepositoryFactoryBeanSupport (https://jira.spring.io/browse/DATACMNS-891) maybe it's a good moment to consider this issue, in my opinion the only way to resolve it is by changing MongoRepositoryFactoryBean signature
They are not related but both need changes into MongoRepositoryFactoryBean, a factory class responsible for creating Spring Data Mongo repositories, changes into such an important class are done from time to time, in major releases preferably.
In the context of this issue in the PR done I proposed changing MongoRepositoryFactoryBean signature in order to implement ApplicationContextAware, and use the received context as an ApplicationEventPublisher.
So I was wondering that maybe now is the right moment to consider/fix this issue, given that MongoRepositoryFactoryBean has already been modified because of DATAMONGO-1566
Resolved via DATAMONGO-1848. We now use MongoTemplate for query execution and result mapping thoughout our Querydsl support. Therfore events are published the very same way they are when using the template directly
Jordi Llach Fernandez opened DATAMONGO-1185 and commented
As far as I know and remember interface auto-generated methods,
@Query
methods, ... and in fact all the rest end up usingMongoTemplate
.As described in http://docs.spring.io/spring-data/data-mongo/docs/1.6.2.RELEASE/reference/html/#mongodb.mapping-usage.events lifecycle events work when using
MongoTemplate
but they do no work when using QueryDSL because it does not useMongoTemplate
We have implemented an extension of
SpringDataMongodbQuery
which in turn is used by QueryDSL that fires afterLoad and afterConvert events to theApplicationContext
I think that it would be quite useful to trigger lifecycle events in all cases, actually I think that QueryDSL is the missing part in all the work done in this area
Issue Links:
("depends on")
Referenced from: pull request #324
1 votes, 3 watchers
The text was updated successfully, but these errors were encountered: