SmsContentDAO extends BaseIbatisDAO { public SmsContent save(final SmsContent sms) { if (null == sms || StringUtils.isEmpty(sms.getMobile()) || StringUtils.isEmpty(sms.getContent())) { return sms; } this.applyRule(sms); super.insert("SMS_CONTENT.insert", sms); if (LOG.isDebugEnabled()) { LOG.debug("save " + sms + " successfully!"); } return sms; }  SmsContent save(final SmsContent sms); @SuppressWarnings("unchecked") List<SmsContent> query(final Map<String, Object> parameters); void deleteByPrimaryKey(final Serializable id); void delete(final Map<String, Object> parameters); void updateFailureCount(final Serializable id); SmsContent getByPrimaryKey(final Serializable id); void retrySend(final Serializable serialId); static int getRule(); static void setRule(int rule); @SuppressWarnings("unchecked") List<SmsContent> queryByParam(Map<String, Object> param); void reSendSmsByMap(Map<Object, Object> extendParam); int update(SmsContent smsContent); void insert(SmsContent smsContent);  }
@Test public void testSave() throws Exception { SmsContent smsContent = new SmsContent("Test Sms", "13917677725"); smsContentDAO.save(smsContent); Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery("select * from sms_content where content = 'Test Sms' and mobile = '13917677725'"); rs.next(); Assert.assertNotNull(rs.getLong("id")); Assert.assertEquals("Test Sms", rs.getString("content")); Assert.assertEquals("13917677725", rs.getString("mobile")); Assert.assertEquals(5, rs.getInt("priority")); Assert.assertNull(rs.getString("type")); Assert.assertNotNull(rs.getDate("send_date")); Assert.assertEquals(0, rs.getInt("failure")); if (rs.next()) { fail("插入了多条数据!"); } }