Web hosting comparison - 238 APPENDIX A n MORE ADVANCED FEATURES APPENDIX

238 APPENDIX A n MORE ADVANCED FEATURES APPENDIX A n MORE ADVANCED FEATURES be checked for changes. If the fields being checked have changed prior to the commit, then the commit will fail. Versioning is generally a simpler and more reliable approach, so we suggest that you use this whenever you need optimistic locking features. XML Relational Persistence Hibernate provides a feature that allows XML data to be mapped into the entity model for access using the normal session methods. This functionality is provided primarily so that data can be imported into and exported from the underlying relational data store it is not intended as a replacement for relational databases! The feature can be used for various purposes archiving data, implementing SOAP interfaces, and so on but the most common use is for the purposes of processing (and providing) external data feeds such as product catalogs. We show here how the example application in Chapter 3 (an advertisements database) can be configured to read and write appropriate XML feeds for the mapped entities. Hibernate requires the use of Dom4J as the API for XML access because Hibernate s internals already rely upon Dom4J to read configuration and mapping files. Adding Node Information to Mappings Two attributes are used to add all the XML-specific information to your existing mapping files: node and embed-xml. The node attribute applies to most tags that correspond to tables or columns in the database. The value can be a single string, in which case it represents an element name in the XML markup; or it can be preceded by a commercial at symbol (@), in which case it represents the attribute of an element. Paths can be indicated using forward slashes. This is the standard XPath syntax for identifying elements in an XML document. If set to true, the embed-xmlattribute indicates that the property or entity referenced should be included inline as XML. If set to false, it indicates that a reference to the primary key should be substituted instead. This is necessary because the DOM generation does not perform reference handling automatically so loops in the entity model references would result in infinite loops in XML generation if this option could not be set to true. Note that if embed-xmlis set to false for an association, generating XML output that references another entity will not automatically include a representation of the entity elsewhere in the generated document. This is your responsibility. Listing A-7 shows how our example Advert class from Chapter 3 might be marked up with nodeand embed-xml attributes. Listing A-7. The AdvertExample Classes from Chapter 3 Marked Up for XML Persistence
We recommend high quality webhost to host and run your jsp application: christian web host services.

Leave a Reply