IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes Getting a 'BatchUpdateException' error message Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Getting a Watch "Getting a New topic
Author

Getting a 'BatchUpdateException' error message

Vance Arocho
Greenhorn

Joined: Sep 29, 2011
Posts: 6
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:


Here's part of the code for the 'RefitemToAuthor' class:



And here's part of the code for the 'RefitemToAuthorID' class:




Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3563

ava.sql.BatchUpdateException: Unknown column 'id' in 'field list'

How you map the columns to fields in the DB? Specifically Author, Referenceitem mappings etc...?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vance Arocho
Greenhorn

Joined: Sep 29, 2011
Posts: 6
To resolve that error, I created 2 classes, 'RefitemToAuthor.java' and 'RefitemToAuthorID.java'. ''RefitemToAuthorID.java' has instance variables representing the different parts of the composite primary key. And 'RefitemToAuthor.java' has a 'RefitemToAuthorID' instance variable and associated 'get' method with the '@Id' annotation. 'RefitemToAuthor.java' also has '@Entity' and '@Table' annotations.
 
 
subject: Getting a 'BatchUpdateException' error message
 
Threads others viewed
Column index not populated?
Edit primary key, if it's a foreign key
Problems with Many to Many on Hibernate!
Outer join between 3 entities in HQL
using 2 @OnetoMany annoations in one Entity Class
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture