我使用的是informix数据库,我有两个表;实例和联系。联系表包含以下字段; contact_id,fname和lname。实例表具有以下字段:instance_id,name和contact_ids(contact_ids是联系人ID的informix集合集合,com.informix.jdbc.IfxCollection@429681e8)。 我使用hibernate进行数据持久化。我的Instance Class的代码如下所示:
@Entity
public class Instance{
@Id
private int instance_id;
private String name;
@Lob
private Set<Integer> contact_ids
....
setters and getters
}
联系班级:
@Entity
public class Contact{
@Id
private int contact_id;
private String fname;
private String lname;
....
setters and getters
}
当我加载实例实体时,我收到以下错误:
20:32:18,527 ERROR [jsp:154] java.sql.SQLException: **Can't convert to: binary stream**
at com.informix.util.IfxErrMsg.getSQLMinorException(IfxErrMsg.java:575)
at com.informix.jdbc.IfxObject.toBlob(IfxObject.java:647)
at com.informix.jdbc.IfxResultSet.getBlob(IfxResultSet.java:3338)
at com.informix.jdbc.IfxResultSet.getBlob(IfxResultSet.java:3437)
我只想检索该集。
答案 0 :(得分:0)
尝试使用@ElementCollection注释,如下所示:
@ElementCollection
@CollectionTable(name="contact_ids", joinColumns=@JoinColumn(name="instance_id"))
@Column(name="contact_id")
public Set<Integer> contactIds;
但是,对于您的场景,我建议在实际实体之间建立OneToMany关系,因此在您的实例类中,您将拥有以下内容而不是contactIds字段:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "instance", cascade = {...})
public Set<Contact> contacts;
并且在您的Contact课程中,您也可以(以匹配上述内容):
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "instance_id", referencedColumnName = "instance_id", nullable = false)
public Instance instance;
答案 1 :(得分:0)
您需要自定义Informix typeHandeler:
假设您正在使用myBatis add:
{
"query": {
"bool": {
"must": {
"match": {
"_index": "ntopng-2017.07.26"
}
},
"filter": {
"term": {
"IPV4_DST_ADDR": "192.168.0.1"
}
}
}
},
"aggs": {
"IN_PKTS": {
"sum": {
"field": "IN_PKTS"
}
},
"IN_BYTES": {
"sum": {
"field": "IN_BYTES"
}
},
"OUT_BYTES": {
"sum": {
"field": "OUT_BYTES"
}
},
"OUT_PKTS": {
"sum": {
"field": "OUT_PKTS"
}
}
}
}
在mybatis-config.xml文件中
提示:&#34; javaType&#34;应该是你想要的类型