Announcement Announcement Module
Collapse
No announcement yet.
hibernateTemplate.update query error in spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • hibernateTemplate.update query error in spring

    I want to update the database from an input form. I am using hibernate template in spring to deal with database transactions.

    Following i the code where i am encountering an error.

    Code:
    String firstName=request.getParameter("first_name");
          String place=request.getParameter("place");
       hibernateTemplate.update("update Details set place =?"+place+" WHERE first_name=?"+firstName+"");
    I want to update the place for a particular name. The above hibernate query is giving this error.

    Code:
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: java.lang.String; nested exception is org.hibernate.MappingException: Unknown entity: java.lang.String
    I am able to run insert and find queries successfully, so i am sure about the configuration in the XML files.

    Can anyone suggest me right way of writing the above query.

    Thanks

  • #2
    Looks like you're generating invalid SQL.

    You've got bind parameters (?) and parameters in the same string.

    Comment


    • #3
      1) NEVER NEVER NEVER use string concat to create a query
      2) You are mixing ? + the actual value
      3) You are using hibernate so create HQL not SQL
      4) Don't use hibernateTemplate as it isn't recommended anymore.
      5) Read the javadocs

      Comment

      Working...
      X