Hi,
I am fairly new to hibernate,I have a query, i am trying to delete records.
Can i directly use Delete command and use executeUpdate(), as I am trying to do
Code:
StringBuffer queryString = new StringBuffer();
queryString.append("Delete from TableDO table ");
queryString.append(" where table.createdDate < '");
queryString.append(currentDate);
queryString.append("'");
then for executing this query.. I am using this function
Code:
public List executeQuery(final String query)
throws ServiceException {
init();
return (List)this.hibernateTemplate.execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException
{
Query q = session.createQuery(query);
q.executeUpdate();
}
});
}
assuming that all my mapping are correctly done as i am able to insert records in this table and also update those records.
When i am trying to execute the above statement , it gives me an error :-
Code:
20:36:00,265 ERROR [JDBCExceptionReporter] ORA-00942: table or view does not exist
Caused by:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2214)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)