文档详情

用Hibernate3.1实现XML和数据库的同步(Using Hibernate3.1 to realize synchronization of XML and database).doc

发布:2017-07-21约1.3万字共14页下载文档
文本预览下载声明
用Hibernate3.1实现XML和数据库的同步(Using Hibernate3.1 to realize synchronization of XML and database) Using Hibernate3.1 to realize synchronization of XML and database Hibernate is an open source Java library for object / relational persistence and query services. Now, the latest version of Hibernate is 3.1., introducing a new feature in this release: XML to database mapping (also referred to as synchronization of XML and databases). This feature allows programmers to map data based on XML documents into databases (supporting DB2, MySQL, Oracle, and PostgreSQL in the current version of Hibernate). By using Hibernate, you can map the nodes of the XML document (Node) into columns in the database. Each XML file is mapped directly into a database table, and in this process no POJO.Hibernate is required to generate the corresponding SQL (including create, update, delete, insert, etc.) as needed. We can also generate new tables through the Hibernate configuration file and add the XML data to the database. You can also get data in the database tables in XML format and add or update data via XML. At the same time, Hibernate3.1 also supports Dom4j API, and supports Ant.. In this article, Ill learn how to use Hibernate3.1 to develop an application based on XML mapping. The first thing we need to do is to design the database configuration properties, which can be set in perties. This property includes the database to be connected, the JDBC drive class, and the connection string that connects the database. You also need to set up a mapping file, hbm.xml., which specifies the correspondence between the nodes of the XML document and the columns in the corresponding data table. The data table name to be mapped to Java Bean is also specified in this file. We can use the org.hibernate.tool.hbm2ddl.SchemaExport tool to map the mapping file onto the data table. This article will describe in detail how to map a Catalog.hbm.xml file onto a Oracle data table. First, the preparatory work Before yo
显示全部
相似文档