把多个int类型的字段转换成字符串类型_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 把多个int类型的字段转换成字符串类型

把多个int类型的字段转换成字符串类型

 2012/1/13 9:06:38  lxx_amy  程序员俱乐部  我要评论(0)
  • 摘要:publicclassSearchCredentialResult{privateStringaccessGroup1Name;privateStringaccessGroup2Name;privateStringaccessGroup3Name;privateStringaccessGroup4Name;privateStringaccessGroup5Name;privateStringaccessGroup6Name;privateStringaccessGroup7Name
  • 标签:字符串
public class SearchCredentialResult{

private String accessGroup1Name;
private String accessGroup2Name;
private String accessGroup3Name;
private String accessGroup4Name;
private String accessGroup5Name;
private String accessGroup6Name;
private String accessGroup7Name;
private String accessGroup8Name;

public String getAccessGroup1Name() {
return this.accessGroup1Name == null ? "" : this.accessGroup1Name;
}

public void setAccessGroup1Name(String accessGroup1Name) {
this.accessGroup1Name = accessGroup1Name;
}

public String getAccessGroup2Name() {
return this.accessGroup2Name == null ? "" : this.accessGroup2Name;
}

public void setAccessGroup2Name(String accessGroup2Name) {
this.accessGroup2Name = accessGroup2Name;
}

public String getAccessGroup3Name() {
return this.accessGroup3Name != null ? "" :this.accessGroup3Name;
}

public void setAccessGroup3Name(String accessGroup3Name) {
this.accessGroup3Name = accessGroup3Name;
}

public String getAccessGroup4Name() {
return this.accessGroup4Name !=null ? "" :this.accessGroup4Name;
}

public void setAccessGroup4Name(String accessGroup4Name) {
this.accessGroup4Name = accessGroup4Name;
}

public String getAccessGroup5Name() {
return accessGroup5Name != null ? "":this.accessGroup5Name;
}

public void setAccessGroup5Name(String accessGroup5Name) {
this.accessGroup5Name = accessGroup5Name;
}

public String getAccessGroup6Name() {
return accessGroup6Name != null ? "":this.accessGroup6Name;
}

public void setAccessGroup6Name(String accessGroup6Name) {
this.accessGroup6Name = accessGroup6Name;
}

public String getAccessGroup7Name() {
return accessGroup7Name != null ? "":this.accessGroup7Name;
}

public void setAccessGroup7Name(String accessGroup7Name) {
this.accessGroup7Name = accessGroup7Name;
}

public String getAccessGroup8Name() {
return accessGroup8Name != null ? "":this.accessGroup8Name;
}

public void setAccessGroup8Name(String accessGroup8Name) {
this.accessGroup8Name = accessGroup8Name;
}

public String getAccessGroupNames() {
StringBuilder sb = new StringBuilder();
if(this.accessGroup1Name != null) {
sb.append(this.accessGroup1Name);
}
if(this.accessGroup2Name != null) {
if(sb.length() > 0) {
sb.append(",").append(this.accessGroup2Name);
}
sb.append(this.accessGroup2Name);
}
if(this.accessGroup3Name != null) {
if(sb.length() > 0) {
sb.append(",").append(this.accessGroup3Name);
}
sb.append(this.accessGroup3Name);
}
if(this.accessGroup4Name != null) {
if(sb.length() > 0) {
sb.append(",").append(this.accessGroup4Name);
}
sb.append(this.accessGroup4Name);
}
if(this.accessGroup5Name != null) {
if(sb.length() > 0) {
sb.append(",").append(this.accessGroup5Name);
}
sb.append(this.accessGroup5Name);
}
if(this.accessGroup6Name != null) {
if(sb.length() > 0) {
sb.append(",").append(this.accessGroup6Name);
}
sb.append(this.accessGroup6Name);
}
if(this.accessGroup7Name != null) {
if(sb.length() > 0) {
sb.append(",").append(this.accessGroup7Name);
}
sb.append(this.accessGroup7Name);
}
if(this.accessGroup8Name != null) {
if(sb.length() > 0) {
sb.append(",").append(this.accessGroup8Name);
}
sb.append(this.accessGroup8Name);
}
return sb.toString();
}
}

ProcessorImpl 实现:
SearchCredentialResult result = accessControlCardService.findAccessGroupName(creden.getCredentialId());
if(null != result){
credentialdto.setGroupNames(result.getAccessGroupNames()); 
}
ibatis sql:
<resultMap class="SearchCredentialResult" id="AccessCredentialResultMap">
  <result column="groupname1" property="accessGroup1Name" jdbcType="VARCHAR" />
    <result column="groupname2" property="accessGroup2Name" jdbcType="VARCHAR" />
    <result column="groupname3" property="accessGroup3Name" jdbcType="VARCHAR" />
    <result column="groupname4" property="accessGroup4Name" jdbcType="VARCHAR" />
    <result column="groupname5" property="accessGroup5Name" jdbcType="VARCHAR" />
    <result column="groupname6" property="accessGroup6Name" jdbcType="VARCHAR" />
    <result column="groupname7" property="accessGroup7Name" jdbcType="VARCHAR" />
    <result column="groupname8" property="accessGroup8Name" jdbcType="VARCHAR" />
  </resultMap>

<select id="findAccessGroupName" resultMap="AccessCredentialResultMap" parameterClass="Integer">
    SELECT f.CRDT_ID,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP1) as groupname1,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP2) as groupname2,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP3) as groupname3,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP4) as groupname4,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP5) as groupname5,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP6) as groupname6,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP7) as groupname7,
(SELECT g.ACS_GRP_NAM FROM ACS_CTRL_ACS_GRP g WHERE g.ACS_GRP_ID=f.ACS_GRP8) as groupname8
FROM ACS_CTRL_CRDT f
WHERE f.CRDT_ID= #credentialId:INTEGER#
    </select>
发表评论
用户名: 匿名