我已经开发了几个 GWT Web 应用程序。最新的一个是对另一个的小修改。除了最新的,它们都运行良好。例外是:
The response could not be deserialized
我在 Hibernate 和 GWT 之间使用 Hibernate 和数据传输对象。每个 DTO 都实现 java.io.Serializable 接口。正如我之前所说,在其他应用程序中运行良好。有人可以帮我解决这个错误吗?我不知道是什么原因。
我的休眠对象代码是:
public List<AttributeDTO> getAttributes(){
String sql = "from Attribute where (select max(tDate) from Attribute)-tDate < '0 days 00:05'";
List<Attribute> attributes = new ArrayList<Attribute>(DatabaseManager.createQuery(sql));
List<AttributeDTO> attributeDTOs = new ArrayList<AttributeDTO>(attributes != null ? attributes.size() : 0);
if (attributes != null) {
for (Attribute attribute : attributes) {
String date = format.format(attribute.gettDate());
attributeDTOs.add(new AttributeDTO(attribute.getiAttrId(),attribute.getsName(),attribute.getsValue(),date,attribute.getiDeviceId(),attribute.getsUnits(),new ApplicationFieldDTO()));
}
}
return attributeDTOs;
}
而 AttributeDTO 是:
public class AttributeDTO implements Serializable {
private static final long serialVersionUID = 1L;
private int iAttrId;
private String name;
private String value;
private String date;
private String units;
private int iDeviceId;
private ApplicationFieldDTO appField;
public AttributeDTO() {}
public AttributeDTO(int attrId, String name, String value, String date, int deviceId, String units, ApplicationFieldDTO appField) {
this.iAttrId = attrId;
this.name = name;
this.value = value;
this.date = date;
this.iDeviceId = deviceId;
this.units = units;
this.appField = appField;
}
}
从 GWT 调用 getAttributes() 方法,该方法返回一个 AttributeDTO 列表。
谢谢!!!