예제 #1
0
  public void insert(CmsContent entity) {
    String sql =
        "insert into cms_content "
            + " (id,channel_code,tags,head_title,title,content,author,date_created,date_last_modified,site,level,search_keyword,source_url) "
            + " values "
            + " (:id,:channelCode,:tags,:headTitle,:title,:content,:author,:dateCreated,:dateLastModified,:site,:level,:searchKeyword,:sourceUrl)";
    entity.setDateCreated(new Date());
    entity.setDateLastModified(new Date());
    insertWithGeneratedKey(entity, sql); // for sqlserver:identity and mysql:auto_increment

    // 其它主键生成策略
    // insertWithOracleSequence(entity,"sequenceName",sql); //oracle sequence:
    // insertWithDB2Sequence(entity,"sequenceName",sql); //db2 sequence:
    // insertWithUUID(entity,sql); //uuid
    // insertWithAssigned(entity,sql) //手工分配
  }
예제 #2
0
 public int update(CmsContent entity) {
   String sql =
       "update cms_content set "
           + " channel_code=:channelCode,tags=:tags,head_title=:headTitle,title=:title,content=:content,author=:author,date_created=:dateCreated,date_last_modified=:dateLastModified,site=:site,level=:level,search_keyword=:searchKeyword,source_url=:sourceUrl"
           + " where  id = :id ";
   entity.setDateLastModified(new Date());
   return getNamedParameterJdbcTemplate().update(sql, new BeanPropertySqlParameterSource(entity));
 }