Serialization 无法反序列化-POJO文件错误

Serialization 无法反序列化-POJO文件错误,serialization,Serialization,使用Netbeans“从数据库创建映射和POJO文件”,我收到以下错误: INFO: HHH000327: Error performing load command : org.hibernate.type.SerializationException: could not deserialize org.hibernate.type.SerializationException: could not deserialize at org.hibernate.internal.util

使用Netbeans“从数据库创建映射和POJO文件”,我收到以下错误:

INFO: HHH000327: Error performing load command : org.hibernate.type.SerializationException: could not deserialize
org.hibernate.type.SerializationException: could not deserialize
    at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)
    at org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:306)
    at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:155)
    at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:130)
    at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:44)
    at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:71)
    at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:259)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)
    at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:334)
    at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969)
    at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.loadFromResultSet(EntityReferenceInitializerImpl.java:324)
    at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.hydrateEntityState(EntityReferenceInitializerImpl.java:251)
    at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:107)
    at org.hibernate.loader.plan.exec.internal.EntityLoadQueryDetails$EntityLoaderRowReader.readRow(EntityLoadQueryDetails.java:255)
    at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:129)
    at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:138)
    at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:102)
    at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:186)
    at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4120)
    at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:502)
    at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:467)
    at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:212)
    at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:145)
    at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1066)
    at org.hibernate.internal.SessionImpl.immediateLoad(SessionImpl.java:972)
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:173)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:285)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:185)
    at yy.mavenproject2.Bpauser_$$_jvst210_0.getFullName(Bpauser_$$_jvst210_0.java)
    at yy.mavenproject2.PP.main(PP.java:29)
Caused by: java.io.StreamCorruptedException: invalid stream header: 786F0607
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
    at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:328)
    at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:318)
    at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:237)
    ... 31 more
和Bpauser.java:

package yy.mavenproject2;
// Generated Nov 25, 2015 1:43:19 PM by Hibernate Tools 4.3.1

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

/**
 * Bpauser generated by hbm2java
 */



@Entity
@Table(name = "BPAUSER", schema = "BPA", uniqueConstraints = @UniqueConstraint(columnNames = {"USERNAME", "ACTIVE", "DEACTIVATION_DATE"})
)
public class Bpauser implements java.io.Serializable { 

    private String id;
    private long version;
    private Bpauser bpauser;
    private String password;
    private String region;
    private String surName;
    private String firstName;
    private String department;
    private String company;
    private String country;
    private String branch;
    private String fullName;
    private String username;
    private String email;
    private String location;
    private String displayName;
    private boolean active;
    private Serializable modified;
    private Boolean ignoreInSync;
    private Boolean receiveNewTaskEmail;
    private BigDecimal cbdSyncVersion;
    private Serializable deactivationDate;
    private Set bpausers = new HashSet(0);

    public Bpauser() {
    }

    public Bpauser(String id, boolean active) {
        this.id = id;
        this.active = active;
    }

    public Bpauser(String id, Bpauser bpauser, String password, String region, String surName, String firstName, String department, String company, String country, String branch, String fullName, String username, String email, String location, String displayName, boolean active, Serializable modified, Boolean ignoreInSync, Boolean receiveNewTaskEmail, BigDecimal cbdSyncVersion, Serializable deactivationDate, Set bpausers) {
        this.id = id;
        this.bpauser = bpauser;
        this.password = password;
        this.region = region;
        this.surName = surName;
        this.firstName = firstName;
        this.department = department;
        this.company = company;
        this.country = country;
        this.branch = branch;
        this.fullName = fullName;
        this.username = username;
        this.email = email;
        this.location = location;
        this.displayName = displayName;
        this.active = active;
        this.modified = modified;
        this.ignoreInSync = ignoreInSync;
        this.receiveNewTaskEmail = receiveNewTaskEmail;
        this.cbdSyncVersion = cbdSyncVersion;
        this.deactivationDate = deactivationDate;
        this.bpausers = bpausers;
    }

    @Id

