List of usage examples for org.springframework.jdbc.core BeanPropertyRowMapper BeanPropertyRowMapper
public BeanPropertyRowMapper(Class<T> mappedClass)
From source file:edu.uca.aca2016.impulse.repository.UsersDAO.java
/** *getUsersByUsername method and SQL Query * @param username/*from w w w. ja v a2 s . co m*/ * @return */ public Users getUsersbyUsername(String username) { logger.info(username); String sql = "SELECT * FROM users WHERE username = ?"; return template.queryForObject(sql, new Object[] { username }, new BeanPropertyRowMapper<Users>(Users.class)); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsUserWriterTest.java
@Test public void test() throws Exception { final Operation op = sequenceOf( insertInto("mantis_project_table").columns("id", "name").values(1, "project_1").build(), insertInto("mantis_user_table").columns("id", "name").values(1, "old_user_1").build(), insertInto("mantis_project_user_list_table").columns("user_id", "project_id").values(1, 1).build()); lauchOperation(op);/*from ww w. j a v a 2 s . c om*/ projectUsersWriter.write(buildItems()); final List<AccountData> results = getJdbcTemplate() .query("SELECT usr.id, usr.name" + " FROM mantis_user_table usr" + " INNER JOIN mantis_project_user_list_table pul ON pul.user_id = usr.id" + " WHERE pul.project_id = 1", new BeanPropertyRowMapper<AccountData>(AccountData.class)); assertEquals(2, results.size()); for (final AccountData item : results) { if (item.getId() == BigInteger.ONE) { assertEquals("new_user_1", item.getName()); } else { assertEquals(BigInteger.valueOf(2), item.getId()); assertEquals("new_user_2", item.getName()); } } }
From source file:edu.uca.aca2016.impulse.repository.ClientDAO.java
/** *getClientById method and SQL Query//from w ww.ja v a 2 s . c o m * @param id * @return */ public Client getClientById(int id) { String sql = "SELECT * FROM Client WHERE ClientId = ?"; return template.queryForObject(sql, new Object[] { id }, new BeanPropertyRowMapper<Client>(Client.class)); }
From source file:konditer_reorganized_database.dao.CakeDao.java
@Override public Cake getCake(int cakeId) { String SQL_QUERY = "SELECT CAKE_ID, CUSTOMER_ID, CAKE_PRICE, ORDER_ID, " + "CAKE_NAME, CAKE_WEIGHT, CAKE_PHOTO_MINI, CAKE_PHOTO_MAXI, " + "CAKE_KEYWORDS, CAKE_STATUS, TIMESTAMP " + "FROM cakes " + "WHERE CAKE_ID = ?"; Cake cake = (Cake) jdbcTemplate.queryForObject(SQL_QUERY, new Object[] { cakeId }, new BeanPropertyRowMapper(Cake.class)); return cake;// w w w. jav a 2s .c o m }
From source file:mylife.respository.client1DAO.java
/** * * @param id//w w w .j a v a 2 s.c om * @return */ public client1 getclient1ById(int id) { String sql = "SELECT idclient1, firstname, lastname, addressline1, addressline2, city, state, zip, email, currentstatus, phone_number FROM client1 WHERE idclient1 = ?"; return template.queryForObject(sql, new Object[] { id }, new BeanPropertyRowMapper<client1>(client1.class)); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsCategoriesWriterTest.java
/** * Get the items from the database//from w ww. j a v a2 s . c o m * * @param tableName * Name of the target table * @return items in the DB */ private List<ProjectCategoryBean> getItemsFromDb() { return getJdbcTemplate().query("SELECT id, name, project_id FROM mantis_category_table", new BeanPropertyRowMapper<ProjectCategoryBean>(ProjectCategoryBean.class)); }
From source file:net.noday.d4c.dao.SubdomainDao.java
public List<Subdomain> findPage(Subdomain condition, int pIndex, int pSize) { StringBuffer sql = new StringBuffer("select * from domain d where 1=1"); SqlParameterSource ps = null;//from w w w .j av a2 s. c o m if (condition != null) { ps = new BeanPropertySqlParameterSource(condition); sql.append(toConditionSql(condition)); } sql.append(" order by d.regist_time desc").append(" limit ").append((pIndex - 1) * pSize).append(",") .append(pSize); List<Subdomain> list = namedJdbc.query(sql.toString(), ps, new BeanPropertyRowMapper<Subdomain>(Subdomain.class)); return list; }
From source file:mylife.respository.userDAO.java
/** * * @param username//from www .ja v a 2 s. com * @return */ public user getUsersbyUsername(String username) { String sql = "SELECT * FROM users WHERE username = ?"; return template.queryForObject(sql, new Object[] { username }, new BeanPropertyRowMapper<user>(user.class)); }
From source file:net.noday.core.dao.AppDao.java
public App getAppConfig() { List<String> tables = jdbc.queryForList("show tables", String.class); Connection conn = DataSourceUtils.getConnection(jdbc.getDataSource()); try {/*from ww w .j a va2 s . com*/ conn.setAutoCommit(false); if (tables == null || tables.size() == 0 || !tables.contains("app_config")) { initDB(); } else { String version = jdbc.queryForObject("select a.version from app_config a limit 1", String.class); if (!"1.1".equalsIgnoreCase(version)) { updateDB("1_1"); } } conn.commit(); } catch (DataAccessException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } String sql = "select * from app_config limit 1"; App cfg = jdbc.queryForObject(sql, new BeanPropertyRowMapper<App>(App.class)); if (cfg == null) { throw new AppStartupException("??"); } return cfg; }