This content has been marked as final.
Show 2 replies
-
1. Re: Hibernate and XML persistence implementation
andydale May 25, 2007 6:22 AM (in response to pattchen)Hi,
You will need to use a Hibernate session, with the EntityMode set to DOM4J. You should hopefully be able to extract the data and store it into an xml document, but you will have to set up all the mappings in hbm.xml files (I think)
Thanks,
Andy -
2. Re: Hibernate and XML persistence implementation
pattchen May 26, 2007 4:57 AM (in response to pattchen)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.