0

I'm trying to use the reactive way of database communication and my expectation was, that when I observe some entity from database, then always when it will change, I'll get update on it. But the stream completes right after the entities are emitted. Now I'm confused, if the spring data implementation works this way, or I made some wrong configuration. My current state is:

Entity

@Table(name = "USERS")
public class UserEntity implements Persistable<Long> {
...
}

DAO:

@Repository
public interface UserDao extends RxJava3CrudRepository<UserEntity, Long> {
}

and repository which uses this DAO:

@Component
public class UserRepository {

  private final UserDao userDao;

  public Flowable<Integer> getUserLoginAttempts() {
    return userDao
        .findAll()
        .map(UserEntity::getLoginAttempts);
  }
}

And the problem is with this Flowable, because it completes direct after items are emitted. My expectation is, that this stream should be active and always when something change in the database, the changed entity will be reemitted. Can someone help me with that?

michalp
  • 83
  • 5

0 Answers0