List of usage examples for org.springframework.jdbc.core BeanPropertyRowMapper BeanPropertyRowMapper
public BeanPropertyRowMapper(Class<T> mappedClass)
From source file:net.noday.d4c.dao.SubdomainDao.java
public List<Subdomain> findSubdomain(String dnspodDomainId) { String sql = "select * from subdomain where dnspod_domain_id=?"; return jdbc.query(sql, new BeanPropertyRowMapper<Subdomain>(Subdomain.class), dnspodDomainId); }
From source file:konditer_reorganized_database.dao.GenIdDao.java
public int getId(String tableName) throws SQLException { String SQL_QUERY_1 = "SELECT ROW_COUNT FROM cake_portal.gen_id WHERE TABLE_NAME = ?"; String SQL_QUERY_2 = "UPDATE cake_portal.gen_id SET ROW_COUNT = ? WHERE TABLE_NAME = ?"; GenId genId = (GenId) jdbcTemplate.queryForObject(SQL_QUERY_1, new Object[] { tableName }, new BeanPropertyRowMapper(GenId.class)); newId = genId.getRowCount() + 1;/*from www. jav a 2 s . c o m*/ jdbcTemplate.update(SQL_QUERY_2, new Object[] { newId, tableName }, new int[] { Types.INTEGER, Types.VARCHAR }); return newId; }
From source file:CRM.repository.InteractionsDAO.java
public interactions getInteractionsById(int interaction_id) { String sql = "SELECT * from interactions WHERE interaction_id = ?"; return template.queryForObject(sql, new Object[] { interaction_id }, new BeanPropertyRowMapper<interactions>(interactions.class)); }
From source file:net.noday.cat.dao.UserDao.java
public List<User> findPage(User condition, int pIndex, int pSize) { StringBuffer sql = new StringBuffer("select * from user u where 1=1"); SqlParameterSource ps = null;/* w ww . ja v a2s . c om*/ if (condition != null) { ps = new BeanPropertySqlParameterSource(condition); sql.append(toConditionSql(condition)); } sql.append(" order by u.regist_time desc").append(" limit ").append((pIndex - 1) * pSize).append(",") .append(pSize); List<User> list = namedJdbcTemplate.query(sql.toString(), ps, new BeanPropertyRowMapper<User>(User.class)); return list; }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsCustomFieldsWriterTest.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_enum_custom_field_types").columns("id", "name").values(1, "type_1").build(), insertInto("mantis_custom_field_table").columns("id", "name", "type_id").values(1, "old_field_1", 1) .build(),//from w w w . j a va 2s . co m insertInto("mantis_custom_field_project_table").columns("field_id", "project_id").values(1, 1) .build()); lauchOperation(op); projectCustomFieldsWriter.write(buildItems()); final List<ProjectCustomFieldBean> results = getJdbcTemplate().query( "SELECT cf.id, cf.name, cfp.project_id" + " FROM mantis_custom_field_table cf" + " INNER JOIN mantis_custom_field_project_table cfp ON cf.id = cfp.field_id", new BeanPropertyRowMapper<ProjectCustomFieldBean>(ProjectCustomFieldBean.class)); assertEquals(2, results.size()); for (final ProjectCustomFieldBean item : results) { assertEquals(Integer.valueOf(1), item.getProjectId()); if (item.getId() == 1) { assertEquals("new_field_1", item.getName()); } else { assertEquals(Integer.valueOf(2), item.getId()); assertEquals("new_field_2", item.getName()); } } }
From source file:CRM.repository.ClientsDAO.java
public clients getClientById(int client_id) { String sql = "SELECT * FROM clients WHERE client_id = ?"; return template.queryForObject(sql, new Object[] { client_id }, new BeanPropertyRowMapper<clients>(clients.class)); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsVersionsWriterTest.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_project_version_table").columns("id", "version", "project_id") .values(1, "old_version_1", 1).build()); lauchOperation(op);//w w w . j a v a 2 s . c om projectVersionsWriter.write(buildItems()); final List<ProjectVersionData> results = getJdbcTemplate().query( "SELECT id, version as name, project_id" + " FROM mantis_project_version_table" + " WHERE project_id = 1", new BeanPropertyRowMapper<ProjectVersionData>(ProjectVersionData.class)); assertEquals(2, results.size()); for (final ProjectVersionData item : results) { assertEquals(BigInteger.ONE, item.getProject_id()); if (item.getId() == BigInteger.ONE) { assertEquals("new_version_1", item.getName()); } else { assertEquals(BigInteger.valueOf(2), item.getId()); assertEquals("new_version_2", item.getName()); } } }
From source file:au.org.ala.layers.dao.UserDataDAOImpl.java
@Override public Ud_header put(String user_id, String record_type, String description, String metadata, String data_path, String analysis_id) {/*from w ww. j a va 2s . co m*/ String sql_insert = "INSERT INTO ud_header (user_id,record_type,description,metadata,data_path,analysis_id,upload_dt) " + " VALUES (?,?,?,?,?,?,?);"; Date upload_dt = new Date(System.currentTimeMillis()); int rows = jdbcTemplate.update(sql_insert, new Object[] { user_id, record_type, description, metadata, data_path, analysis_id, upload_dt }); if (rows > 0) { String sql_select = "SELECT * FROM ud_header WHERE user_id = ? AND upload_dt = ?"; Ud_header ud_header = (Ud_header) jdbcTemplate.queryForObject(sql_select, new BeanPropertyRowMapper(Ud_header.class), new Object[] { user_id, upload_dt }); return ud_header; } return null; }
From source file:org.cloudfoundry.samples.handson.ex6.CopyController.java
private List<Person> fetchPersons(NamedParameterJdbcTemplate template) { return template.query("SELECT firstName, lastName, age FROM Persons", // new HashMap<String, Object>(), // new BeanPropertyRowMapper<Person>(Person.class)); }