Results 1 to 4 of 4

Thread: dirty hibernate session causes update during spring validation

  1. #1
    Join Date
    Aug 2008
    Posts
    2

    Default 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 at 07:08 AM.

  2. #2
    Join Date
    Aug 2008
    Posts
    2

    Default

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

    Best regards,
    dumbi

  3. #3
    Join Date
    Feb 2007
    Posts
    4

    Default

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

  4. #4
    Join Date
    Dec 2006
    Posts
    311

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •