Apr 19th, 2010, 09:55 AM
Where to load hibernate associations
I have to parse and import a txt flatfile to a hibernate domain named Domain1.
I have planned to create a SimpleStepFactoryBean with a FlatFileItemReader and a HibernateItemWriter.
Every record I read from the file has a column named domain2id wich is the id of another hibernate object of type Domain2 already present in the db.
I thinking of loading the the associated domain2 object in the ItemReader doing
Domain1 d = new Domain1()
Domain1.property = fieldSet.readInt(0)
Domain1.domain2 = Domain2.load( fieldSet.readInt(1) )
It this the best way to proceed?