title: Hibernate Session.flush() efficiency problems
body: <p>Sorry in advance if someone has already answered this specific question but I have yet to find an answer to my problem so here goes.</p>
  
  <p>I am working on an application (no I cannot give the code as it is for a job so I'm sorry about that one) which uses DAO's and Hibernate and POJO's and all that stuff for communicating and writing to the database.  This works well for the application assuming I don't have a ton of data to check when I call Session.flush().  That being said, there is a page where a user can add any number of items to a product and there is one particular case where there are something along the lines of 25 items.  Each item has about 8 fields a piece that are all stored in the database.  When I call the flush it does save everything to the database but it takes FOREVER to complete.  The three lines I am calling are:</p>
  
  <pre><code>merge(myObject);
  Session.flush();
  Session.refresh(myObject);
  </code></pre>
  
  <p>I have tried a number of different combinations of things to fix this problem and a number of different solutions so coming back and saying "Don't use flus()" isn't much help as the saveOrUpdate() and other hibernate sessions don't seem to work.  The only solution I can think of is to scrap the entire project (the code we got was inherited and poorly written to say the least) or tell the user community to suck it up.</p>
  
  <p>It is my understanding from Hibernate API that if you want to write the data to the database it runs a check on every item, if there is a difference it creates a queue of update queries, then runs the queries.  It seems as though this data is being updated every time because the "DATE_CREATED" column in my database is different even if the other values are unchanged.</p>
  
  <p>What I was wondering is if there was another way to prevent such a large committing of data or a way of excluding that particular column from the "check" hibernate does so I don't have to commit all 25 items if I only made a change to 1?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Mike</p>