I want to save my excel file data into a session before push it into the database, so i try to save it into the session but it keep show up this error org.hibernate.action.internal.EntityActionVetoException: The EntityInsertAction was vetoed
values.each {
println("")
println(it)
println("abctesting")
// println("values -> " + it)
def newObjectInstance = objectInstance.propertyMapping(it)
println("abctesting")
newObjectInstance.each{ obj ->
println(obj.colorName)
println(obj.price)
println(obj.totalVolume)
}
if (newObjectInstance != null) {
//why cannot save into session??????
session.save(newObjectInstance)
}
else {
System.err.println("Data Import: I am NULL. Processing object -> ${newObjectInstance}")
}
println("abctesting")
if (counter % 1000 == 0) {
println("Counter -> " + counter)
println("Flush and Clear Session")
//clear session and save records after every 100 records
session.flush();
session.clear();
}
if (counter % 10000 == 0) {
println("Process -> " + counter)
}
counter++
}
//Commit and close Session
tx.commit();
session.close();
LocalTime endTime = LocalTime.now()
println("Start Time -> ${startTime}")
println("End Time -> ${endTime}")
println("Duration (sec) -> ${Duration.between(startTime, endTime).toMillis() / 1000}")
println("Done Processing -> ${className}")
i found out the line that causing this error is on the session.save(newObjectInstance). After commenting out this line, this code is working. But that's not the approach, since it was not saving into the session and database