[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: Hibernate and XML persistence implementation

pattchen do-not-reply at jboss.com
Sat May 26 04:57:12 EDT 2007


Thanks for your answer Andy,

I've explored documentation about Hibernate and XML.It seems that I must open a database session before open a DOM4J session. Moreover,It is not possible to retrieve objects from an xml storage.
Here is an example of what i want to achieve:

/**XMLSession is an imaginary class(or interface) which is used to manipulate an xml doc.
  | The factory is configured in properties file where we specify the xml file to handle.Just like we specify database parameters in hibernate.properties
  | */
  | 
  | //Store an object to an XML file
  | XMLSession xmlSess = factory.getSession();
  | Employee e = new Employee();
  | e.setName("Andy");
  | e.setAge(25); //too much or too low?? :-)
  | Employee e1 = new Employee();
  | e1.setName("King");
  | e1.setAge(35); //too much or too low?? :-)
  | 
  | Company c = new Company ();
  | c.setName("Future Software");
  | c.setLocation("Cameroon");
  | c.add(e);
  | c.add(e1);
  | 
  | xmlSess.store(c);//persist company object and his employees
  | 
  | //Retrieve an object and update it
  | Employee who = xmlSess.load(Employee.class, 1);//1=id
  | who.setAge(30);
  | xmlSess.update(who);
  | 
  | xmlSess.close();//certainly release i/o resource??

So,I just want to replace database persistence by an xml file and create a mapping file between classes and the xml schema.

Is it possible with Hibernate? if not,is there another solution out there?

Thanks again.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048831#4048831

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048831



More information about the jboss-user mailing list