Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate/Spring HibernateTemplate.findByCriteria(Deatched Criteria dc) executes a sql update on view
    primarykey
    data
    text
    <p>I am trying to search a view based on given criteria. This view has a few fields for multiple different entities in my application that a user may want to search for. </p> <p>When I enter the name of an entity I want to search for, I add a restriction for the name field to the detached criteria before calling <code>.findByCriteria()</code>. This causes <code>.findByCriteria()</code> to retrieve a list of results with the name I am looking for.</p> <p>Also, when I look through my log, I can see hibernate calling a <code>select</code> statment.</p> <p>I have now added another entity to my view, with a few searchable fields. When I try to search for a field related to this new entity, I get an exception in my log.</p> <p>When I look through my log with the exception, I can see hibernate calling a <code>select</code> statment with an <code>update</code> statement right after the <code>select</code> (I am not trying to update a record, just retrieve it in a list).</p> <p>So why is hibernate calling an update when I am calling <code>.findByCriteria()</code> for my new entity?</p> <pre> org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266) </pre> <p>SQL that is executed: </p> <p>Hibernate: </p> <pre><code> select * from ( select this_.SEARCH_ID as SEARCH1_35_0_, this_.ST_NM as ST24_35_0_ from SEARCH_RESULT this_ where this_.LOAN_TYPE=? ) where rownum &lt;= ? </code></pre> <pre> DEBUG 2012-03-21 11:37:19,332 142195 (http-8181-3:org.springframework.orm.hibernate3.HibernateTemplate): [org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:389)] Eagerly flushing Hibernate session DEBUG 2012-03-21 11:37:19,384 142247 (http-8181-3:org.hibernate.SQL): [org.hibernate.jdbc.util.SQLStatementLogger.logStatement(SQLStatementLogger.java:111)] </pre> <pre><code>update SEARCH_RESULT set ADDR_LINE1=?, ASSGND_REGION=?, BASE_DEAL_ID=?, ST_NM=? where SEARCH_ID=? </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload