title: Hibernate error while update
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7475876/using-hibernate-query-colon-gets-treated-as-parameter-escaping-colon">Using Hibernate query : colon gets treated as parameter / escaping colon</a>  </p>
  </blockquote>
  
  
  
  <p>We are trying to write a native query. When we try to update a particular column value that contains a <code>": "</code> ,we get an  exception.</p>
  
  <p>This is the generated query</p>
  
  <pre><code>  UPDATE MY_TABLE SET DESCRIPTION = "Test 01 : ABC",LAST_UPDATE_TS =
    CURRENT_TIMESTAMP ,LAST_UPDATE_USER_ID = 111 WHERE MY_ID =123 
  </code></pre>
  
  <p>I think the problem lies in the DESCRIPTION data, which contains <code>': '</code></p>
  
  <p>We get this error</p>
  
  <pre><code> nested exception is org.hibernate.QueryException:Space is not allowed after 
   parameter prefix ':' ' UPDATE 
   MY_TABLE SET DESCRIPTION = "MY Test 01 : ABC",LAST_UPDATE_TS =
   CURRENT_TIMESTAMP, LAST_UPDATE_USER_ID = 111 WHERE MY_ID =123'
  </code></pre>
  
  <p>This is the Java code that is responsible for the query :</p>
  
  <pre><code> StringBuffer strQry = new StringBuffer(" UPDATE MY_TABLE SET ");
  
            if(myForm.getDescription() != null){
                   if(flag == 1){
                         strQry.append(",");
                   }
                   strQry.append(" DESCRIPTION = \"" + myForm.getDescription().trim()+ "\" ");
                   flag = 1;
  </code></pre>
  
  <p>Any idea why this error is occurring and how we can get around it ?</p>