-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Getting a 'BatchUpdateException' error message
PostPosted: Fri Feb 10, 2012 5:03 pm 
Newbie

Joined: Fri Feb 10, 2012 4:57 pm
Posts: 1
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;
}
...


Top
 Profile  
 
 Post subject: Re: Getting a 'BatchUpdateException' error message
PostPosted: Mon Feb 13, 2012 3:56 am 
Newbie

Joined: Thu Feb 02, 2012 11:28 pm
Posts: 13
Location: shenzhen china
Come to this!

Two may

1、The table never have got a column 'id';

2、Case spelling mistakes;

Learn from each other, exchange!

MSN:goldfish_sun@sina.com.cn


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.