Hello!
I've the following problem when creating a table for MetaDataUpdates..
Code:
Hibernate: insert into MetadataUpdate_KiWiExtendedTriple (MetadataUpdateId, currentTripleId) values (?, ?)
ERROR [org.hibernate.util.JDBCExceptionReporter] Field 'prevTripleId' doesn't have a default value
The insert statement should normally insert 3 values: MetadataUpdateId, currentTripleId and prevTripleId. currentTriple and prevTriple are both persisted in the Database. After persisting MetadataUpdate (and em.flush), the above error is printed.
Here's my MetadataUpdate class:
Code:
package kiwi.model.revision;
import java.io.Serializable;
@Entity
public class MetadataUpdate extends KiWiUpdate implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1157304931584263193L;
@OneToOne
private KiWiSpecialResource resource;
private Date date;
/* TripleStore - Metadata */
@OneToMany(cascade={CascadeType.PERSIST})
private Set<KiWiExtendedTriple> prevTriple;
@OneToMany(cascade={CascadeType.PERSIST})
private Set<KiWiExtendedTriple> currentTriple;
@ManyToOne
private Revision revision;
public MetadataUpdate() {
}
/**
* @return the currentTriple
*/
public Set<KiWiExtendedTriple> getCurrentTriple() {
return currentTriple;
}
/**
* @param currentTriple the currentTriple to set
*/
public void setCurrentTriple(Set<KiWiExtendedTriple> currentTriple) {
this.currentTriple = currentTriple;
}
/**
* @return the prevTriple
*/
public Set<KiWiExtendedTriple> getPrevTriple() {
return prevTriple;
}
/**
* @param prevTriple the prevTriple to set
*/
public void setPrevTriple(Set<KiWiExtendedTriple> prevTriple) {
this.prevTriple = prevTriple;
}
[...]
}
And that's my KiWiExtendedTriple class:
Code:
@Entity
public class KiWiExtendedTriple implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8726615974625660845L;
@Id
@DocumentId
@GeneratedValue(strategy=GenerationType.TABLE)
private Long id;
@Transient
KiWiTripleStore context;
@OneToOne(cascade={CascadeType.PERSIST})
KiWiResource subject;
@OneToOne(cascade={CascadeType.PERSIST})
KiWiUriResource property;
@OneToOne(cascade={CascadeType.PERSIST})
KiWiNode object;
@OneToOne(cascade={CascadeType.PERSIST})
KiWiResource tripleId;
@OneToOne
User author;
public KiWiExtendedTriple(KiWiTripleStore context, KiWiResource subject, KiWiUriResource property, KiWiNode object) {
this.context = context;
this.subject = subject;
this.property = property;
this.object = object;
this.tripleId = context.createAnonResource();
}
public KiWiExtendedTriple(KiWiTripleStore context, KiWiResource subject, KiWiUriResource property, KiWiNode object, KiWiUriResource tripleId) {
this.context = context;
this.subject = subject;
this.property = property;
this.object = object;
this.tripleId = tripleId;
}
[...]
}
I'm using Seam, but I don't know if this problem related to Seam or Hibernate