“无效的流标题”异常 - 与JPA和MySQL的Lob

时间:2012-12-23 01:43:04

标签: java mysql jpa lob

我有一个像这样定义的字段

@MappedSupperclass
public abstract class BaseItem {

    ...
    @Lob @Basic(fetch=FetchType.EAGER)
    private String description;
    ...
}

@Entity
public class Item extends BaseItem {
}

我使用的是MySQL 5,desccription字段类型为TEXT

尝试读取Item类型的对象时,出现以下错误:

java.io.StreamCorruptedException: invalid stream header: 6576656E
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:782)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
    at org.datanucleus.store.rdbms.datatype.BlobImpl.getObject(BlobImpl.java:121)
    at org.datanucleus.store.rdbms.mapping.AbstractLargeBinaryRDBMSMapping.getObjectForBytes(AbstractLargeBinaryRDBMSMapping.java:362)
    at org.datanucleus.store.rdbms.mapping.AbstractLargeBinaryRDBMSMapping.getObject(AbstractLargeBinaryRDBMSMapping.java:395)
    at org.datanucleus.store.mapped.mapping.AbstractContainerMapping.getObject(AbstractContainerMapping.java:228)
    at org.datanucleus.store.rdbms.fieldmanager.ResultSetGetter.fetchObjectField(ResultSetGetter.java:176)
    at org.datanucleus.state.AbstractStateManager.replacingObjectField(AbstractStateManager.java:2353)
    ...

您是否知道可能的原因是什么?

我正在使用JDK6和DataNucleus 3.1.1。

1 个答案:

答案 0 :(得分:2)

删除@Lob注释修复了问题。