• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring Transactions: commiting "correct" records during file import

 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a XML file with 100s of records. Because we don't have XSD for it, sometimes during import few records fail to import. We are using Spring (version 4) transactions. The problem we are having is, because of few incorrect records, at the end of the functions, it does not save any records in database. In other words, in order import records successfully, all records have to be "correct", otherwise none of the records would be imported and saved into database.

I understand that transaction works this way. But is there any way I can resolve this issue.

Below is my Spring configurations,

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

After getting records from XML file you may be sending to database using Hibernate ,Before persisting the object ,you should validate the record using Hibernate validator or write your own validator.Just Ignore invalid records.


 
Grow a forest with seedballs and this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic