'blob'개체로 변환하여 데이터베이스에 저장해야하는 serialize 된 개체가 있습니다. 이전에는 다른 프로젝트 객체에 의해 정의 된 객체를 저장하는 데 사용되었지만 여러 문제가 발생하여 직렬화 규칙을 따르기 때문에 원시 객체 만 포함하는 구조의 'blob'객체를 변경하기로 결정했습니다 (String, 부울, 정수 등). 지금까지 우리는 모든 속성을 두 가지로 만들 수있었습니다.개체를 Blob 개체로 변환 할 때의 문제
private byte[] encode(ScheduledReport schedSTDReport)
{
byte[] bytes = null;
try
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(schedSTDReport);
oos.flush();
oos.close();
bos.close();
//byte [] data = bos.toByteArray();
//ByteArrayOutputStream baos = new ByteArrayOutputStream();
//GZIPOutputStream out = new GZIPOutputStream(baos);
//XMLEncoder encoder = new XMLEncoder(out);
//encoder.writeObject(schedSTDReport);
//encoder.close();
bytes = bos.toByteArray();
//GZIPOutputStream out = new GZIPOutputStream(bos);
//out.write(bytes);
//bytes = bos.toByteArray();
}
위 쓰고 방울 물방울이 속성을가 때라도하는 보고서 개체에서
public class ScheduledReport extends ScheduledReportInfo implements Serializable {
private SupervisoryScope _scope = null;
private Report _attributes = null;
private ScheduledReportScheduleBase _schedule = null;
private HashMap selectionList = new HashMap();
private EmailInfo _emailInfo = null;
private String _pdfFileName = null;
private short _baseDateOffset = -1;
을 포함
private String deflt = null;
private Object guiValue = null;
protected Object serverValue = null;
변수 객체는 같은 배열 목록, 문자열, 부울을 가질 수 있습니다 또는 클래스 객체. 그러나 실제 객체로 디코딩 한 후에는 형식이 무엇이든간에 형변환을해야합니다. 우리의 목표는이 객체를 원시 유형 및 저장소로 변환하고 원래 값으로 다시 가져 오는 것입니다. 본질적으로 모든 객체는 '1_integer', 'Y_Boolean'과 같이 객체의 유형을 가진 문자열로 생각하고 BLOB로 변환하고 분할 문자열을 되살리는 역할을하며 반사를 위해 객체의 유형을 가져 오기 위해 문자열을 사용합니다. 그러나 이것은 실현 가능하거나 정확한 해결책이 아닙니다. 어떤 아이디어.