Package com.nurkiewicz.jdbcrepository.repositories

Examples of com.nurkiewicz.jdbcrepository.repositories.UserRepository


  }

  @Bean
  @Override
  public UserRepository userRepository() {
    return new UserRepository("users");
  }
View Full Code Here


  }

  @Bean
  @Override
  public UserRepository userRepository() {
    return new UserRepository("users");
  }
View Full Code Here

    return new CommentRepository("COMMENTS");
  }

  @Bean
  public UserRepository userRepository() {
    return new UserRepository("USERS");
  }
View Full Code Here

  public void shouldStartRepositoryWithoutSpring() throws Exception {
    //given
    final JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setURL(JDBC_URL);

    final UserRepository userRepository = new UserRepository("users");
    userRepository.setDataSource(dataSource);
    userRepository.setSqlGenerator(new SqlGenerator())//optional

    //when
    final List<User> list = userRepository.findAll();

    //then
    assertThat(list).isEmpty();
  }
View Full Code Here

  public void shouldInsertIntoDatabase() throws Exception {
    //given
    final JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setURL(JDBC_URL);

    final UserRepository userRepository = new UserRepository("users");
    userRepository.setDataSource(dataSource);
    userRepository.setSqlGenerator(new SqlGenerator());

    //and
    final TransactionOperations tx = new TransactionTemplate(
        new DataSourceTransactionManager(dataSource));

    //when
    final List<User> users = tx.execute(new TransactionCallback<List<User>>() {
      @Override
      public List<User> doInTransaction(TransactionStatus status) {
        final User user = new User("john", new Date(), 0, false);
        userRepository.save(user);
        return userRepository.findAll();
      }
    });

    //then
    assertThat(users).hasSize(1);
View Full Code Here

  }

  @Bean
  @Override
  public UserRepository userRepository() {
    return new UserRepository("users");
  }
View Full Code Here

  }

  @Bean
  @Override
  public UserRepository userRepository() {
    return new UserRepository("users");
  }
View Full Code Here

TOP

Related Classes of com.nurkiewicz.jdbcrepository.repositories.UserRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.