Hibernate ne pouvait pas désérialiser erreur

J'ai cette table Oracle:

SQL>  Name                                         Null?    Type
 ----------------------------------------- -------- ----------------------------
 JOB_ID                                    NOT NULL VARCHAR2(13)
 TYPE                                      NOT NULL NUMBER
 COMPONENT_DESCRIPTION                     NOT NULL VARCHAR2(255)
 COMPONENT_ID                                       VARCHAR2(13)
 STATUS                                    NOT NULL NUMBER(1)
 REASON                                             VARCHAR2(255)
 NOTES                                              VARCHAR2(255)

SQL>

Il n'y a pas de clé primaire définie mais JOB_ID, le TYPE et la COMPONENT_DESCRIPTION combinés sont uniques. Je ne peux pas apporter des modifications à la structure de base de données et le code je m'efforce de ne jamais lire de la bd, il ne sera jamais à écrire.

J'ai fait cette Hibernate fichier de la carte:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
    "classpath://org/hibernate/hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="ARCHIVE">

<class name="myclass.ArchiveJobHeaderComponents" table="JOB_HEADER_COMPONENTS">
    <composite-id>
        <key-property name="jobId" column="JOB_ID" type="java.lang.String" />
        <key-property name="type" column="TYPE" type="java.lang.Number" />
        <key-property name="componentDescription" column="COMPONENT_DESCRIPTION" type="java.lang.String" />
    </composite-id>
    <property name="componentId" column="COMPONENT_ID" type="java.lang.String" not-null="false" />
    <property name="status" column="STATUS" type="java.lang.Number" />
    <property name="reason" column="REASON" type="java.lang.String" not-null="false" />
    <property name="notes" column="NOTES" type="java.lang.String" not-null="false" />
</class>

<query name="JobHeaderComponents.lookupJobHeaderComponents">
    <![CDATA[from myclass.ArchiveJobHeaderComponents where
               jobId = :jobId and
               type = :type and
               componentDescription = :componentDescription ]]>
</query>

<query name="JobHeaderComponents.listJobHeaderComponentsByComponentId">
    <![CDATA[from myclass.ArchiveJobHeaderComponents where componentId = :id]]>
</query>

</hibernate-mapping>

C'est le fichier de classe Java:

package myclass;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
import java.lang.Number;
import java.util.HashSet;
public class ArchiveJobHeaderComponents implements Serializable {
private String jobId;
private Number type;
private String componentDescription;
private String componentId;
private Number status;
private String reason;
private String notes;
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public Number getType() {
return type;
}
public void setType(Number type) {
this.type = type;
}
public String getComponentDescription() {
return componentDescription;
}
public void setComponentDescription(String componentDescription) {
this.componentDescription = componentDescription;
}
public String getComponentId() {
return componentId;
}
public void setComponentId(String componentId) {
this.componentId = componentId;
}
public Number getStatus() {
return status;
}
public void setStatus(Number status) {
this.status = status;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public int hashCode() {
return new HashCodeBuilder().
append(getJobId()).
append(getType()).
append(getComponentDescription()).
append(getComponentId()).
append(getStatus()).
append(getReason()).
append(getNotes()).toHashCode();
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ArchiveJobHeaderComponents)) {
return false;
}
ArchiveJobHeaderComponents that = (ArchiveJobHeaderComponents) o;
return new EqualsBuilder().append(this.getJobId(), that.getJobId()).
append(this.getType(), that.getType()).
append(this.getComponentDescription(), that.getComponentDescription()).
append(this.getComponentId(), that.getComponentId()).
append(this.getStatus(), that.getStatus()).
append(this.getReason(), that.getReason()).
append(this.getNotes(), that.getNotes()).isEquals();
}
public String toString() {
return new ToStringBuilder(this).
append("jobId", getJobId()).
append("type", getType()).
append("componentDescription", getComponentDescription()).
append("componentId", getComponentId()).
append("status", getStatus()).
append("reason", getReason()).
append("notes", getNotes()).toString();
}
}

Chaque fois que je récupère les données à partir d'une requête, j'obtiens "ne Pourrait pas désérialiser" suivi par un "EOFException' erreur.

J'ai vérifié:

- Il n'y a pas de variables dans la classe Java de type sérialiser

- La classe Java est la mise en œuvre de Serializable

Je ne veux pas me couper les trois colonnes (JOB_ID, le TYPE et la COMPONENT_DESCRIPTION) dans un 'Id' de la classe que je vais avoir des problèmes conceptuels avec la façon dont les données sont accessibles. (Je me rends compte que ce n'est pas recommandé, mais est pris en charge).

Quelqu'un peut-il point de ce que j'ai fait de mal avec la façon dont je l'ai mis en œuvre cette?

Grâce

EDIT:

J'ai changé la hbm.xml pour ne pas avoir une clé composite, juste une id sur JOB_ID sans aucune amélioration.

J'ai ajouté pas-null="false" pour les colonnes qui peuvent être vides, aussi aucune amélioration.

Pouvez-vous s'il vous plaît également coller le full stack-trace?

OriginalL'auteur user1174838 | 2013-12-29