    @Column(name = "ID", unique = true, nullable = false, length = 1020)
    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Version
    @Column(name = "VERSION", nullable = false, precision = 10, scale = 0)
    public long getVersion() {
        return this.version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SUPERIOR_USER_ID")
    public Bpauser getBpauser() {
        return this.bpauser;
    }

    public void setBpauser(Bpauser bpauser) {
        this.bpauser = bpauser;
    }

    @Column(name = "PASSWORD", length = 400)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "REGION", length = 12)
    public String getRegion() {
        return this.region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    @Column(name = "SUR_NAME", length = 200)
    public String getSurName() {
        return this.surName;
    }

    public void setSurName(String surName) {
        this.surName = surName;
    }

    @Column(name = "FIRST_NAME", length = 200)
    public String getFirstName() {
        return this.firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @Column(name = "DEPARTMENT", length = 60)
    public String getDepartment() {
        return this.department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    @Column(name = "COMPANY", length = 200)
    public String getCompany() {
        return this.company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    @Column(name = "COUNTRY", length = 8)
    public String getCountry() {
        return this.country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    @Column(name = "BRANCH", length = 16)
    public String getBranch() {
        return this.branch;
    }

    public void setBranch(String branch) {
        this.branch = branch;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @Column(name = "FULL_NAME", length = 400)    
    public String getFullName() {
        return this.fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    @Column(name = "USERNAME", length = 400)
    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Column(name = "EMAIL", length = 300)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "LOCATION", length = 20)
    public String getLocation() {
        return this.location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Column(name = "DISPLAY_NAME", length = 400)
    public String getDisplayName() {
        return this.displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    @Column(name = "ACTIVE", nullable = false, precision = 1, scale = 0)
    public boolean isActive() {
        return this.active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    @Column(name = "MODIFIED")
    public Serializable getModified() {
        return this.modified;
    }

    public void setModified(Serializable modified) {
        this.modified = modified;
    }

    @Column(name = "IGNORE_IN_SYNC", precision = 1, scale = 0)
    public Boolean getIgnoreInSync() {
        return this.ignoreInSync;
    }

    public void setIgnoreInSync(Boolean ignoreInSync) {
        this.ignoreInSync = ignoreInSync;
    }

    @Column(name = "RECEIVE_NEW_TASK_EMAIL", precision = 1, scale = 0)
    public Boolean getReceiveNewTaskEmail() {
        return this.receiveNewTaskEmail;
    }

    public void setReceiveNewTaskEmail(Boolean receiveNewTaskEmail) {
        this.receiveNewTaskEmail = receiveNewTaskEmail;
    }

    @Column(name = "CBD_SYNC_VERSION", scale = 0)
    public BigDecimal getCbdSyncVersion() {
        return this.cbdSyncVersion;
    }

    public void setCbdSyncVersion(BigDecimal cbdSyncVersion) {
        this.cbdSyncVersion = cbdSyncVersion;
    }

    @Column(name = "DEACTIVATION_DATE")
    public Serializable getDeactivationDate() {
        return this.deactivationDate;
    }

    public void setDeactivationDate(Serializable deactivationDate) {
        this.deactivationDate = deactivationDate;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "bpauser")
    public Set getBpausers() {
        return this.bpausers;
    }

    public void setBpausers(Set bpausers) {
        this.bpausers = bpausers;
    }

}

你能帮忙吗?我找不到与getter getFullName相关的错误的原因。任何评论都会非常有用。

好的,我自己发现了问题。DB有timestamp6类型,我用这些时间戳序列化了变量类型。所以我在POJO中更改了这个序列化类型。已解决。

哪个版本的NetBeans?您正在连接哪种类型的数据库?很抱歉忘了提及:Oracle、netbeans 8.0.2
package yy.mavenproject2;
// Generated Nov 25, 2015 1:43:19 PM by Hibernate Tools 4.3.1

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

/**
 * Bpauser generated by hbm2java
 */



@Entity
@Table(name = "BPAUSER", schema = "BPA", uniqueConstraints = @UniqueConstraint(columnNames = {"USERNAME", "ACTIVE", "DEACTIVATION_DATE"})
)
public class Bpauser implements java.io.Serializable { 

    private String id;
    private long version;
    private Bpauser bpauser;
    private String password;
    private String region;
    private String surName;
    private String firstName;
    private String department;
    private String company;
    private String country;
    private String branch;
    private String fullName;
    private String username;
    private String email;
    private String location;
    private String displayName;
    private boolean active;
    private Serializable modified;
    private Boolean ignoreInSync;
    private Boolean receiveNewTaskEmail;
    private BigDecimal cbdSyncVersion;
    private Serializable deactivationDate;
    private Set bpausers = new HashSet(0);

    public Bpauser() {
    }

    public Bpauser(String id, boolean active) {
        this.id = id;
        this.active = active;
    }

    public Bpauser(String id, Bpauser bpauser, String password, String region, String surName, String firstName, String department, String company, String country, String branch, String fullName, String username, String email, String location, String displayName, boolean active, Serializable modified, Boolean ignoreInSync, Boolean receiveNewTaskEmail, BigDecimal cbdSyncVersion, Serializable deactivationDate, Set bpausers) {
        this.id = id;
        this.bpauser = bpauser;
        this.password = password;
        this.region = region;
        this.surName = surName;
        this.firstName = firstName;
        this.department = department;
        this.company = company;
        this.country = country;
        this.branch = branch;
        this.fullName = fullName;
        this.username = username;
        this.email = email;
        this.location = location;
        this.displayName = displayName;
        this.active = active;
        this.modified = modified;
        this.ignoreInSync = ignoreInSync;
        this.receiveNewTaskEmail = receiveNewTaskEmail;
        this.cbdSyncVersion = cbdSyncVersion;
        this.deactivationDate = deactivationDate;
        this.bpausers = bpausers;
    }

    @Id

    @Column(name = "ID", unique = true, nullable = false, length = 1020)
    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Version
    @Column(name = "VERSION", nullable = false, precision = 10, scale = 0)
    public long getVersion() {
        return this.version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SUPERIOR_USER_ID")
    public Bpauser getBpauser() {
        return this.bpauser;
    }

    public void setBpauser(Bpauser bpauser) {
        this.bpauser = bpauser;
    }

    @Column(name = "PASSWORD", length = 400)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "REGION", length = 12)
    public String getRegion() {
        return this.region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    @Column(name = "SUR_NAME", length = 200)
    public String getSurName() {
        return this.surName;
    }

    public void setSurName(String surName) {
        this.surName = surName;
    }

    @Column(name = "FIRST_NAME", length = 200)
    public String getFirstName() {
        return this.firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @Column(name = "DEPARTMENT", length = 60)
    public String getDepartment() {
        return this.department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    @Column(name = "COMPANY", length = 200)
    public String getCompany() {
        return this.company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    @Column(name = "COUNTRY", length = 8)
    public String getCountry() {
        return this.country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    @Column(name = "BRANCH", length = 16)
    public String getBranch() {
        return this.branch;
    }

    public void setBranch(String branch) {
        this.branch = branch;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @Column(name = "FULL_NAME", length = 400)    
    public String getFullName() {
        return this.fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    @Column(name = "USERNAME", length = 400)
    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Column(name = "EMAIL", length = 300)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "LOCATION", length = 20)
    public String getLocation() {
        return this.location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Column(name = "DISPLAY_NAME", length = 400)
    public String getDisplayName() {
        return this.displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    @Column(name = "ACTIVE", nullable = false, precision = 1, scale = 0)
    public boolean isActive() {
        return this.active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    @Column(name = "MODIFIED")
    public Serializable getModified() {
        return this.modified;
    }

    public void setModified(Serializable modified) {
        this.modified = modified;
    }

    @Column(name = "IGNORE_IN_SYNC", precision = 1, scale = 0)
    public Boolean getIgnoreInSync() {
        return this.ignoreInSync;
    }

    public void setIgnoreInSync(Boolean ignoreInSync) {
        this.ignoreInSync = ignoreInSync;
    }

    @Column(name = "RECEIVE_NEW_TASK_EMAIL", precision = 1, scale = 0)
    public Boolean getReceiveNewTaskEmail() {
        return this.receiveNewTaskEmail;
    }

    public void setReceiveNewTaskEmail(Boolean receiveNewTaskEmail) {
        this.receiveNewTaskEmail = receiveNewTaskEmail;
    }

    @Column(name = "CBD_SYNC_VERSION", scale = 0)
    public BigDecimal getCbdSyncVersion() {
        return this.cbdSyncVersion;
    }

    public void setCbdSyncVersion(BigDecimal cbdSyncVersion) {
        this.cbdSyncVersion = cbdSyncVersion;
    }

    @Column(name = "DEACTIVATION_DATE")
    public Serializable getDeactivationDate() {
        return this.deactivationDate;
    }

    public void setDeactivationDate(Serializable deactivationDate) {
        this.deactivationDate = deactivationDate;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "bpauser")
    public Set getBpausers() {
        return this.bpausers;
    }

    public void setBpausers(Set bpausers) {
        this.bpausers = bpausers;
    }

}