-
Jun 22nd, 2011, 12:57 PM
#1
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.
-
Jun 22nd, 2011, 12:59 PM
#2
-
Jun 22nd, 2011, 08:57 PM
#3
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
-
Forum Rules