MongoDB Lifecycle events not being initialized
After I register:
<bean class="com.xxx.event.OnAfterConvertUserEventListen er"/>
I would expect the below method "userRepository.findByUsername" to initiate the aforementioned bean. It doesn't. In the docs, it says that if I use findOne(), it will pick it up.
It does work when I call userRepository.findAll().
@Repository("userRepository")
public class MongoUserRepository extends QueryDslMongoRepository<User, String> implements UserRepository {
QUser user = QUser.user;
@Autowired
public MongoUserRepository(MongoTemplate mongoTemplate) {
super(new MappingMongoEntityInformation<User, String>(
new BasicMongoPersistentEntity<User>(
new ClassTypeInformation<User>(User.class))
), mongoTemplate
);
}
@Override
public User findByUsername(String username) {
return findOne(user.username.eq(username));
}
}
Interface:
public interface UserRepository extends PagingAndSortingRepository<User, String>, QueryDslPredicateExecutor<User> {
User findByUsername(String username);
}