-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Convert Big XML -> Java Object -> Data Base
PostPosted: Sun Feb 19, 2006 8:11 am 
Beginner
Beginner

Joined: Mon Nov 28, 2005 11:03 am
Posts: 39
Location: Madrid
Dear Members,

I need to feed my database base with som input files (initially I have flat file, that I have converted to XML using XMLConvert). I have now XML files like this:

Code:
<bookstore>
  <book></book>
  <book></book>
  <book></book>
  ....
</bookstore>


I don't need to store the bookstores information just all the books information. So I don't need to load in memory the whole bookstore information at time, just each time the book information then to the database and again to take the next book.

Using Castor I don't see the way to do that without loading the hole XML file and I would like to unmarshal a <book> node or a limit number of <book> nodes for avoiding overflow then to store into the database.

The <book> element has a very similar information to my Book class (generated using Hibernate Tool).

On Hibernate User Manual there is a section about XML mapping but they talk about the inverse process (marshal), so asking to the database and then having the result in XML format, but there is no comment about the inverse process.

I was looking into HyberJaxB:

http://www.hibernate.org/218.html

but it uses annotation and I have the constraint to use 1.4.* jdk version only.

My idea is to do something like this:

Code:
open file()

List books;
Book book;
int counter = 0;
int maxCounter = 0; // Maximum Bath size

while(there are book nodes pending for unmarshal) {
  book = unmarshal();
  books.add(book);
  counter++;
  if (counter == maxCounter) {
    save (books)
    counter = 0;
    clear books list
  }
}
close file()

so

    1. open file
    2. unmarshal books until the maximum batch size
    3. Save the books into database
    4. Go to 2 while there are books pending to unmarshal on the file.
    5. Close file

Thanks in advance for any help,

David Leal

_________________
David Leal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.