I am using spring + hibernate,
i am getting following error after saveOrUpdate into a table fails and i am trying to execute SQL query after failure
The code in Controller as is below
Code:
@Controller
@Transactional
public class AirportController {
@RequestMapping(value = "/displayAddAirport")
public String displayAddAirport(@ModelAttribute("newairport") Airport newairport,Model model)throws Exception{
try{
airportDao.saveAirport(newairport);
}
catch(Exception exc){
// trying to read some other table data fails
airtportDao.getData();
}
}
}
The error is
Code:
org.hibernate.AssertionFailure: null id in XXXXXXX entry (don't flush the Session after an exception occurs)
org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:82)
org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:190)
org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:147)
org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1185)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1261)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:921)
org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)