Announcement Announcement Module
Collapse
No announcement yet.
dirty hibernate session causes update during spring validation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • dirty hibernate session causes update during spring validation

    Hello,

    I am using Spring 1.2.8 and Hibernate 3 and have the following problem:

    In my web application there is a page where it is possible to edit some entities. The user chooses an entity to edit the property "name" (String) and submits the form when done. In the validator of the form I would like to test if the property "name" of the entity is unique, before the change is persisted to MySQL. But every time the query (which checks whether the property "name" of the entity is unique or not) is executed, hibernate updates the data in the MySQL table, no matter whether the validation fails afterwards or not. Is there a nice way to run a hibernate SELECT query whithout the UPDATE of dirty objects is triggered?

    Thank you and sorry for my english
    Kind Regards,
    dumbi
    Last edited by dumbi; Aug 27th, 2008, 08:08 AM.

  • #2
    Hello everyone! I am still having this problem. Please help!

    Best regards,
    dumbi

    Comment


    • #3
      Could you attach your config files, model objects, and form controller? It's pretty hard to diagnose a problem without any point of reference.

      Comment


      • #4
        I just went through this. Here are your options:


        1) Throw a business error if validation fails then catch this error on the web side of the code.

        2) do the validation in the webui and dont let it get to the business code.

        3) Evict the entity before it gets into your service method.

        4) Have a delegate layer that does validation and if it passes call the transactional service.

        5) Use a dto not a hibernate object on your form that way you dont dirty your loaded hibernate object.


        There are some other options as well but this could get you started. I did something similar to number 4.

        Comment

        Working...
        X