问题要点:
- 问题1:
- 我有几个变量(太大..每个 2K)需要连接到最终内容。这是实习生列表的列表。oracle concat无法concat超过4k,导致我concat异常过长
- 问题2:
- 当我试图解决问题 1 时,通过将这些变量放入 java VO(ValueObject) 并将其连接到 java 字符串中。问题是我有一个由这个 query2 创建的 InstructionType 列表和 AdditionalInfo 子列表,我无法将多行设置为单个字符串。试图有字符串数组列表。
**
问题1描述:
** 我有一个 mybatis 查询,看起来像这样。
<select id="xyz" parameterType="com.test.VO" resultMap="abc" fetchSize="100" resultSetType="FORWARD_ONLY">
select tag.TAG_desc TAGNAME,
(det.tag_val_1 || det.tag_val_2 || det.tag_val_3 || det.tag_val_4 ||
det.tag_val_5 || det.tag_val_6 || det.tag_val_7 || det.tag_val_8 ||
det.tag_val_9 || det.tag_val_10) TAGVALUE,
det.tag_no||lpad(det.sub_fld, 2, '0') TAGID
from A det, B tag
where det.brch_code = #{branchCode}
and det.prod_ref_id = #{refId}
and det.tnx_id= #{tnxId}
and det.msg_type= #{messageNumber}
and det.msg_type = tag.msg_type
and (det.tag_no = tag.tag_no or substr(det.tag_no, 0, 2) = tag.tag_no )
and (det.tag_no = rpad(tag.tag_no, 3, '_') )
and det.tag_val_1 is not null
</select>
<resultMap id="abc" type="com.test.InstructionType$AdditionalInfo">
<result property="name" column="TAGNAME" />
<result property="id" column="TAGID" />
<result property="content" column="TAGVALUE" />
</resultMap>
它给了我以下错误:
; uncategorized SQLException for SQL []; SQL state [72000]; error code [1489]; ORA-01489: result of string concatenation is too long
; nested exception is java.sql.SQLException: ORA-01489: result of string concatenation is too long
tag_val_1 到 tag_val_10 最多可以有 2K 个字符,这导致了上述问题。
问题2描述:
试图在 Java 中将 tag_val 获取到 ValueObject(VO) 和 concat。
看起来有点像
<select id="XYZ" parameterType="com.test.OutboundInterfaceVO" resultMap="abc" fetchSize="100" resultSetType="FORWARD_ONLY">
select tag.TAG_desc TAGNAME,
(det.tag_val_1||det.tag_val_2)TAGVAL12,
(det.tag_val_3||det.tag_val_4 )TAGVAL34,
(det.tag_val_5||det.tag_val_6 )TAGVAL56,
(det.tag_val_7||det.tag_val_8||det.tag_val_9 || det.tag_val_10) TAGVALUE710,
from A det, B tag
where det.brch_code = #{branchCode}
and det.prod_ref_id = #{refId}
and det.tnx_id= #{tnxId}
and det.msg_type= #{messageNumber}
and det.msg_type = tag.msg_type
and (det.tag_no = tag.tag_no or substr(det.tag_no, 0, 2) = tag.tag_no )
and (det.tag_no = rpad(tag.tag_no, 3, '_') )
and det.tag_val_1 is not null
</select>
<resultMap id="abc" type="com.test.OutboundInterfaceVO">
<result property="tagName" column="TAGNAME" />
<result property="tagId" column="TAGID" />
<result property="tagVal12" column="TAGVAL12" />
<result property="tagVal34" column="TAGVAL34" />
<result property="tagVal56" column="TAGVAL56" />
<result property="tagVal710" column="TAGVAL710" />
</resultMap>
case1>试图认为它正在返回一行(我的坏)
private String tagName;
private String tagId;
private String tagVal12;
private String tagVal34;
private String tagVal56;
private String tagVal710;
Case2>由于查询成功返回,没有那个ORA错误(在PL/SQL Dev中检查)
这次问题出在结果图中。
返回大约 30 行,试图将它们作为字符串列表捕获,
private List<String[]> tagName = new ArrayList<String[]>();
private List<String[]> tagId = new ArrayList<String[]>();
private List<String[]> tagVal12 = new ArrayList<String[]>();
private List<String[]> tagVal34 = new ArrayList<String[]>();
private List<String[]> tagVal56 = new ArrayList<String[]>();
private List<String[]> tagVal710 = new ArrayList<String[]>();
在java中使用如下循环。
List<InstructionType> instructionList = mapper.pqr(interfaceVO);
for (InstructionType instructionType : instructionList) {
------
mapper.XYZ(VO);
for (InstructionType.AdditionalInfo addlist : instructionType.getAdditionalInfo())
{
addlist.setID(interfaceVO.getTagId());
addlist.setName(interfaceVO.getTagName());
content.append(interfaceVO.getTagVal12());
content.append(interfaceVO.getTagVal34());
content.append(interfaceVO.getTagVal56());
content.append(interfaceVO.getTagVal710());
addlist.setContent(content.toString());
}
}
instructionDetails.getInstruction().addAll(instructionList);
我的 InstructionType 类,会有所帮助
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "InstructionType", namespace = "http://www.db.com/tf", propOrder = {
"additionalInfo"
})
public class InstructionType {
@XmlElement(name = "AdditionalInfo", namespace = "http://www.abc.com/tf")
protected List<InstructionType.AdditionalInfo> additionalInfo;
...along with setters and getters
public static class AdditionalInfo {
@XmlValue
protected String content;
@XmlAttribute(name = "Name", required = true)
protected String name;
@XmlAttribute(name = "ID")
protected String id;
.....along with setters and getter in each class
}
}
注意:我有 mybatis 3.2.2 和 Oracle 11g,java 6
卡在那里的家伙,任何形式的帮助解决问题1避免问题2都会很棒。否则,请帮助我以更好的方式设置列表列表。
非常感谢您提前。