Sripaul Sripaul - 7 days ago 6
Java Question

GenericJDBCException in HSQL

I have an entity called

ProdTransaction
. I am saving two records of type
ProdTransaction
. Both the two inserts succeed when run independently. I mean

tranDAO.save(record1) //alone works
tranDAO.save(record2) //alone works


but together running them as

tranDAO.save(record1)
tranDAO.save(record2)


HSQL throws a
GenericJDBCException
error.

@Entity
@Table(name = "ProdTransaction")
public class ProdTransactionextends PersistentObject implements Serializable {
private static final long serialVersionUID = 1L;

@Embedded
private ProdTranPK id;

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "REC_ID")
private Long recId;

@Temporal(TemporalType.DATE)
private Date date1;

@Column(length = 1)
private String comment;
}


I have verified the data and it's all fine. When I run against HSQL I get:


GenericJDBCException: could not execute JDBC batch update.


But if I connect to my physical DB, and run with the same sequence, it works fine. What could be the problem in HSQL? I am using version 1.8.

Answer

HSQLDB batching bug was fixed, now it works ok. Problem is that if you have an error, such as a problem with your sql statement etc, you'll only get a generic exception that doesn't really tell you anything. What I like to do is have a helper class that can execute sql queris in batch mode and individually, and I switch to individual queris when I get weird errors from batch mode. Try that, maybe it's just a simple mistake in your SQL

Comments