CHAPTER 7 n CREATING MAPPINGS WITH HIBERNATE XML (Web site traffic)

CHAPTER 7 n CREATING MAPPINGS WITH HIBERNATE XML FILES n CREATING MAPPINGS WITH HIBERNATE XML FILES 141 Hibernate 3 Type Corresponding Java Type big_decimal java.math.BigDecimal big_integer locale java.math.BigInteger java.util.Locale timezone java.util.TimeZone currency java.util.Currency class java.lang.Class binary byte[] text serializable java.lang.String java.io.Serializable clob java.sql.Clob blob java.sql.Blob In addition to these standard types, you can create your own. Your user type class should implement either the org.hibernate.usertype.UserType interface or the org.hibernate. usertype.CompositeUserType interface. Once implemented, a custom type can behave identically to the standard types; though depending on your requirements, it may be necessary to specify multiple column names to contain its values, or to provide initialization parameters for your implementation. For one-off cases, we recommend that you use components these have similar behavior, but they can be created in the mapping file without needing to write Hibernate-specific code. Unless you propose to make substantial use of a custom type throughout your application, it will not be worth the effort. We do not discuss this feature further in this book. The Anatomy of a Mapping File A mapping file is a normal XML file. It is validated against a DTD, which can be downloaded from http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd. You can also look through the annotated version at http://hibernatebook.com. The terminology used in the naming of elements and attributes is somewhat confusing at first because it is the point of contact between the jargon of the object-oriented and relational worlds. The Element The root element of any mapping file is . As the top-level element, its attributes mostly define default behaviors and settings to apply to the child elements (see Table 7-2).
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply