流水会知音
2015-07-17 03:40
采纳率: 50%
浏览 3.8k

在java中怎么处理才能将数据存入postgresql数据库中类型为hstore的字段?

/**

 * 增加批量导入映射.
 * 
 * @param 
 * @return 
 */
@Action(value = "addImportMapper", results = { @Result(name = "addImportMapper", type = "json", params = {
        "root", "jsonResult" }) })
public String addImportMapper() {
    Boolean operateResult = getImportMapperService().addImportMapper(
            assembleParameterToAddImportMapper());
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("result", operateResult);


    jsonResult = map;


    return "addImportMapper";
}


/**
 * 由于是对外提供接口,不宜显式地暴露对象. <br/>
 * 故将参数组装成对象.
 * 
 * @return 
 */
@SuppressWarnings("unchecked")
private ImportMapper assembleParameterToAddImportMapper() {
    ImportMapper importMapper = new ImportMapper();


    importMapper.setUuid(UUIDGenerator.genUuidStr());
    importMapper.setMapperName("教职工姓名");
    importMapper.setMatchedOrgUuid("123456");
    importMapper.setMapperRule("name=>name,age=>20");  //hstore类型
    importMapper.setCreatorUuid("789456");


    return importMapper;
}
<insert id="insertImportMapper"
    parameterType="net.firstelite.bicp.dtd.personnel$manage.system.ImportMapper">
    insert into t_pm_sys_import_mapper (
    uuid,
    mapper_name,
    matched_org_uuid,
    mapper_rule,
    creator_uuid,
    create_time,
    modify_time
    )values(
    #{uuid},
    #{mapperName},
    #{matchedOrgUuid},
    #{mapperRule},
    #{creatorUuid},
    current_timestamp(0),
    current_timestamp(0)
    )
</insert>

3条回答 默认 最新

相关推荐 更多相似问题