I'm getting a 'BatchUpdateException' error message returned by my code for updating several related tables, here's part of the stack trace:
java.sql.BatchUpdateException: Unknown column 'id' in 'field list' at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2020) at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1451) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
and here's the code that's causing the error:
primaryAuthor = reference.getPrimaryauthor(); RefitemToAuthor refitemToAuthor = new RefitemToAuthor(reference, primaryAuthor); hibernateTemplateObj.save(refitemToAuthor);
Here's part of the code for the 'RefitemToAuthor' class:
@Entity @Table(name="refitemtoauthor") public class RefitemToAuthor implements Serializable { @Id private RefitemToAuthorID id = new RefitemToAuthorID(); @SuppressWarnings("unused") @Column(name="ReferenceID", nullable=false, updatable=false, insertable=false) private Integer reference; @SuppressWarnings("unused") @Column(name="authorid", nullable=false, updatable=false, insertable=false) private Integer author; //---- public RefitemToAuthor() { } public RefitemToAuthor(Referenceitem reference, Author author) { this.id = new RefitemToAuthorID(reference, author); this.reference = reference.getReferenceID(); this.author = author.getAuthorid(); } ... }
And here's part of the code for the 'RefitemToAuthorID' class:
public class RefitemToAuthorID implements Serializable { @ManyToOne private Referenceitem reference; @ManyToOne private Author author; public RefitemToAuthorID() { } public RefitemToAuthorID(Referenceitem reference, Author author) { this.reference = reference; this.author = author; } public Author getAuthor() { return author; } ...
|