Discussions

EJB design: XML API persistence

  1. XML API persistence (5 messages)

    Hi, I would like to know if there is a java XML persistence api out there? In fact,I want an api like hibernate which can persist/retrieve plain old java objects to/from an xml store which conforms to a given schema. This schema defines foreign key,but objects use aggregation like in hibernate mapping. Let me explain you the problem behind this problem.I've used hibernate to persist some objects to a relational database.Now I want to persist/retrieve these objects to/from a xml store which is an instance of a schema. This xml schema is in fact an xml version of the database schema. Of course, I don't want to modify existing pojo classes. I just want another persistence(an xml one) implementation. I've seen JAXB,but it constraints me to use classes that it has generated,isn't it(please correct me if I am wrong)? Moreover,it doesn't seem to persist objects to aggregation Thanks.

    Threaded Messages (5)

  2. Re: XML API persistence[ Go to top ]

    Do you know the experimentale part of hibernate : http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#xml Maybe it can help you ? regards
  3. Re: XML API persistence[ Go to top ]

    Thanks for your answer, 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 sp ecify 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.
  4. Re: XML API persistence[ Go to top ]

    Check CASTOR it allows you to use non JAXB sensitive POJOs through external mapping files. Can read and write too to XML files.
  5. Re: XML API persistence[ Go to top ]

    OBIX: http://obix-framework.sourceforge.net/ Not ment for this purpose, but if it solves your problem :|
  6. Re: XML API persistence[ Go to top ]

    Try out the XStream. http://xstream.codehaus.org/