dharmendra.pandey wrote:
Hi Gopal,
For Dynamic Update use
dynamic-update ="true" and select-before-update="true" on class tag
Hi Dharmendra,
I tried that. Now I am getting this exception :
Hibernate: select evalformbe_.ID, evalformbe_.NAME as EVALUATION2_14_, evalformbe_.DESC as EVALUATION3_14_, evalformbe_.ALIAS as EVALUATION4_14_, evalformbe_.STATUS as STATUS14_, evalformbe_.CREATE_BY as CREATE6_14_, evalformbe_.CREATE_DATE as CREATE7_14_, evalformbe_.UPDATE_BY as UPDATE8_14_, evalformbe_.UPDATE_DATE as UPDATE9_14_ from evalform evalformbe_ where evalformbe_.ID=?
Hibernate: update evalform set NAME=?, CREATE_DATE=?, UPDATE_DATE=? where ID=?
Exception in thread "main" org.springframework.dao.DataIntegrityViolationException: could not update: [com.persistence.Bean#107]; nested exception is org.hibernate.exception.ConstraintViolationException: could not update: [com.persistence.Bean#107]
Caused by: org.hibernate.exception.ConstraintViolationException: could not update: [com.persistence.Bean#107]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:654)
at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:650)
at com.knoahsoft.daosupportimpl.formbuilder.EvalFormDaoDataImpl.editEvalFormData(EvalFormDaoDataImpl.java:302)
at com.knoahsoft.serviceimpl.formbuilder.EvalFormDetailServiceImpl.editEvalFormService(EvalFormDetailServiceImpl.java:114)
at com.knoahsoft.util.JavaMainClass.main(JavaMainClass.java:264)
Caused by: java.sql.SQLException: Cannot insert the value NULL into column 'CREATE_DATE', table 'DBName.dbo.tableName'; column does not allow nulls. UPDATE fails.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:525)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:487)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:421)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2403)
... 16 more
I am not setting createDate and updateDate fields and in update query why do I am getting these fields ? I am setting only
name
desc
status
id
why do I am not getting these fields in update query ?
please look for this problem ASAP.
Thanks,
Gopal