kapok

          垃圾桶,嘿嘿,我藏的這么深你們還能找到啊,真牛!

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            455 隨筆 :: 0 文章 :: 76 評論 :: 0 Trackbacks
          <2005年5月>
          24252627282930
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          常用鏈接

          留言簿(28)

          隨筆分類

          隨筆檔案

          Corba

          EAI

          Online Document

          Open Source

          Portal

          RSS Links

          Weblogic

          不錯的鏈接

          工具集合

          數(shù)據(jù)倉庫相關(guān)

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

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

          HyperJAXB - relational persistence for XML objects with JAXB and Hibernate

          What is HyperJAXB?

          HyperJAXB is an add-on for Sun's reference implementation of JAXB (Java Architecture for XML Binding). It provides JAXB objects with relational persistence layer using Hibernate.

          What can I do with HyperJAXB?

          HyperJAXB eases usage of XML with relational databases. With HyperJAXB you can combine JAXB and Hibernate to implement one of the following target usage scenarios:

          • load (unmarshal) object structure from XML document and save (persist) these objects in a relational database;
          • load objects from a relational database and present (marshal) loaded objects in XML form;
          • query relational database using HQL and present query results in XML.

          How it works?

          JAXB is basically a code generation engine. It accepts a schematic definition of you XML documents (usually in the form of an XML Schema) as input and generates source code of XML-enabled classes. HyperJAXB augments generated code by adding Hibernate XDoclet annotations. Added annotations effectively define Hibernate O/R mapping for the generated classes.

          Combination of JAXB RI, HyperJAXB and Hibernate toolset allows you automatically generate the following artifacts out of you XML Schema:

          • source code of XML-enabled objects with Hibernate XDoclet annotations;
          • object/relational mapping for Hibernate;
          • database schema for the target database.

          Please see the reference for more information.

          A code example?

          Unmarshalling and saving:

          // Unmarshall the document
          final MyObject myObject = (MyObject) unmarshaller.unmarshal(document);
          
          // Open the session, save object into the database
          final Session saveSession = sessionFactory.openSession();
          // Save id for the later use
          final String id = saveSession.save(myObject);
          saveSession.flush();
          // Close the session
          saveSession.close()
          

          Loading and marshalling:

          // Open the session, load the object
          final Session loadSession = sessionFactory.openSession();
          final MyObject myLoadedObject = (MyObject) loadSession.load(MyObject.class, id);
          loadSession.close();
          
          // Marshall loaded object into the document
          final Document loadedDocument = documentBuilder.newDocument();
          marshaller.marshal(myLoadedObject, loadedDocument);
          

          Mapping generated by HyperJAXB ensures that document and loadedDocument are identical.

          Where can I find it?

          Check out this project on https://hyperjaxb.dev.java.net.

          posted on 2005-05-24 20:30 笨笨 閱讀(611) 評論(0)  編輯  收藏 所屬分類: J2EEHibernateAndSpringALL
          主站蜘蛛池模板: 汤原县| 萍乡市| 微博| 西峡县| 西林县| 威远县| 兴安县| 凉山| 乐至县| 龙泉市| 宾川县| 伊金霍洛旗| 河曲县| 北碚区| 阿荣旗| 建始县| 祥云县| 蓝田县| 双鸭山市| 林西县| 五大连池市| 荆门市| 秦安县| 德钦县| 盐津县| 沂水县| 长葛市| 武冈市| 闸北区| 体育| 共和县| 当雄县| 纳雍县| 永清县| 通江县| 伊宁市| 黄石市| 定兴县| 洪湖市| 瑞丽市| 紫云|