Results 1 to 3 of 3

Thread: MongoDB Lifecycle events not being initialized

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Posts
    116

    Default 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);
    }
    Last edited by bjornharvold; Jun 22nd, 2011 at 01:03 PM.

  2. #2
    Join Date
    Jul 2008
    Posts
    116

  3. #3
    Join Date
    Jul 2008
    Posts
    116

    Default

    It does work if I do not implement my own Repository but instead use <mongo:repositories base-package="com.xxxx.repository"/>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •