I have a simple java page in which I am trying to insert data into the DB. Following is the code for it -->
Code:
public void execute() throws JobExecutionException {
Session session = null;
try{
session = HibernateUtil.getSessionFactory().openSession();
org.hibernate.Transaction tx = session.beginTransaction();
java.util.List taskList = session.createQuery("from Task as t where t.frequency = 'W'").list();
Iterator i = taskList.iterator();
int len=taskList.size();
System.out.println("test"+len);
while(i.hasNext())
{
Task task=(Task)i.next();
TaskUser tu= new TaskUser();
System.out.println(task.getProcessOwner());
tu.setUserId(task.getProcessOwner());
System.out.println(task.getTaskId());
tu.setTaskId(task.getTaskId());
System.out.println(task.getDueDate());
tu.setDueDate(task.getDueDate());
System.out.println(task.getDurationDays());
tu.setDurationDays(task.getDurationDays());
System.out.println(task.getReportTO());
tu.setReportingTo(task.getReportTO());
tu.setScanned("Y");
tu.setLevels(3);
tu.setStatus(3);
session.save(tu);
}
tx.commit();
} catch (Exception e) {
System.out.println(e);
} finally {
session.flush();
session.close();
}
}
The code was working perfectly some time back but then now it is throwing the following error. --
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Task_User_Rel (Usr_Id, Task_Id, Due_Date, Duration_Days, Status, Scanned, Path, Levels, Reporting_To, Document_Date, Task_User_Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
I have checked the CMT and bean class the properties match with the DB. Is there anything I need to take care of?